MCPcopy Create free account
hub / github.com/cuberite/cuberite / read_string

Function read_string

lib/lua/src/llex.c:280–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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