MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / luaO_chunkid

Function luaO_chunkid

lua/lobject.c:193–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191
192
193void luaO_chunkid (char *out, const char *source, size_t bufflen) {
194 if (*source == '=') {
195 strncpy(out, source+1, bufflen); /* remove first char */
196 out[bufflen-1] = '\0'; /* ensures null termination */
197 }
198 else { /* out = "source", or "...source" */
199 if (*source == '@') {
200 size_t l;
201 source++; /* skip the `@' */
202 bufflen -= sizeof(" '...' ");
203 l = strlen(source);
204 strcpy(out, "");
205 if (l > bufflen) {
206 source += (l-bufflen); /* get last part of file name */
207 strcat(out, "...");
208 }
209 strcat(out, source);
210 }
211 else { /* out = [string "string"] */
212 size_t len = strcspn(source, "\n\r"); /* stop at first newline */
213 bufflen -= sizeof(" [string \"...\"] ");
214 if (len > bufflen) len = bufflen;
215 strcpy(out, "[string \"");
216 if (source[len] != '\0') { /* must truncate? */
217 strncat(out, source, len);
218 strcat(out, "...");
219 }
220 else
221 strcat(out, source);
222 strcat(out, "\"]");
223 }
224 }
225}
226

Callers 4

luaX_lexerrorFunction · 0.85
funcinfoFunction · 0.85
info_tailcallFunction · 0.85
addinfoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected