MCPcopy Create free account
hub / github.com/TASEmulators/fceux / read_string

Function read_string

src/lua/src/llex.c:276–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274
275
276static void read_string (LexState *ls, int del, SemInfo *seminfo) {
277 save_and_next(ls);
278 while (ls->current != del) {
279 switch (ls->current) {
280 case EOZ:
281 luaX_lexerror(ls, "unfinished string", TK_EOS);
282 continue; /* to avoid warnings */
283 case '\n':
284 case '\r':
285 luaX_lexerror(ls, "unfinished string", TK_STRING);
286 continue; /* to avoid warnings */
287 case '\\': {
288 int c;
289 next(ls); /* do not save the `\' */
290 switch (ls->current) {
291 case 'a': c = '\a'; break;
292 case 'b': c = '\b'; break;
293 case 'f': c = '\f'; break;
294 case 'n': c = '\n'; break;
295 case 'r': c = '\r'; break;
296 case 't': c = '\t'; break;
297 case 'v': c = '\v'; break;
298 case '\n': /* go through */
299 case '\r': save(ls, '\n'); inclinenumber(ls); continue;
300 case EOZ: continue; /* will raise an error next loop */
301 default: {
302 if (!isdigit(ls->current))
303 save_and_next(ls); /* handles \\, \", \', and \? */
304 else { /* \xxx */
305 int i = 0;
306 c = 0;
307 do {
308 c = 10*c + (ls->current-'0');
309 next(ls);
310 } while (++i<3 && isdigit(ls->current));
311 if (c > UCHAR_MAX)
312 luaX_lexerror(ls, "escape sequence too large", TK_STRING);
313 save(ls, c);
314 }
315 continue;
316 }
317 }
318 save(ls, c);
319 next(ls);
320 continue;
321 }
322 default:
323 save_and_next(ls);
324 }
325 }
326 save_and_next(ls); /* skip delimiter */
327 seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1,
328 luaZ_bufflen(ls->buff) - 2);
329}
330
331
332static int llex (LexState *ls, SemInfo *seminfo) {

Callers 1

llexFunction · 0.85

Calls 4

luaX_lexerrorFunction · 0.85
saveFunction · 0.85
inclinenumberFunction · 0.85
luaX_newstringFunction · 0.85

Tested by

no test coverage detected