MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / luaO_chunkid

Function luaO_chunkid

other_src/lua/src/lobject.cpp:183–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 4

funcinfoFunction · 0.70
info_tailcallFunction · 0.70
addinfoFunction · 0.70
luaX_lexerrorFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected