Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/libbb/simplify_path.c

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

revision 983 by niro, Fri Apr 24 18:33:46 2009 UTC revision 984 by niro, Sun May 30 11:32:42 2010 UTC
# Line 6  Line 6 
6   *   *
7   * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.   * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8   */   */
   
9  #include "libbb.h"  #include "libbb.h"
10    
11  char* FAST_FUNC bb_simplify_path(const char *path)  char* FAST_FUNC bb_simplify_abs_path_inplace(char *start)
12  {  {
13   char *s, *start, *p;   char *s, *p;
14    
  if (path[0] == '/')  
  start = xstrdup(path);  
  else {  
  s = xrealloc_getcwd_or_warn(NULL);  
  start = concat_path_file(s, path);  
  free(s);  
  }  
15   p = s = start;   p = s = start;
   
16   do {   do {
17   if (*p == '/') {   if (*p == '/') {
18   if (*s == '/') { /* skip duplicate (or initial) slash */   if (*s == '/') { /* skip duplicate (or initial) slash */
# Line 47  char* FAST_FUNC bb_simplify_path(const c Line 38  char* FAST_FUNC bb_simplify_path(const c
38   if ((p == start) || (*p != '/')) { /* not a trailing slash */   if ((p == start) || (*p != '/')) { /* not a trailing slash */
39   ++p; /* so keep last character */   ++p; /* so keep last character */
40   }   }
41   *p = 0;   *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     }
56    
57   return start;   bb_simplify_abs_path_inplace(s);
58     return s;
59  }  }

Legend:
Removed from v.983  
changed lines
  Added in v.984