** Load a nullable string into prototype 'p'. */
| 108 | ** Load a nullable string into prototype 'p'. |
| 109 | */ |
| 110 | static TString *loadStringN (LoadState *S, Proto *p) { |
| 111 | lua_State *L = S->L; |
| 112 | TString *ts; |
| 113 | size_t size = loadSize(S); |
| 114 | if (size == 0) /* no string? */ |
| 115 | return NULL; |
| 116 | else if (--size <= LUAI_MAXSHORTLEN) { /* short string? */ |
| 117 | char buff[LUAI_MAXSHORTLEN]; |
| 118 | loadVector(S, buff, size); /* load string into buffer */ |
| 119 | ts = luaS_newlstr(L, buff, size); /* create string */ |
| 120 | } |
| 121 | else { /* long string */ |
| 122 | ts = luaS_createlngstrobj(L, size); /* create string */ |
| 123 | setsvalue2s(L, L->top, ts); /* anchor it ('loadVector' can GC) */ |
| 124 | luaD_inctop(L); |
| 125 | loadVector(S, getstr(ts), size); /* load directly in final place */ |
| 126 | L->top--; /* pop string */ |
| 127 | } |
| 128 | luaC_objbarrier(L, p, ts); |
| 129 | return ts; |
| 130 | } |
| 131 | |
| 132 | |
| 133 | /* |
no test coverage detected