lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



On Apr 06, 2006, at 01:26, D Burgess wrote:

David Jones wrote:
So how do you suggest the two bits of Lua that use ungetc are changed
so that they don't use ungetc?

in lauxlib.c

typedef struct LoadF {
  int extraline;
+  int firstchar;
  LUA_FILE f;
  char buff[LUAL_BUFFERSIZE];
} LoadF;

in the getF function
+  if (lf->firstchar != (int)-1) {
+   lf->buff[0] = (char)lf->firstchar;
+    lf->firstchar = (int)-1;
+    *size=1;
+   return lf->buff;
+  }

Didn't you just tell me that you didn't want to implement ungetc yourself?

This is buggy. In C a char can be negative for representations of characters that are not in the required execution character set.

drj