U E D R S I H C RSS
ID
Password
Join
언제나 문제 해결의 최선책은 남의 돈을 들이는 것인 듯. ―밀튼 프리드먼

 * 원본링크 : [http]http://lua-users.org/files/wiki_insecure/users/pshook/lua-5.0-hex.patch
  • 위 패치는 5.1work버전에서는 동작하지 않아서 약간 고쳐서 만들어봤습니다. 아래와 같이 패치하면 됩니다.
  • llex.c에서 아래와 같은 부분을 찾습니다.
...
/*
** =======================================================
** LEXICAL ANALYZER
** =======================================================
*/

/* LUA_NUMBER */
static void read_numeral (LexState *ls, SemInfo *seminfo) {
  while (isdigit(ls->current)) {
    save_and_next(ls);
  }
  if (ls->current == '.') {
    save_and_next(ls);
    if (ls->current == '.') {
      save_and_next(ls);
      luaX_lexerror(ls,
                 "ambiguous syntax (decimal point x string concatenation)",
                 TK_NUMBER);
    }
...
다음과 같이 고친다.
...
/*
** =======================================================
** LEXICAL ANALYZER
** =======================================================
*/

static int luaO_hexstr2d (const char *s, lua_Number *result) {
  char *endptr;
  lua_Number res = strtoul(s, &endptr, 0);
  if (endptr == s) return 0;  /* no conversion */
  while (isspace((unsigned char)(*endptr))) endptr++;
  if (*endptr != '\0') return 0;  /* invalid trailing characters? */
  *result = res;
  return 1;
}

/* LUA_NUMBER */
static void read_numeral (LexState *ls, SemInfo *seminfo) {
  if (ls->current == '0') {  /* check for hex prefix */
    save_and_next(ls);
    if (ls->current == 'x' || ls->current == 'X') {
      save_and_next(ls);
      while (isxdigit(ls->current)) {
        save_and_next(ls);
      }
      save(ls, '\0');
      if (!luaO_hexstr2d(luaZ_buffer(ls->buff), &seminfo->r))
        luaX_lexerror(ls, "malformed hex number", TK_NUMBER);
      return;
    }
  }
	
  while (isdigit(ls->current)) {
    save_and_next(ls);
  }
  if (ls->current == '.') {
    save_and_next(ls);
    if (ls->current == '.') {
      save_and_next(ls);
      luaX_lexerror(ls,
                 "ambiguous syntax (decimal point x string concatenation)",
                 TK_NUMBER);
    }
...

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2010-10-28 12:42:52
Processing time 0.0941 sec