lib/package_alternatives.c: get rid of goto in normpath.

This commit is contained in:
Enno Boland 2015-11-08 10:38:31 +01:00
parent 8bd2808108
commit 19a65158d9

View File

@ -62,11 +62,10 @@ right(const char *str)
static const char * static const char *
normpath(char *path) { normpath(char *path) {
char *seg, *p; char *seg, *p;
reinit:
for (p = path, seg = NULL; *p; p++) { for (p = path, seg = NULL; *p; p++) {
if (strncmp(p, "/../", 4) == 0 || strncmp(p, "/..", 4) == 0) { if (strncmp(p, "/../", 4) == 0 || strncmp(p, "/..", 4) == 0) {
memmove(seg ? seg : p, p+3, strlen(p+3) + 1); memmove(seg ? seg : p, p+3, strlen(p+3) + 1);
goto reinit; return normpath(path);
} }
else if (strncmp(p, "/./", 3) == 0 || strncmp(p, "/.", 3) == 0) { else if (strncmp(p, "/./", 3) == 0 || strncmp(p, "/.", 3) == 0) {
memmove(p, p+2, strlen(p+2) + 1); memmove(p, p+2, strlen(p+2) + 1);