Magellan Linux

Diff of /tags/mkinitrd-6_1_11/busybox/libbb/simplify_path.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 532 by niro, Sat Sep 1 22:45:15 2007 UTC revision 816 by niro, Fri Apr 24 18:33:46 2009 UTC
# Line 9  Line 9 
9    
10  #include "libbb.h"  #include "libbb.h"
11    
12  char *bb_simplify_path(const char *path)  char* FAST_FUNC bb_simplify_path(const char *path)
13  {  {
14   char *s, *start, *p;   char *s, *start, *p;
15    
16   if (path[0] == '/')   if (path[0] == '/')
17   start = xstrdup(path);   start = xstrdup(path);
18   else {   else {
19   s = xgetcwd(NULL);   s = xrealloc_getcwd_or_warn(NULL);
20   start = concat_path_file(s, path);   start = concat_path_file(s, path);
21   free(s);   free(s);
22   }   }
# Line 26  char *bb_simplify_path(const char *path) Line 26  char *bb_simplify_path(const char *path)
26   if (*p == '/') {   if (*p == '/') {
27   if (*s == '/') { /* skip duplicate (or initial) slash */   if (*s == '/') { /* skip duplicate (or initial) slash */
28   continue;   continue;
29   } else if (*s == '.') {   }
30   if (s[1] == '/' || s[1] == 0) { /* remove extra '.' */   if (*s == '.') {
31     if (s[1] == '/' || !s[1]) { /* remove extra '.' */
32   continue;   continue;
33   } else if ((s[1] == '.') && (s[2] == '/' || s[2] == 0)) {   }
34     if ((s[1] == '.') && (s[2] == '/' || !s[2])) {
35   ++s;   ++s;
36   if (p > start) {   if (p > start) {
37   while (*--p != '/'); /* omit previous dir */   while (*--p != '/') /* omit previous dir */
38     continue;
39   }   }
40   continue;   continue;
41   }   }

Legend:
Removed from v.532  
changed lines
  Added in v.816