| 7440 | |
| 7441 | |
| 7442 | void luaO_chunkid (char *out, const char *source, size_t bufflen) { |
| 7443 | if (*source == '=') { |
| 7444 | strncpy(out, source+1, bufflen); /* remove first char */ |
| 7445 | out[bufflen-1] = '\0'; /* ensures null termination */ |
| 7446 | } |
| 7447 | else { /* out = "source", or "...source" */ |
| 7448 | if (*source == '@') { |
| 7449 | size_t l; |
| 7450 | source++; /* skip the `@' */ |
| 7451 | bufflen -= sizeof(" '...' "); |
| 7452 | l = strlen(source); |
| 7453 | strcpy(out, ""); |
| 7454 | if (l > bufflen) { |
| 7455 | source += (l-bufflen); /* get last part of file name */ |
| 7456 | strcat(out, "..."); |
| 7457 | } |
| 7458 | strcat(out, source); |
| 7459 | } |
| 7460 | else { /* out = [string "string"] */ |
| 7461 | size_t len = strcspn(source, "\n\r"); /* stop at first newline */ |
| 7462 | bufflen -= sizeof(" [string \"...\"] "); |
| 7463 | if (len > bufflen) len = bufflen; |
| 7464 | strcpy(out, "[string \""); |
| 7465 | if (source[len] != '\0') { /* must truncate? */ |
| 7466 | strncat(out, source, len); |
| 7467 | strcat(out, "..."); |
| 7468 | } |
| 7469 | else |
| 7470 | strcat(out, source); |
| 7471 | strcat(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 |
no outgoing calls
no test coverage detected