Ignore:
Timestamp:
Oct 6, 2007, 3:59:35 AM (18 years ago)
Author:
bird
Message:

Fixed a couple of slash problems in cp and install (dos based systems).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin/cp.c

    r1183 r1194  
    100100#endif
    101101
     102#if defined(__WIN32__) || defined(__WIN64__) || defined(__OS2__)
     103# define IS_SLASH(ch)   ((ch) == '/' || (ch) == '\\')
     104#else
     105# define IS_SLASH(ch)   ((ch) == '/')
     106#endif
     107
    102108#define STRIP_TRAILING_SLASH(p) {                                       \
    103         while ((p).p_end > (p).p_path + 1 && (p).p_end[-1] == '/')      \
     109        while ((p).p_end > (p).p_path + 1 && IS_SLASH((p).p_end[-1]))   \
    104110                *--(p).p_end = 0;                                       \
    105111}
     
    257263                *to.p_end = 0;
    258264        }
    259         have_trailing_slash = (to.p_end[-1] == '/');
     265        have_trailing_slash = IS_SLASH(to.p_end[-1]);
    260266        if (have_trailing_slash)
    261267                STRIP_TRAILING_SLASH(to);
     
    388394                                if (type != DIR_TO_DNE) {
    389395                                        p = strrchr(curr->fts_path, '/');
     396#if defined(__WIN32__) || defined(__WIN64__) || defined(__OS2__)
     397                                        if (strrchr(curr->fts_path, '\\') > p)
     398                                            p = strrchr(curr->fts_path, '\\');
     399#endif
    390400                                        base = (p == NULL) ? 0 :
    391401                                            (int)(p - curr->fts_path + 1);
     
    401411                        nlen = curr->fts_pathlen - base;
    402412                        target_mid = to.target_end;
    403                         if (*p != '/' && target_mid[-1] != '/')
     413                        if (!IS_SLASH(*p) && !IS_SLASH(target_mid[-1]))
    404414                                *target_mid++ = '/';
    405415                        *target_mid = 0;
Note: See TracChangeset for help on using the changeset viewer.