diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-08-31 16:46:07 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-08-31 16:46:07 -0300 |
| commit | e1d072571ec6f9d830e575a2ecdc95fd43428e53 (patch) | |
| tree | 830fab7f2acb9adaee2d63073d339cc9557a5437 /llex.c | |
| parent | 7651a5c6b2ee6ec59cadec6199319d482071f176 (diff) | |
| download | lua-e1d072571ec6f9d830e575a2ecdc95fd43428e53.tar.gz lua-e1d072571ec6f9d830e575a2ecdc95fd43428e53.tar.bz2 lua-e1d072571ec6f9d830e575a2ecdc95fd43428e53.zip | |
better syntax for type casts
Diffstat (limited to 'llex.c')
| -rw-r--r-- | llex.c | 14 |
1 files changed, 7 insertions, 7 deletions
| @@ -41,7 +41,7 @@ void luaX_init (lua_State *L) { | |||
| 41 | for (i=0; i<NUM_RESERVED; i++) { | 41 | for (i=0; i<NUM_RESERVED; i++) { |
| 42 | TString *ts = luaS_new(L, token2string[i]); | 42 | TString *ts = luaS_new(L, token2string[i]); |
| 43 | lua_assert(strlen(token2string[i])+1 <= TOKEN_LEN); | 43 | lua_assert(strlen(token2string[i])+1 <= TOKEN_LEN); |
| 44 | ts->tsv.marked = (unsigned short)(RESERVEDMARK+i); /* reserved word */ | 44 | ts->tsv.marked = cast(unsigned short, RESERVEDMARK+i); /* reserved word */ |
| 45 | } | 45 | } |
| 46 | } | 46 | } |
| 47 | 47 | ||
| @@ -71,7 +71,7 @@ void luaX_error (LexState *ls, const l_char *s, int token) { | |||
| 71 | l_char buff[TOKEN_LEN]; | 71 | l_char buff[TOKEN_LEN]; |
| 72 | luaX_token2str(token, buff); | 72 | luaX_token2str(token, buff); |
| 73 | if (buff[0] == l_c('\0')) | 73 | if (buff[0] == l_c('\0')) |
| 74 | luaX_syntaxerror(ls, s, (l_char *)G(ls->L)->Mbuffer); | 74 | luaX_syntaxerror(ls, s, cast(l_char *, G(ls->L)->Mbuffer)); |
| 75 | else | 75 | else |
| 76 | luaX_syntaxerror(ls, s, buff); | 76 | luaX_syntaxerror(ls, s, buff); |
| 77 | } | 77 | } |
| @@ -134,7 +134,7 @@ void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source) { | |||
| 134 | if (((len)+(n))*sizeof(l_char) > G(L)->Mbuffsize) \ | 134 | if (((len)+(n))*sizeof(l_char) > G(L)->Mbuffsize) \ |
| 135 | luaO_openspace(L, (len)+(n)+EXTRABUFF, l_char) | 135 | luaO_openspace(L, (len)+(n)+EXTRABUFF, l_char) |
| 136 | 136 | ||
| 137 | #define save(L, c, l) (((l_char *)G(L)->Mbuffer)[l++] = (l_char)c) | 137 | #define save(L, c, l) (cast(l_char *, G(L)->Mbuffer)[l++] = (l_char)c) |
| 138 | #define save_and_next(L, LS, l) (save(L, LS->current, l), next(LS)) | 138 | #define save_and_next(L, LS, l) (save(L, LS->current, l), next(LS)) |
| 139 | 139 | ||
| 140 | 140 | ||
| @@ -185,7 +185,7 @@ static void read_number (LexState *LS, int comma, SemInfo *seminfo) { | |||
| 185 | } | 185 | } |
| 186 | } | 186 | } |
| 187 | save(L, l_c('\0'), l); | 187 | save(L, l_c('\0'), l); |
| 188 | if (!luaO_str2d((l_char *)G(L)->Mbuffer, &seminfo->r)) | 188 | if (!luaO_str2d(cast(l_char *, G(L)->Mbuffer), &seminfo->r)) |
| 189 | luaX_error(LS, l_s("malformed number"), TK_NUMBER); | 189 | luaX_error(LS, l_s("malformed number"), TK_NUMBER); |
| 190 | } | 190 | } |
| 191 | 191 | ||
| @@ -231,7 +231,7 @@ static void read_long_string (LexState *LS, SemInfo *seminfo) { | |||
| 231 | } endloop: | 231 | } endloop: |
| 232 | save_and_next(L, LS, l); /* skip the second `]' */ | 232 | save_and_next(L, LS, l); /* skip the second `]' */ |
| 233 | save(L, l_c('\0'), l); | 233 | save(L, l_c('\0'), l); |
| 234 | seminfo->ts = luaS_newlstr(L, (l_char *)G(L)->Mbuffer+2, l-5); | 234 | seminfo->ts = luaS_newlstr(L, cast(l_char *, G(L)->Mbuffer)+2, l-5); |
| 235 | } | 235 | } |
| 236 | 236 | ||
| 237 | 237 | ||
| @@ -283,7 +283,7 @@ static void read_string (LexState *LS, int del, SemInfo *seminfo) { | |||
| 283 | } | 283 | } |
| 284 | save_and_next(L, LS, l); /* skip delimiter */ | 284 | save_and_next(L, LS, l); /* skip delimiter */ |
| 285 | save(L, l_c('\0'), l); | 285 | save(L, l_c('\0'), l); |
| 286 | seminfo->ts = luaS_newlstr(L, (l_char *)G(L)->Mbuffer+1, l-3); | 286 | seminfo->ts = luaS_newlstr(L, cast(l_char *, G(L)->Mbuffer)+1, l-3); |
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | 289 | ||
| @@ -371,7 +371,7 @@ int luaX_lex (LexState *LS, SemInfo *seminfo) { | |||
| 371 | else if (isalpha(LS->current) || LS->current == l_c('_')) { | 371 | else if (isalpha(LS->current) || LS->current == l_c('_')) { |
| 372 | /* identifier or reserved word */ | 372 | /* identifier or reserved word */ |
| 373 | size_t l = readname(LS); | 373 | size_t l = readname(LS); |
| 374 | TString *ts = luaS_newlstr(LS->L, (l_char *)G(LS->L)->Mbuffer, l); | 374 | TString *ts = luaS_newlstr(LS->L, cast(l_char *, G(LS->L)->Mbuffer), l); |
| 375 | if (ts->tsv.marked >= RESERVEDMARK) /* reserved word? */ | 375 | if (ts->tsv.marked >= RESERVEDMARK) /* reserved word? */ |
| 376 | return ts->tsv.marked-RESERVEDMARK+FIRST_RESERVED; | 376 | return ts->tsv.marked-RESERVEDMARK+FIRST_RESERVED; |
| 377 | seminfo->ts = ts; | 377 | seminfo->ts = ts; |
