summaryrefslogtreecommitdiff
path: root/lobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'lobject.c')
-rw-r--r--lobject.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/lobject.c b/lobject.c
index 9292f053..c66a3b02 100644
--- a/lobject.c
+++ b/lobject.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.c,v 1.65 2001/02/20 18:15:33 roberto Exp roberto $ 2** $Id: lobject.c,v 1.66 2001/02/22 17:15:18 roberto Exp roberto $
3** Some generic functions over Lua objects 3** Some generic functions over Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -35,21 +35,21 @@ int luaO_equalObj (const TObject *t1, const TObject *t2) {
35} 35}
36 36
37 37
38char *luaO_openspace (lua_State *L, size_t n) { 38l_char *luaO_openspace (lua_State *L, size_t n) {
39 if (n > G(L)->Mbuffsize) { 39 if (n > G(L)->Mbuffsize) {
40 luaM_reallocvector(L, G(L)->Mbuffer, G(L)->Mbuffsize, n, char); 40 luaM_reallocvector(L, G(L)->Mbuffer, G(L)->Mbuffsize, n, l_char);
41 G(L)->Mbuffsize = n; 41 G(L)->Mbuffsize = n;
42 } 42 }
43 return G(L)->Mbuffer; 43 return G(L)->Mbuffer;
44} 44}
45 45
46 46
47int luaO_str2d (const char *s, lua_Number *result) { /* LUA_NUMBER */ 47int luaO_str2d (const l_char *s, lua_Number *result) { /* LUA_NUMBER */
48 char *endptr; 48 l_char *endptr;
49 lua_Number res = lua_str2number(s, &endptr); 49 lua_Number res = lua_str2number(s, &endptr);
50 if (endptr == s) return 0; /* no conversion */ 50 if (endptr == s) return 0; /* no conversion */
51 while (isspace(uchar(*endptr))) endptr++; 51 while (isspace(uchar(*endptr))) endptr++;
52 if (*endptr != '\0') return 0; /* invalid trailing characters? */ 52 if (*endptr != l_c('\0')) return 0; /* invalid trailing characters? */
53 *result = res; 53 *result = res;
54 return 1; 54 return 1;
55} 55}
@@ -59,9 +59,9 @@ int luaO_str2d (const char *s, lua_Number *result) { /* LUA_NUMBER */
59#define MAX_VERROR 280 59#define MAX_VERROR 280
60 60
61/* this function needs to handle only '%d' and '%.XXs' formats */ 61/* this function needs to handle only '%d' and '%.XXs' formats */
62void luaO_verror (lua_State *L, const char *fmt, ...) { 62void luaO_verror (lua_State *L, const l_char *fmt, ...) {
63 va_list argp; 63 va_list argp;
64 char buff[MAX_VERROR]; /* to hold formatted message */ 64 l_char buff[MAX_VERROR]; /* to hold formatted message */
65 va_start(argp, fmt); 65 va_start(argp, fmt);
66 vsprintf(buff, fmt, argp); 66 vsprintf(buff, fmt, argp);
67 va_end(argp); 67 va_end(argp);
@@ -69,36 +69,36 @@ void luaO_verror (lua_State *L, const char *fmt, ...) {
69} 69}
70 70
71 71
72void luaO_chunkid (char *out, const char *source, int bufflen) { 72void luaO_chunkid (l_char *out, const l_char *source, int bufflen) {
73 if (*source == '=') { 73 if (*source == l_c('=')) {
74 strncpy(out, source+1, bufflen); /* remove first char */ 74 strncpy(out, source+1, bufflen); /* remove first char */
75 out[bufflen-1] = '\0'; /* ensures null termination */ 75 out[bufflen-1] = l_c('\0'); /* ensures null termination */
76 } 76 }
77 else { 77 else {
78 if (*source == '@') { 78 if (*source == l_c('@')) {
79 int l; 79 int l;
80 source++; /* skip the `@' */ 80 source++; /* skip the `@' */
81 bufflen -= sizeof("file `...%s'"); 81 bufflen -= sizeof(l_s("file `...%s'"));
82 l = strlen(source); 82 l = strlen(source);
83 if (l>bufflen) { 83 if (l>bufflen) {
84 source += (l-bufflen); /* get last part of file name */ 84 source += (l-bufflen); /* get last part of file name */
85 sprintf(out, "file `...%.99s'", source); 85 sprintf(out, l_s("file `...%.99s'"), source);
86 } 86 }
87 else 87 else
88 sprintf(out, "file `%.99s'", source); 88 sprintf(out, l_s("file `%.99s'"), source);
89 } 89 }
90 else { 90 else {
91 int len = strcspn(source, "\n"); /* stop at first newline */ 91 int len = strcspn(source, l_s("\n")); /* stop at first newline */
92 bufflen -= sizeof("string \"%.*s...\""); 92 bufflen -= sizeof(l_s("string \"%.*s...\""));
93 if (len > bufflen) len = bufflen; 93 if (len > bufflen) len = bufflen;
94 if (source[len] != '\0') { /* must truncate? */ 94 if (source[len] != l_c('\0')) { /* must truncate? */
95 strcpy(out, "string \""); 95 strcpy(out, l_s("string \""));
96 out += strlen(out); 96 out += strlen(out);
97 strncpy(out, source, len); 97 strncpy(out, source, len);
98 strcpy(out+len, "...\""); 98 strcpy(out+len, l_s("...\""));
99 } 99 }
100 else 100 else
101 sprintf(out, "string \"%.99s\"", source); 101 sprintf(out, l_s("string \"%.99s\""), source);
102 } 102 }
103 } 103 }
104} 104}