misc/liblua/lobject.c
author Wuzzy <almikes@aol.com>
Sat, 15 Apr 2017 04:28:00 +0200
changeset 12253 8e9603088f99
parent 2812 0a24853de796
permissions -rw-r--r--
Make all hogs say Yessir taunt on their turn start (replaces revenge taunts) Rationale: The taunts Illgetyou, JustYouWait were fairly odd and almost always inapproriate to the situation as most voicepacks clearly assume these to be used for revenge only (e.g. “You'll gonna pay for that.” was played at turn start because of this.).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     1
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     2
** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     3
** Some generic functions over Lua objects
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     4
** See Copyright Notice in lua.h
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     5
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     6
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     7
#include <ctype.h>
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     8
#include <stdarg.h>
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     9
#include <stdio.h>
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    10
#include <stdlib.h>
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    11
#include <string.h>
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    12
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    13
#define lobject_c
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    14
#define LUA_CORE
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    15
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    16
#include "lua.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    17
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    18
#include "ldo.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    19
#include "lmem.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    20
#include "lobject.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    21
#include "lstate.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    22
#include "lstring.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    23
#include "lvm.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    24
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    25
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    26
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    27
const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL};
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    28
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    29
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    30
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    31
** converts an integer to a "floating point byte", represented as
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    32
** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    33
** eeeee != 0 and (xxx) otherwise.
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    34
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    35
int luaO_int2fb (unsigned int x) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    36
  int e = 0;  /* expoent */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    37
  while (x >= 16) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    38
    x = (x+1) >> 1;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    39
    e++;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    40
  }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    41
  if (x < 8) return x;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    42
  else return ((e+1) << 3) | (cast_int(x) - 8);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    43
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    44
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    45
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    46
/* converts back */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    47
int luaO_fb2int (int x) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    48
  int e = (x >> 3) & 31;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    49
  if (e == 0) return x;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    50
  else return ((x & 7)+8) << (e - 1);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    51
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    52
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    53
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    54
int luaO_log2 (unsigned int x) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    55
  static const lu_byte log_2[256] = {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    56
    0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    57
    6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    58
    7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    59
    7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    60
    8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    61
    8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    62
    8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    63
    8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    64
  };
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    65
  int l = -1;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    66
  while (x >= 256) { l += 8; x >>= 8; }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    67
  return l + log_2[x];
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    68
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    69
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    70
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    71
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    72
int luaO_rawequalObj (const TValue *t1, const TValue *t2) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    73
  if (ttype(t1) != ttype(t2)) return 0;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    74
  else switch (ttype(t1)) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    75
    case LUA_TNIL:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    76
      return 1;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    77
    case LUA_TNUMBER:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    78
      return luai_numeq(nvalue(t1), nvalue(t2));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    79
    case LUA_TBOOLEAN:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    80
      return bvalue(t1) == bvalue(t2);  /* boolean true must be 1 !! */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    81
    case LUA_TLIGHTUSERDATA:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    82
      return pvalue(t1) == pvalue(t2);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    83
    default:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    84
      lua_assert(iscollectable(t1));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    85
      return gcvalue(t1) == gcvalue(t2);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    86
  }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    87
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    88
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    89
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    90
int luaO_str2d (const char *s, lua_Number *result) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    91
  char *endptr;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    92
  *result = lua_str2number(s, &endptr);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    93
  if (endptr == s) return 0;  /* conversion failed */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    94
  if (*endptr == 'x' || *endptr == 'X')  /* maybe an hexadecimal constant? */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    95
    *result = cast_num(strtoul(s, &endptr, 16));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    96
  if (*endptr == '\0') return 1;  /* most common case */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    97
  while (isspace(cast(unsigned char, *endptr))) endptr++;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    98
  if (*endptr != '\0') return 0;  /* invalid trailing characters? */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    99
  return 1;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   100
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   101
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   102
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   103
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   104
static void pushstr (lua_State *L, const char *str) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   105
  setsvalue2s(L, L->top, luaS_new(L, str));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   106
  incr_top(L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   107
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   108
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   109
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   110
/* this function handles only `%d', `%c', %f, %p, and `%s' formats */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   111
const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   112
  int n = 1;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   113
  pushstr(L, "");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   114
  for (;;) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   115
    const char *e = strchr(fmt, '%');
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   116
    if (e == NULL) break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   117
    setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   118
    incr_top(L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   119
    switch (*(e+1)) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   120
      case 's': {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   121
        const char *s = va_arg(argp, char *);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   122
        if (s == NULL) s = "(null)";
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   123
        pushstr(L, s);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   124
        break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   125
      }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   126
      case 'c': {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   127
        char buff[2];
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   128
        buff[0] = cast(char, va_arg(argp, int));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   129
        buff[1] = '\0';
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   130
        pushstr(L, buff);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   131
        break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   132
      }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   133
      case 'd': {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   134
        setnvalue(L->top, cast_num(va_arg(argp, int)));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   135
        incr_top(L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   136
        break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   137
      }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   138
      case 'f': {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   139
        setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber)));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   140
        incr_top(L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   141
        break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   142
      }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   143
      case 'p': {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   144
        char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   145
        sprintf(buff, "%p", va_arg(argp, void *));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   146
        pushstr(L, buff);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   147
        break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   148
      }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   149
      case '%': {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   150
        pushstr(L, "%");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   151
        break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   152
      }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   153
      default: {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   154
        char buff[3];
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   155
        buff[0] = '%';
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   156
        buff[1] = *(e+1);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   157
        buff[2] = '\0';
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   158
        pushstr(L, buff);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   159
        break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   160
      }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   161
    }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   162
    n += 2;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   163
    fmt = e+2;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   164
  }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   165
  pushstr(L, fmt);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   166
  luaV_concat(L, n+1, cast_int(L->top - L->base) - 1);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   167
  L->top -= n;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   168
  return svalue(L->top - 1);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   169
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   170
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   171
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   172
const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   173
  const char *msg;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   174
  va_list argp;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   175
  va_start(argp, fmt);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   176
  msg = luaO_pushvfstring(L, fmt, argp);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   177
  va_end(argp);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   178
  return msg;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   179
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   180
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   181
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   182
void luaO_chunkid (char *out, const char *source, size_t bufflen) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   183
  if (*source == '=') {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   184
    strncpy(out, source+1, bufflen);  /* remove first char */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   185
    out[bufflen-1] = '\0';  /* ensures null termination */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   186
  }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   187
  else {  /* out = "source", or "...source" */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   188
    if (*source == '@') {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   189
      size_t l;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   190
      source++;  /* skip the `@' */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   191
      bufflen -= sizeof(" '...' ");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   192
      l = strlen(source);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   193
      strcpy(out, "");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   194
      if (l > bufflen) {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   195
        source += (l-bufflen);  /* get last part of file name */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   196
        strcat(out, "...");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   197
      }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   198
      strcat(out, source);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   199
    }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   200
    else {  /* out = [string "string"] */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   201
      size_t len = strcspn(source, "\n\r");  /* stop at first newline */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   202
      bufflen -= sizeof(" [string \"...\"] ");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   203
      if (len > bufflen) len = bufflen;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   204
      strcpy(out, "[string \"");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   205
      if (source[len] != '\0') {  /* must truncate? */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   206
        strncat(out, source, len);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   207
        strcat(out, "...");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   208
      }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   209
      else
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   210
        strcat(out, source);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   211
      strcat(out, "\"]");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   212
    }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   213
  }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   214
}