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

Function luaO_chunkid

third-party/lua-5.5.0/src/lobject.c:682–717  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

680#define addstr(a,b,l) ( memcpy(a,b,(l) * sizeof(char)), a += (l) )
681
682void luaO_chunkid (char *out, const char *source, size_t srclen) {
683 size_t bufflen = LUA_IDSIZE; /* free space in buffer */
684 if (*source == '=') { /* 'literal' source */
685 if (srclen <= bufflen) /* small enough? */
686 memcpy(out, source + 1, srclen * sizeof(char));
687 else { /* truncate it */
688 addstr(out, source + 1, bufflen - 1);
689 *out = '\0';
690 }
691 }
692 else if (*source == '@') { /* file name */
693 if (srclen <= bufflen) /* small enough? */
694 memcpy(out, source + 1, srclen * sizeof(char));
695 else { /* add '...' before rest of name */
696 addstr(out, RETS, LL(RETS));
697 bufflen -= LL(RETS);
698 memcpy(out, source + 1 + srclen - bufflen, bufflen * sizeof(char));
699 }
700 }
701 else { /* string; format as [string "source"] */
702 const char *nl = strchr(source, '\n'); /* find first new line (if any) */
703 addstr(out, PRE, LL(PRE)); /* add prefix */
704 bufflen -= LL(PRE RETS POS) + 1; /* save space for prefix+suffix+'\0' */
705 if (srclen < bufflen && nl == NULL) { /* small one-line source? */
706 addstr(out, source, srclen); /* keep it */
707 }
708 else {
709 if (nl != NULL)
710 srclen = ct_diff2sz(nl - source); /* stop at first newline */
711 if (srclen > bufflen) srclen = bufflen;
712 addstr(out, source, srclen);
713 addstr(out, RETS, LL(RETS));
714 }
715 memcpy(out, POS, (LL(POS) + 1) * sizeof(char));
716 }
717}
718

Callers 2

funcinfoFunction · 0.70
luaG_addinfoFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected