diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2009-04-22 13:49:16 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2009-04-22 13:49:16 +0000 |
commit | 1cf4a0eb81ed85d222d3310c39ac89c84c13ca17 (patch) | |
tree | 11875bcafe1a1bb8b41ab1ef41d47c0a6d856326 /libbb | |
parent | 574c316e5ac576ba8f4aa07596dd21bca95eb333 (diff) | |
download | busybox-w32-1cf4a0eb81ed85d222d3310c39ac89c84c13ca17.tar.gz busybox-w32-1cf4a0eb81ed85d222d3310c39ac89c84c13ca17.tar.bz2 busybox-w32-1cf4a0eb81ed85d222d3310c39ac89c84c13ca17.zip |
httpd: simplify insane conf file parser
function old new delta
bb_simplify_abs_path_inplace - 98 +98
parse_expr 824 832 +8
passwd_main 1025 1027 +2
evalvar 1374 1376 +2
parse_command 1463 1460 -3
bb_simplify_path 137 55 -82
parse_conf 1572 1422 -150
------------------------------------------------------------------------------
(add/remove: 3/2 grow/shrink: 3/3 up/down: 126/-251) Total: -125 bytes
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/simplify_path.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/libbb/simplify_path.c b/libbb/simplify_path.c index 367f1f04d..f80e3e8a5 100644 --- a/libbb/simplify_path.c +++ b/libbb/simplify_path.c | |||
@@ -6,22 +6,13 @@ | |||
6 | * | 6 | * |
7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
8 | */ | 8 | */ |
9 | |||
10 | #include "libbb.h" | 9 | #include "libbb.h" |
11 | 10 | ||
12 | char* FAST_FUNC bb_simplify_path(const char *path) | 11 | char* FAST_FUNC bb_simplify_abs_path_inplace(char *start) |
13 | { | 12 | { |
14 | char *s, *start, *p; | 13 | char *s, *p; |
15 | 14 | ||
16 | if (path[0] == '/') | ||
17 | start = xstrdup(path); | ||
18 | else { | ||
19 | s = xrealloc_getcwd_or_warn(NULL); | ||
20 | start = concat_path_file(s, path); | ||
21 | free(s); | ||
22 | } | ||
23 | p = s = start; | 15 | p = s = start; |
24 | |||
25 | do { | 16 | do { |
26 | if (*p == '/') { | 17 | if (*p == '/') { |
27 | if (*s == '/') { /* skip duplicate (or initial) slash */ | 18 | if (*s == '/') { /* skip duplicate (or initial) slash */ |
@@ -47,7 +38,22 @@ char* FAST_FUNC bb_simplify_path(const char *path) | |||
47 | if ((p == start) || (*p != '/')) { /* not a trailing slash */ | 38 | if ((p == start) || (*p != '/')) { /* not a trailing slash */ |
48 | ++p; /* so keep last character */ | 39 | ++p; /* so keep last character */ |
49 | } | 40 | } |
50 | *p = 0; | 41 | *p = '\0'; |
42 | return p; | ||
43 | } | ||
44 | |||
45 | char* FAST_FUNC bb_simplify_path(const char *path) | ||
46 | { | ||
47 | char *s, *p; | ||
48 | |||
49 | if (path[0] == '/') | ||
50 | s = xstrdup(path); | ||
51 | else { | ||
52 | p = xrealloc_getcwd_or_warn(NULL); | ||
53 | s = concat_path_file(p, path); | ||
54 | free(p); | ||
55 | } | ||
51 | 56 | ||
52 | return start; | 57 | bb_simplify_abs_path_inplace(s); |
58 | return s; | ||
53 | } | 59 | } |