MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaO_chunkid

Function luaO_chunkid

third-party/lua-5.2.4/src/lobject.c:252–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

250#define addstr(a,b,l) ( memcpy(a,b,(l) * sizeof(char)), a += (l) )
251
252void luaO_chunkid (char *out, const char *source, size_t bufflen) {
253 size_t l = strlen(source);
254 if (*source == '=') { /* 'literal' source */
255 if (l <= bufflen) /* small enough? */
256 memcpy(out, source + 1, l * sizeof(char));
257 else { /* truncate it */
258 addstr(out, source + 1, bufflen - 1);
259 *out = '\0';
260 }
261 }
262 else if (*source == '@') { /* file name */
263 if (l <= bufflen) /* small enough? */
264 memcpy(out, source + 1, l * sizeof(char));
265 else { /* add '...' before rest of name */
266 addstr(out, RETS, LL(RETS));
267 bufflen -= LL(RETS);
268 memcpy(out, source + 1 + l - bufflen, bufflen * sizeof(char));
269 }
270 }
271 else { /* string; format as [string "source"] */
272 const char *nl = strchr(source, '\n'); /* find first new line (if any) */
273 addstr(out, PRE, LL(PRE)); /* add prefix */
274 bufflen -= LL(PRE RETS POS) + 1; /* save space for prefix+suffix+'\0' */
275 if (l < bufflen && nl == NULL) { /* small one-line source? */
276 addstr(out, source, l); /* keep it */
277 }
278 else {
279 if (nl != NULL) l = nl - source; /* stop at first newline */
280 if (l > bufflen) l = bufflen;
281 addstr(out, source, l);
282 addstr(out, RETS, LL(RETS));
283 }
284 memcpy(out, POS, (LL(POS) + 1) * sizeof(char));
285 }
286}
287

Callers 3

lexerrorFunction · 0.70
funcinfoFunction · 0.70
addinfoFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected