Changeset 2648 for branches


Ignore:
Timestamp:
Mar 15, 2006, 5:24:06 AM (19 years ago)
Author:
bird
Message:

#69: Corrected a few problems related to dos drives and slashes in basename and dirname.

Location:
branches/libc-0.6/src
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/src/lib/misc/basename.c

    r1506 r2648  
    7171        }
    7272
     73        /* d:/ */
     74        if (*endp == ':' && endp == path + 1) {
     75                (void)strncpy(bname, path, 3);
     76                bname[3] = '\0';
     77                return(bname);
     78        }
     79
    7380        /* Find the start of the base */
    7481        startp = endp;
    75         while (startp > path && *(startp - 1) != '/' && *(startp - 1) != '\\' && *(startp - 1) != ':')
     82        while (    startp > path
     83               &&  *(startp - 1) != '/'
     84               &&  *(startp - 1) != '\\'
     85               &&  (*(startp - 1) != ':' || startp != path + 2))
    7686                startp--;
    7787
  • branches/libc-0.6/src/emx/src/lib/misc/dirname.c

    r1506 r2648  
    6767
    6868        /* Find the start of the dir */
    69         while (endp > path && *endp != '/' && *endp != '/' && *endp != ':')
     69        while (endp > path && *endp != '/' && *endp != '\\' && (*endp != ':' || endp != path + 1))
    7070                endp--;
    7171
     
    7474                (void)strcpy(bname, *endp == '/' || *endp == '\\' ? "/" : ".");
    7575                return(bname);
    76         } else {
     76        }
     77
     78        if (*endp == ':' && endp == path + 1) {
     79                if (endp[1] == '/' || endp[1] == '\\')
     80                        endp++;
     81        } else if (endp != path + 2 || path[1] != ':') {
    7782                do {
    7883                        endp--;
  • branches/libc-0.6/src/libctests/libc/Makefile

    r2547 r2648  
    9696        smoketests/fchmod-1.c \
    9797        smoketests/nonblock-1.c \
    98         smoketests/fclose-2.c
     98        smoketests/fclose-2.c \
     99        smoketests/basename-dirname-1.c
    99100       
    100101#       smoketests/weak-export-1.c - dll
Note: See TracChangeset for help on using the changeset viewer.