/[ascend]/trunk/base/generic/general/ospath.c
ViewVC logotype

Diff of /trunk/base/generic/general/ospath.c

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

revision 997 by johnpye, Wed Dec 13 23:53:57 2006 UTC revision 998 by johnpye, Sat Dec 30 06:05:48 2006 UTC
# Line 40  Line 40 
40    
41  /* to test this code, 'gcc -DTEST ospath.c && ./a' */  /* to test this code, 'gcc -DTEST ospath.c && ./a' */
42    
43  #ifndef __FUNCTION__  #ifndef __GNUC__
44  # define __FUNCTION__ "<ospath>"  # ifndef __FUNCTION__
45    #  define __FUNCTION__ "<ospath>"
46    # endif
47  #endif  #endif
48    
49    
# Line 71  Line 73 
73  # define X(VAR) fprintf(stderr,"%s:%d: (%s) %s=%s\n",__FILE__,__LINE__,__FUNCTION__,#VAR,VAR);fflush(stderr)  # define X(VAR) fprintf(stderr,"%s:%d: (%s) %s=%s\n",__FILE__,__LINE__,__FUNCTION__,#VAR,VAR);fflush(stderr)
74  # define C(VAR) fprintf(stderr,"%s:%d: (%s) %s=%c\n",__FILE__,__LINE__,__FUNCTION__,#VAR,VAR);fflush(stderr)  # define C(VAR) fprintf(stderr,"%s:%d: (%s) %s=%c\n",__FILE__,__LINE__,__FUNCTION__,#VAR,VAR);fflush(stderr)
75  # define V(VAR) fprintf(stderr,"%s:%d: (%s) %s=%d\n",__FILE__,__LINE__,__FUNCTION__,#VAR,(VAR));fflush(stderr)  # define V(VAR) fprintf(stderr,"%s:%d: (%s) %s=%d\n",__FILE__,__LINE__,__FUNCTION__,#VAR,(VAR));fflush(stderr)
76    # define P(VAR) fprintf(stderr,"%s:%d: (%s) %s=%p\n",__FILE__,__LINE__,__FUNCTION__,#VAR,(VAR));fflush(stderr)
77  # define D(VAR) fprintf(stderr,"%s:%d: (%s) %s=",__FILE__,__LINE__,__FUNCTION__,#VAR);ospath_debug(VAR);fflush(stderr)  # define D(VAR) fprintf(stderr,"%s:%d: (%s) %s=",__FILE__,__LINE__,__FUNCTION__,#VAR);ospath_debug(VAR);fflush(stderr)
78  # define DD(VAR) fprintf(stderr,"%c[34;1m%s:%d: (%s)%c[0m %s=",27,__FILE__,__LINE__,__FUNCTION__,27,#VAR);ospath_debug(VAR);fflush(stderr)  # define DD(VAR) fprintf(stderr,"%c[34;1m%s:%d: (%s)%c[0m %s=",27,__FILE__,__LINE__,__FUNCTION__,27,#VAR);ospath_debug(VAR);fflush(stderr)
79  #else  #else
# Line 81  Line 84 
84  # define C(VAR) ((void)0)  # define C(VAR) ((void)0)
85  # define V(VAR) ((void)0)  # define V(VAR) ((void)0)
86  # define D(VAR) ((void)0)  # define D(VAR) ((void)0)
87    # define P(VAR) ((void)0)
88  # define DD(VAR) ((void)0)  # define DD(VAR) ((void)0)
89  # define MM(VAR) ((void)0)  # define MM(VAR) ((void)0)
90  #endif  #endif
# Line 188  struct FilePath *ospath_new(const char * Line 192  struct FilePath *ospath_new(const char *
192  /** Create but with no 'cleanup', and no fixing of / vs \. */  /** Create but with no 'cleanup', and no fixing of / vs \. */
193  struct FilePath *ospath_new_noclean(const char *path){  struct FilePath *ospath_new_noclean(const char *path){
194      struct FilePath *fp = (struct FilePath *)MALLOC(sizeof(struct FilePath));      struct FilePath *fp = (struct FilePath *)MALLOC(sizeof(struct FilePath));
195        P(fp);
196        X(path);
197      STRNCPY(fp->path,path,PATH_MAX);      STRNCPY(fp->path,path,PATH_MAX);
198      assert(strcmp(fp->path,path)==0);      assert(strcmp(fp->path,path)==0);
199  #ifdef WINPATHS  #ifdef WINPATHS
# Line 253  struct FilePath *ospath_new_from_posix(c Line 259  struct FilePath *ospath_new_from_posix(c
259    
260  void ospath_free(struct FilePath *fp){  void ospath_free(struct FilePath *fp){
261      if(fp!=NULL){      if(fp!=NULL){
262            P(fp);
263          FREE(fp);          FREE(fp);
264      }      }
265      fp=NULL;      fp=NULL;
# Line 327  void ospath_fixslash(char *path){ Line 334  void ospath_fixslash(char *path){
334  #endif  #endif
335    
336  struct FilePath *ospath_getcwd(void){  struct FilePath *ospath_getcwd(void){
337      struct FilePath *fp = (struct FilePath *)MALLOC(sizeof(struct FilePath));      struct FilePath *fp;
338      char *cwd;      char *cwd;
339    
340      /* get current working directory */      /* get current working directory */
# Line 480  void ospath_cleanup(struct FilePath *fp) Line 487  void ospath_cleanup(struct FilePath *fp)
487    
488                  D(fp);                  D(fp);
489                  X(p);                  X(p);
 #if 0  
490                  X(path+strlen(p)+1);                  X(path+strlen(p)+1);
491    
492                  ospath_free(working);                  ospath_free(working);
 #endif  
493                  continue;                  continue;
494              }else{/* later in the path: just skip it */              }else{/* later in the path: just skip it */
495                  M("SKIPPING '.' IN PATH");                  M("SKIPPING '.' IN PATH");
# Line 496  void ospath_cleanup(struct FilePath *fp) Line 502  void ospath_cleanup(struct FilePath *fp)
502              if(ospath_isvalid(parent)){              if(ospath_isvalid(parent)){
503                  ospath_copy(fp,parent);                  ospath_copy(fp,parent);
504              }              }
 #if 0  
505              ospath_free(parent);              ospath_free(parent);
 #endif  
506              continue;              continue;
507          }          }
508    
# Line 642  struct FilePath *ospath_getparent(struct Line 646  struct FilePath *ospath_getparent(struct
646          return ospath_new_noclean(fp->path);          return ospath_new_noclean(fp->path);
647      }      }
648    
649        M("Creating 'sub'");
650      fp1 = ospath_new_noclean(sub);      fp1 = ospath_new_noclean(sub);
651        M("... 'sub'");
652      D(fp1);      D(fp1);
653      return fp1;      return fp1;
654  }  }
# Line 1254  struct FilePath **ospath_searchpath_new( Line 1260  struct FilePath **ospath_searchpath_new(
1260  #if 0  #if 0
1261          D(pp[i]);          D(pp[i]);
1262  #endif  #endif
1263            FREE(list[i]);
1264      }      }
1265      pp[n] = NULL;      pp[n] = NULL;
1266    

Legend:
Removed from v.997  
changed lines
  Added in v.998

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22