first (big) step to support wide chars
This commit is contained in:
42
lobject.c
42
lobject.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lobject.c,v 1.65 2001/02/20 18:15:33 roberto Exp roberto $
|
||||
** $Id: lobject.c,v 1.66 2001/02/22 17:15:18 roberto Exp roberto $
|
||||
** Some generic functions over Lua objects
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@@ -35,21 +35,21 @@ int luaO_equalObj (const TObject *t1, const TObject *t2) {
|
||||
}
|
||||
|
||||
|
||||
char *luaO_openspace (lua_State *L, size_t n) {
|
||||
l_char *luaO_openspace (lua_State *L, size_t n) {
|
||||
if (n > G(L)->Mbuffsize) {
|
||||
luaM_reallocvector(L, G(L)->Mbuffer, G(L)->Mbuffsize, n, char);
|
||||
luaM_reallocvector(L, G(L)->Mbuffer, G(L)->Mbuffsize, n, l_char);
|
||||
G(L)->Mbuffsize = n;
|
||||
}
|
||||
return G(L)->Mbuffer;
|
||||
}
|
||||
|
||||
|
||||
int luaO_str2d (const char *s, lua_Number *result) { /* LUA_NUMBER */
|
||||
char *endptr;
|
||||
int luaO_str2d (const l_char *s, lua_Number *result) { /* LUA_NUMBER */
|
||||
l_char *endptr;
|
||||
lua_Number res = lua_str2number(s, &endptr);
|
||||
if (endptr == s) return 0; /* no conversion */
|
||||
while (isspace(uchar(*endptr))) endptr++;
|
||||
if (*endptr != '\0') return 0; /* invalid trailing characters? */
|
||||
if (*endptr != l_c('\0')) return 0; /* invalid trailing characters? */
|
||||
*result = res;
|
||||
return 1;
|
||||
}
|
||||
@@ -59,9 +59,9 @@ int luaO_str2d (const char *s, lua_Number *result) { /* LUA_NUMBER */
|
||||
#define MAX_VERROR 280
|
||||
|
||||
/* this function needs to handle only '%d' and '%.XXs' formats */
|
||||
void luaO_verror (lua_State *L, const char *fmt, ...) {
|
||||
void luaO_verror (lua_State *L, const l_char *fmt, ...) {
|
||||
va_list argp;
|
||||
char buff[MAX_VERROR]; /* to hold formatted message */
|
||||
l_char buff[MAX_VERROR]; /* to hold formatted message */
|
||||
va_start(argp, fmt);
|
||||
vsprintf(buff, fmt, argp);
|
||||
va_end(argp);
|
||||
@@ -69,36 +69,36 @@ void luaO_verror (lua_State *L, const char *fmt, ...) {
|
||||
}
|
||||
|
||||
|
||||
void luaO_chunkid (char *out, const char *source, int bufflen) {
|
||||
if (*source == '=') {
|
||||
void luaO_chunkid (l_char *out, const l_char *source, int bufflen) {
|
||||
if (*source == l_c('=')) {
|
||||
strncpy(out, source+1, bufflen); /* remove first char */
|
||||
out[bufflen-1] = '\0'; /* ensures null termination */
|
||||
out[bufflen-1] = l_c('\0'); /* ensures null termination */
|
||||
}
|
||||
else {
|
||||
if (*source == '@') {
|
||||
if (*source == l_c('@')) {
|
||||
int l;
|
||||
source++; /* skip the `@' */
|
||||
bufflen -= sizeof("file `...%s'");
|
||||
bufflen -= sizeof(l_s("file `...%s'"));
|
||||
l = strlen(source);
|
||||
if (l>bufflen) {
|
||||
source += (l-bufflen); /* get last part of file name */
|
||||
sprintf(out, "file `...%.99s'", source);
|
||||
sprintf(out, l_s("file `...%.99s'"), source);
|
||||
}
|
||||
else
|
||||
sprintf(out, "file `%.99s'", source);
|
||||
sprintf(out, l_s("file `%.99s'"), source);
|
||||
}
|
||||
else {
|
||||
int len = strcspn(source, "\n"); /* stop at first newline */
|
||||
bufflen -= sizeof("string \"%.*s...\"");
|
||||
int len = strcspn(source, l_s("\n")); /* stop at first newline */
|
||||
bufflen -= sizeof(l_s("string \"%.*s...\""));
|
||||
if (len > bufflen) len = bufflen;
|
||||
if (source[len] != '\0') { /* must truncate? */
|
||||
strcpy(out, "string \"");
|
||||
if (source[len] != l_c('\0')) { /* must truncate? */
|
||||
strcpy(out, l_s("string \""));
|
||||
out += strlen(out);
|
||||
strncpy(out, source, len);
|
||||
strcpy(out+len, "...\"");
|
||||
strcpy(out+len, l_s("...\""));
|
||||
}
|
||||
else
|
||||
sprintf(out, "string \"%.99s\"", source);
|
||||
sprintf(out, l_s("string \"%.99s\""), source);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user