MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / luaO_chunkid

Function luaO_chunkid

Source/Misc/lua/src/lua.c:7442–7474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7440
7441
7442void luaO_chunkid (char *out, const char *source, size_t bufflen) {
7443if (*source == '=') {
7444strncpy(out, source+1, bufflen); /* remove first char */
7445out[bufflen-1] = '\0'; /* ensures null termination */
7446}
7447else { /* out = "source", or "...source" */
7448if (*source == '@') {
7449size_t l;
7450source++; /* skip the `@' */
7451bufflen -= sizeof(" '...' ");
7452l = strlen(source);
7453strcpy(out, "");
7454if (l > bufflen) {
7455source += (l-bufflen); /* get last part of file name */
7456strcat(out, "...");
7457}
7458strcat(out, source);
7459}
7460else { /* out = [string "string"] */
7461size_t len = strcspn(source, "\n\r"); /* stop at first newline */
7462bufflen -= sizeof(" [string \"...\"] ");
7463if (len > bufflen) len = bufflen;
7464strcpy(out, "[string \"");
7465if (source[len] != '\0') { /* must truncate? */
7466strncat(out, source, len);
7467strcat(out, "...");
7468}
7469else
7470strcat(out, source);
7471strcat(out, "\"]");
7472}
7473}
7474}
7475/*
7476** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
7477** See Copyright Notice in lua.h

Callers 4

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

Calls

no outgoing calls

Tested by

no test coverage detected