Changeset 1248 for trunk/dll/pathutil.c


Ignore:
Timestamp:
Oct 16, 2008, 12:10:00 AM (17 years ago)
Author:
Gregg Young
Message:

Cleanup of NormalizeCmdLine changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/pathutil.c

    r1247 r1248  
    116116/** NormalizeCmdLine
    117117 * Checks a command line for common errors (missing quotes, missing extension,
    118  * no space between exe and args etc)
     118 * no space between exe and args etc) Also check for the existance of the file
     119 * and checks .com and .exe file headers.
    119120 * Command line passed as pszCmdLine_
    120121 * A pointer to a buffer of the size MaxComLineStrg should be supplied in
     
    131132  char *pszChar;
    132133  char *FullPath;
    133   FILEFINDBUF3 FindBuffer;
    134   ULONG ulResultBufLen = sizeof(FILEFINDBUF3);
    135   HDIR hdirFindHandle = HDIR_CREATE;
    136   ULONG ulFindCount = 1;
    137134  PSZ pszNewCmdLine = pszWorkBuf;
    138135
     
    187184               pszCmdLine_);
    188185      if (!offsetexe && !offsetcom) {
    189         ret = DosFindFirst(szCmdLine, &hdirFindHandle, FILE_NORMAL, &FindBuffer,
    190                            ulResultBufLen, &ulFindCount, FIL_STANDARD);
    191         if (ret) {
    192           FullPath = searchapath("PATH", szCmdLine);
    193           if (*FullPath != 0)
    194             ret = 0;
    195         }
    196         DosFindClose(hdirFindHandle);
     186        FullPath = searchapath("PATH", szCmdLine);
     187        if (*FullPath)
     188          ret = 0;
    197189      }
    198190      else
     
    230222        while (strchr(szCmdLine, '\"'))
    231223          remove_first_occurence_of_character("\"", szCmdLine);
    232         ret = DosQueryAppType(szCmdLine, &ulAppType);
     224        ret = DosQueryAppType(szCmdLine, &ulAppType); // exe automatically appended
    233225        if (!ret)
    234226          strcat(szCmdLine, ".exe");
     
    241233            strcat(szCmdLine, ".cmd");
    242234            FullPath = searchapath("PATH", szCmdLine);
    243             if (*FullPath != 0)
     235            if (*FullPath)
    244236              ret = 0;
    245237            else {
    246               offset = strrchr(szCmdLine, '.' );
    247238              *offset = 0;
    248239              strcat(szCmdLine, ".bat");
    249240              FullPath = searchapath("PATH", szCmdLine);
    250               if (*FullPath != 0)
     241              if (*FullPath)
    251242                ret = 0;
    252243              else {
    253                 offset = strrchr(szCmdLine, '.' );
    254244                *offset = 0;
    255245                strcat(szCmdLine, ".bmt");
    256246                FullPath = searchapath("PATH", szCmdLine);
    257                 if (*FullPath != 0)
     247                if (*FullPath)
    258248                  ret = 0;
    259249              }
     
    283273                strcat(szCmdLine, ".cmd");
    284274                FullPath = searchapath("PATH", szCmdLine);
    285                 if (*FullPath != 0) {
     275                if (*FullPath) {
    286276                  ret = 0;
    287277                  break;
    288278                }
    289279                else {
    290                   offset = strrchr(szCmdLine, '.' );
    291280                  *offset = 0;
    292281                  strcat(szCmdLine, ".bat");
    293282                  FullPath = searchapath("PATH", szCmdLine);
    294                   if (*FullPath != 0) {
     283                  if (*FullPath) {
    295284                    ret = 0;
    296285                    break;
    297286                  }
    298287                  else {
    299                     offset = strrchr(szCmdLine, '.' );
    300288                    *offset = 0;
    301289                    strcat(szCmdLine, ".bmt");
    302290                    FullPath = searchapath("PATH", szCmdLine);
    303                     if (*FullPath != 0) {
     291                    if (*FullPath) {
    304292                      ret = 0;
    305293                      break;
     
    333321        strcat(pszNewCmdLine, szArgs);
    334322      }
    335       else { // fail if no extension can be found we require one
     323      else { // fail if no extension can be found runemf2 requires one
    336324        ret = saymsg(MB_OK,
    337325                     HWND_DESKTOP,
     
    361349             GetPString(IDS_QUOTESINARGSTEXT),
    362350             pszCmdLine_);
    363     ret = DosFindFirst(szCmdLine, &hdirFindHandle, FILE_NORMAL, &FindBuffer,
    364                        ulResultBufLen, &ulFindCount, FIL_STANDARD);
    365     DosFindClose(hdirFindHandle);
     351    FullPath = searchapath("PATH", szCmdLine);
    366352    BldQuotedFileName(pszNewCmdLine, szCmdLine);
    367353    //printf("%d %s ", ret, szCmdLine); fflush(stdout);
    368     if (ret) {
     354    if (!*FullPath) {
    369355      ret = saymsg(MB_YESNO,
    370356                   HWND_DESKTOP,
     
    382368      }
    383369    }
    384     ret = saymsg(MB_YESNOCANCEL,
     370    else {
     371      ret = saymsg(MB_YESNOCANCEL,
    385372                   HWND_DESKTOP,
    386373                   NullStr,
    387374                   GetPString(IDS_PROGRAMNOTEXE3TEXT),
    388375                   pszCmdLine_, pszNewCmdLine);
    389       if (ret == MBID_YES){
    390         if (szArgs[0] != ' ')
    391           strcat(pszNewCmdLine, " ");
    392         strcat(pszNewCmdLine, szArgs);
    393       }
    394       if (ret == MBID_CANCEL){
    395         fCancelAction = TRUE;
    396         pszNewCmdLine = pszCmdLine_;
     376        if (ret == MBID_YES){
     377          if (szArgs[0] != ' ')
     378            strcat(pszNewCmdLine, " ");
     379          strcat(pszNewCmdLine, szArgs);
     380        }
     381        if (ret == MBID_CANCEL){
     382          fCancelAction = TRUE;
     383          pszNewCmdLine = pszCmdLine_;
     384        }
    397385      }
    398386    }
Note: See TracChangeset for help on using the changeset viewer.