Changeset 22028


Ignore:
Timestamp:
Oct 22, 2012, 12:48:13 PM (8 years ago)
Author:
dmik
Message:

pe: A better fix for adding .EXE than r22016.

It will only add .EXE if there is no (any) extention already specified,
regardless of whether the path is present or not. This matches the
behavior of CMD.EXE on both Windows and OS/2.

Location:
trunk/src/peldr
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/peldr/helpers.c

    r21942 r22028  
    7575}
    7676
     77const char *str_find_last_char(const char *s, int c)
     78{
     79    int len = strlen (s);
     80    const char *e = s + len;
     81    while (e >= s && *e != c)
     82        e--;
     83    return e < s ? s + len : e;
     84}
     85
    7786//
    7887// BEGIN: taken from _ras.cpp
  • trunk/src/peldr/helpers.h

    r21942 r22028  
    2020const char *str_skip_char(const char *s, int c);
    2121const char *str_find_char(const char *s, int c);
     22const char *str_find_last_char(const char *s, int c);
    2223int vsnprintf (char *buf, int n, const char *fmt, va_list args);
    2324int snprintf(char *buf, int n, const char *fmt, ...);
  • trunk/src/peldr/pe.c

    r22016 r22028  
    199199        win32cmdline = pszTemp;
    200200
    201         // add the .EXE extension if missing (only if there's no path)
    202         if (*str_find_char(exeName, '.') == '\0' &&
    203             *str_find_char(exeName, '\\') == '\0' &&
    204             *str_find_char(exeName, '/') == '\0')
     201        // add the .EXE extension if missing (only if there's no extension already)
     202        if (*str_find_last_char(exeName, '.') == '\0')
    205203        {
    206204            int i = strlen(exeName);
    207             if (i < 4 || !((exeName[i-1] == 'E' || exeName[i-1] == 'e') &&
    208                            (exeName[i-2] == 'X' || exeName[i-2] == 'x') &&
    209                            (exeName[i-3] == 'E' || exeName[i-3] == 'e') &&
    210                            exeName[i-4] == '.'))
    211             {
    212                 if (i + 4 < CCHMAXPATH)
    213                     strcat(exeName, ".exe");
    214             }
     205            if (i + 4 < CCHMAXPATH)
     206                strcat(exeName, ".exe");
    215207        }
    216208
Note: See TracChangeset for help on using the changeset viewer.