Changeset 783


Ignore:
Timestamp:
Aug 14, 2007, 6:09:54 AM (18 years ago)
Author:
Steven Levine
Message:

Rework DosFindFirst/Next loops to optimize memory allocation and code paths
Adjust FilesToGet limits
Update configuration notebook scanning page
Start updating #pragma alloc_text positioning for OpenWatcom compatibility

Location:
trunk/dll
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/comp.c

    r775 r783  
    3131  07 Aug 07 SHL COMP_COLLECT: Avoid collecting empty entries when nothing selected
    3232  06 Aug 07 GKY Reduce DosSleep times (ticket 148)
    33 
     33  13 Aug 07 SHL Sync code with other FilesToGet usage
     34  13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat
    3435
    3536***********************************************************************/
     
    3738#define INCL_DOS
    3839#define INCL_WIN
     40#define INCL_DOSERRORS
    3941#define INCL_GPI
    4042#define INCL_LONGLONG
     
    5254#include "fm3dlg.h"
    5355#include "fm3str.h"
    54 
    55 #pragma alloc_text(COMPAREDIR,FillCnrsThread,FillDirList,CompNames,BldFullPathName)
    56 #pragma alloc_text(COMPAREDIR1,CompareDlgProc)
    57 #pragma alloc_text(COMPAREDIR2,SelectCnrsThread,ActionCnrThread)
    58 #pragma alloc_text(COMPAREFILE,CFileDlgProc,CompareFilesThread)
    59 #pragma alloc_text(SNAPSHOT,SnapShot,StartSnap)
    6056
    6157typedef struct
     
    9288//=== SnapShot() Write directory tree to file and recurse if requested ===
    9389
    94 static VOID SnapShot(char *path, FILE * fp, BOOL recurse)
     90static VOID SnapShot(char *path, FILE *fp, BOOL recurse)
    9591{
    96   FILEFINDBUF4 *fb;
     92  PFILEFINDBUF4 pffb;
    9793  char *mask, *enddir;
    9894  HDIR hdir = HDIR_CREATE;
    99   ULONG nm = 1;
    100 
    101   fb = xmalloc(sizeof(FILEFINDBUF4), pszSrcFile, __LINE__);
    102   if (fb) {
     95  ULONG ulFindCnt;
     96
     97  // 13 Aug 07 SHL fimxe to use FileToGet
     98  pffb = xmalloc(sizeof(FILEFINDBUF4), pszSrcFile, __LINE__);
     99  if (pffb) {
    103100    mask = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
    104101    if (mask) {
    105       sprintf(mask,
    106               "%s%s*",
    107               path, (path[strlen(path) - 1] != '\\') ? "\\" : NullStr);
     102      BldFullPathName(mask, path, "*");
     103      // sprintf(mask,
     104      //         "%s%s*",
     105      //         path, (path[strlen(path) - 1] != '\\') ? "\\" : NullStr);
    108106      enddir = strrchr(mask, '\\');
    109107      enddir++;
     108      ulFindCnt = 1;
     109      // 13 Aug 07 SHL fixme to report errors
    110110      if (!DosFindFirst(mask,
    111111                        &hdir,
     
    113113                        FILE_ARCHIVED | FILE_READONLY | FILE_HIDDEN |
    114114                        FILE_SYSTEM,
    115                         fb, sizeof(FILEFINDBUF4), &nm, FIL_QUERYEASIZE)) {
     115                        pffb, sizeof(FILEFINDBUF4), &ulFindCnt, FIL_QUERYEASIZE)) {
    116116        do {
    117           strcpy(enddir, fb->achName);
    118           if (!(fb->attrFile & FILE_DIRECTORY))
     117          strcpy(enddir, pffb->achName);
     118          if (!(pffb->attrFile & FILE_DIRECTORY))
    119119            fprintf(fp,
    120120                    "\"%s\",%u,%lu,%04u/%02u/%02u,%02u:%02u:%02u,%lu,%lu,N\n",
    121121                    mask,
    122122                    enddir - mask,
    123                     fb->cbFile,
    124                     (fb->fdateLastWrite.year + 1980),
    125                     fb->fdateLastWrite.month,
    126                     fb->fdateLastWrite.day,
    127                     fb->ftimeLastWrite.hours,
    128                     fb->ftimeLastWrite.minutes,
    129                     fb->ftimeLastWrite.twosecs,
    130                     fb->attrFile, (fb->cbList > 4) ? (fb->cbList / 2) : 0);
     123                    pffb->cbFile,
     124                    (pffb->fdateLastWrite.year + 1980),
     125                    pffb->fdateLastWrite.month,
     126                    pffb->fdateLastWrite.day,
     127                    pffb->ftimeLastWrite.hours,
     128                    pffb->ftimeLastWrite.minutes,
     129                    pffb->ftimeLastWrite.twosecs,
     130                    pffb->attrFile, (pffb->cbList > 4) ? (pffb->cbList / 2) : 0);
    131131          // Skip . and ..
    132132          else if (recurse &&
    133                    (fb->achName[0] != '.' ||
    134                     (fb->achName[1] &&
    135                      (fb->achName[1] != '.' || fb->achName[2])))) {
     133                   (pffb->achName[0] != '.' ||
     134                    (pffb->achName[1] &&
     135                     (pffb->achName[1] != '.' || pffb->achName[2])))) {
    136136            SnapShot(mask, fp, recurse);
    137137          }
    138           nm = 1;
    139         } while (!DosFindNext(hdir, fb, sizeof(FILEFINDBUF4), &nm));
     138          ulFindCnt = 1;
     139        } while (!DosFindNext(hdir, pffb, sizeof(FILEFINDBUF4), &ulFindCnt));
    140140        DosFindClose(hdir);
    141141      }
    142142      free(mask);
    143143    }
    144     free(fb);
     144    free(pffb);
    145145  }
    146146}
     
    683683  HMQ hmq;
    684684
    685   if (!cmp)
     685  if (!cmp) {
     686    Runtime_Error(pszSrcFile, __LINE__, "no data");
    686687    return;
     688  }
    687689
    688690  DosError(FERR_DISABLEHARDERR);
     
    729731                        FILELIST ***list, INT *numfiles, INT *numalloc)
    730732{
    731 
    732   BYTE *fb;
    733733  CHAR *enddir;
    734734  ULONG x;
    735735  CHAR *maskstr;
    736   FILEFINDBUF4 *ffb4, *pffb;
     736  PFILEFINDBUF4 pffbArray;
     737  PFILEFINDBUF4 pffbFile;
    737738  HDIR hDir;
    738   ULONG nm, fl = 0, ulM = FilesToGet;
     739  ULONG ulFindCnt;
     740  ULONG ulBufBytes = sizeof(FILEFINDBUF4) * FilesToGet;
    739741  APIRET rc;
    740742
     
    744746  }
    745747
    746   //if (!recurse)
    747   //  ulM = FilesToGet;
    748748  maskstr = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
    749749  if (!maskstr)
    750750    return;
    751   ffb4 = xmalloc(sizeof(FILEFINDBUF4) * ulM, pszSrcFile, __LINE__);
    752   if (!ffb4) {
     751  pffbArray = xmalloc(ulBufBytes, pszSrcFile, __LINE__);
     752  if (!pffbArray) {
    753753    free(maskstr);
    754754    return;
     
    765765  *(enddir + 1) = 0;
    766766  hDir = HDIR_CREATE;
    767   nm = ulM;
    768   if (recurse)
    769     fl = FILE_DIRECTORY;
    770767  DosError(FERR_DISABLEHARDERR);
     768  ulFindCnt = FilesToGet;
    771769  rc = DosFindFirst(maskstr, &hDir,
    772                     (FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED |
    773                      FILE_SYSTEM | FILE_HIDDEN) | fl,
    774                     ffb4, sizeof(FILEFINDBUF4) * nm, &nm, FIL_QUERYEASIZE);
     770                    FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED |
     771                    FILE_SYSTEM | FILE_HIDDEN |
     772                    (recurse ? FILE_DIRECTORY : 0),
     773                    pffbArray, ulBufBytes, &ulFindCnt, FIL_QUERYEASIZE);
    775774  if (!rc) {
    776     while (!rc) {
    777       fb = (BYTE *) ffb4;
    778       x = 0;
    779       while (x < nm) {
    780         pffb = (FILEFINDBUF4 *) fb;
    781         if (pffb->attrFile & FILE_DIRECTORY) {
     775    do {
     776      pffbFile = pffbArray;
     777      for (x = 0; x < ulFindCnt; x++) {
     778        if (pffbFile->attrFile & FILE_DIRECTORY) {
    782779          // Skip . and ..
    783780          if (recurse &&
    784               (pffb->achName[0] != '.' ||
    785                (pffb->achName[1] &&
    786                 (pffb->achName[1] != '.' || pffb->achName[2])))) {
     781              (pffbFile->achName[0] != '.' ||
     782               (pffbFile->achName[1] &&
     783                (pffbFile->achName[1] != '.' || pffbFile->achName[2])))) {
    787784            if (fForceUpper)
    788               strupr(pffb->achName);
     785              strupr(pffbFile->achName);
    789786            else if (fForceLower)
    790               strlwr(pffb->achName);
    791             memcpy(enddir, pffb->achName, pffb->cchName + 1);
     787              strlwr(pffbFile->achName);
     788            memcpy(enddir, pffbFile->achName, pffbFile->cchName + 1);
    792789            FillDirList(maskstr, skiplen, recurse, list, numfiles, numalloc);
    793790          }
     
    795792        else {
    796793          if (fForceUpper)
    797             strupr(pffb->achName);
     794            strupr(pffbFile->achName);
    798795          else if (fForceLower)
    799             strlwr(pffb->achName);
    800           memcpy(enddir, pffb->achName, pffb->cchName + 1);
    801           if (AddToFileList
    802               (maskstr + skiplen, pffb, list, numfiles, numalloc))
     796            strlwr(pffbFile->achName);
     797          memcpy(enddir, pffbFile->achName, pffbFile->cchName + 1);
     798          if (AddToFileList(maskstr + skiplen,
     799                            pffbFile, list, numfiles, numalloc)) {
    803800            goto Abort;
    804         }
    805         fb += pffb->oNextEntryOffset;
    806         x++;
    807       }
    808       nm = ulM;
     801          }
     802        }
     803        pffbFile = (PFILEFINDBUF4)((PBYTE)pffbFile + pffbFile->oNextEntryOffset);
     804      } // for
    809805      DosError(FERR_DISABLEHARDERR);
    810       rc = DosFindNext(hDir, ffb4, sizeof(FILEFINDBUF4) * nm, &nm);
    811     }
    812   Abort:
     806      ulFindCnt = FilesToGet;
     807      rc = DosFindNext(hDir, pffbArray, ulBufBytes, &ulFindCnt);
     808    } while (!rc);
     809
     810Abort:
     811
    813812    DosFindClose(hDir);
    814813    DosSleep(1);
    815814  }
     815
     816  if (rc && rc != ERROR_NO_MORE_FILES) {
     817    Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     818              GetPString(IDS_CANTFINDDIRTEXT), maskstr);
     819  }
     820
    816821  free(maskstr);
    817   free(ffb4);
     822  free(pffbArray);
    818823}
    819824
     
    25002505  return WinDefDlgProc(hwnd, msg, mp1, mp2);
    25012506}
     2507
     2508#pragma alloc_text(COMPAREDIR,FillCnrsThread,FillDirList,CompNames,BldFullPathName)
     2509#pragma alloc_text(COMPAREDIR1,CompareDlgProc)
     2510#pragma alloc_text(COMPAREDIR2,SelectCnrsThread,ActionCnrThread)
     2511#pragma alloc_text(COMPAREFILE,CFileDlgProc,CompareFilesThread)
     2512#pragma alloc_text(SNAPSHOT,SnapShot,StartSnap)
     2513
  • trunk/dll/dirsize.c

    r781 r783  
    2828  03 Aug 07 SHL DirSizeProc; correct sizing and positioning to be deterministic
    2929  06 Aug 07 GKY Reduce DosSleep times (ticket 148)
    30   11 Aug 07 SHL ProcessDir: remove unneeded reallocs
     30  13 Aug 07 SHL ProcessDir: remove unneeded reallocs.  Sanitize code
     31  13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat
    3132
    3233***********************************************************************/
     
    6869static PSZ pszSrcFile = __FILE__;
    6970
    70 #pragma alloc_text(DIRSIZE,ProcessDir,FillCnrThread,DirSizeProc)
    71 #pragma alloc_text(DIRSIZE2,PrintToFile,FillInRecSizes,SortSizeCnr)
    72 
    73 static SHORT APIENTRY SortSizeCnr(PMINIRECORDCORE p1, PMINIRECORDCORE p2,
     71static SHORT APIENTRY SortSizeCnr(PMINIRECORDCORE p1,
     72                                  PMINIRECORDCORE p2,
    7473                                  PVOID SortFlags)
    7574{
     
    9594  register char *sp;
    9695  register char *pp;
    97   ULONG nm;
     96  ULONG ulFindCnt;
    9897  ULONGLONG ullCurDirBytes = 0;
    9998  ULONGLONG ullSubDirBytes = 0;
    10099  ULONGLONG ull;
    101100  HDIR hdir;
    102   FILEFINDBUF4 *pffb;
     101  PFILEFINDBUF4 pffbArray;
    103102  APIRET rc;
    104103  RECORDINSERT ri;
    105104  PCNRITEM pci;
    106 
    107   // fixme to report errors
     105  ULONG ulBufBytes;
     106
    108107  *pullTotalBytes = 0;                  // In case we fail
    109108
    110   pffb = xmalloc(sizeof(FILEFINDBUF4) * FilesToGet, pszSrcFile, __LINE__);
    111   if (!pffb)
     109  ulBufBytes = sizeof(FILEFINDBUF4) * FilesToGet;
     110  pffbArray = xmalloc(ulBufBytes, pszSrcFile, __LINE__);
     111  if (!pffbArray)
    112112    return FALSE;                       // Error already reported
    113113
     
    119119
    120120  hdir = HDIR_CREATE;
    121   nm = 1;
    122   // 11 Aug 07 SHL fixme to know if we can bypass memset
    123   memset(pffb, 0, sizeof(FILEFINDBUF4));
     121  ulFindCnt = 1;
     122  // memset(pffbArray, 0, sizeof(FILEFINDBUF4));        // 11 Aug 07 SHL bypass memset
    124123  DosError(FERR_DISABLEHARDERR);
    125124  // Check directory exists
     
    127126                    FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED |
    128127                    FILE_SYSTEM | FILE_HIDDEN | MUST_HAVE_DIRECTORY,
    129                     pffb, sizeof(FILEFINDBUF4), &nm, FIL_QUERYEASIZE);
     128                    pffbArray, ulBufBytes, &ulFindCnt, FIL_QUERYEASIZE);
    130129
    131130  if (!rc)
     
    137136   * requesting EASIZE.  sheesh.
    138137   */
    139   if ((!rc && (pffb->attrFile & FILE_DIRECTORY)) || strlen(pszFileName) < 4) {
     138  if ((!rc && (pffbArray->attrFile & FILE_DIRECTORY)) || strlen(pszFileName) < 4) {
    140139    if (*pchStopFlag) {
    141       free(pffb);
     140      free(pffbArray);
    142141      return FALSE;
    143142    }
     
    145144                     MPFROMLONG(1));
    146145    if (!pci) {
    147       free(pffb);
     146      Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_ALLOCRECORD");
     147      free(pffbArray);
    148148      return FALSE;
    149149    }
    150150    if (!rc) {
    151       ullCurDirBytes = pffb->cbFile;
    152       ullCurDirBytes += CBLIST_TO_EASIZE(pffb->cbList);
     151      ullCurDirBytes = pffbArray->cbFile;
     152      ullCurDirBytes += CBLIST_TO_EASIZE(pffbArray->cbList);
    153153    }
    154154    else
     
    161161  else {
    162162    // No match
    163     free(pffb);
     163    free(pffbArray);
    164164    Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    165165              GetPString(IDS_CANTFINDDIRTEXT), pszFileName);
     
    186186    pci->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__);
    187187  }
    188   // fixme to know why - it appears to be indirectly saving length, but why?
     188  // fixme to understand this - appears to be indirectly saving length, but why?
    189189  pci->pszDisplayName = pci->pszFileName + strlen(pci->pszFileName);
    190190  pci->pszLongName = pci->pszFileName;  // fixme to be sure?
     
    204204  ri.fInvalidateRecord = TRUE;
    205205  if (!WinSendMsg(hwndCnr, CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) {
    206     free(pffb);
     206    free(pffbArray);
    207207    return FALSE;
    208208  }
     
    210210  // Find files and directories in this directory
    211211  hdir = HDIR_CREATE;
    212   nm = FilesToGet;
     212  // 13 Aug 07 SHL fixme to know if need to support fRemoteBug here like objcnr.c?
     213  ulFindCnt = FilesToGet;
    213214  rc = DosFindFirst(maskstr, &hdir,
    214215                    FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED |
    215216                    FILE_SYSTEM | FILE_HIDDEN | FILE_DIRECTORY,
    216                     pffb, nm * sizeof(FILEFINDBUF4), &nm, FIL_QUERYEASIZE);
     217                    pffbArray, ulBufBytes, &ulFindCnt, FIL_QUERYEASIZE);
    217218  if (!rc) {
    218     PBYTE fb = (PBYTE)pffb;
    219     FILEFINDBUF4 *pffbFile;
     219    PFILEFINDBUF4 pffbFile;
    220220    ULONG x;
    221221
    222222    while (!rc) {
     223
     224#if 0 // 13 Aug 07 SHL fixme to be gone
     225      {
     226        static ULONG ulMaxCnt = 1;
     227        if (ulFindCnt > ulMaxCnt) {
     228          ulMaxCnt = ulFindCnt;
     229          DbgMsg(pszSrcFile, __LINE__, "ulMaxCnt %u/%u", ulMaxCnt, FilesToGet);
     230        }
     231      }
     232#endif
     233
    223234      priority_normal();
    224       for (x = 0; x < nm; x++) {
    225         pffbFile = (FILEFINDBUF4 *)fb;
     235      pffbFile = pffbArray;
     236      for (x = 0; x < ulFindCnt; x++) {
    226237        // Total size skipping . and ..
    227238        if ((~pffbFile->attrFile & FILE_DIRECTORY) ||
     
    232243          ullCurDirBytes += CBLIST_TO_EASIZE(pffbFile->cbList) & 0x3ff;
    233244
    234           if (!(pffbFile->attrFile & FILE_DIRECTORY))
    235             pci->attrFile++;            // Bump file count
    236245          if (*pchStopFlag)
    237246            break;
    238           if (pffbFile->attrFile & FILE_DIRECTORY) {
     247          if (~pffbFile->attrFile & FILE_DIRECTORY)
     248            pci->attrFile++;            // Bump file count
     249          else {
    239250            // Recurse into subdir
    240251            strcpy(pEndMask, pffbFile->achName);        // Append dirname to base dirname
    241             if (!*pchStopFlag) {
    242               ProcessDir(hwndCnr, maskstr, pci, pchStopFlag, FALSE, &ull);
    243               ullSubDirBytes += ull;
    244             }
     252            ProcessDir(hwndCnr, maskstr, pci, pchStopFlag, FALSE, &ull);
     253            ullSubDirBytes += ull;
    245254          }
    246255        }
    247256        if (!pffbFile->oNextEntryOffset)
    248257          break;
    249         fb += pffbFile->oNextEntryOffset;
     258        pffbFile = (PFILEFINDBUF4)((PBYTE)pffbFile + pffbFile->oNextEntryOffset);
     259
     260#if 0 // 13 Aug 07 SHL fixme to be gone
     261        {
     262          static ULONG ulMaxBytes = 65535;
     263          ULONG ul = (PBYTE)pffbFile - (PBYTE)pffbArray;
     264          if (ul > ulMaxBytes) {
     265            ulMaxBytes = ul;
     266            DbgMsg(pszSrcFile, __LINE__, "ulFindCnt %u/%u ulMaxBytes %u/%u",
     267                   ulFindCnt, FilesToGet, ulMaxBytes, ulBufBytes);
     268          }
     269        }
     270#endif
     271
    250272      } // for matches
    251273      if (*pchStopFlag)
    252274        break;
    253       DosSleep(1);
    254       nm = FilesToGet;
     275      DosSleep(0);
     276      ulFindCnt = FilesToGet;
    255277      DosError(FERR_DISABLEHARDERR);
    256       rc = DosFindNext(hdir, pffb, sizeof(FILEFINDBUF4) * FilesToGet, &nm);
     278      rc = DosFindNext(hdir, pffbArray, ulBufBytes, &ulFindCnt);
    257279    } // while more found
    258 
    259     if (rc != ERROR_NO_MORE_FILES) {
    260       Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    261                 GetPString(IDS_CANTFINDDIRTEXT), pszFileName);
    262     }
    263280
    264281    DosFindClose(hdir);
     
    266283  } // if got files or directories
    267284
    268   free(pffb);
     285  if (rc && rc != ERROR_NO_MORE_FILES) {
     286    Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     287              GetPString(IDS_CANTFINDDIRTEXT), pszFileName);
     288  }
     289
     290  free(pffbArray);
    269291
    270292  pci->cbFile = ullCurDirBytes;
     
    407429}
    408430
    409 static VOID FillCnrThread(VOID * args)
     431static VOID FillCnrThread(VOID *args)
    410432{
    411433  HAB hab;
    412434  HMQ hmq;
    413   DIRSIZE *dirsize = (DIRSIZE *) args;
     435  DIRSIZE *dirsize = (DIRSIZE *)args;
    414436  HWND hwndCnr;
    415437  ULONGLONG ull;
    416438
    417   if (!dirsize)
     439  if (!dirsize) {
     440    Runtime_Error(pszSrcFile, __LINE__, "no data");
    418441    return;
     442  }
     443
    419444  hwndCnr = dirsize->hwndCnr;
    420445
     
    965990  return WinDefDlgProc(hwnd, msg, mp1, mp2);
    966991}
     992
     993#pragma alloc_text(DIRSIZE,ProcessDir,FillCnrThread,DirSizeProc)
     994#pragma alloc_text(DIRSIZE2,PrintToFile,FillInRecSizes,SortSizeCnr)
     995
  • trunk/dll/filldir.c

    r775 r783  
    3737  04 Aug 07 SHL Update #pragma alloc_test for new functions
    3838  06 Aug 07 GKY Reduce DosSleep times (ticket 148)
     39  13 Aug 07 SHL Sync code with other FilesToGet usage and optimize
     40  13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat
    3941
    4042***********************************************************************/
     
    4244#define INCL_DOS
    4345#define INCL_WIN
     46#define INCL_DOSERRORS
    4447#define INCL_LONGLONG
    4548#include <os2.h>
     
    5356#include <time.h>
    5457
    55 #if 1 // fixme to disable or to be configurable
     58#if 0 // fixme to disable or to be configurable
    5659#include <malloc.h>                     // _heapchk
    5760#endif
     
    6164
    6265static PSZ pszSrcFile = __FILE__;
    63 
    64 #pragma alloc_text(FILLDIR,FillInRecordFromFFB,FillInRecordFromFSA,IDFile)
    65 #pragma alloc_text(FILLDIR1,ProcessDirectory,FillDirCnr,FillTreeCnr,FileAttrToString)
    66 #pragma alloc_text(EMPTYCNR,EmptyCnr,FreeCnrItemData,FreeCnrItem,FreeCnrItemList,RemoveCnrItems)
    6766
    6867/**
     
    240239                              DIRCNRDATA *dcd)
    241240{
    242   /* fill in a container record from a FILEFINDBUF4 structure */
     241  // fill in a container record from a FILEFINDBUF4 structure
    243242
    244243  CHAR *p;
     
    271270  }
    272271
    273   /* load the object's Subject, if required */
     272  // load the object's Subject, if required
    274273  pci->pszSubject = NullStr;
    275274  if (pffb->cbList > 4L &&
     
    316315    pci->pszSubject = NullStr;
    317316
    318   /* load the object's longname */
     317  // load the object's longname
    319318  pci->pszLongName = 0;
    320319  if (fLoadLongnames &&
     
    363362    pci->pszLongName = NullStr;
    364363
    365   /* do anything required to case of filename */
     364  // do anything required to case of filename
    366365  if (fForceUpper)
    367366    strupr(pci->pszFileName);
     
    369368    strlwr(pci->pszFileName);
    370369
    371   /* get an icon to use with it */
     370  // get an icon to use with it
    372371  if (pffb->attrFile & FILE_DIRECTORY) {
    373372    // is directory
     
    425424  pci->pszDisplayName = p;
    426425
    427   /* now fill the darned thing in... */
     426  // now fill the darned thing in...
    428427  pci->date.day = pffb->fdateLastWrite.day;
    429428  pci->date.month = pffb->fdateLastWrite.month;
     
    451450  pci->rc.hptrIcon = hptr;
    452451
    453   /* check to see if record should be visible */
     452  // check to see if record should be visible
    454453  if (dcd && (*dcd->mask.szMask || dcd->mask.antiattr ||
    455454              ((dcd->mask.attrFile &
     
    483482  CHAR *p;
    484483
    485   /* fill in a container record from a FILESTATUS4 structure */
     484  // fill in a container record from a FILESTATUS4 structure
    486485
    487486  pci->hwndCnr = hwndCnr;
     
    489488  strcpy(pci->pszFileName, pszFileName);
    490489
    491   /* load the object's Subject, if required */
     490  // load the object's Subject, if required
    492491  pci->pszSubject = NullStr;
    493492  if (pfsa4->cbList > 4L &&
     
    708707  PFILEFINDBUF4 paffbTemp;
    709708  HDIR hdir = HDIR_CREATE;
    710   ULONG ulFileCnt;
    711   ULONG ulExtraBytes;
    712   ULONG ulM = 1;
     709  ULONG ulFindCnt;
     710  ULONG ulFindMax;
     711  ULONG ulSelCnt;
    713712  ULONG ulTotal = 0;
    714713  ULONGLONG ullBytes;
     
    721720  PCNRITEM pciFirst;
    722721  RECORDINSERT ri;
    723   PBYTE pByte;
    724   PBYTE pByte2;
    725722  BOOL ok = TRUE;
     723  ULONG ulBufBytes;
     724  ULONG x;
    726725
    727726  if (isalpha(*szDirBase) && szDirBase[1] == ':' && szDirBase[2] == '\\') {
    728     ulExtraBytes = EXTRA_RECORD_BYTES;
    729727    if ((driveflags[toupper(*szDirBase) - 'A'] & DRIVE_REMOTE) && fRemoteBug)
    730       ulM = 1;                          /* file system gets confused */
     728      ulFindMax = 1;                            // file system gets confused
    731729    else if (driveflags[toupper(*szDirBase) - 'A'] & DRIVE_ZIPSTREAM)
    732       ulM = min(FilesToGet, 225);       /* anything more is wasted */
     730      ulFindMax = min(FilesToGet, 225); // anything more is wasted
    733731    else
    734       ulM = FilesToGet;                 /* full-out */
     732      ulFindMax = FilesToGet;           // full-out
    735733  }
    736734  else {
    737     ulExtraBytes = EXTRA_RECORD_BYTES;
    738     ulM = FilesToGet;
     735    ulFindMax = FilesToGet;
    739736  }
    740737  if (OS2ver[0] == 20 && OS2ver[1] < 30)
    741     ulM = min(ulM, (65535 / sizeof(FILEFINDBUF4)));
    742 
    743   ulFileCnt = ulM;
     738    ulFindMax = min(ulFindMax, (65535 / sizeof(FILEFINDBUF4)));
     739
     740  ulBufBytes = ulFindMax * sizeof(FILEFINDBUF4);
     741
    744742  pszFileSpec = xmalloc(CCHMAXPATH + 2, pszSrcFile, __LINE__);
    745   paffbFound =
    746     xmalloc((ulM + 1) * sizeof(FILEFINDBUF4), pszSrcFile, __LINE__);
    747   papffbSelected =
    748     xmalloc((ulM + 1) * sizeof(PFILEFINDBUF4), pszSrcFile, __LINE__);
     743  paffbFound = xmalloc(ulBufBytes, pszSrcFile, __LINE__);
     744  papffbSelected = xmalloc(sizeof(PFILEFINDBUF4) * ulFindMax, pszSrcFile, __LINE__);
     745
    749746  if (paffbFound && papffbSelected && pszFileSpec) {
    750747    t = strlen(szDirBase);
     
    757754    memcpy(pchEndPath, "*", 2);
    758755    DosError(FERR_DISABLEHARDERR);
    759     rc = DosFindFirst(pszFileSpec, &hdir,
    760                       FILE_NORMAL | ((filestoo) ? FILE_DIRECTORY :
    761                                      MUST_HAVE_DIRECTORY) | FILE_READONLY |
    762                       FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
    763                       paffbFound, ulM * sizeof(FILEFINDBUF4),
    764                       &ulFileCnt, FIL_QUERYEASIZE);
     756    ulFindCnt = ulFindMax;
     757    rc = DosFindFirst(pszFileSpec,
     758                      &hdir,
     759                      FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED |
     760                      FILE_SYSTEM | FILE_HIDDEN |
     761                      (filestoo ? FILE_DIRECTORY : MUST_HAVE_DIRECTORY),
     762                      paffbFound,
     763                      ulBufBytes,
     764                      &ulFindCnt,
     765                      FIL_QUERYEASIZE);
    765766    priority_normal();
    766767    *pchEndPath = 0;
    767768    if (!rc) {
    768       while (!rc) {
     769      do {
    769770        /*
    770771         * remove . and .. from list if present
     
    774775         * network file systems exhibit such a problem).
    775776         */
    776         register ULONG x;
     777#if 0 // 13 Aug 07 SHL fixme to be gone
     778        {
     779          static ULONG ulMaxCnt = 1;
     780          if (ulFindCnt > ulMaxCnt) {
     781            ulMaxCnt = ulFindCnt;
     782            DbgMsg(pszSrcFile, __LINE__, "ulMaxCnt %u/%u", ulMaxCnt, ulFindMax);
     783          }
     784        }
     785#endif // fixme to be gone
    777786
    778787        if (stopflag && *stopflag)
    779788          goto Abort;
    780         pByte = (PBYTE) paffbFound;
    781         for (x = 0; x < ulFileCnt;) {
    782           pffbFile = (PFILEFINDBUF4) pByte;
     789        pffbFile = paffbFound;
     790        ulSelCnt = 0;
     791        for (;;) {
    783792          if (!*pffbFile->achName ||
    784               (!filestoo && !(pffbFile->attrFile & FILE_DIRECTORY)) ||
    785               ((pffbFile->attrFile & FILE_DIRECTORY) &&
     793              (!filestoo && ~pffbFile->attrFile & FILE_DIRECTORY) ||
     794              (pffbFile->attrFile & FILE_DIRECTORY &&
    786795               pffbFile->achName[0] == '.' &&
    787796               (!pffbFile->achName[1] ||
    788797                (pffbFile->achName[1] == '.' && !pffbFile->achName[2])))) {
    789             ulFileCnt--;                // Got . or ..
     798            // ulFindCnt--;             // Got . or .. or file to be skipped
    790799          }
    791800          else
    792             papffbSelected[x++] = pffbFile;     // Count file
     801            papffbSelected[ulSelCnt++] = pffbFile;      // Remember selected file
    793802          if (!pffbFile->oNextEntryOffset) {
    794             ulFileCnt = x;              // Adjust count
     803            // ulFindCnt = ulSelCnt;    // Remember number selected
    795804            break;
    796805          }
    797           pByte += pffbFile->oNextEntryOffset;
     806          pffbFile = (PFILEFINDBUF4)((PBYTE)pffbFile + pffbFile->oNextEntryOffset);
    798807        } // for
    799         if (ulFileCnt) {
     808        if (ulSelCnt) {
     809          // One or more entries selected
    800810          if (stopflag && *stopflag)
    801811            goto Abort;
    802812          if (fSyncUpdates) {
    803813            pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD,
    804                                   MPFROMLONG(ulExtraBytes),
    805                                   MPFROMLONG(ulFileCnt));
     814                                  MPFROMLONG(EXTRA_RECORD_BYTES),
     815                                  MPFROMLONG(ulSelCnt));
    806816            if (!pciFirst) {
    807817              Win_Error2(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__,
     
    811821            }
    812822            else {
    813               register INT i;
    814 
    815823              pci = pciFirst;
    816824              ullTotalBytes = 0;
    817               for (i = 0; i < ulFileCnt; i++) {
    818                 pffbFile = papffbSelected[i];
     825              // Insert selected in container
     826              for (x = 0; x < ulSelCnt; x++) {
     827                pffbFile = papffbSelected[x];
    819828                ullBytes = FillInRecordFromFFB(hwndCnr, pci, pszFileSpec,
    820829                                               pffbFile, partial, dcd);
     
    822831                ullTotalBytes += ullBytes;
    823832              } // for
    824               if (ulFileCnt) {
    825                 memset(&ri, 0, sizeof(RECORDINSERT));
    826                 ri.cb = sizeof(RECORDINSERT);
    827                 ri.pRecordOrder = (PRECORDCORE) CMA_END;
    828                 ri.pRecordParent = (PRECORDCORE) pciParent;
    829                 ri.zOrder = (ULONG) CMA_TOP;
    830                 ri.cRecordsInsert = ulFileCnt;
    831                 ri.fInvalidateRecord = (!fSyncUpdates && dcd &&
    832                                         dcd->type == DIR_FRAME) ?
     833              // 13 Aug 07 SHL ulSelCnt checked already?
     834              // if (ulSelCnt) {
     835              memset(&ri, 0, sizeof(RECORDINSERT));
     836              ri.cb = sizeof(RECORDINSERT);
     837              ri.pRecordOrder = (PRECORDCORE) CMA_END;
     838              ri.pRecordParent = (PRECORDCORE) pciParent;
     839              ri.zOrder = (ULONG) CMA_TOP;
     840              ri.cRecordsInsert = ulSelCnt;
     841              ri.fInvalidateRecord =
     842                !fSyncUpdates && dcd && dcd->type == DIR_FRAME ?
    833843                  FALSE : TRUE;
     844              if (!WinSendMsg(hwndCnr,
     845                              CM_INSERTRECORD,
     846                              MPFROMP(pciFirst), MPFROMP(&ri))) {
     847                DosSleep(10);           // Give GUI time to work
     848                WinSetFocus(HWND_DESKTOP, hwndCnr);
    834849                if (!WinSendMsg(hwndCnr,
    835850                                CM_INSERTRECORD,
    836851                                MPFROMP(pciFirst), MPFROMP(&ri))) {
    837                   DosSleep(10);
    838                   WinSetFocus(HWND_DESKTOP, hwndCnr);
    839                   if (!WinSendMsg(hwndCnr,
    840                                   CM_INSERTRECORD,
    841                                   MPFROMP(pciFirst), MPFROMP(&ri))) {
    842                     Win_Error2(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__,
    843                                IDS_CMINSERTERRTEXT);
    844                     ok = FALSE;
    845                     ullTotalBytes = 0;
    846                     if (WinIsWindow((HAB) 0, hwndCnr))
    847                       FreeCnrItemList(hwndCnr, pciFirst);
    848                   }
     852                  Win_Error2(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__,
     853                             IDS_CMINSERTERRTEXT);
     854                  ok = FALSE;
     855                  ullTotalBytes = 0;
     856                  if (WinIsWindow((HAB) 0, hwndCnr))
     857                    FreeCnrItemList(hwndCnr, pciFirst);
    849858                }
     859              // }
    850860              }
    851861            }
    852862            if (ok) {
    853863              ullReturnBytes += ullTotalBytes;
    854               ulReturnFiles += ulFileCnt;
     864              ulReturnFiles += ulSelCnt;
    855865            }
    856           }
     866          } // if sync updates
    857867          else {
     868            // Append newly selected entries to aggregate list
    858869            paffbTemp = xrealloc(paffbTotal,
    859                                  sizeof(FILEFINDBUF4) * (ulFileCnt + ulTotal),
     870                                 sizeof(FILEFINDBUF4) * (ulSelCnt + ulTotal),
    860871                                 pszSrcFile, __LINE__);
    861872            if (paffbTemp) {
     873              // 13 Aug 07 SHL fixme to optimize copy
    862874              paffbTotal = paffbTemp;
    863               for (x = 0; x < ulFileCnt; x++)
     875              for (x = 0; x < ulSelCnt; x++)
    864876                paffbTotal[x + ulTotal] = *papffbSelected[x];
    865               ulTotal += ulFileCnt;
     877              ulTotal += ulSelCnt;
    866878            }
    867879            else {
     
    872884            }
    873885          }
    874         }
     886        } // if entries selected
    875887        if (stopflag && *stopflag)
    876888          goto Abort;
    877         ulFileCnt = ulM;
    878889        DosError(FERR_DISABLEHARDERR);
    879         rc = DosFindNext(hdir, paffbFound, ulM * sizeof(FILEFINDBUF4),
    880                          &ulFileCnt);
     890        ulFindCnt = ulFindMax;
     891        rc = DosFindNext(hdir, paffbFound, ulBufBytes, &ulFindCnt);
    881892        priority_normal();
    882893        if (rc)
    883894          DosError(FERR_DISABLEHARDERR);
    884       }
     895      } while (!rc);
     896
    885897      DosFindClose(hdir);
    886898
    887       if (paffbFound || papffbSelected) {
    888         if (paffbFound)
    889           free(paffbFound);
    890         if (papffbSelected)
    891           free(papffbSelected);
     899      if (paffbFound) {
     900        free(paffbFound);
     901        paffbFound = NULL;
     902      }
     903      if (papffbSelected) {
     904        free(papffbSelected);
    892905        papffbSelected = NULL;
    893         paffbFound = NULL;
    894906      }
    895907
     
    900912
    901913        pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD,
    902                               MPFROMLONG(ulExtraBytes), MPFROMLONG(ulTotal));
     914                              MPFROMLONG(EXTRA_RECORD_BYTES), MPFROMLONG(ulTotal));
    903915        if (!pciFirst) {
    904916          Win_Error2(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__,
     
    908920        }
    909921        else {
    910           register INT i;
    911 
    912922          pci = pciFirst;
    913923          ullTotalBytes = 0;
    914           pByte2 = (PBYTE) paffbTotal;
    915           for (i = 0; i < ulTotal; i++) {
    916             pffbFile = (PFILEFINDBUF4) pByte2;
     924          pffbFile = paffbTotal;
     925          for (x = 0; x < ulTotal; x++) {
    917926            ullBytes = FillInRecordFromFFB(hwndCnr, pci, pszFileSpec,
    918927                                           pffbFile, partial, dcd);
    919928            pci = (PCNRITEM) pci->rc.preccNextRecord;
    920929            ullTotalBytes += ullBytes;
    921 
    922             pByte2 += sizeof(FILEFINDBUF4);
     930            // Can not use offset since we have merged lists - this should be equivalent
     931            pffbFile = (PFILEFINDBUF4)((PBYTE)pffbFile + sizeof(FILEFINDBUF4));
    923932          }
    924933          if (ulTotal) {
     
    933942            if (!WinSendMsg(hwndCnr, CM_INSERTRECORD,
    934943                            MPFROMP(pciFirst), MPFROMP(&ri))) {
    935               DosSleep(10);
     944              DosSleep(10);             // Give GUI time to work
    936945              WinSetFocus(HWND_DESKTOP, hwndCnr);
    937946              if (!WinSendMsg(hwndCnr, CM_INSERTRECORD,
     
    949958        if (ok) {
    950959          ullReturnBytes += ullTotalBytes;
    951           ulReturnFiles += ulFileCnt;
     960          ulReturnFiles += ulFindCnt;
    952961        }
    953962      }
     963    }
     964
     965    if (rc && rc != ERROR_NO_MORE_FILES) {
     966      Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     967                GetPString(IDS_CANTFINDDIRTEXT), pszFileSpec);
    954968    }
    955969
     
    959973  }
    960974Abort:
    961   if (paffbTotal || papffbSelected || paffbFound || pszFileSpec) {
    962     if (paffbTotal)
    963       free(paffbTotal);
    964     if (pszFileSpec)
    965       free(pszFileSpec);
    966     if (paffbFound)
    967       free(paffbFound);
    968     if (papffbSelected)
    969       free(papffbSelected);
    970   }
     975  if (paffbTotal)
     976    free(paffbTotal);
     977  if (pszFileSpec)
     978    free(pszFileSpec);
     979  if (paffbFound)
     980    free(paffbFound);
     981  if (papffbSelected)
     982    free(papffbSelected);
     983
    971984  if (recurse) {
    972985    pci = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pciParent),
     
    12311244      }
    12321245      pci->rc.flRecordAttr |= CRA_RECORDREADONLY;
    1233       pci = (PCNRITEM) pci->rc.preccNextRecord; /* next rec */
     1246      pci = (PCNRITEM) pci->rc.preccNextRecord; // next rec
    12341247    }
    12351248    else if (!(ulDriveMap & (1L << x)))
     
    12401253  drivesbuilt = TRUE;
    12411254
    1242   /* insert the drives */
     1255  // insert the drives
    12431256  if (numtoinsert && pciFirst) {
    12441257    RECORDINSERT ri;
     
    12591272  }
    12601273
    1261   /* move cursor onto the default drive rather than the first drive */
     1274  // move cursor onto the default drive rather than the first drive
    12621275  if (!fSwitchTree) {
    12631276    pci = (PCNRITEM) WinSendMsg(hwndCnr,
     
    14461459  if (!drivesbuilt && hwndMain)
    14471460    PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
    1448   DosSleep(16);//05 Aug 07 GKY 33
     1461  DosSleep(16);                         // 05 Aug 07 GKY 33
    14491462  fDummy = FALSE;
    14501463  DosPostEventSem(CompactSem);
     
    15831596    Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,
    15841597              "CM_FREERECORD hwnd %x pci %p file %s",
    1585               hwnd, pci,
     1598              hwnd, pci,
    15861599              pci && pci->pszFileName ? pci->pszFileName : "n/a");
    15871600  }
     
    16641677}
    16651678
     1679#pragma alloc_text(FILLDIR,FillInRecordFromFFB,FillInRecordFromFSA,IDFile)
     1680#pragma alloc_text(FILLDIR1,ProcessDirectory,FillDirCnr,FillTreeCnr,FileAttrToString)
     1681#pragma alloc_text(EMPTYCNR,EmptyCnr,FreeCnrItemData,FreeCnrItem,FreeCnrItemList,RemoveCnrItems)
     1682
  • trunk/dll/fm3res.dlg

    r756 r783  
    2828  19 Jun 07 SHL Update ABT_FRAME to include netlabs URL and built with OpenWatcom
    2929  03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speed file loading)
     30  13 Aug 07 SHL Tweak scanning page
    3031
    3132***********************************************************************/
     
    18741875        AUTOCHECKBOX    "Lowercase names", CFGS_FORCELOWER, 4, 68, 106, 10
    18751876        AUTOCHECKBOX    "Remote find bug", CFGS_REMOTEBUG, 4, 56, 106, 10
    1876         AUTOCHECKBOX    "Don't scan remov.", CFGS_NOREMOVABLESCAN, 4, 44,
     1877        AUTOCHECKBOX    "Don't scan removables", CFGS_NOREMOVABLESCAN, 4, 44,
    18771878                        106, 10
    1878         LTEXT           "Findbuf:", -1, 4, 28, 54, 12, NOT WS_GROUP
     1879        LTEXT           "Find count", -1, 4, 28, 54, 12, NOT WS_GROUP
    18791880        CONTROL         "", CFGS_FILESTOGET, 44, 30, 64, 12, WC_SPINBUTTON,
    18801881                        SPBS_NUMERICONLY | SPBS_MASTER | SPBS_SERVANT |
  • trunk/dll/grep.c

    r775 r783  
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2001, 2006 Steven H. Levine
     9  Copyright (c) 2001, 2007 Steven H. Levine
    1010
    1111  12 Feb 03 SHL insert_grepfile: standardize EA math
     
    2121  03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speed file loading)
    2222  06 Aug 07 GKY Reduce DosSleep times (ticket 148)
    23 
     23  13 Aug 07 SHL Avoid pointer errors; sanitize code
     24  13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat
    2425
    2526***********************************************************************/
     
    2728#define INCL_DOS
    2829#define INCL_WIN
     30#define INCL_DOSERRORS
    2931#define INCL_LONGLONG
    3032#include <os2.h>
     
    4446static PSZ pszSrcFile = __FILE__;
    4547
    46 #pragma alloc_text(GREP,SecsSince1980,match,mmatch,GrepThread)
    47 #pragma alloc_text(GREP,doallsubdirs,domatchingfiles)
    48 
    49 /*****************************/
    50 /*   Function Prototypes     */
    51 /*****************************/
    52 
    53 static VOID doallsubdirs(GREP * grep, CHAR * searchPath, BOOL recursing,
     48static VOID doallsubdirs(GREP *grep, CHAR *searchPath, BOOL recursing,
    5449                         char **fle, int numfls);
    55 static INT domatchingfiles(GREP * grep, CHAR * path, char **fle, int numfls);
    56 static BOOL doonefile(GREP * grep, CHAR * fileName, FILEFINDBUF4 * f);
    57 static BOOL doinsertion(GREP * grep);
    58 static BOOL InsertDupe(GREP * grep, CHAR * dir, FILEFINDBUF4 * f);
    59 static VOID FillDupes(GREP * g);
    60 static VOID FreeDupes(GREP * g);
     50static INT domatchingfiles(GREP *grep, CHAR *path, char **fle, int numfls);
     51static BOOL doonefile(GREP *grep, CHAR *fileName, FILEFINDBUF4 *pffb);
     52static BOOL doinsertion(GREP *grep);
     53static BOOL InsertDupe(GREP *grep, CHAR *dir, FILEFINDBUF4 *pffb);
     54static VOID FillDupes(GREP *grep);
     55static VOID FreeDupes(GREP *grep);
    6156
    6257#define GREPCHARS "*?[] \\"
    6358
    6459#define isleap(year) ((((year%4)==0) && ((year%100)!=0)) || \
    65         ((year%400)==0))
     60        ((year%400)==0))
    6661
    6762static INT monthdays[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
     
    9994                    LONG len)
    10095{
    101 
    102   /* return TRUE if pattern found in string */
    103 
     96  // return TRUE if pattern found in string
    10497  register CHAR *tn = pattern;
    10598  register LONG len2 = 0;
     
    108101
    109102  if (len && string && pattern) {
    110     if (absolute)                       /* no pattern matching */
     103    if (absolute)                       // no pattern matching
    111104      return (findstring(pattern, strlen(pattern), string, len,
    112105                         (ignore == FALSE)) != NULL);
     
    180173        if (!*tn)
    181174          return FALSE;
    182         /* else intentional fallthru */
     175        // else intentional fallthru
    183176      default:
    184177        if (ignore) {
     
    217210                  LONG len, ULONG numlines, CHAR * matched, BOOL matchall)
    218211{
    219 
    220212  BOOL ret = FALSE;
    221213  register CHAR *p;
     
    229221    if (matched && ret && x < numlines)
    230222      matched[x] = 1;
    231     p += strlen(p);                     /* check each pattern in 0-terminated list */
     223    p += strlen(p);                     // check each pattern in 0-terminated list
    232224    p++;
    233225    x++;
     
    245237  CHAR *p, *pp, searchPath[CCHMAXPATH * 2];
    246238
    247   if (!arg)
     239  if (!arg) {
     240    Runtime_Error(pszSrcFile, __LINE__, "no data");
    248241    return;
    249   grep = *(GREP *) arg;
    250   *grep.stopflag = 0;                   /* reset thread-killing flag */
     242  }
     243
     244  grep = *(GREP *)arg;
     245  *grep.stopflag = 0;                   // reset thread-killing flag
    251246  grep.FilesToGet = FilesToGet;
    252247  DosError(FERR_DISABLEHARDERR);
     
    268263      while (*pp) {
    269264        if (!grep.absFlag) {
    270           p = GREPCHARS;                /* see if any sense in pattern matching */
     265          p = GREPCHARS;                // see if any sense in pattern matching
    271266          while (*p) {
    272267            if (strchr(pp, *p))
     
    274269            p++;
    275270          }
    276           if (!*p)                      /* nope, turn it off */
     271          if (!*p)                      // nope, turn it off
    277272            grep.absFlag = TRUE;
    278273        }
     
    300295      }
    301296
    302       while (x < numfls) {              /* loop through search masks */
    303 
    304         if (*fle[x] == '/')             /* is an exclude mask only */
     297      while (x < numfls) {              // loop through search masks
     298
     299        if (*fle[x] == '/')             // is an exclude mask only
    305300          goto ExcludeSkip;
    306301
    307         /* first, separate any path from mask */
     302        // first, separate any path from mask
    308303
    309304        p = (char *)(fle[x] + (strlen(fle[x]) - 1));
     
    311306          --p;
    312307
    313         if (p == fle[x]) {              /* no path */
     308        if (p == fle[x]) {              // no path
    314309          strcpy(searchPath, grep.curdir);
    315310          strncpy(grep.fileMask, fle[x], CCHMAXPATH);
    316311          grep.fileMask[CCHMAXPATH - 1] = 0;
    317312        }
    318         else {                          /* got to deal with a path */
    319           if (*p == ':') {              /* just a drive, start in root dir */
     313        else {                          // got to deal with a path
     314          if (*p == ':') {              // just a drive, start in root dir
    320315            *p = 0;
    321316            p++;
     
    325320            strcpy(grep.fileMask, p);
    326321          }
    327           if (*p == '\\') {             /* got a 'full' path */
     322          if (*p == '\\') {             // got a 'full' path
    328323
    329324            CHAR temp;
     
    342337        if (*grep.stopflag)
    343338          break;
    344         /* do single directory */
     339        // do single directory
    345340        domatchingfiles(&grep, searchPath, fle, numfls);
    346         if (grep.dirFlag)               /* do subdirs */
     341        if (grep.dirFlag)               // do subdirs
    347342          doallsubdirs(&grep, searchPath, FALSE, fle, numfls);
    348343      ExcludeSkip:
     
    351346        x++;
    352347        if (WinIsWindow(grep.ghab, grep.hwndFiles))
    353           doinsertion(&grep);           /* insert any remaining objects */
     348          doinsertion(&grep);           // insert any remaining objects
    354349      } // while
    355350
    356351      if (WinIsWindow(grep.ghab, grep.hwndFiles))
    357         doinsertion(&grep);             /* insert any remaining objects */
     352        doinsertion(&grep);             // insert any remaining objects
    358353
    359354      if (WinIsWindow(grep.ghab, grep.hwndFiles) && grep.finddupes &&
     
    361356        FillDupes(&grep);
    362357
    363       if (!PostMsg(grep.hwndFiles, UM_CONTAINER_FILLED, MPVOID, MPVOID))        /* tell window we're done */
     358      if (!PostMsg(grep.hwndFiles, UM_CONTAINER_FILLED, MPVOID, MPVOID))        // tell window we're done
    364359        WinSendMsg(grep.hwndFiles, UM_CONTAINER_FILLED, MPVOID, MPVOID);
    365360      WinDestroyMsgQueue(ghmq);
     
    379374static BOOL IsExcluded(char *name, char **fle, int numfls)
    380375{
    381   register int x;
     376  int x;
    382377  char *n;
    383378
     
    401396                         char **fle, int numfls)
    402397{
    403 
    404   /* process all subdirectories */
    405 
    406   FILEFINDBUF4 findBuffer;
     398  // process all subdirectories
     399
     400  FILEFINDBUF4 ffb;
    407401  HDIR findHandle = HDIR_CREATE;
    408   LONG findCount = 1L;
     402  LONG ulFindCnt = 1;
    409403  CHAR *p = NULL;
    410404
    411   /* add a mask to search path */
     405  // add a mask to search path
    412406  if (searchPath[strlen(searchPath) - 1] != '\\')
    413407    strcat(searchPath, "\\");
    414408  strcat(searchPath, "*");
    415   /* step through all subdirectories */
     409  // step through all subdirectories
    416410  DosError(FERR_DISABLEHARDERR);
    417411  if (!DosFindFirst(searchPath, &findHandle, (MUST_HAVE_DIRECTORY |
    418412                                              FILE_ARCHIVED | FILE_SYSTEM |
    419413                                              FILE_HIDDEN | FILE_READONLY),
    420                     &findBuffer, (ULONG) sizeof(findBuffer),
    421                     (PULONG) & findCount, FIL_QUERYEASIZE)) {
    422 
    423     /* get rid of mask portion, save end-of-directory */
     414                    &ffb, (ULONG) sizeof(ffb),
     415                    (PULONG) & ulFindCnt, FIL_QUERYEASIZE)) {
     416
     417    // get rid of mask portion, save end-of-directory
    424418
    425419    p = strrchr(searchPath, '\\');
     
    428422    else
    429423      p = searchPath;
    430     do {                                /* Process each directory that matches the mask */
     424    do {                                // Process each directory that matches the mask
    431425      priority_normal();
    432426      if (*grep->stopflag)
    433427        break;
    434428      // Skip . and ..
    435       if (findBuffer.achName[0] != '.' ||
    436           (findBuffer.achName[1] &&
    437            (findBuffer.achName[1] != '.' || findBuffer.achName[2]))) {
    438         strcpy(p, findBuffer.achName);
     429      if (ffb.achName[0] != '.' ||
     430          (ffb.achName[1] &&
     431           (ffb.achName[1] != '.' || ffb.achName[2]))) {
     432        strcpy(p, ffb.achName);
    439433        if (!grep->anyexcludes || !IsExcluded(searchPath, fle, numfls)) {
    440434          domatchingfiles(grep, searchPath, fle, numfls);
     
    443437        }
    444438      }
    445       findCount = 1;
     439      ulFindCnt = 1;
    446440    } while (!DosFindNext(findHandle,
    447                           &findBuffer,
    448                           sizeof(findBuffer), (PULONG) & findCount));
     441                          &ffb,
     442                          sizeof(ffb), (PULONG) & ulFindCnt));
    449443    DosFindClose(findHandle);
    450444    priority_normal();
    451445  }
    452   if (p)                                /* strip off last directory addition */
     446  if (p)                                // strip off last directory addition
    453447    *p = 0;
    454448}
     
    456450static INT domatchingfiles(GREP * grep, CHAR * path, char **fle, int numfls)
    457451{
    458   /* process all matching files in a directory */
    459 
    460   PFILEFINDBUF4 findBuffer;
     452  // process all matching files in a directory
     453
     454  PFILEFINDBUF4 pffbArray;
    461455  PFILEFINDBUF4 pffbFile;
    462   register PBYTE fb;
    463   register ULONG x;
     456  ULONG x;
    464457  HDIR findHandle = HDIR_CREATE;
    465   ULONG findCount = grep->FilesToGet;
    466   CHAR newPath[CCHMAXPATH], *p;
     458  ULONG ulFindCnt;
     459  CHAR szFindPath[CCHMAXPATH];
     460  PSZ p;
    467461  APIRET rc;
    468 
    469   findBuffer =
    470     xmalloc(grep->FilesToGet * sizeof(FILEFINDBUF4), pszSrcFile, __LINE__);
    471   if (!findBuffer)
     462  ULONG ulBufBytes = grep->FilesToGet * sizeof(FILEFINDBUF4);
     463
     464  pffbArray = xmalloc(ulBufBytes, pszSrcFile, __LINE__);
     465  if (!pffbArray)
    472466    return 0;
    473467
    474   /* build filemask */
    475 
    476   sprintf(newPath,
    477           "%s%s%s",
    478           path,
    479           (path[strlen(path) - 1] == '\\') ? NullStr : "\\", grep->fileMask);
    480 
    481   MakeFullName(newPath);
    482 
    483   /* find and save end-of-dir position */
    484   p = strrchr(newPath, '\\');
     468  // build filemask
     469  BldFullPathName(szFindPath, path, grep->fileMask);
     470  // sprintf(szFindPath,
     471  //      "%s%s%s",
     472  //      path,
     473  //      (path[strlen(path) - 1] == '\\') ? NullStr : "\\", grep->fileMask);
     474
     475  MakeFullName(szFindPath);
     476
     477  // find and save end-of-dir position
     478  p = strrchr(szFindPath, '\\');
    485479  if (p)
    486480    p++;
    487481  else
    488     p = newPath;
    489 
    490   /* step through matching files */
     482    p = szFindPath;
     483
     484  // step through matching files
    491485  DosError(FERR_DISABLEHARDERR);
    492   if (!DosFindFirst(newPath,
     486  ulFindCnt = grep->FilesToGet;
     487  rc = DosFindFirst(szFindPath,
    493488                    &findHandle,
    494                     (FILE_NORMAL | grep->attrFile | grep->antiattr),
    495                     findBuffer,
    496                     (ULONG) (grep->FilesToGet * sizeof(FILEFINDBUF4)),
    497                     (PULONG) & findCount, FIL_QUERYEASIZE)) {
    498 
    499     do {                                /* Process each file that matches the mask */
     489                    FILE_NORMAL | grep->attrFile | grep->antiattr,
     490                    pffbArray,
     491                    ulBufBytes,
     492                    &ulFindCnt,
     493                    FIL_QUERYEASIZE);
     494  if (!rc) {
     495    do {
     496      // Process each file that matches the mask
    500497      priority_normal();
    501       fb = (PBYTE) findBuffer;
    502       for (x = 0L; x < findCount; x++) {
    503         pffbFile = (PFILEFINDBUF4) fb;
     498      pffbFile = pffbArray;
     499      for (x = 0; x < ulFindCnt; x++) {
    504500        if (*grep->stopflag)
    505501          break;
    506502        if (*pffbFile->achName != '.' ||
    507503            (pffbFile->achName[1] && pffbFile->achName[1] != '.')) {
    508           strcpy(p, pffbFile->achName); /* build filename */
    509           if (!grep->anyexcludes || !IsExcluded(newPath, fle, numfls)) {
     504          strcpy(p, pffbFile->achName); // build filename
     505          if (!grep->anyexcludes || !IsExcluded(szFindPath, fle, numfls)) {
    510506            if (!grep->finddupes)
    511               doonefile(grep, newPath, pffbFile);
    512             else if (!InsertDupe(grep, newPath, pffbFile)) {
     507              doonefile(grep, szFindPath, pffbFile);
     508            else if (!InsertDupe(grep, szFindPath, pffbFile)) {
    513509              DosFindClose(findHandle);
    514               free(findBuffer);
     510              free(pffbArray);
    515511              return 1;
    516512            }
     
    519515        if (!pffbFile->oNextEntryOffset)
    520516          break;
    521         fb += pffbFile->oNextEntryOffset;
    522       }
    523       findCount = grep->FilesToGet;
    524       rc = DosFindNext(findHandle,
    525                        findBuffer,
    526                        (ULONG) (grep->FilesToGet * sizeof(FILEFINDBUF4)),
    527                        (PULONG) & findCount);
    528       if (!rc)
    529         DosSleep(1);
     517        pffbFile = (PFILEFINDBUF4)((PBYTE)pffbFile + pffbFile->oNextEntryOffset);
     518      } // for
     519      if (*grep->stopflag)
     520        break;
     521      DosSleep(1);
     522      ulFindCnt = grep->FilesToGet;
     523      rc = DosFindNext(findHandle, pffbArray, ulBufBytes, &ulFindCnt);
    530524    } while (!rc);
     525
    531526    DosFindClose(findHandle);
    532527    priority_normal();
    533   }
    534   free(findBuffer);
     528  } // if
     529
     530  if (rc && rc != ERROR_NO_MORE_FILES) {
     531    Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     532              GetPString(IDS_CANTFINDDIRTEXT), szFindPath);
     533  }
     534
     535  free(pffbArray);
    535536  return 0;
    536537}
    537538
    538 #pragma alloc_text(GREP,insert_grepfile,doonefile,doinsertion,freegreplist)
    539 
    540539static VOID freegreplist(GREP * grep)
    541540{
    542   register INT x;
     541  INT x;
    543542
    544543  if (grep) {
     
    607606}
    608607
    609 static BOOL insert_grepfile(GREP * grep, CHAR * filename, FILEFINDBUF4 * f)
    610 {
    611   CHAR *p, szDirectory[CCHMAXPATH];
     608static BOOL insert_grepfile(GREP *grep, CHAR *filename, PFILEFINDBUF4 pffb)
     609{
     610  PSZ p;
     611  CHAR szDirectory[CCHMAXPATH];
    612612
    613613  if (WinIsWindow(grep->ghab, grep->hwndFiles)) {
     
    620620      *p = 0;
    621621      if (!grep->insertffb) {
    622         grep->insertffb = xmallocz(sizeof(FILEFINDBUF4 *) *
    623                                    (grep->FilesToGet + 1), pszSrcFile,
    624                                    __LINE__);
     622        // Allocate 1 extra for end marker?
     623        grep->insertffb =
     624          xmallocz(sizeof(PFILEFINDBUF4) * (grep->FilesToGet + 1),
     625                          pszSrcFile, __LINE__);
    625626        if (!grep->insertffb)
    626627          return FALSE;
    627628        grep->dir =
    628           xmallocz(sizeof(CHAR *) * (grep->FilesToGet + 1), pszSrcFile,
    629                    __LINE__);
     629          xmallocz(sizeof(CHAR *) * (grep->FilesToGet + 1),
     630                   pszSrcFile, __LINE__);
    630631        if (!grep->dir) {
    631632          free(grep->insertffb);
     
    637638      if (!grep->insertffb[grep->toinsert])
    638639        return FALSE;
    639       memcpy(grep->insertffb[grep->toinsert], f, sizeof(FILEFINDBUF4));
     640      memcpy(grep->insertffb[grep->toinsert], pffb, sizeof(FILEFINDBUF4));
    640641      grep->dir[grep->toinsert] = xstrdup(szDirectory, pszSrcFile, __LINE__);
    641642      if (!grep->dir) {
     
    643644        return FALSE;
    644645      }
    645       grep->insertedbytes += f->cbFile + CBLIST_TO_EASIZE(f->cbList);
     646      grep->insertedbytes += pffb->cbFile + CBLIST_TO_EASIZE(pffb->cbList);
    646647      grep->toinsert++;
    647648      if (grep->toinsert == grep->FilesToGet)
     
    655656}
    656657
    657 static BOOL doonefile(GREP * grep, CHAR * filename, FILEFINDBUF4 * f)
    658 {
    659   /* process a single file */
    660 
     658static BOOL doonefile(GREP *grep, CHAR *filename, FILEFINDBUF4 * pffb)
     659{
     660  // process a single file
    661661  CHAR *input;
    662662  FILE *inputFile;
     
    673673    ULONG adjsize;
    674674
    675     adjsize = f->cbFile + (grep->searchEAs ? CBLIST_TO_EASIZE(f->cbList) : 0);
     675    adjsize = pffb->cbFile + (grep->searchEAs ? CBLIST_TO_EASIZE(pffb->cbList) : 0);
    676676    if (grep->greaterthan) {
    677677      if (adjsize < grep->greaterthan)
     
    691691    ULONG numsecs;
    692692
    693     numsecs = SecsSince1980(&f->fdateLastWrite, &f->ftimeLastWrite);
     693    numsecs = SecsSince1980(&pffb->fdateLastWrite, &pffb->ftimeLastWrite);
    694694    if (grep->newerthan) {
    695695      if (numsecs < grep->newerthan)
     
    704704  }
    705705
    706   if ((!grep->searchEAs && !grep->searchFiles) || !*grep->searchPattern)        /* just a find */
    707     return insert_grepfile(grep, filename, f);
     706  if ((!grep->searchEAs && !grep->searchFiles) || !*grep->searchPattern)        // just a find
     707    return insert_grepfile(grep, filename, pffb);
    708708
    709709  if (grep->searchEAs) {
     
    849849
    850850  if (strmatch)
    851     ret = insert_grepfile(grep, filename, f);
     851    ret = insert_grepfile(grep, filename, pffb);
    852852  return ret;
    853853}
    854854
    855 #pragma alloc_text(DUPES,InsertDupe,FillDupes,FreeDupes,CRCFile,CRCBlock)
    856 #pragma alloc_text(DUPES,comparenamesq,comparenamesqe,comparenamesb)
    857 #pragma alloc_text(DUPES,comparenamesbe,comparesizesq,comparesizesb)
    858 
    859 static LONG cr3tab[] = {        /* CRC polynomial 0xEDB88320 */
     855static LONG cr3tab[] = {        // CRC polynomial 0xEDB88320
    860856
    861857  0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
     
    966962}
    967963
    968 static VOID FreeDupes(GREP * g)
     964static VOID FreeDupes(GREP *grep)
    969965{
    970966  DUPES *i, *next;
    971967
    972   i = g->dupehead;
     968  i = grep->dupehead;
    973969  while (i) {
    974970    next = i->next;
     
    978974    i = next;
    979975  }
    980   g->dupehead = g->dupelast = NULL;
    981   if (g->dupenames)
    982     free(g->dupenames);
    983   if (g->dupesizes)
    984     free(g->dupesizes);
    985   g->dupesizes = g->dupenames = NULL;
     976  grep->dupehead = grep->dupelast = NULL;
     977  if (grep->dupenames)
     978    free(grep->dupenames);
     979  if (grep->dupesizes)
     980    free(grep->dupesizes);
     981  grep->dupesizes = grep->dupenames = NULL;
    986982}
    987983
     
    11101106}
    11111107
    1112 static VOID FillDupes(GREP * g)
     1108static VOID FillDupes(GREP * grep)
    11131109{
    11141110  DUPES *c, *i, **r;
     
    11191115  ULONG cntr = 100;
    11201116
    1121   if (g->CRCdupes)
     1117  if (grep->CRCdupes)
    11221118    cntr = 50;
    1123   i = g->dupehead;
     1119  i = grep->dupehead;
    11241120  while (i) {
    11251121    x++;
     
    11271123  }
    11281124  if (x) {
    1129     WinSetWindowText(g->hwndCurFile, GetPString(IDS_GREPDUPESORTINGTEXT));
     1125    WinSetWindowText(grep->hwndCurFile, GetPString(IDS_GREPDUPESORTINGTEXT));
    11301126    DosSleep(1);
    1131     g->dupenames = xmalloc(sizeof(DUPES *) * (x + 1), pszSrcFile, __LINE__);
    1132     if (!g->nosizedupes)
    1133       g->dupesizes = xmalloc(sizeof(DUPES *) * (x + 1), pszSrcFile, __LINE__);
    1134     if (g->dupenames && (g->nosizedupes || g->dupesizes)) {
    1135       i = g->dupehead;
     1127    grep->dupenames = xmalloc(sizeof(DUPES *) * (x + 1), pszSrcFile, __LINE__);
     1128    if (!grep->nosizedupes)
     1129      grep->dupesizes = xmalloc(sizeof(DUPES *) * (x + 1), pszSrcFile, __LINE__);
     1130    if (grep->dupenames && (grep->nosizedupes || grep->dupesizes)) {
     1131      i = grep->dupehead;
    11361132      while (i) {
    1137         g->dupenames[y] = i;
    1138         if (!g->nosizedupes)
    1139           g->dupesizes[y] = i;
     1133        grep->dupenames[y] = i;
     1134        if (!grep->nosizedupes)
     1135          grep->dupesizes[y] = i;
    11401136        i = i->next;
    11411137        y++;
    11421138      }
    1143       g->dupenames[y] = NULL;
    1144       if (!g->nosizedupes)
    1145         g->dupesizes[y] = NULL;
     1139      grep->dupenames[y] = NULL;
     1140      if (!grep->nosizedupes)
     1141        grep->dupesizes[y] = NULL;
    11461142      DosSleep(1);
    1147       qsort(g->dupenames,
     1143      qsort(grep->dupenames,
    11481144            x,
    11491145            sizeof(DUPES *),
    1150             ((g->ignoreextdupes) ? comparenamesqe : comparenamesq));
     1146            ((grep->ignoreextdupes) ? comparenamesqe : comparenamesq));
    11511147      DosSleep(1);
    1152       if (!g->nosizedupes) {
    1153         qsort(g->dupesizes, x, sizeof(DUPES *), comparesizesq);
     1148      if (!grep->nosizedupes) {
     1149        qsort(grep->dupesizes, x, sizeof(DUPES *), comparesizesq);
    11541150        DosSleep(1);
    11551151      }
    1156       WinSetWindowText(g->hwndCurFile, GetPString(IDS_GREPDUPECOMPARINGTEXT));
    1157 
    1158       i = g->dupehead;
     1152      WinSetWindowText(grep->hwndCurFile, GetPString(IDS_GREPDUPECOMPARINGTEXT));
     1153
     1154      i = grep->dupehead;
    11591155      y = 0;
    11601156      while (i) {
    1161         if (*g->stopflag)
     1157        if (*grep->stopflag)
    11621158          break;
    11631159        if (!(i->flags & GF_SKIPME)) {
    1164           r = (DUPES **) bsearch(i, g->dupenames, x, sizeof(DUPES *),
    1165                                  ((g->ignoreextdupes) ? comparenamesbe :
     1160          r = (DUPES **) bsearch(i, grep->dupenames, x, sizeof(DUPES *),
     1161                                 ((grep->ignoreextdupes) ? comparenamesbe :
    11661162                                  comparenamesb));
    11671163          if (r) {
    1168             while (r > g->dupenames && ((g->ignoreextdupes) ?
     1164            while (r > grep->dupenames && ((grep->ignoreextdupes) ?
    11691165                                        !comparenamesqe((r - 1), &i) :
    11701166                                        !comparenamesq((r - 1), &i)))
    11711167              r--;
    1172             while (*r && ((g->ignoreextdupes) ?
     1168            while (*r && ((grep->ignoreextdupes) ?
    11731169                          !comparenamesqe(r, &i) : !comparenamesq(r, &i))) {
    11741170              if (*r == i || ((*r)->flags & (GF_INSERTED | GF_SKIPME))) {
     
    11761172                continue;
    11771173              }
    1178               if (g->CRCdupes) {
     1174              if (grep->CRCdupes) {
    11791175                if ((*r)->CRC == -1L) {
    11801176                  (*r)->CRC = CRCFile((*r)->name, &error);
     
    12001196              if (!AddToList((*r)->name, &list, &numfiles, &numalloced)) {
    12011197                (*r)->flags |= GF_INSERTED;
    1202                 if (g->sayfiles)
    1203                   WinSetWindowText(g->hwndFiles, (*r)->name);
     1198                if (grep->sayfiles)
     1199                  WinSetWindowText(grep->hwndFiles, (*r)->name);
    12041200                if ((*r)->size == i->size &&
    12051201                    (i->date.year == (*r)->date.year &&
     
    12211217            }
    12221218          }
    1223           if (!g->nosizedupes) {
     1219          if (!grep->nosizedupes) {
    12241220            r = (DUPES **) bsearch(i,
    1225                                    g->dupesizes,
     1221                                   grep->dupesizes,
    12261222                                   x, sizeof(DUPES *), comparesizesb);
    12271223            if (r) {
    1228               while (r > g->dupesizes && !comparesizesq((r - 1), &i))
     1224              while (r > grep->dupesizes && !comparesizesq((r - 1), &i))
    12291225                r--;
    12301226              while (*r && !comparesizesq(r, &i)) {
     
    12391235                  continue;
    12401236                }
    1241                 if (g->CRCdupes) {
     1237                if (grep->CRCdupes) {
    12421238                  if ((*r)->CRC == -1L) {
    12431239                    (*r)->CRC = CRCFile((*r)->name, &error);
     
    12611257                }
    12621258                if (!AddToList((*r)->name, &list, &numfiles, &numalloced)) {
    1263                   if (g->sayfiles)
    1264                     WinSetWindowText(g->hwndCurFile, (*r)->name);
     1259                  if (grep->sayfiles)
     1260                    WinSetWindowText(grep->hwndCurFile, (*r)->name);
    12651261                  (*r)->flags |= GF_INSERTED;
    1266                   if (((g->ignoreextdupes) ?
     1262                  if (((grep->ignoreextdupes) ?
    12671263                       comparenamesqe(r, &i) : comparenamesq(r, &i)))
    12681264                    (*r)->flags |= GF_SKIPME;
     
    12861282          CHAR s[44];
    12871283
    1288           sprintf(s, GetPString(IDS_GREPDUPECHECKPROGTEXT), y, g->numfiles);
    1289           WinSetWindowText(g->hwndCurFile, s);
    1290           DosSleep(100); //05 Aug 07 GKY 128
     1284          sprintf(s, GetPString(IDS_GREPDUPECHECKPROGTEXT), y, grep->numfiles);
     1285          WinSetWindowText(grep->hwndCurFile, s);
     1286          DosSleep(100);                //05 Aug 07 GKY 128
    12911287        }
    12921288        DosSleep(y % 2);
     
    12961292      // Insufficient memory - fall back
    12971293      DosBeep(50, 100);
    1298       WinSetWindowText(g->hwndCurFile, GetPString(IDS_GREPDUPECOMPARINGTEXT));
     1294      WinSetWindowText(grep->hwndCurFile, GetPString(IDS_GREPDUPECOMPARINGTEXT));
    12991295      x = y = 0;
    1300       if (g->dupenames) {
    1301         free(g->dupenames);
    1302         g->dupenames = NULL;
     1296      if (grep->dupenames) {
     1297        free(grep->dupenames);
     1298        grep->dupenames = NULL;
    13031299      }
    1304       if (g->dupesizes) {
    1305         free(g->dupesizes);
    1306         g->dupesizes = NULL;
     1300      if (grep->dupesizes) {
     1301        free(grep->dupesizes);
     1302        grep->dupesizes = NULL;
    13071303      }
    1308       i = g->dupehead;
     1304      i = grep->dupehead;
    13091305      while (i) {
    1310         if (*g->stopflag)
     1306        if (*grep->stopflag)
    13111307          break;
    13121308        if (!(i->flags & GF_SKIPME)) {
     
    13151311            CHAR s[44];
    13161312
    1317             sprintf(s, GetPString(IDS_GREPDUPECHECKPROGTEXT), y, g->numfiles);
    1318             WinSetWindowText(g->hwndCurFile, s);
     1313            sprintf(s, GetPString(IDS_GREPDUPECHECKPROGTEXT), y, grep->numfiles);
     1314            WinSetWindowText(grep->hwndCurFile, s);
    13191315            DosSleep(1);
    13201316          }
     
    13251321          else
    13261322            pi = i->name;
    1327           c = g->dupehead;
     1323          c = grep->dupehead;
    13281324          while (c) {
    1329             if (*g->stopflag)
     1325            if (*grep->stopflag)
    13301326              break;
    13311327            if (c != i && !(c->flags & (GF_INSERTED | GF_SKIPME))) {
     
    13361332              else
    13371333                pc = c->name;
    1338               if ((!g->nosizedupes && i->size == c->size && i->date.year == c->date.year && i->date.month == c->date.month && i->date.day == c->date.day && i->time.hours == c->time.hours && i->time.minutes == c->time.minutes && i->time.twosecs == c->time.twosecs) || !stricmp(pc, pi)) {  /* potential dupe */
    1339                 if (g->CRCdupes) {
    1340                   if (g->CRCdupes) {
     1334              if ((!grep->nosizedupes && i->size == c->size && i->date.year == c->date.year && i->date.month == c->date.month && i->date.day == c->date.day && i->time.hours == c->time.hours && i->time.minutes == c->time.minutes && i->time.twosecs == c->time.twosecs) || !stricmp(pc, pi)) {       // potential dupe
     1335                if (grep->CRCdupes) {
     1336                  if (grep->CRCdupes) {
    13411337                    if (c->CRC == -1L) {
    13421338                      c->CRC = CRCFile(c->name, &error);
     
    13671363                    goto BreakOut;      // Failed
    13681364                }
    1369                 if (g->sayfiles)
    1370                   WinSetWindowText(g->hwndCurFile, pc);
     1365                if (grep->sayfiles)
     1366                  WinSetWindowText(grep->hwndCurFile, pc);
    13711367                c->flags |= GF_INSERTED;
    13721368                i->flags |= GF_INSERTED;
     
    13871383  }
    13881384BreakOut:
    1389   FreeDupes(g);
     1385  FreeDupes(grep);
    13901386  if (numfiles && list) {
    1391     if (!PostMsg(g->hwndFiles,
     1387    if (!PostMsg(grep->hwndFiles,
    13921388                 WM_COMMAND, MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list)))
    13931389      FreeList(list);
     
    13971393}
    13981394
    1399 static BOOL InsertDupe(GREP * g, CHAR * dir, FILEFINDBUF4 * f)
     1395static BOOL InsertDupe(GREP *grep, CHAR *dir, FILEFINDBUF4 *pffb)
    14001396{
    14011397  DUPES *info;
     
    14051401    if (!info)
    14061402      return FALSE;
    1407     else {
    1408       info->name = xstrdup(dir, pszSrcFile, __LINE__);
    1409       if (!info->name) {
    1410         free(info);
    1411         return FALSE;
    1412       }
    1413       else {
    1414         info->size = f->cbFile;
    1415         info->date = f->fdateLastWrite;
    1416         info->time = f->ftimeLastWrite;
    1417         info->CRC = -1L;
    1418         g->numfiles++;
    1419         if (!g->dupehead)
    1420           g->dupehead = info;
    1421         if (g->dupelast)
    1422           g->dupelast->next = info;
    1423         g->dupelast = info;
    1424         info->next = NULL;
    1425       }
    1426     }
     1403
     1404    info->name = xstrdup(dir, pszSrcFile, __LINE__);
     1405    if (!info->name) {
     1406      free(info);
     1407      return FALSE;
     1408    }
     1409
     1410    info->size = pffb->cbFile;
     1411    info->date = pffb->fdateLastWrite;
     1412    info->time = pffb->ftimeLastWrite;
     1413    info->CRC = -1L;
     1414    grep->numfiles++;
     1415    if (!grep->dupehead)
     1416      grep->dupehead = info;
     1417    if (grep->dupelast)
     1418      grep->dupelast->next = info;
     1419    grep->dupelast = info;
     1420    info->next = NULL;
    14271421  }
    14281422  return TRUE;
    14291423}
     1424
     1425#pragma alloc_text(GREP,insert_grepfile,doonefile,doinsertion,freegreplist)
     1426#pragma alloc_text(GREP,SecsSince1980,match,mmatch,GrepThread)
     1427#pragma alloc_text(GREP,doallsubdirs,domatchingfiles,InsertDupes,FreeDupes)
     1428
     1429#pragma alloc_text(DUPES,InsertDupe,FillDupes,FreeDupes,CRCFile,CRCBlock)
     1430#pragma alloc_text(DUPES,comparenamesq,comparenamesqe,comparenamesb)
     1431#pragma alloc_text(DUPES,comparenamesbe,comparesizesq,comparesizesb)
  • trunk/dll/init.c

    r775 r783  
    2828  03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speed file loading)
    2929  06 Aug 07 GKY Reduce DosSleep times (ticket 148)
    30 
     30  13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat
    3131
    3232***********************************************************************/
     
    5656#include "version.h"
    5757
    58 #ifdef __WATCOMC__
     58#ifdef __IBMC__
    5959#pragma alloc_text(INIT,LibMain,InitFM3DLL,DeInitFM3DLL)
    60 #else // __IBMC__
    61 #pragma alloc_text(INIT,_DLL_InitTerm,InitFM3DLL,DeInitFM3DLL)
     60#pragma alloc_text(INIT1,StartFM3,FindSwapperDat)
    6261#endif
    63 
    64 #pragma alloc_text(INIT1,StartFM3,FindSwapperDat)
    6562
    6663extern int _CRT_init(void);
     
    174171
    175172unsigned APIENTRY LibMain(unsigned hModule,
    176                           unsigned ulFlag)
     173                          unsigned ulFlag)
    177174{
    178175  CHAR *env;
     
    14081405  return ok;
    14091406}
     1407
     1408#ifdef __WATCOMC__
     1409#pragma alloc_text(INIT,LibMain,InitFM3DLL,DeInitFM3DLL)
     1410#pragma alloc_text(INIT1,StartFM3,FindSwapperDat)
     1411#endif
     1412
  • trunk/dll/ipf/notebook.ipf

    r756 r783  
    66.*
    77.* Copyright (c) 1993-98 M. Kimes
    8 .* Copyright (c) 2006-07 Steven H.Levine
     8.* Copyright (c) 2006, 2007 Steven H.Levine
    99.*
    1010.* 30 Dec 06 GKY Corrected statement re copy/move "toggle" in OS/2
    1111.* 03 Mar 07 GKY Update that file systems other than HPFS support long names
    12 .* 20 Mar 07 DG  Add discribtion for Mommy make it stop
     12.* 20 Mar 07 DG  Add description for Mommy make it stop
     13.* 13 Aug 07 SHL Tweak scanning page
    1314.*
    1415.***********************************************************************
     
    698699from the INI (which will cause FM/2 to revert to the default setting).
    699700:p.
    700 If the :hp6.Don't scan remov.:ehp6. is checked, FM/2 won't attempt to
     701If the :hp6.Don't scan removables:ehp6. is checked, FM/2 won't attempt to
    701702find subdirectories on removable drives until you double-click the drive
    702703in the Drive Tree, so you won't see a [+] sign beside removable drives
     
    707708loaded and scanned automatically at FM/2 startup.
    708709:p.
    709 The :hp6.Findbuf:ehp6. spin button controls how many files FM/2 searches
     710The :hp6.Find count:ehp6. spin button controls how many files FM/2 searches
    710711for in one system call. The higher this number, the faster FM/2 works
    711712(with properly operating FSDs that support "finding" more than one file
     
    716717memory, boosting this may be a good idea. On the other hand, if you are
    717718extremely limited in memory (less than 16 megs), reducing this might be
    718 the thing to do. The range is 2048 to 102400, with 10240 the default.
     719the thing to do. The range is 512 to 4096, with 4096 being the default.
    719720
    720721
  • trunk/dll/notebook.c

    r756 r783  
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2004, 2006 Steven H. Levine
     9  Copyright (c) 2004, 2007 Steven H. Levine
    1010
    1111  01 Aug 04 SHL Rework lstrip/rstrip usage
     
    1616  15 Aug 06 SHL Rework SetMask args
    1717  03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speed file loading)
     18  13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat
     19  13 Aug 07 SHL Rework FileToGet min/max to match how DosFindFirst/Next works
    1820
    1921***********************************************************************/
     
    3133#include "fm3str.h"
    3234
     35#define FILESTOGET_MIN  256
     36#define FILESTOGET_MAX  4096
     37
    3338#pragma data_seg(DATA2)
    3439
    3540static PSZ pszSrcFile = __FILE__;
    36 
    37 #pragma alloc_text(NOTEBOOK,CfgTDlgProc,CfgTSDlgProc,CfgMDlgProc)
    38 #pragma alloc_text(NOTEBOOK2,CfgADlgProc,CfgSDlgProc,CfgVDlgProc)
    39 #pragma alloc_text(NOTEBOOK3,CfgDDlgProc,Cfg5DlgProc,Cfg6DlgProc)
    40 #pragma alloc_text(NOTEBOOK4,Cfg7DlgProc,Cfg8DlgProc,CfgCDlgProc)
    41 #pragma alloc_text(NOTEBOOK5,CfgGDlgProc,CfgDlgProc,CfgBDlgProc)
    4241
    4342typedef struct
     
    226225                      MPFROMSHORT(8), MPVOID);
    227226    WinSendDlgItemMsg(hwnd, CFGS_FILESTOGET, SPBM_OVERRIDESETLIMITS,
    228                       MPFROMLONG(102400), MPFROMLONG(2048));
     227                      MPFROMLONG(FILESTOGET_MAX), MPFROMLONG(FILESTOGET_MIN));
    229228    PostMsg(hwnd, UM_UNDO, MPVOID, MPVOID);
    230229    break;
     
    319318      WinSendDlgItemMsg(hwnd, CFGS_FILESTOGET, SPBM_QUERYVALUE,
    320319                        MPFROMP(&temp), MPFROM2SHORT(0, SPBQ_DONOTUPDATE));
    321       if (temp < 2048)
    322         temp = 2048;
    323       else if (temp > 102400)
    324         temp = 102400;
     320      if (temp < FILESTOGET_MIN)
     321        temp = FILESTOGET_MIN;
     322      else if (temp > FILESTOGET_MAX)
     323        temp = FILESTOGET_MAX;
    325324      FilesToGet = temp;
    326325      PrfWriteProfileData(fmprof,
     
    21842183      fVerify = FALSE;
    21852184      DosSetVerify(FALSE);
    2186       FilesToGet = 10240;
     2185      FilesToGet = FILESTOGET_MAX;
    21872186      fQuickArcFind = TRUE;
    21882187      fMinOnOpen = TRUE;
     
    22352234      fQuickArcFind = TRUE;
    22362235      fNoRemovableScan = TRUE;
    2237       FilesToGet = 2048;
     2236      FilesToGet = FILESTOGET_MIN;
    22382237      fFreeTree = FALSE;
    22392238      fSplitStatus = TRUE;
     
    23542353      fQuickArcFind = TRUE;
    23552354      fNoRemovableScan = FALSE;
    2356       FilesToGet = 10240;
     2355      FilesToGet = FILESTOGET_MAX;
    23572356      fFreeTree = FALSE;
    23582357      fSplitStatus = TRUE;
     
    29302929  return WinDefDlgProc(hwnd, msg, mp1, mp2);
    29312930}
     2931
     2932#pragma alloc_text(NOTEBOOK,CfgTDlgProc,CfgTSDlgProc,CfgMDlgProc)
     2933#pragma alloc_text(NOTEBOOK2,CfgADlgProc,CfgSDlgProc,CfgVDlgProc)
     2934#pragma alloc_text(NOTEBOOK3,CfgDDlgProc,Cfg5DlgProc,Cfg6DlgProc)
     2935#pragma alloc_text(NOTEBOOK4,Cfg7DlgProc,Cfg8DlgProc,CfgCDlgProc)
     2936#pragma alloc_text(NOTEBOOK5,CfgGDlgProc,CfgDlgProc,CfgBDlgProc)
     2937
  • trunk/dll/objcnr.c

    r775 r783  
    1818  03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speed file loading)
    1919  06 Aug 07 GKY Reduce DosSleep times (ticket 148)
    20 
     20  13 Aug 07 SHL Avoid realloc - not needed; sanitize code
     21  13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat
    2122
    2223***********************************************************************/
     
    2425#define INCL_DOS
    2526#define INCL_WIN
     27#define INCL_DOSERRORS
    2628#include <os2.h>
    2729
     
    5961static HWND objcnrwnd;
    6062
    61 #pragma alloc_text(OBJCNR,ProcessDir,FillCnrsThread,ObjCnrDlgProc)
    62 
    63 static VOID ProcessDir(HWND hwndCnr, CHAR * filename, PCNRITEM pciParent,
    64                        CHAR * stopflag)
     63static VOID ProcessDir(HWND hwndCnr,
     64                       CHAR *filename,
     65                      PCNRITEM pciParent,
     66                       CHAR *stopflag)
    6567{
    6668  CHAR maskstr[CCHMAXPATH], *endpath, *p;
    67   ULONG nm, ulM;
     69  ULONG ulFindCnt, ulFindMax;
     70  ULONG ulBufBytes;
    6871  HDIR hdir;
    69   FILEFINDBUF3 *ffb, *fft;
     72  PFILEFINDBUF3 pffbArray;
    7073  APIRET rc;
    7174  RECORDINSERT ri;
    7275  PCNRITEM pciP;
    73 
    74   ffb = xmalloc(sizeof(FILEFINDBUF3), pszSrcFile, __LINE__);
    75   if (!ffb)
    76     return;
     76  HPOINTER hptr;
     77
     78  ulBufBytes = sizeof(FILEFINDBUF3) * FilesToGet;
     79  pffbArray = xmalloc(ulBufBytes, pszSrcFile, __LINE__);
     80  if (!pffbArray)
     81    return;                             // Error already reported
    7782  strcpy(maskstr, filename);
    7883  if (maskstr[strlen(maskstr) - 1] != '\\')
     
    8186  strcat(maskstr, "*");
    8287  hdir = HDIR_CREATE;
    83   nm = 1;
     88  ulFindCnt = 1;
    8489  rc = DosFindFirst(filename, &hdir,
    8590                    FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED |
    8691                    FILE_SYSTEM | FILE_HIDDEN | MUST_HAVE_DIRECTORY,
    87                     ffb, sizeof(FILEFINDBUF3), &nm, FIL_STANDARD);
     92                    pffbArray, ulBufBytes, &ulFindCnt, FIL_STANDARD);
    8893  if (!rc)
    8994    DosFindClose(hdir);
    90 
    91   if (rc) {                             /* work around furshluginer FAT bug... */
    92     if (IsRoot(filename))
    93       rc = 0;
    94   }
    95 
    96   if ((!rc && (ffb->attrFile & FILE_DIRECTORY))) {
     95  // work around furshluginer FAT root bug
     96  else if (IsRoot(filename))
     97    rc = 0;
     98
     99  if ((!rc && (pffbArray->attrFile & FILE_DIRECTORY))) {
    97100    pciP = WinSendMsg(hwndCnr,
    98101                      CM_ALLOCRECORD,
     
    100103                      MPFROMLONG(1));
    101104    if (!pciP) {
    102       free(ffb);
     105      Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_ALLOCRECORD");
     106      free(pffbArray);
    103107      return;
    104108    }
     
    125129  }
    126130  else {
    127     free(ffb);
    128     Dos_Error(MB_ENTER,
    129               rc,
    130               HWND_DESKTOP,
    131               pszSrcFile,
    132               __LINE__, GetPString(IDS_CANTFINDDIRTEXT), filename);
     131    free(pffbArray);
     132    Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     133              GetPString(IDS_CANTFINDDIRTEXT), filename);
    133134    return;
    134135  }
    135   {
    136     HPOINTER hptr;
    137 
    138     hptr = WinLoadFileIcon(pciP->pszFileName, FALSE);
    139     if (hptr)
    140       pciP->rc.hptrIcon = hptr;
    141   }
     136
     137  hptr = WinLoadFileIcon(pciP->pszFileName, FALSE);
     138  if (hptr)
     139    pciP->rc.hptrIcon = hptr;
     140
    142141  if (!pciP->rc.hptrIcon || pciP->rc.hptrIcon == hptrFile)      /* OS/2 bug bug bug bug */
    143142    pciP->rc.hptrIcon = hptrDir;
     143
    144144  memset(&ri, 0, sizeof(RECORDINSERT));
    145145  ri.cb = sizeof(RECORDINSERT);
     
    150150  ri.fInvalidateRecord = TRUE;
    151151  if (!WinSendMsg(hwndCnr, CM_INSERTRECORD, MPFROMP(pciP), MPFROMP(&ri))) {
    152     free(ffb);
     152    free(pffbArray);
    153153    return;
    154154  }
     
    156156  if (!isalpha(*maskstr) || maskstr[1] != ':' || maskstr[2] != '\\' ||
    157157      ((driveflags[toupper(*maskstr) - 'A'] & DRIVE_REMOTE) && fRemoteBug))
    158     ulM = 1;
     158    ulFindMax = 1;
    159159  else
    160     ulM = FilesToGet;
    161   if (ulM > 1) {
    162     fft = xrealloc(ffb, sizeof(FILEFINDBUF3) * ulM, pszSrcFile, __LINE__);
    163     if (!fft)
    164       ulM = 1;
    165     else
    166       ffb = fft;
    167   }
    168   nm = ulM;
     160    ulFindMax = FilesToGet;
     161  ulFindCnt = ulFindMax;
    169162  rc = DosFindFirst(maskstr, &hdir,
    170163                    FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED |
    171                     FILE_SYSTEM | FILE_HIDDEN | MUST_HAVE_DIRECTORY, ffb,
    172                     sizeof(FILEFINDBUF3) * ulM, &nm, FIL_STANDARD);
     164                    FILE_SYSTEM | FILE_HIDDEN | MUST_HAVE_DIRECTORY,
     165                    pffbArray, ulBufBytes, &ulFindCnt, FIL_STANDARD);
    173166  if (!rc) {
    174 
    175     register PBYTE fb = (PBYTE) ffb;
    176     FILEFINDBUF3 *pffbFile;
     167    PFILEFINDBUF3 pffbFile;
    177168    ULONG x;
    178169
    179170    while (!rc) {
    180       for (x = 0; x < nm; x++) {
    181         pffbFile = (FILEFINDBUF3 *) fb;
     171      pffbFile = pffbArray;
     172      for (x = 0; x < ulFindCnt; x++) {
    182173        if (*stopflag)
    183174          break;
     
    192183        if (!pffbFile->oNextEntryOffset)
    193184          break;
    194         fb += pffbFile->oNextEntryOffset;
    195       }
     185        pffbFile = (PFILEFINDBUF3)((PBYTE)pffbFile + pffbFile->oNextEntryOffset);
     186      } // for
    196187      DosSleep(1);
    197188      if (*stopflag)
    198189        break;
    199       nm = ulM;
    200       rc = DosFindNext(hdir, ffb, sizeof(FILEFINDBUF3) * ulM, &nm);
    201     }
     190      ulFindCnt = ulFindMax;
     191      rc = DosFindNext(hdir, pffbArray, ulBufBytes, &ulFindCnt);
     192    } // while
    202193    DosFindClose(hdir);
    203194  }
    204   free(ffb);
     195
     196  if (rc && rc != ERROR_NO_MORE_FILES) {
     197    Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     198              GetPString(IDS_CANTFINDDIRTEXT), filename);
     199  }
     200
     201  free(pffbArray);
    205202  WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPFROMP(&pciP),
    206203             MPFROM2SHORT(1, 0));
     
    211208  HAB hab;
    212209  HMQ hmq;
    213   DIRSIZE *dirsize = (DIRSIZE *) args;
    214 
    215   if (!dirsize)
     210  DIRSIZE *dirsize = (DIRSIZE *)args;
     211
     212  if (!dirsize) {
     213    Runtime_Error(pszSrcFile, __LINE__, "no data");
    216214    return;
     215  }
    217216
    218217  DosError(FERR_DISABLEHARDERR);
     
    430429  return WinDefDlgProc(hwnd, msg, mp1, mp2);
    431430}
     431
     432#pragma alloc_text(OBJCNR,ProcessDir,FillCnrsThread,ObjCnrDlgProc)
  • trunk/dll/seeall.c

    r775 r783  
    2222  03 Nov 06 SHL Count thread usage
    2323  30 Mar 07 GKY Remove GetPString for window class names
    24   03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speed file loading)
     24  03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speeds file loading)
    2525  06 Aug 07 GKY Reduce DosSleep times (ticket 148)
    2626  07 Aug 07 SHL Use BldQuotedFullPathName and BldQuotedFileName
     27  13 Aug 07 SHL Sync code with other FilesToGet usage
     28  13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat
    2729
    2830***********************************************************************/
     
    4850
    4951static PSZ pszSrcFile = __FILE__;
    50 
    51 #pragma alloc_text(SEEALL,comparefullnames,comparenames,comparesizes)
    52 #pragma alloc_text(SEEALL,comparedates,compareexts,SeeStatusProc)
    53 #pragma alloc_text(SEEALL,InitWindow,PaintLine,SeeAllWndProc)
    54 #pragma alloc_text(SEEALL,UpdateList,CollectList,ReSort,Mark)
    55 #pragma alloc_text(SEEALL,BuildAList,RemoveDeleted,SeeFrameWndProc,FilterList)
    56 #pragma alloc_text(SEEALL2,SeeObjWndProc,MakeSeeObjWinThread,FindDupes,DupeDlgProc)
    57 #pragma alloc_text(SEEALL3,FreeAllFilesList,DoADir,FindAllThread,AFDrvsWndProc)
    58 #pragma alloc_text(SEEALL3,StartSeeAll)
    5952
    6053typedef struct
     
    726719                  // Assume <2GB since file did not fit
    727720                  clFreeBytes = fsa.cUnitAvail * fsa.cSectorUnit *
    728                     fsa.cbSector;
     721                                fsa.cbSector;
    729722                  if (clFreeBytes) {
    730723                    // Find item that will fit in available space
     
    14131406}
    14141407
    1415 static BOOL UpdateList(HWND hwnd, CHAR ** list)
     1408static BOOL UpdateList(HWND hwnd, CHAR **list)
    14161409{
    14171410  /* Updates files in the list */
    14181411
    14191412  ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
    1420   register ULONG x, z;
     1413  ULONG x, z;
    14211414  BOOL ret, didone = FALSE;
    14221415  FILEFINDBUF3 ffb;
    1423   ULONG nm;
     1416  ULONG ulFindCnt;
    14241417  HDIR hdir;
    14251418  CHAR *p;
     
    14371430        didone = TRUE;
    14381431        hdir = HDIR_CREATE;
    1439         nm = 1;
     1432        ulFindCnt = 1;
    14401433        if (!DosFindFirst(list[z], &hdir, FILE_NORMAL | FILE_ARCHIVED |
    14411434                          FILE_DIRECTORY | FILE_READONLY | FILE_SYSTEM |
    1442                           FILE_HIDDEN, &ffb, sizeof(ffb), &nm,
     1435                          FILE_HIDDEN, &ffb, sizeof(ffb), &ulFindCnt,
    14431436                          FIL_STANDARD)) {
    14441437          DosFindClose(hdir);
     
    14581451        didone = TRUE;
    14591452        hdir = HDIR_CREATE;
    1460         nm = 1;
     1453        ulFindCnt = 1;
    14611454        if (!DosFindFirst(list[z], &hdir, FILE_NORMAL | FILE_ARCHIVED |
    14621455                          FILE_DIRECTORY | FILE_READONLY | FILE_SYSTEM |
    1463                           FILE_HIDDEN, &ffb, sizeof(ffb), &nm,
     1456                          FILE_HIDDEN, &ffb, sizeof(ffb), &ulFindCnt,
    14641457                          FIL_STANDARD)) {
    14651458          DosFindClose(hdir);
     
    18931886  ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
    18941887  CHAR *filename, *enddir;
    1895   FILEFINDBUF3 *pffb, *ffb;
     1888  PFILEFINDBUF3 pffbArray, pffbFile;
    18961889  HDIR hdir = HDIR_CREATE;
    1897   ULONG nm, uL;
    1898   register ULONG x;
    1899   register PBYTE fb;
     1890  ULONG ulFindCnt;
     1891  ULONG ulFindMax;
     1892  ULONG ulBufBytes;
     1893  ULONG x;
     1894  APIRET rc;
    19001895
    19011896  filename = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
     
    19031898    return;
    19041899
    1905   uL = ad->afFilesToGet;
     1900  ulFindMax = ad->afFilesToGet;
    19061901  if (fRemoteBug && isalpha(*pathname) && pathname[1] == ':' &&
    19071902      pathname[2] == '\\' &&
    19081903      (driveflags[toupper(*pathname) - 'A'] & DRIVE_REMOTE))
    1909     uL = 1;
    1910   pffb = xmalloc(sizeof(FILEFINDBUF3) * uL, pszSrcFile, __LINE__);
    1911   if (!pffb) {
     1904    ulFindMax = 1;
     1905
     1906  ulBufBytes = sizeof(FILEFINDBUF3) * ulFindMax;
     1907  pffbArray = xmalloc(ulBufBytes, pszSrcFile, __LINE__);
     1908  if (!pffbArray) {
    19121909    free(filename);
    19131910    return;
    19141911  }
    1915   nm = uL;
     1912
    19161913  strcpy(filename, pathname);
    19171914  enddir = &filename[strlen(filename) - 1];
     
    19231920  strcpy(enddir, "*");
    19241921  DosError(FERR_DISABLEHARDERR);
    1925   if (!DosFindFirst(filename, &hdir, FILE_NORMAL | FILE_ARCHIVED |
     1922  ulFindCnt = ulFindMax;
     1923  rc = DosFindFirst(filename, &hdir, FILE_NORMAL | FILE_ARCHIVED |
    19261924                    FILE_READONLY | FILE_DIRECTORY | FILE_SYSTEM |
    1927                     FILE_HIDDEN, pffb, sizeof(FILEFINDBUF3) * nm, &nm,
    1928                     FIL_STANDARD)) {
     1925                    FILE_HIDDEN,
     1926                    pffbArray, ulBufBytes, &ulFindCnt, FIL_STANDARD);
     1927  if (!rc) {
    19291928    do {
     1929#if 0 // 13 Aug 07 SHL fixme to be gone
     1930      {
     1931        static ULONG ulMaxCnt = 1;
     1932        if (ulFindCnt > ulMaxCnt) {
     1933          ulMaxCnt = ulFindCnt;
     1934          DbgMsg(pszSrcFile, __LINE__, "ulMaxCnt %u/%u", ulMaxCnt, ulFindMax);
     1935        }
     1936      }
     1937#endif // fixme to be gone
    19301938      priority_normal();
    1931       fb = (PBYTE) pffb;
    1932       for (x = 0; x < nm; x++) {
    1933         ffb = (FILEFINDBUF3 *) fb;
    1934         if (ffb->attrFile & FILE_DIRECTORY) {
     1939      pffbFile = pffbArray;
     1940      for (x = 0; x < ulFindCnt; x++) {
     1941        if (pffbFile->attrFile & FILE_DIRECTORY) {
    19351942          // Skip . and ..
    1936           if (ffb->achName[0] != '.' ||
    1937               (ffb->achName[1] &&
    1938                (ffb->achName[1] != '.' || ffb->achName[2]))) {
    1939             strcpy(enddir, ffb->achName);
     1943          if (pffbFile->achName[0] != '.' ||
     1944              (pffbFile->achName[1] &&
     1945               (pffbFile->achName[1] != '.' || pffbFile->achName[2]))) {
     1946            strcpy(enddir, pffbFile->achName);
    19401947            DoADir(hwnd, filename);
    19411948          }
     
    19431950        else {
    19441951          *enddir = 0;
    1945           strcpy(enddir, ffb->achName);
     1952          strcpy(enddir, pffbFile->achName);
    19461953          if (!ad->afalloc || ad->affiles > ad->afalloc - 1) {
    19471954
     
    19701977            ad->afhead[ad->affiles].filename =
    19711978              ad->afhead[ad->affiles].fullname + (enddir - filename);
    1972             ad->afhead[ad->affiles].cbFile = ffb->cbFile;
    1973             ad->afhead[ad->affiles].date = ffb->fdateLastWrite;
    1974             ad->afhead[ad->affiles].time = ffb->ftimeLastWrite;
    1975             ad->afhead[ad->affiles].attrFile = (USHORT) ffb->attrFile;
     1979            ad->afhead[ad->affiles].cbFile = pffbFile->cbFile;
     1980            ad->afhead[ad->affiles].date = pffbFile->fdateLastWrite;
     1981            ad->afhead[ad->affiles].time = pffbFile->ftimeLastWrite;
     1982            ad->afhead[ad->affiles].attrFile = (USHORT) pffbFile->attrFile;
    19761983            ad->afhead[ad->affiles].flags = 0;
    19771984            ad->affiles++;
    1978             if (ad->longest < ffb->cchName)
    1979               ad->longest = ffb->cchName;
    1980             if (ad->longestw < ffb->cchName + (enddir - filename))
    1981               ad->longestw = ffb->cchName + (enddir - filename);
    1982           }
    1983         }
    1984         fb += ffb->oNextEntryOffset;
    1985       }
    1986       nm = uL;
    1987     } while (!ad->stopflag &&
    1988              !DosFindNext(hdir, pffb, sizeof(FILEFINDBUF3) * nm, &nm));
     1985            if (ad->longest < pffbFile->cchName)
     1986              ad->longest = pffbFile->cchName;
     1987            if (ad->longestw < pffbFile->cchName + (enddir - filename))
     1988              ad->longestw = pffbFile->cchName + (enddir - filename);
     1989          }
     1990        }
     1991        pffbFile = (PFILEFINDBUF3)((PBYTE)pffbFile + pffbFile->oNextEntryOffset);
     1992      } // for
     1993      if (ad->stopflag)
     1994        break;
     1995      ulFindCnt = ulFindMax;
     1996      rc = DosFindNext(hdir, pffbArray, sizeof(FILEFINDBUF3) * ulFindCnt, &ulFindCnt);
     1997    } while (!rc);
    19891998    DosFindClose(hdir);
    19901999  }
    1991   free(pffb);
     2000
     2001  if (rc && rc != ERROR_NO_MORE_FILES) {
     2002    Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     2003              GetPString(IDS_CANTFINDDIRTEXT), filename);
     2004  }
     2005
     2006  free(pffbArray);
    19922007  free(filename);
    19932008}
     
    22162231                      RECTL * Rectl)
    22172232{
    2218 
    22192233  ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
    22202234  POINTL ptl;
     
    38023816
    38033817  case WM_COMMAND:
    3804     if (!pAD)
     3818    if (!pAD) {
     3819      Runtime_Error(pszSrcFile, __LINE__, "no data");
    38053820      return 0;
     3821    }
    38063822    switch (SHORT1FROMMP(mp1)) {
    38073823    case IDM_SETTARGET:
     
    42724288  return hwndFrame;
    42734289}
     4290
     4291#pragma alloc_text(SEEALL,comparefullnames,comparenames,comparesizes)
     4292#pragma alloc_text(SEEALL,comparedates,compareexts,SeeStatusProc)
     4293#pragma alloc_text(SEEALL,InitWindow,PaintLine,SeeAllWndProc)
     4294#pragma alloc_text(SEEALL,UpdateList,CollectList,ReSort,Mark)
     4295#pragma alloc_text(SEEALL,BuildAList,RemoveDeleted,SeeFrameWndProc,FilterList)
     4296#pragma alloc_text(SEEALL2,SeeObjWndProc,MakeSeeObjWinThread,FindDupes,DupeDlgProc)
     4297#pragma alloc_text(SEEALL3,FreeAllFilesList,DoADir,FindAllThread,AFDrvsWndProc)
     4298#pragma alloc_text(SEEALL3,StartSeeAll)
     4299
Note: See TracChangeset for help on using the changeset viewer.