** Get the next name in '*path' = 'name1;name2;name3;...', changing ** the ending ';' to '\0' to create a zero-terminated string. Return ** NULL when list ends. */
| 445 | ** NULL when list ends. |
| 446 | */ |
| 447 | static const char *getnextfilename (char **path, char *end) { |
| 448 | char *sep; |
| 449 | char *name = *path; |
| 450 | if (name == end) |
| 451 | return NULL; /* no more names */ |
| 452 | else if (*name == '\0') { /* from previous iteration? */ |
| 453 | *name = *LUA_PATH_SEP; /* restore separator */ |
| 454 | name++; /* skip it */ |
| 455 | } |
| 456 | sep = strchr(name, *LUA_PATH_SEP); /* find next separator */ |
| 457 | if (sep == NULL) /* separator not found? */ |
| 458 | sep = end; /* name goes until the end */ |
| 459 | *sep = '\0'; /* finish file name */ |
| 460 | *path = sep; /* will start next search from here */ |
| 461 | return name; |
| 462 | } |
| 463 | |
| 464 | |
| 465 | /* |