Pārlūkot izejas kodu

sizeof(string) != strlen(string)+1 when sizeof(char) != 1

Roberto Ierusalimschy 24 gadi atpakaļ
vecāks
revīzija
e9a3820370
3 mainītis faili ar 6 papildinājumiem un 6 dzēšanām
  1. 2 2
      ldebug.c
  2. 2 2
      llex.c
  3. 2 2
      llex.h

+ 2 - 2
ldebug.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ldebug.c,v 1.70 2001/02/23 20:30:52 roberto Exp roberto $
+** $Id: ldebug.c,v 1.71 2001/03/02 17:27:50 roberto Exp roberto $
 ** Debug Interface
 ** See Copyright Notice in lua.h
 */
@@ -223,7 +223,7 @@ static void funcinfo (lua_State *L, lua_Debug *ar, StkId func) {
   }
   else
     infoLproto(ar, cl->f.l);
-  luaO_chunkid(ar->short_src, ar->source, sizeof(ar->short_src));
+  luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE);
   if (ar->linedefined == 0)
     ar->what = l_s("main");
 }

+ 2 - 2
llex.c

@@ -1,5 +1,5 @@
 /*
-** $Id: llex.c,v 1.80 2001/02/23 17:17:25 roberto Exp roberto $
+** $Id: llex.c,v 1.81 2001/02/23 20:32:16 roberto Exp roberto $
 ** Lexical Analyzer
 ** See Copyright Notice in lua.h
 */
@@ -58,7 +58,7 @@ void luaX_checklimit (LexState *ls, int val, int limit, const l_char *msg) {
 
 void luaX_syntaxerror (LexState *ls, const l_char *s, const l_char *token) {
   l_char buff[MAXSRC];
-  luaO_chunkid(buff, getstr(ls->source), sizeof(buff));
+  luaO_chunkid(buff, getstr(ls->source), MAXSRC);
   luaO_verror(ls->L,
               l_s("%.99s;\n  last token read: `%.30s' at line %d in %.80s"),
               s, token, ls->linenumber, buff);

+ 2 - 2
llex.h

@@ -1,5 +1,5 @@
 /*
-** $Id: llex.h,v 1.33 2001/01/10 16:40:56 roberto Exp roberto $
+** $Id: llex.h,v 1.34 2001/02/23 17:17:25 roberto Exp roberto $
 ** Lexical Analyzer
 ** See Copyright Notice in lua.h
 */
@@ -14,7 +14,7 @@
 #define FIRST_RESERVED	257
 
 /* maximum length of a reserved word */
-#define TOKEN_LEN	(sizeof(l_s("function")))
+#define TOKEN_LEN	(sizeof(l_s("function"))/sizeof(l_char))
 
 
 /*