Changeset 362


Ignore:
Timestamp:
Jul 26, 2006, 11:40:57 PM (19 years ago)
Author:
root
Message:

Use Runtime_Error

Location:
trunk/dll
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/comp.c

    r316 r362  
    1616  25 May 05 SHL Rework with ULONGLONG
    1717  06 Jun 05 SHL Drop unused
    18   12 Jul 06 SHL Renames and comments
     18  12 Jul 06 SHL Renames and comments
     19  13 Jul 06 SHL Use Runtime_Error
    1920
    2021***********************************************************************/
     
    4950} SNAPSTUFF;
    5051
     52static PSZ pszSrcFile = __FILE__;
     53
    5154//=== SnapShot() Write directory tree to file and recurse if requested ===
    5255
     
    5861  ULONG         nm = 1L;
    5962
    60   fb = malloc(sizeof(FILEFINDBUF4));
     63  fb = xmalloc(sizeof(FILEFINDBUF4),pszSrcFile,__LINE__);
    6164  if(fb) {
    62     mask = malloc(CCHMAXPATH);
     65    mask = xmalloc(CCHMAXPATH,pszSrcFile,__LINE__);
    6366    if(mask) {
    6467      sprintf(mask,
     
    127130        p++;
    128131      }
    129       fp = fopen(sf->filename,"w");
    130       if(fp) {
     132      fp = xfopen(sf->filename,"w",pszSrcFile,__LINE__);
     133      if (fp) {
    131134        fprintf(fp,"\"%s\"\n",sf->dirname);
    132135        SnapShot(sf->dirname,fp,sf->recurse);
     
    178181        AddToListboxBottom(fc.hwndList,s);
    179182        fp1 = _fsopen(fc.file1,"rb",SH_DENYNO);
    180         if(fp1) {
     183        if (!fp1) {
     184          sprintf(s,GetPString(IDS_COMPCANTOPENTEXT),fc.file1);
     185          AddToListboxBottom(fc.hwndList,s);
     186          WinSetWindowText(fc.hwndHelp,GetPString(IDS_ERRORTEXT));
     187        }
     188        else {
    181189          fp2 = _fsopen(fc.file2,"rb",SH_DENYNO);
    182           if(fp2) {
     190          if (!fp2) {
     191            sprintf(s,GetPString(IDS_COMPCANTOPENTEXT),fc.file2);
     192            AddToListboxBottom(fc.hwndList,s);
     193            WinSetWindowText(fc.hwndHelp,GetPString(IDS_ERRORTEXT));
     194          }
     195          else {
    183196            len1 = filelength(fileno(fp1));
    184197            len2 = filelength(fileno(fp2));
     
    246259            fclose(fp2);
    247260          }
    248           else {
    249             sprintf(s,GetPString(IDS_COMPCANTOPENTEXT),fc.file2);
    250             AddToListboxBottom(fc.hwndList,s);
    251             WinSetWindowText(fc.hwndHelp,GetPString(IDS_ERRORTEXT));
    252           }
    253261          fclose(fp1);
    254         }
    255         else {
    256           sprintf(s,GetPString(IDS_COMPCANTOPENTEXT),fc.file1);
    257           AddToListboxBottom(fc.hwndList,s);
    258           WinSetWindowText(fc.hwndHelp,GetPString(IDS_ERRORTEXT));
    259262        }
    260263        WinDestroyMsgQueue(hmq2);
     
    294297          break;
    295298        }
    296         if(_beginthread(CompareFilesThread,
    297                         NULL,
    298                         65536,
    299                         (PVOID)fc) == -1) {
    300           Win_Error(hwnd,hwnd,__FILE__,__LINE__,
    301                     GetPString(IDS_CANTCOMPARETEXT));
     299        if (_beginthread(CompareFilesThread,NULL,65536,(PVOID)fc) == -1) {
     300          Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT));
    302301          WinDismissDlg(hwnd,0);
    303302        }
     
    392391          break;
    393392        default:
    394           DosBeep(250,100);
     393          Runtime_Error(pszSrcFile, __LINE__, "bad case %u", cmp->action);
    395394          goto Abort;
    396395      }
     
    493492                           MPFROM2SHORT(1,CMA_ERASE | CMA_TEXTCHANGED));
    494493              }
    495               else if(rc) {
     494              else if (rc) {
    496495                rc = Dos_Error(MB_ENTERCANCEL,
    497496                               rc,
    498497                               HWND_DESKTOP,
    499                                __FILE__,
     498                               pszSrcFile,
    500499                               __LINE__,
    501500                               GetPString(IDS_COMPMOVEFAILEDTEXT),
     
    527526              }
    528527              rc = docopyf(COPY,pci->szFileName,"%s",newname);
    529               if(!rc) {
     528              if (rc) {
     529                rc = Dos_Error(MB_ENTERCANCEL,
     530                               rc,
     531                               HWND_DESKTOP,
     532                               pszSrcFile,
     533                               __LINE__,
     534                               GetPString(IDS_COMPCOPYFAILEDTEXT),
     535                               pci->szFileName,
     536                               newname);
     537                if(rc == MBID_CANCEL)
     538                  pcin = NULL;           /* cause loop to break */
     539              }
     540              else {
    530541                WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pci),
    531542                           MPFROM2SHORT(FALSE,CRA_SELECTED));
     
    562573                           MPFROM2SHORT(1,CMA_ERASE | CMA_TEXTCHANGED));
    563574              }
    564               else {
    565                 rc = Dos_Error(MB_ENTERCANCEL,
    566                                rc,
    567                                HWND_DESKTOP,
    568                                __FILE__,
    569                                __LINE__,
    570                                GetPString(IDS_COMPCOPYFAILEDTEXT),
    571                                pci->szFileName,
    572                                newname);
    573                 if(rc == MBID_CANCEL) /* cause loop to break */
    574                   pcin = NULL;
    575               }
    576575              break;
    577576
     
    654653  if(!recurse)
    655654    ulM = 128;
    656   maskstr = malloc(CCHMAXPATH);
     655  maskstr = xmalloc(CCHMAXPATH,pszSrcFile,__LINE__);
    657656  if(!maskstr)
    658657    return;
    659   ffb4 = malloc(sizeof(FILEFINDBUF4) * ulM);
     658  ffb4 = xmalloc(sizeof(FILEFINDBUF4) * ulM,pszSrcFile,__LINE__);
    660659  if(!ffb4) {
    661660    free(maskstr);
     
    750749
    751750  hab = WinInitialize(0);
    752   if(hab) {
     751  if(!hab)
     752    Win_Error(NULLHANDLE,NULLHANDLE,pszSrcFile,__LINE__,"WinInitialize");
     753  else {
    753754    hmq = WinCreateMsgQueue(hab,0);
    754     if(hmq) {
    755 
     755    if(!hmq)
     756      Win_Error(NULLHANDLE,NULLHANDLE,pszSrcFile,__LINE__,"WinCreateMsgQueue");
     757    else {
    756758      INT             x;
    757759      INT             l;
     
    821823        memset(&fb4,0,sizeof(fb4));
    822824        fp = fopen(cmp->rightlist,"r");
    823         if(fp) {
     825        if(!fp)
     826          Runtime_Error(pszSrcFile, __LINE__, "can not open %s (%d)", cmp->rightlist, errno);
     827        else {
    824828          while(!feof(fp)) {
    825829            /* first get name of directory */
     
    944948          fclose(fp);
    945949        }
    946         else
    947           DosBeep(50,100);
    948950      } // if snapshot file
    949951
     
    982984                               MPFROMLONG(EXTRA_RECORD_BYTES2),
    983985                               MPFROMLONG(recsNeeded));
    984         if(!pcilFirst) {
     986        if (!pcilFirst) {
     987          Runtime_Error(pszSrcFile, __LINE__, "CM_ALLOCRECORD %u failed", recsNeeded);
    985988          recsNeeded = 0;
    986           DosBeep(100,100);
    987989        }
    988990      }
    989       if(recsNeeded) {
     991      if (recsNeeded) {
    990992        pcirFirst = WinSendMsg(hwndRight,CM_ALLOCRECORD,
    991993                               MPFROMLONG(EXTRA_RECORD_BYTES2),
    992994                               MPFROMLONG(recsNeeded));
    993         if(!pcirFirst) {
     995        if (!pcirFirst) {
     996          Runtime_Error(pszSrcFile, __LINE__, "CM_ALLOCRECORD %u failed", recsNeeded);
    994997          recsNeeded = 0;
    995           DosBeep(100,100);
    996998          pcil = pcilFirst;
    997999          while(pcil) {
     
    10031005        }
    10041006      }
    1005       if(recsNeeded) {
     1007      if (recsNeeded) {
    10061008        pcil = pcilFirst;
    10071009        pcir = pcirFirst;
     
    10581060              pcil->crtime.minutes = filesl[l]->crtime.minutes;
    10591061              pcil->crtime.hours   = filesl[l]->crtime.hours;
    1060               if(*cmp->dcd.mask.szMask) {
     1062              if (*cmp->dcd.mask.szMask) {
    10611063                if(!Filter((PMINIRECORDCORE)pcil,(PVOID)&cmp->dcd.mask)) {
    10621064                  pcil->rc.flRecordAttr |= CRA_FILTERED;
     
    11941196              pcil->crtime.minutes = filesl[l]->crtime.minutes;
    11951197              pcil->crtime.hours   = filesl[l]->crtime.hours;
    1196               if(*cmp->dcd.mask.szMask) {
    1197                 if(!Filter((PMINIRECORDCORE)pcil,(PVOID)&cmp->dcd.mask)) {
     1198              if (*cmp->dcd.mask.szMask) {
     1199                if (!Filter((PMINIRECORDCORE)pcil,(PVOID)&cmp->dcd.mask)) {
    11981200                  pcil->rc.flRecordAttr |= CRA_FILTERED;
    11991201                  pcir->rc.flRecordAttr |= CRA_FILTERED;
     
    12121214              // pcir->rc.hptrIcon    = hptrFile;
    12131215              y = 0;
    1214               for(x = 0;x < 6;x++)
    1215                 if(attrstring[x])
     1216              for (x = 0;x < 6;x++) {
     1217                if (attrstring[x])
    12161218                  pcir->szDispAttr[y++] = (CHAR)((pcir->attrFile & (1 << x)) ?
    12171219                                                 attrstring[x] : '-');
     1220              }
    12181221              pcir->szDispAttr[5]  = 0;
    12191222              pcir->cbFile         = filesr[r]->cbFile;
     
    13001303            // pcir->rc.hptrIcon    = hptrFile;
    13011304            y = 0;
    1302             for(x = 0;x < 6;x++)
     1305            for (x = 0;x < 6;x++) {
    13031306              if(attrstring[x])
    13041307                pcir->szDispAttr[y++] = (CHAR)((pcir->attrFile & (1 << x)) ?
    13051308                                               attrstring[x] : '-');
     1309            }
    13061310            pcir->szDispAttr[5]  = 0;
    13071311            pcir->cbFile         = filesr[r]->cbFile;
     
    13251329            pcir->crtime.minutes = filesr[r]->crtime.minutes;
    13261330            pcir->crtime.hours   = filesr[r]->crtime.hours;
    1327             if(*cmp->dcd.mask.szMask) {
    1328               if(!Filter((PMINIRECORDCORE)pcir,(PVOID)&cmp->dcd.mask)) {
     1331            if (*cmp->dcd.mask.szMask) {
     1332              if (!Filter((PMINIRECORDCORE)pcir,(PVOID)&cmp->dcd.mask)) {
    13291333                pcir->rc.flRecordAttr |= CRA_FILTERED;
    13301334                pcil->rc.flRecordAttr |= CRA_FILTERED;
     
    13571361        ri.cRecordsInsert     = recsNeeded;
    13581362        ri.fInvalidateRecord  = FALSE;
    1359         if(!WinSendMsg(hwndLeft,CM_INSERTRECORD,
     1363        if (!WinSendMsg(hwndLeft,CM_INSERTRECORD,
    13601364                       MPFROMP(pcilFirst),MPFROMP(&ri))) {
    13611365          pcil = pcilFirst;
    1362           while(pcil) {
     1366          while (pcil) {
    13631367            pcit = (PCNRITEM)pcil->rc.preccNextRecord;
    13641368            WinSendMsg(hwndLeft,CM_FREERECORD,
     
    13751379        ri.cRecordsInsert     = recsNeeded;
    13761380        ri.fInvalidateRecord  = FALSE;
    1377         if(!WinSendMsg(hwndRight,CM_INSERTRECORD,
     1381        if (!WinSendMsg(hwndRight,CM_INSERTRECORD,
    13781382                       MPFROMP(pcirFirst),MPFROMP(&ri))) {
    13791383          WinSendMsg(hwndLeft,CM_REMOVERECORD,
    13801384                     MPVOID,MPFROM2SHORT(0,CMA_FREE | CMA_INVALIDATE));
    13811385          pcir = pcirFirst;
    1382           while(pcir) {
     1386          while (pcir) {
    13831387            pcit = (PCNRITEM)pcir->rc.preccNextRecord;
    13841388            WinSendMsg(hwndRight,CM_FREERECORD,
     
    13931397      Deselect(hwndLeft);
    13941398      Deselect(hwndRight);
    1395       if(!PostMsg(cmp->hwnd,UM_CONTAINER_FILLED,MPVOID,MPVOID))
    1396         WinSendMsg(cmp->hwnd,UM_CONTAINER_FILLED,MPVOID,MPVOID);
     1399      if (!PostMsg(cmp->hwnd,UM_CONTAINER_FILLED,MPVOID,MPVOID))
     1400        WinSendMsg (cmp->hwnd,UM_CONTAINER_FILLED,MPVOID,MPVOID);
    13971401      notified = TRUE;
    1398       if(filesl)
     1402      if (filesl)
    13991403        FreeList((CHAR **)filesl);      // Must have failed to create container
    1400       if(filesr)
     1404      if (filesr)
    14011405        FreeList((CHAR **)filesr);
    14021406      WinDestroyMsgQueue(hmq);
    14031407    }
    1404     else
    1405       DosBeep(250,100);
    14061408    WinTerminate(hab);
    14071409  }
    1408   else
    1409     DosBeep(50,100);
    1410   if(!notified)
     1410  if (!notified)
    14111411    PostMsg(cmp->hwnd,UM_CONTAINER_FILLED,MPVOID,MPVOID);
    14121412  free(cmp);
     
    14221422{
    14231423  COMPARE        *cmp;
     1424
    14241425  static HPOINTER hptr = (HPOINTER)0;
    14251426
     
    14271428    case WM_INITDLG:
    14281429      cmp = (COMPARE *)mp2;
    1429       if(cmp) {
    1430         if(!hptr)
     1430      if (!cmp) {
     1431        Runtime_Error(pszSrcFile, __LINE__, "no data");
     1432        WinDismissDlg(hwnd,0);
     1433      }
     1434      else {
     1435        if (!hptr)
    14311436          hptr = WinLoadPointer(HWND_DESKTOP,FM3ModHandle,COMPARE_ICON);
    14321437        WinDefDlgProc(hwnd,WM_SETICON,MPFROMLONG(hptr),MPVOID);
    14331438        cmp->hwnd = hwnd;
    1434         WinSetWindowPtr(hwnd,0,(PVOID)cmp);
     1439        WinSetWindowPtr(hwnd,QWL_USER,(PVOID)cmp);
    14351440        SetCnrCols(hwndLeft,TRUE);
    14361441        SetCnrCols(hwndRight,TRUE);
     
    14521457        }
    14531458      }
    1454       else
    1455         WinDismissDlg(hwnd,0);
    14561459      break;
    14571460
     
    16401643    case UM_CONTAINER_FILLED:
    16411644      cmp = INSTDATA(hwnd);
    1642       if(cmp) {
     1645      if (!cmp) {
     1646        Runtime_Error(pszSrcFile, __LINE__, "pCompare NULL");
     1647        WinDismissDlg(hwnd,0);
     1648      }
     1649      else {
    16431650        cmp->filling = FALSE;
    16441651        WinEnableWindow(hwndLeft,TRUE);
     
    16461653        WinEnableWindowUpdate(hwndLeft,TRUE);
    16471654        WinEnableWindowUpdate(hwndRight,TRUE);
    1648         // if(!mp1) {
    16491655        {
    16501656          CHAR s[81];
     
    16971703                            GetPString(IDS_COMPREADYTEXT));
    16981704      }
    1699       else {
    1700         DosBeep(50,100);
    1701         WinDismissDlg(hwnd,0);
    1702       }
    17031705      break;
    17041706
     
    18401842              break;
    18411843
     1844            // fixme to be gone - field edits not allowed
    18421845            case CN_BEGINEDIT:
    18431846              {
     
    18451848                PCNRITEM   pci = (PCNRITEM)((PCNREDITDATA)mp2)->pRecord;
    18461849
    1847                 if(pfi || pci) {
     1850                if (pfi || pci) {
    18481851                  PostMsg(hwnd,
    18491852                          CM_CLOSEEDIT,
    18501853                          MPVOID,
    18511854                          MPVOID);
    1852                   DosBeep(250,100);
     1855                  // DosBeep(250,100);          // fixme
     1856                  Runtime_Error(pszSrcFile, __LINE__, "CN_BEGINEDIT unexpected");
    18531857                }
    18541858              }
    18551859              break;
    18561860
     1861            // fixme to be gone - field edits not allowed
    18571862            case CN_REALLOCPSZ:
    18581863              cmp = INSTDATA(hwnd);
    1859               if(cmp) {
    1860 
     1864              if (!cmp)
     1865                Runtime_Error(pszSrcFile, __LINE__, "no data");
     1866              else {
    18611867                PFIELDINFO  pfi = ((PCNREDITDATA)mp2)->pFieldInfo;
    18621868                PCNRITEM    pci = (PCNRITEM)((PCNREDITDATA)mp2)->pRecord;
     
    18641870                CHAR        szData[CCHMAXPATH],testname[CCHMAXPATH],*p;
    18651871
    1866                 if(!pci && !pfi) {
     1872                Runtime_Error(pszSrcFile, __LINE__, "CN_REALLOCPSZ unexpected");
     1873                if (!pci && !pfi) {
    18671874                  hwndMLE = WinWindowFromID(WinWindowFromID(hwnd,
    18681875                                            SHORT1FROMMP(mp1)),CID_MLE);
     
    18711878                                     szData);
    18721879                  p = strchr(szData,'\n');
    1873                   if(p)
     1880                  if (p)
    18741881                    *p = 0;
    18751882                  p = strchr(szData,'\r');
    1876                   if(p)
     1883                  if (p)
    18771884                    *p = 0;
    18781885                  bstrip(szData);
    1879                   if(*szData) {
    1880                     if(!DosQueryPathInfo(szData,
     1886                  if (*szData) {
     1887                    if (!DosQueryPathInfo(szData,
    18811888                                         FIL_QUERYFULLNAME,
    18821889                                         testname,
    18831890                                         sizeof(testname))) {
    1884                       if(!SetDir(cmp->hwndParent,
     1891                      if (!SetDir(cmp->hwndParent,
    18851892                                 hwnd,
    18861893                                 testname,
    18871894                                 1)) {
    1888                         if(SHORT1FROMMP(mp1) == COMP_LEFTDIR)
     1895                        if (SHORT1FROMMP(mp1) == COMP_LEFTDIR)
    18891896                          strcpy(cmp->leftdir,testname);
    18901897                        else {
     
    20052012                          MPFROMLONG(CMA_CNRTITLE | CMA_FLWINDOWATTR));
    20062013        cmp->filling = TRUE;
    2007         forthread = malloc(sizeof(COMPARE));
    2008         if(forthread) {
     2014        forthread = xmalloc(sizeof(COMPARE),pszSrcFile,__LINE__);
     2015        if(!forthread)
     2016          WinDismissDlg(hwnd,0);
     2017        else {
    20092018          *forthread = *cmp;
    20102019          forthread->cmp = cmp;
    2011           if(_beginthread(FillCnrsThread,NULL,122880,(PVOID)forthread) != -1) {
     2020          if (_beginthread(FillCnrsThread,NULL,122880,(PVOID)forthread) == -1) {
     2021            Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT));
     2022            WinDismissDlg(hwnd,0);
     2023            free(forthread);
     2024          }
     2025          else {
    20122026            WinEnableWindowUpdate(hwndLeft,FALSE);
    20132027            WinEnableWindowUpdate(hwndRight,FALSE);
     
    20512065            WinEnableWindow(WinWindowFromID(hwnd,COMP_FILTER),FALSE);
    20522066          }
    2053           else {
    2054             DosBeep(250,100);
    2055             WinDismissDlg(hwnd,0);
    2056             free(forthread);
    2057           }
    2058         }
    2059         else {
    2060           DosBeep(250,100);
    2061           WinDismissDlg(hwnd,0);
    20622067        }
    20632068      }
     
    22802285            if(export_filename(HWND_DESKTOP,fullname,1) && *fullname &&
    22812286               !strchr(fullname,'*') && !strchr(fullname,'?')) {
    2282               sf = malloc(sizeof(SNAPSTUFF));
    2283               if(sf) {
    2284                 memset(sf,0,sizeof(SNAPSTUFF));
     2287              sf = xmallocz(sizeof(SNAPSTUFF),pszSrcFile,__LINE__);
     2288              if (sf) {
    22852289                strcpy(sf->filename,fullname);
    22862290                if(hwndLeft == cmp->hwndCalling)
     
    22892293                  strcpy(sf->dirname,cmp->rightdir);
    22902294                sf->recurse = cmp->includesubdirs;
    2291                 if(_beginthread(StartSnap,NULL,65536,(PVOID)sf) == -1) {
     2295                if (_beginthread(StartSnap,NULL,65536,(PVOID)sf) == -1) {
     2296                  Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT));
    22922297                  free(sf);
    2293                   DosBeep(50,100);
    22942298                }
    22952299              }
     
    23342338
    23352339            cmp->filling = TRUE;
    2336             forthread = malloc(sizeof(COMPARE));
    2337             if(forthread) {
     2340            forthread = xmalloc(sizeof(COMPARE),pszSrcFile,__LINE__);
     2341            if (forthread) {
    23382342              *forthread = *cmp;
    23392343              forthread->cmp = cmp;
    23402344              forthread->action = SHORT1FROMMP(mp1);
    2341               if(_beginthread(ActionCnrThread,NULL,122880,(PVOID)forthread) != -1) {
     2345              if (_beginthread(ActionCnrThread,NULL,122880,(PVOID)forthread) == -1) {
     2346                Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT));
     2347                free(forthread);
     2348              }
     2349              else {
    23422350                WinEnableWindowUpdate(hwndLeft,FALSE);
    23432351                WinEnableWindowUpdate(hwndRight,FALSE);
     
    23952403                WinEnableWindow(WinWindowFromID(hwnd,COMP_FILTER),FALSE);
    23962404              }
    2397               else {
    2398                 DosBeep(250,100);
    2399                 free(forthread);
    2400               }
    24012405            }
    2402             else
    2403               DosBeep(250,100);
    24042406          }
    24052407          break;
     
    24372439        case IDM_INVERT:
    24382440          cmp = INSTDATA(hwnd);
    2439           if(cmp) {
    2440 
     2441          if (!cmp)
     2442              Runtime_Error(pszSrcFile, __LINE__, "no data");
     2443          else {
    24412444            COMPARE *forthread;
    24422445
    24432446            cmp->filling = TRUE;
    2444             forthread = malloc(sizeof(COMPARE));
    2445             if(forthread) {
     2447            forthread = xmalloc(sizeof(COMPARE),pszSrcFile,__LINE__);
     2448            if (forthread) {
    24462449              *forthread = *cmp;
    24472450              forthread->cmp = cmp;
    24482451              forthread->action = SHORT1FROMMP(mp1);
    2449               if(_beginthread(SelectCnrsThread,NULL,65536,(PVOID)forthread) != -1) {
     2452              if (_beginthread(SelectCnrsThread,NULL,65536,(PVOID)forthread) == -1) {
     2453                Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT));
     2454                free(forthread);
     2455              }
     2456              else {
    24502457                WinEnableWindowUpdate(hwndLeft,FALSE);
    24512458                WinEnableWindowUpdate(hwndRight,FALSE);
     
    25022509                WinEnableWindow(WinWindowFromID(hwnd,COMP_FILTER),FALSE);
    25032510              }
    2504               else {
    2505                 DosBeep(250,100);
    2506                 free(forthread);
    2507               }
    25082511            }
    2509             else
    2510               DosBeep(250,100);
    25112512          }
    25122513          break;
  • trunk/dll/select.c

    r317 r362  
    33
    44  $Id$
     5
     6  Container item selection support routines
    57
    68  Copyright (c) 1993-98 M. Kimes
     
    1113  06 Jun 05 SHL Drop unused code
    1214  06 Jul 06 SHL Support compare content (IDM_SELECTSAMECONTENT)
     15  13 Jul 06 SHL Use Runtime_Error
    1316
    1417***********************************************************************/
     
    3235#pragma alloc_text(SELECT1,Deselect,HideAll,RemoveAll,ExpandAll,InvertAll)
    3336
     37static PSZ pszSrcFile = __FILE__;
     38
    3439VOID UnHilite (HWND hwndCnr,BOOL all,CHAR ***list)
    3540{
     
    3843  INT      attribute = CRA_CURSORED;
    3944
    40   if(all && list && *list) {
     45  if (all && list && *list) {
    4146    FreeList(*list);
    4247    *list = NULL;
    4348  }
    4449  pci = (PCNRITEM)CurrentRecord(hwndCnr);
    45   if(pci && (INT)pci != -1) {
    46     if(pci->rc.flRecordAttr & CRA_SELECTED) {
     50  if (pci && (INT)pci != -1) {
     51    if (pci->rc.flRecordAttr & CRA_SELECTED) {
    4752      attribute = CRA_SELECTED;
    4853      pci = WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS,MPFROMLONG(CMA_FIRST),
    4954                       MPFROMSHORT(attribute));
    5055    }
    51     while(pci && (INT)pci != -1) {
     56    while (pci && (INT)pci != -1) {
    5257      WinSendMsg(hwndCnr,CM_SETRECORDEMPHASIS,MPFROMP(pci),
    5358                 MPFROM2SHORT(FALSE,CRA_SELECTED));
    54       if(!all)
     59      if (!all)
    5560        break;
    56       if(list)
     61      if (list)
    5762        AddToList(pci->szFileName,list,&numfiles,&numalloc);
    5863      pci = (PCNRITEM)WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS,
     
    6469
    6570VOID SelectList (HWND hwndCnr,BOOL partial,BOOL deselect,BOOL clearfirst,
    66                  PCNRITEM pciParent,CHAR *filename,CHAR **list) {
     71                 PCNRITEM pciParent,CHAR *filename,CHAR **list)
     72{
    6773
    6874  PCNRITEM     pci;
     
    7177  ULONG        errs = 0L;
    7278
    73   if(clearfirst && !deselect)
     79  if (clearfirst && !deselect)
    7480    UnHilite(hwndCnr,TRUE,NULL);
    75   if(list && list[0]) {
    76     for(x = 0;list[x];x++) {
     81  if (list && list[0]) {
     82    for (x = 0;list[x];x++) {
    7783      pci = FindCnrRecord(hwndCnr,
    7884                          list[x],
     
    8187                          partial,
    8288                          TRUE);
    83       if(pci) {
     89      if (pci) {
    8490        WinSendMsg(hwndCnr,
    8591                   CM_SETRECORDEMPHASIS,
     
    9096      }
    9197    }
    92     if(!foundone)
    93       DosBeep(250,50);
    94   }
    95   else if(filename && *filename) {
     98    if (!foundone)
     99      Runtime_Error(pszSrcFile, __LINE__, "select failed");
     100  }
     101  else if (filename && *filename) {
    96102
    97103    FILE *fp;
     
    99105
    100106    fp = _fsopen(filename,"r",SH_DENYNO);
    101     if(fp) {
    102       while(!feof(fp)) {
    103         if(!fgets(input,1024,fp))
     107    if (fp) {
     108      while (!feof(fp)) {
     109        if (!fgets(input,1024,fp))
    104110          break;
    105111        input[1023] = 0;
    106112        bstripcr(input);
    107         if(*input == '\"') {
     113        if (*input == '\"') {
    108114          memmove(input,input + 1,strlen(input) + 1);
    109115          lstrip(input);
    110116          p = strchr(input,'\"');
    111           if(p)
     117          if (p)
    112118            *p = 0;
    113119          rstrip(input);
     
    115121        else {
    116122          p = strchr(input,' ');
    117           if(p)
     123          if (p)
    118124            *p = 0;
    119125        }
     
    125131                            partial,
    126132                            TRUE);
    127         if(pci)       /* found it? */
     133        if (pci)       /* found it? */
    128134          WinSendMsg(hwndCnr,
    129135                     CM_SETRECORDEMPHASIS,
     
    133139        else
    134140          errs++;
    135         if(errs > 50L) {  /* prevent runaway on bad file */
     141        if (errs > 50L) {  /* prevent runaway on bad file */
    136142
    137143          APIRET ret;
     
    142148                       GetPString(IDS_MAYNOTBELISTTEXT),
    143149                       filename);
    144           if(ret == MBID_NO)
     150          if (ret == MBID_NO)
    145151            break;
    146152          errs = 0L;
     
    153159
    154160VOID SelectAll (HWND hwndCnr,BOOL files,BOOL dirs,CHAR *mask,
    155                 CHAR *text,BOOL arc) {
     161                CHAR *text,BOOL is_arc)
     162{
    156163
    157164  PCNRITEM       pci;
     
    162169  ULONG          textlen = 0;
    163170
    164   if(text)
     171  if (text)
    165172    textlen = strlen(text);
    166173  memset(&Mask,0,sizeof(Mask));
    167   if(mask && *mask)
     174  if (mask && *mask)
    168175    SetMask(mask,&Mask);
    169176  pci = (PCNRITEM)WinSendMsg(hwndCnr,CM_QUERYRECORD,MPVOID,
    170177                             MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
    171   while( pci && (INT)pci != -1 ) {
     178  while ( pci && (INT)pci != -1 ) {
    172179    markit = FALSE;
    173     if(!(pci->rc.flRecordAttr & CRA_FILTERED)) {
    174       if(!arc) {
    175         if(files && !(pci->attrFile & FILE_DIRECTORY))
     180    if (!(pci->rc.flRecordAttr & CRA_FILTERED)) {
     181      if (!is_arc) {
     182        if (files && !(pci->attrFile & FILE_DIRECTORY))
    176183          markit = TRUE;
    177         if(dirs && (pci->attrFile & FILE_DIRECTORY))
     184        if (dirs && (pci->attrFile & FILE_DIRECTORY))
    178185          markit = TRUE;
    179186      }
    180187      else
    181188        markit = TRUE;
    182       if(mask && *mask && markit) {
     189      if (mask && *mask && markit) {
    183190        markit = FALSE;
    184191        file = strrchr(pci->szFileName,'\\');
    185         if(!file)
     192        if (!file)
    186193          file = strrchr(pci->szFileName,':');
    187         if(file)
     194        if (file)
    188195          file++;
    189196        else
    190197          file = pci->szFileName;
    191         for(x = 0;Mask.pszMasks[x];x++) {
    192           if(*Mask.pszMasks[x]) {
    193             if(*Mask.pszMasks[x] != '/') {
    194               if(wildcard((strchr(Mask.pszMasks[x],'\\') ||
     198        for (x = 0;Mask.pszMasks[x];x++) {
     199          if (*Mask.pszMasks[x]) {
     200            if (*Mask.pszMasks[x] != '/') {
     201              if (wildcard((strchr(Mask.pszMasks[x],'\\') ||
    195202                           strchr(Mask.pszMasks[x],':')) ?
    196203                           pci->szFileName : file,Mask.pszMasks[x],FALSE))
     
    198205            }
    199206            else {
    200               if(wildcard((strchr(Mask.pszMasks[x],'\\') ||
     207              if (wildcard((strchr(Mask.pszMasks[x],'\\') ||
    201208                           strchr(Mask.pszMasks[x],':'),FALSE) ?
    202209                           pci->szFileName : file,Mask.pszMasks[x] + 1,
     
    210217      }
    211218    }
    212     if(markit && text && *text && !(pci->attrFile & FILE_DIRECTORY)) {
     219    if (markit && text && *text && !(pci->attrFile & FILE_DIRECTORY)) {
    213220
    214221      CHAR *input;
    215222
    216223      markit = FALSE;
    217       input = malloc(65537);
    218       if(input) {
    219 
     224      input = xmalloc(65537,pszSrcFile,__LINE__);
     225      if (input) {
    220226        ULONG pos;
    221227        LONG  len;
    222228        FILE *inputFile;
    223229
    224         if((inputFile = _fsopen(pci->szFileName,"rb",SH_DENYNO)) != NULL) {
     230        if ((inputFile = _fsopen(pci->szFileName,"rb",SH_DENYNO)) != NULL) {
    225231          pos = ftell(inputFile);
    226           while(!feof(inputFile)) {
    227             if(pos)
     232          while (!feof(inputFile)) {
     233            if (pos)
    228234              fseek(inputFile,pos - 256,SEEK_SET);
    229235            len = fread(input,1,65536,inputFile);
    230             if(len >= 0) {
    231               if(findstring(text,textlen,input,len,FALSE)) {
     236            if (len >= 0) {
     237              if (findstring(text,textlen,input,len,FALSE)) {
    232238                markit = TRUE;
    233239                break;
     
    243249      }
    244250    }
    245     else if(markit && text && *text && (pci->attrFile & FILE_DIRECTORY))
     251    else if (markit && text && *text && (pci->attrFile & FILE_DIRECTORY))
    246252      markit = FALSE;
    247     if(markit)
     253    if (markit)
    248254      WinSendMsg(hwndCnr,CM_SETRECORDEMPHASIS,MPFROMP(pci),
    249255                 MPFROM2SHORT(TRUE,CRA_SELECTED));
     
    254260
    255261VOID DeselectAll (HWND hwndCnr,BOOL files,BOOL dirs,CHAR *mask,CHAR *text,
    256                   BOOL arc) {
    257 
     262                  BOOL is_arc)
     263{
    258264  PCNRITEM       pci;
    259265  BOOL           unmarkit;
     
    263269  ULONG          textlen = 0;
    264270
    265   if(text)
     271  if (text)
    266272    textlen = strlen(text);
    267273  memset(&Mask,0,sizeof(Mask));
    268   if(mask && *mask)
     274  if (mask && *mask)
    269275    SetMask(mask,&Mask);
    270276  pci = (PCNRITEM)WinSendMsg(hwndCnr,CM_QUERYRECORD,MPVOID,
    271277                             MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
    272   while( pci && (INT)pci != -1 ) {
     278  while ( pci && (INT)pci != -1 ) {
    273279    unmarkit = FALSE;
    274     if(!(pci->rc.flRecordAttr & CRA_FILTERED)) {
    275       if(!arc) {
    276         if(files && !(pci->attrFile & FILE_DIRECTORY))
     280    if (!(pci->rc.flRecordAttr & CRA_FILTERED)) {
     281      if (!is_arc) {
     282        if (files && !(pci->attrFile & FILE_DIRECTORY))
    277283          unmarkit = TRUE;
    278         if(dirs && (pci->attrFile & FILE_DIRECTORY))
     284        if (dirs && (pci->attrFile & FILE_DIRECTORY))
    279285          unmarkit = TRUE;
    280286      }
    281287      else
    282288        unmarkit = TRUE;
    283       if(mask && *mask && unmarkit) {
     289      if (mask && *mask && unmarkit) {
    284290        unmarkit = FALSE;
    285291        file = strrchr(pci->szFileName,'\\');
    286         if(!file)
     292        if (!file)
    287293          file = strrchr(pci->szFileName,':');
    288         if(file)
     294        if (file)
    289295          file++;
    290296        else
    291297          file = pci->szFileName;
    292         for(x = 0;Mask.pszMasks[x];x++) {
    293           if(*Mask.pszMasks[x]) {
    294             if(*Mask.pszMasks[x] != '/') {
    295               if(wildcard((strchr(Mask.pszMasks[x],'\\') ||
     298        for (x = 0;Mask.pszMasks[x];x++) {
     299          if (*Mask.pszMasks[x]) {
     300            if (*Mask.pszMasks[x] != '/') {
     301              if (wildcard((strchr(Mask.pszMasks[x],'\\') ||
    296302                           strchr(Mask.pszMasks[x],':')) ?
    297303                           pci->szFileName : file,Mask.pszMasks[x],FALSE))
     
    299305            }
    300306            else {
    301               if(wildcard((strchr(Mask.pszMasks[x],'\\') ||
     307              if (wildcard((strchr(Mask.pszMasks[x],'\\') ||
    302308                           strchr(Mask.pszMasks[x],':')) ?
    303309                           pci->szFileName : file,Mask.pszMasks[x] + 1,
     
    311317      }
    312318    }
    313     if(unmarkit && text && *text && !(pci->attrFile & FILE_DIRECTORY)) {
     319    if (unmarkit && text && *text && !(pci->attrFile & FILE_DIRECTORY)) {
    314320
    315321      CHAR *input;
    316322
    317323      unmarkit = FALSE;
    318       input = malloc(65537);
    319       if(input) {
    320 
     324      input = xmalloc(65537,pszSrcFile,__LINE__);
     325      if (input) {
    321326        ULONG pos;
    322327        LONG  len;
    323328        FILE *inputFile;
    324329
    325         if((inputFile = _fsopen(pci->szFileName,"rb",SH_DENYNO)) != NULL) {
     330        if ((inputFile = _fsopen(pci->szFileName,"rb",SH_DENYNO)) != NULL) {
    326331          pos = ftell(inputFile);
    327           while(!feof(inputFile)) {
    328             if(pos)
     332          while (!feof(inputFile)) {
     333            if (pos)
    329334              fseek(inputFile,pos - 256,SEEK_SET);
    330335            len = fread(input,1,65536,inputFile);
    331             if(len >= 0) {
    332               if(findstring(text,textlen,input,len,FALSE)) {
     336            if (len >= 0) {
     337              if (findstring(text,textlen,input,len,FALSE)) {
    333338                unmarkit = TRUE;
    334339                break;
     
    344349      }
    345350    }
    346     else if(unmarkit && text && *text && (pci->attrFile & FILE_DIRECTORY))
     351    else if (unmarkit && text && *text && (pci->attrFile & FILE_DIRECTORY))
    347352      unmarkit = FALSE;
    348     if(unmarkit)
     353    if (unmarkit)
    349354      WinSendMsg(hwndCnr,CM_SETRECORDEMPHASIS,pci,
    350355                 MPFROM2SHORT(FALSE,CRA_SELECTED | CRA_CURSORED |
     
    362367                              MPFROMLONG(CMA_FIRST),
    363368                              MPFROMSHORT(CRA_SELECTED));
    364   while(pcil && (INT)pcil != -1) {
     369  while (pcil && (INT)pcil != -1) {
    365370    WinSendMsg(hwndCnr,CM_SETRECORDEMPHASIS,MPFROMP(pcil),
    366371               MPFROM2SHORT(FALSE,CRA_SELECTED));
     
    384389             MPFROMLONG(sizeof(CNRINFO)));
    385390  pci = (PCNRITEM)CurrentRecord(hwndCnr);
    386   if(pci && (INT)pci != -1) {
    387     if(pci->rc.flRecordAttr & CRA_SELECTED) {
     391  if (pci && (INT)pci != -1) {
     392    if (pci->rc.flRecordAttr & CRA_SELECTED) {
    388393      attribute = CRA_SELECTED;
    389394      pci = WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS,MPFROMLONG(CMA_FIRST),
     
    391396    }
    392397  }
    393   while(pci && (INT)pci != -1) {
     398  while (pci && (INT)pci != -1) {
    394399    pciH = WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS,MPFROMP(pci),
    395400                      MPFROMSHORT(attribute));
     
    399404    pci->rc.flRecordAttr |= CRA_FILTERED;
    400405    didone = TRUE;
    401     if(fSyncUpdates) {
    402       if(cnri.flWindowAttr & CV_DETAIL)
     406    if (fSyncUpdates) {
     407      if (cnri.flWindowAttr & CV_DETAIL)
    403408        WinSendMsg(hwndCnr,CM_INVALIDATERECORD,MPVOID,
    404409                   MPFROM2SHORT(0,CMA_REPOSITION | CMA_ERASE));
     
    409414    pci = pciH;
    410415  }
    411   if(didone && !fSyncUpdates)
     416  if (didone && !fSyncUpdates)
    412417      WinSendMsg(hwndCnr,CM_INVALIDATERECORD,MPVOID,
    413418                 MPFROM2SHORT(0,CMA_ERASE | CMA_REPOSITION));
     
    419424  INT      attribute = CRA_CURSORED;
    420425
    421   if(quitit)
     426  if (quitit)
    422427    attribute = (target) ? CRA_TARGET : (source) ? CRA_SOURCE : CRA_INUSE;
    423428  pci = (PCNRITEM)WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS,
    424429                             MPFROMLONG(CMA_FIRST),
    425430                             MPFROMSHORT(attribute));
    426   if(pci && (INT)pci != -1) {
    427     if(attribute == CRA_CURSORED) {
    428       if(pci->rc.flRecordAttr & CRA_SELECTED) {
     431  if (pci && (INT)pci != -1) {
     432    if (attribute == CRA_CURSORED) {
     433      if (pci->rc.flRecordAttr & CRA_SELECTED) {
    429434        attribute = CRA_SELECTED;
    430435        pci = WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS,MPFROMLONG(CMA_FIRST),
     
    433438    }
    434439  }
    435   while( pci && (INT)pci != -1) {
     440  while ( pci && (INT)pci != -1) {
    436441    WinSendMsg(hwndCnr,CM_SETRECORDEMPHASIS,MPFROMP(pci),
    437442               MPFROM2SHORT(!quitit,
     
    449454
    450455  pci = (PCNRITEM)CurrentRecord(hwndCnr);
    451   if(pci && (INT)pci != -1) {
    452     if(pci->rc.flRecordAttr & CRA_SELECTED) {
     456  if (pci && (INT)pci != -1) {
     457    if (pci->rc.flRecordAttr & CRA_SELECTED) {
    453458      attribute = CRA_SELECTED;
    454459      pci = WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS,MPFROMLONG(CMA_FIRST),
     
    456461    }
    457462  }
    458   while(pci && (INT)pci != -1) {
     463  while (pci && (INT)pci != -1) {
    459464    if (!(pci->rc.flRecordAttr & CRA_FILTERED))
    460465    {
     
    466471      WinSendMsg(hwndCnr,CM_SETRECORDEMPHASIS,MPFROMP(pci),
    467472                 MPFROM2SHORT(0,CRA_SELECTED));
    468       if(fSyncUpdates)
     473      if (fSyncUpdates)
    469474        WinSendMsg(hwndCnr,CM_REMOVERECORD,MPFROMP(&pci),
    470475                   MPFROM2SHORT(1,CMA_FREE | CMA_INVALIDATE));
     
    472477        WinSendMsg(hwndCnr,CM_REMOVERECORD,MPFROMP(&pci),
    473478                   MPFROM2SHORT(1,CMA_FREE));
    474       if(attribute == CRA_CURSORED)
     479      if (attribute == CRA_CURSORED)
    475480        break;
    476481      pci = WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS,MPFROMLONG(CMA_FIRST),
     
    481486                       MPFROMSHORT(attribute));
    482487  }
    483   if(didone && !fSyncUpdates)
     488  if (didone && !fSyncUpdates)
    484489      WinSendMsg(hwndCnr,CM_INVALIDATERECORD,MPVOID,
    485490                 MPFROM2SHORT(0,CMA_REPOSITION));
     
    491496  register CHAR *p;
    492497
    493   if(str != mask->szMask)
     498  if (str != mask->szMask)
    494499    strcpy(mask->szMask,str);
    495500  strcpy(mask->szMaskCopy,mask->szMask);
    496501  memset(mask->pszMasks,0,sizeof(CHAR *) * 26);
    497502  p = mask->pszMasks[0] = mask->szMaskCopy;
    498   for(x = 1;x < 24;x++) {
    499     while(*p && *p != ';')
     503  for (x = 1;x < 24;x++) {
     504    while (*p && *p != ';')
    500505     p++;
    501     if(*p) {
     506    if (*p) {
    502507      *p = 0;
    503508      p++;
     
    516521  PCNRITEM pci;
    517522
    518   if(!pciParent)
     523  if (!pciParent)
    519524    pciParent = WinSendMsg(hwndCnr,CM_QUERYRECORD,MPFROMP(NULL),
    520525                           MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
    521   if(pciParent) {
    522     if(expand && !(pciParent->rc.flRecordAttr & CRA_EXPANDED))
     526  if (pciParent) {
     527    if (expand && !(pciParent->rc.flRecordAttr & CRA_EXPANDED))
    523528      WinSendMsg(hwndCnr,CM_EXPANDTREE,MPFROMP(pciParent),MPVOID);
    524     else if(!expand && (pciParent->rc.flRecordAttr & CRA_EXPANDED))
     529    else if (!expand && (pciParent->rc.flRecordAttr & CRA_EXPANDED))
    525530      WinSendMsg(hwndCnr,CM_COLLAPSETREE,MPFROMP(pciParent),MPVOID);
    526531    pci = (PCNRITEM)WinSendMsg(hwndCnr,CM_QUERYRECORD,MPFROMP(pciParent),
    527532                               MPFROM2SHORT(CMA_FIRSTCHILD,CMA_ITEMORDER));
    528     if(pci)
     533    if (pci)
    529534      DosSleep(1L);
    530     while(pci && (INT)pci != -1) {
     535    while (pci && (INT)pci != -1) {
    531536      ExpandAll(hwndCnr,expand,pci);
    532537      pci = (PCNRITEM)WinSendMsg(hwndCnr,CM_QUERYRECORD,MPFROMP(pci),
     
    543548  pci = (PCNRITEM)WinSendMsg(hwndCnr,CM_QUERYRECORD,MPVOID,
    544549                             MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
    545   while( pci && (INT)pci != -1 ) {
    546     if(!(pci->rc.flRecordAttr & CRA_FILTERED)) {
    547       if(!(pci->rc.flRecordAttr & CRA_SELECTED))
     550  while ( pci && (INT)pci != -1 ) {
     551    if (!(pci->rc.flRecordAttr & CRA_FILTERED)) {
     552      if (!(pci->rc.flRecordAttr & CRA_SELECTED))
    548553        WinSendMsg(hwndCnr,CM_SETRECORDEMPHASIS,MPFROMP(pci),
    549554                   MPFROM2SHORT(TRUE,CRA_SELECTED));
     
    567572  register INT   x,numD,numS;
    568573
    569   if(!hwndCnrS || !hwndCnrD)
     574  if (!hwndCnrS || !hwndCnrD)
    570575    return;
    571576
     
    580585             MPFROMLONG(sizeof(CNRINFO)));
    581586  numS = (INT)cnri.cRecords;
    582   if(!numD || numS != numD) {
    583     DosBeep(250,100);
     587  if (!numD || numS != numD) {
    584588    saymsg(MB_ENTER,
    585589           HWND_DESKTOP,
     
    590594    return;
    591595  }
    592   pciDa = malloc(sizeof(PCNRITEM) * numD);
    593   if(!pciDa) {
    594     DosBeep(250,100);
     596  pciDa = xmalloc(sizeof(PCNRITEM) * numD,pszSrcFile,__LINE__);
     597  if (!pciDa)
    595598    return;
    596   }
    597 
    598   pciSa = malloc(sizeof(PCNRITEM) * numS);
    599   if(!pciSa) {
    600     if(pciDa)
    601       free(pciDa);
    602     DosBeep(250,100);
     599
     600  pciSa = xmalloc(sizeof(PCNRITEM) * numS,pszSrcFile,__LINE__);
     601  if (!pciSa) {
     602    free(pciDa);
    603603    return;
    604604  }
     
    612612                              MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
    613613  x = 0;
    614   while( pciD && (INT)pciD != -1 && x < numD) {
    615     if(reset)
     614  while ( pciD && (INT)pciD != -1 && x < numD) {
     615    if (reset)
    616616      pciD->flags = 0;
    617617    pciDa[x] = pciD;
    618618    x++;
    619     if(!slow)
     619    if (!slow)
    620620      pciD = (PCNRITEM)pciD->rc.preccNextRecord;
    621621    else
    622622      pciD = (PCNRITEM)WinSendMsg(hwndCnrD,CM_QUERYRECORD,MPFROMP(pciD),
    623623                                 MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
    624     if(!(x % 500))
     624    if (!(x % 500))
    625625      DosSleep(1L);
    626     else if(!(x % 50))
     626    else if (!(x % 50))
    627627      DosSleep(0L);
    628628  }
    629   if(numD != x) {
    630     if(!slow) {
     629  if (numD != x) {
     630    if (!slow) {
    631631      slow = TRUE;
    632632      goto Restart;
     
    634634    free(pciDa);
    635635    free(pciSa);
    636     DosBeep(250,100);
    637636    saymsg(MB_ENTER,
    638637           HWND_DESKTOP,
     
    647646                              MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
    648647  x = 0;
    649   while( pciS && (INT)pciS != -1 && x < numS) {
    650     if(reset)
     648  while (pciS && (INT)pciS != -1 && x < numS) {
     649    if (reset)
    651650      pciS->flags = 0;
    652651    pciSa[x] = pciS;
    653652    x++;
    654     if(!slow)
     653    if (!slow)
    655654      pciS = (PCNRITEM)pciS->rc.preccNextRecord;
    656655    else
    657656      pciS = (PCNRITEM)WinSendMsg(hwndCnrS,CM_QUERYRECORD,MPFROMP(pciS),
    658657                                 MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
    659     if(!(x % 500))
     658    if (!(x % 500))
    660659      DosSleep(1L);
    661     else if(!(x % 50))
     660    else if (!(x % 50))
    662661      DosSleep(0L);
    663662  }
    664   if(numS != x) {
    665     if(!slow) {
     663  if (numS != x) {
     664    if (!slow) {
    666665      slow = TRUE;
    667666      goto Restart;
     
    669668    free(pciSa);
    670669    free(pciDa);
    671     DosBeep(250,100);
    672     saymsg(MB_ENTER,
    673            HWND_DESKTOP,
    674            DEBUG_STRING,
    675            "numS (%lu) != x (%lu)",
    676            numS,
    677            x);
     670    Runtime_Error(pszSrcFile, __LINE__,
     671           "numS (%lu) != x (%lu)", numS, x);
    678672    return;
    679673  }
    680674
    681   if(reset) {
    682     for(x = 0;x < numS;x++) {
    683       if(!*pciSa[x]->szFileName || !*pciDa[x]->szFileName)
     675  if (reset) {
     676    for (x = 0;x < numS;x++) {
     677      if (!*pciSa[x]->szFileName || !*pciDa[x]->szFileName)
    684678        continue;
    685679      pciSa[x]->flags |= CNRITEM_EXISTS;
    686680      pciDa[x]->flags |= CNRITEM_EXISTS;
    687       if(pciSa[x]->cbFile + pciSa[x]->easize >
     681      if (pciSa[x]->cbFile + pciSa[x]->easize >
    688682         pciDa[x]->cbFile + pciDa[x]->easize) {
    689683        pciSa[x]->flags |= CNRITEM_LARGER;
    690684        pciDa[x]->flags |= CNRITEM_SMALLER;
    691685      }
    692       else if(pciSa[x]->cbFile + pciSa[x]->easize <
     686      else if (pciSa[x]->cbFile + pciSa[x]->easize <
    693687              pciDa[x]->cbFile + pciDa[x]->easize) {
    694688        pciSa[x]->flags |= CNRITEM_SMALLER;
    695689        pciDa[x]->flags |= CNRITEM_LARGER;
    696690      }
    697       if((pciSa[x]->date.year > pciDa[x]->date.year) ? TRUE :
     691      if ((pciSa[x]->date.year > pciDa[x]->date.year) ? TRUE :
    698692         (pciSa[x]->date.year < pciDa[x]->date.year) ? FALSE :
    699693         (pciSa[x]->date.month > pciDa[x]->date.month) ? TRUE :
     
    710704        pciDa[x]->flags |= CNRITEM_OLDER;
    711705      }
    712       else if((pciSa[x]->date.year < pciDa[x]->date.year) ? TRUE :
     706      else if ((pciSa[x]->date.year < pciDa[x]->date.year) ? TRUE :
    713707              (pciSa[x]->date.year > pciDa[x]->date.year) ? FALSE :
    714708              (pciSa[x]->date.month < pciDa[x]->date.month) ? TRUE :
     
    726720        pciDa[x]->flags |= CNRITEM_NEWER;
    727721      }
    728       if(!(x % 500))
     722      if (!(x % 500))
    729723        DosSleep(1L);
    730       else if(!(x % 50))
     724      else if (!(x % 50))
    731725        DosSleep(0L);
    732726    }
     
    735729  switch(action) {
    736730    case IDM_SELECTIDENTICAL:
    737       for(x = 0;x < numS;x++) {
    738         if(!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED)) {
    739           if(*pciSa[x]->szFileName &&
     731      for (x = 0;x < numS;x++) {
     732        if (!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED)) {
     733          if (*pciSa[x]->szFileName &&
    740734             (pciSa[x]->flags & CNRITEM_EXISTS) &&
    741735             !(pciSa[x]->flags & CNRITEM_SMALLER) &&
     
    743737             !(pciSa[x]->flags & CNRITEM_NEWER) &&
    744738             !(pciSa[x]->flags & CNRITEM_OLDER)) {
    745             if(!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))
     739            if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))
    746740              WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]),
    747741                         MPFROM2SHORT(TRUE,CRA_SELECTED));
    748             if(!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))
     742            if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))
    749743              WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]),
    750744                         MPFROM2SHORT(TRUE,CRA_SELECTED));
    751745          }
    752           if(!(x % 500))
     746          if (!(x % 500))
    753747            DosSleep(1L);
    754           else if(!(x % 50))
     748          else if (!(x % 50))
    755749            DosSleep(0L);
    756750        }
     
    759753
    760754    case IDM_SELECTSAME:
    761       for(x = 0;x < numS;x++) {
    762         if(!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     755      for (x = 0;x < numS;x++) {
     756        if (!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    763757           *pciSa[x]->szFileName &&
    764758           (pciSa[x]->flags & CNRITEM_EXISTS) &&
    765759           !(pciSa[x]->flags & CNRITEM_SMALLER) &&
    766760           !(pciSa[x]->flags & CNRITEM_LARGER)) {
    767           if(!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))
     761          if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))
    768762            WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]),
    769763                       MPFROM2SHORT(TRUE,CRA_SELECTED));
    770           if(!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))
     764          if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))
    771765            WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]),
    772766                       MPFROM2SHORT(TRUE,CRA_SELECTED));
    773767        }
    774         if(!(x % 500))
     768        if (!(x % 500))
    775769          DosSleep(1L);
    776         else if(!(x % 50))
     770        else if (!(x % 50))
    777771          DosSleep(0L);
    778772      }
     
    791785          FILE *fp2 = NULL;
    792786          BOOL gotMatch = FALSE;
    793           BOOL gotError = FALSE;
     787          UINT errLineNo = 0;
     788          UINT compErrno = 0;
    794789          CHAR buf1[1024];
    795790          CHAR buf2[1024];
     
    797792
    798793          fp1 = _fsopen(pciSa[x]->szFileName,"rb",SH_DENYNO);
    799           if(!fp1) {
    800             gotError = TRUE;
     794          if (!fp1) {
     795            errLineNo = __LINE__;
     796            compErrno = errno;
    801797          }
    802798          else {
    803799            fp2 = _fsopen(pciDa[x]->szFileName,"rb",SH_DENYNO);
    804             if(!fp2) {
    805               gotError = TRUE;
     800            if (!fp2) {
     801              errLineNo = __LINE__;
     802              compErrno = errno;
    806803            }
    807804            else {
     
    815812                  size_t numread2 = fread(buf2,1,1024,fp2);
    816813                  if (!numread1 || !numread2 || numread1 != numread2) {
    817                     if (ferror(fp1) || ferror(fp2))
    818                       gotError = TRUE;
     814                    if (ferror(fp1) || ferror(fp2)) {
     815                      errLineNo = __LINE__;
     816                      compErrno = errno;
     817                    }
    819818                    else if (feof(fp1) && feof(fp2))
    820819                      gotMatch = TRUE;
     
    834833            fclose(fp2);
    835834
    836           if (gotError) {
    837             // fixme
    838             DosBeep(250,100);
    839             saymsg(MB_CANCEL,HWND_DESKTOP,
    840                    "Compare Content",
    841                    "Unexpected error comparing..."
    842                   );
     835          if (errLineNo) {
     836            Runtime_Error(pszSrcFile, errLineNo,
     837                         "error %d while comparing", compErrno);
    843838          }
    844839          if (gotMatch) {
     
    859854
    860855    case IDM_SELECTBOTH:
    861       for(x = 0;x < numS;x++) {
    862         if(!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     856      for (x = 0;x < numS;x++) {
     857        if (!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    863858           *pciSa[x]->szFileName &&
    864859           (pciSa[x]->flags & CNRITEM_EXISTS)) {
    865           if(!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))
     860          if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))
    866861            WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]),
    867862                       MPFROM2SHORT(TRUE,CRA_SELECTED));
    868           if(!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))
     863          if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))
    869864            WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]),
    870865                       MPFROM2SHORT(TRUE,CRA_SELECTED));
    871866        }
    872         if(!(x % 500))
     867        if (!(x % 500))
    873868          DosSleep(1L);
    874         else if(!(x % 50))
     869        else if (!(x % 50))
    875870          DosSleep(0L);
    876871      }
     
    878873
    879874    case IDM_SELECTONE:
    880       for(x = 0;x < numS;x++) {
    881         if(!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     875      for (x = 0;x < numS;x++) {
     876        if (!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    882877           *pciSa[x]->szFileName &&
    883878           !(pciSa[x]->flags & CNRITEM_EXISTS)) {
    884           if(!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))
     879          if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))
    885880            WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]),
    886881                       MPFROM2SHORT(TRUE,CRA_SELECTED));
    887882        }
    888         else if(*pciDa[x]->szFileName &&
     883        else if (*pciDa[x]->szFileName &&
    889884                !(pciDa[x]->flags & CNRITEM_EXISTS)) {
    890           if(!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))
     885          if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))
    891886            WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]),
    892887                       MPFROM2SHORT(TRUE,CRA_SELECTED));
    893888        }
    894         if(!(x % 500))
     889        if (!(x % 500))
    895890          DosSleep(1L);
    896         else if(!(x % 50))
     891        else if (!(x % 50))
    897892          DosSleep(0L);
    898893      }
     
    900895
    901896    case IDM_SELECTBIGGER:
    902       for(x = 0;x < numS;x++) {
    903         if(!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     897      for (x = 0;x < numS;x++) {
     898        if (!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    904899           *pciSa[x]->szFileName &&
    905900           (pciSa[x]->flags & CNRITEM_LARGER)) {
    906           if(!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))
     901          if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))
    907902            WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]),
    908903                       MPFROM2SHORT(TRUE,CRA_SELECTED));
    909904        }
    910         else if(!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     905        else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    911906                *pciDa[x]->szFileName &&
    912907                (pciDa[x]->flags & CNRITEM_LARGER)) {
    913           if(!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))
     908          if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))
    914909            WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]),
    915910                       MPFROM2SHORT(TRUE,CRA_SELECTED));
    916911        }
    917         if(!(x % 500))
     912        if (!(x % 500))
    918913          DosSleep(1L);
    919         else if(!(x % 50))
     914        else if (!(x % 50))
    920915          DosSleep(0L);
    921916      }
     
    923918
    924919    case IDM_SELECTSMALLER:
    925       for(x = 0;x < numS;x++) {
    926         if(!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     920      for (x = 0;x < numS;x++) {
     921        if (!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    927922           *pciSa[x]->szFileName &&
    928923           (pciSa[x]->flags & CNRITEM_SMALLER)) {
    929           if(!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))
     924          if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))
    930925            WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]),
    931926                       MPFROM2SHORT(TRUE,CRA_SELECTED));
    932927        }
    933         else if(!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     928        else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    934929                *pciDa[x]->szFileName &&
    935930                (pciDa[x]->flags & CNRITEM_SMALLER)) {
    936           if(!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))
     931          if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))
    937932            WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]),
    938933                       MPFROM2SHORT(TRUE,CRA_SELECTED));
    939934        }
    940         if(!(x % 500))
     935        if (!(x % 500))
    941936          DosSleep(1L);
    942         else if(!(x % 50))
     937        else if (!(x % 50))
    943938          DosSleep(0L);
    944939      }
     
    946941
    947942    case IDM_SELECTNEWER:
    948       for(x = 0;x < numS;x++) {
    949         if(!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     943      for (x = 0;x < numS;x++) {
     944        if (!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    950945           *pciSa[x]->szFileName &&
    951946           (pciSa[x]->flags & CNRITEM_NEWER)) {
    952           if(!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))
     947          if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))
    953948            WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]),
    954949                       MPFROM2SHORT(TRUE,CRA_SELECTED));
    955950        }
    956         else if(!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     951        else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    957952                *pciDa[x]->szFileName &&
    958953                (pciDa[x]->flags & CNRITEM_NEWER)) {
    959           if(!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))
     954          if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))
    960955            WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]),
    961956                       MPFROM2SHORT(TRUE,CRA_SELECTED));
    962957        }
    963         if(!(x % 500))
     958        if (!(x % 500))
    964959          DosSleep(1L);
    965         else if(!(x % 50))
     960        else if (!(x % 50))
    966961          DosSleep(0L);
    967962      }
     
    969964
    970965    case IDM_SELECTOLDER:
    971       for(x = 0;x < numS;x++) {
    972         if(!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     966      for (x = 0;x < numS;x++) {
     967        if (!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    973968           *pciSa[x]->szFileName &&
    974969           (pciSa[x]->flags & CNRITEM_OLDER)) {
    975           if(!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))
     970          if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))
    976971            WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]),
    977972                       MPFROM2SHORT(TRUE,CRA_SELECTED));
    978973        }
    979         else if(!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     974        else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    980975                *pciDa[x]->szFileName &&
    981976                (pciDa[x]->flags & CNRITEM_OLDER)) {
    982           if(!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))
     977          if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))
    983978            WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]),
    984979                       MPFROM2SHORT(TRUE,CRA_SELECTED));
    985980        }
    986         if(!(x % 500))
     981        if (!(x % 500))
    987982          DosSleep(1L);
    988         else if(!(x % 50))
     983        else if (!(x % 50))
    989984          DosSleep(0L);
    990985      }
     
    992987
    993988    case IDM_DESELECTBOTH:
    994       for(x = 0;x < numS;x++) {
    995         if(!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     989      for (x = 0;x < numS;x++) {
     990        if (!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    996991           *pciSa[x]->szFileName &&
    997992           (pciSa[x]->flags & CNRITEM_EXISTS)) {
    998           if(pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
     993          if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
    999994            WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]),
    1000995                       MPFROM2SHORT(FALSE,CRA_SELECTED));
    1001           if(pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
     996          if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
    1002997            WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]),
    1003998                       MPFROM2SHORT(FALSE,CRA_SELECTED));
    1004999        }
    1005         if(!(x % 500))
     1000        if (!(x % 500))
    10061001          DosSleep(1L);
    1007         else if(!(x % 50))
     1002        else if (!(x % 50))
    10081003          DosSleep(0L);
    10091004      }
     
    10111006
    10121007    case IDM_DESELECTONE:
    1013       for(x = 0;x < numS;x++) {
    1014         if(!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     1008      for (x = 0;x < numS;x++) {
     1009        if (!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    10151010           *pciSa[x]->szFileName &&
    10161011           !(pciSa[x]->flags & CNRITEM_EXISTS)) {
    1017           if(pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
     1012          if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
    10181013            WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]),
    10191014                       MPFROM2SHORT(FALSE,CRA_SELECTED));
    10201015        }
    1021         else if(*pciDa[x]->szFileName &&
     1016        else if (*pciDa[x]->szFileName &&
    10221017                !(pciDa[x]->flags & CNRITEM_EXISTS)) {
    1023           if(pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
     1018          if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
    10241019            WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]),
    10251020                       MPFROM2SHORT(FALSE,CRA_SELECTED));
    10261021        }
    1027         if(!(x % 500))
     1022        if (!(x % 500))
    10281023          DosSleep(1L);
    1029         else if(!(x % 50))
     1024        else if (!(x % 50))
    10301025          DosSleep(0L);
    10311026      }
     
    10331028
    10341029    case IDM_DESELECTBIGGER:
    1035       for(x = 0;x < numS;x++) {
    1036         if(!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     1030      for (x = 0;x < numS;x++) {
     1031        if (!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    10371032           *pciSa[x]->szFileName &&
    10381033           (pciSa[x]->flags & CNRITEM_LARGER)) {
    1039           if(pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
     1034          if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
    10401035            WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]),
    10411036                       MPFROM2SHORT(FALSE,CRA_SELECTED));
    10421037        }
    1043         else if(!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     1038        else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    10441039                *pciDa[x]->szFileName &&
    10451040                (pciDa[x]->flags & CNRITEM_LARGER)) {
    1046           if(pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
     1041          if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
    10471042            WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]),
    10481043                       MPFROM2SHORT(FALSE,CRA_SELECTED));
    10491044        }
    1050         if(!(x % 500))
     1045        if (!(x % 500))
    10511046          DosSleep(1L);
    1052         else if(!(x % 50))
     1047        else if (!(x % 50))
    10531048          DosSleep(0L);
    10541049      }
     
    10561051
    10571052    case IDM_DESELECTSMALLER:
    1058       for(x = 0;x < numS;x++) {
    1059         if(!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     1053      for (x = 0;x < numS;x++) {
     1054        if (!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    10601055           *pciSa[x]->szFileName &&
    10611056           (pciSa[x]->flags & CNRITEM_SMALLER)) {
    1062           if(pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
     1057          if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
    10631058            WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]),
    10641059                       MPFROM2SHORT(FALSE,CRA_SELECTED));
    10651060        }
    1066         else if(!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     1061        else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    10671062                *pciDa[x]->szFileName &&
    10681063                (pciDa[x]->flags & CNRITEM_SMALLER)) {
    1069           if(pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
     1064          if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
    10701065            WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]),
    10711066                       MPFROM2SHORT(FALSE,CRA_SELECTED));
    10721067        }
    1073         if(!(x % 500))
     1068        if (!(x % 500))
    10741069          DosSleep(1L);
    1075         else if(!(x % 50))
     1070        else if (!(x % 50))
    10761071          DosSleep(0L);
    10771072      }
     
    10791074
    10801075    case IDM_DESELECTNEWER:
    1081       for(x = 0;x < numS;x++) {
    1082         if(!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     1076      for (x = 0;x < numS;x++) {
     1077        if (!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    10831078           *pciSa[x]->szFileName &&
    10841079           (pciSa[x]->flags & CNRITEM_NEWER)) {
    1085           if(pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
     1080          if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
    10861081            WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]),
    10871082                       MPFROM2SHORT(FALSE,CRA_SELECTED));
    10881083        }
    1089         else if(!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     1084        else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    10901085                *pciDa[x]->szFileName &&
    10911086                (pciDa[x]->flags & CNRITEM_NEWER)) {
    1092           if(pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
     1087          if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
    10931088            WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]),
    10941089                       MPFROM2SHORT(FALSE,CRA_SELECTED));
    10951090        }
    1096         if(!(x % 500))
     1091        if (!(x % 500))
    10971092          DosSleep(1L);
    1098         else if(!(x % 50))
     1093        else if (!(x % 50))
    10991094          DosSleep(0L);
    11001095      }
     
    11021097
    11031098    case IDM_DESELECTOLDER:
    1104       for(x = 0;x < numS;x++) {
    1105         if(!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     1099      for (x = 0;x < numS;x++) {
     1100        if (!(pciSa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    11061101           *pciSa[x]->szFileName &&
    11071102           (pciSa[x]->flags & CNRITEM_OLDER)) {
    1108           if(pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
     1103          if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)
    11091104            WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]),
    11101105                       MPFROM2SHORT(FALSE,CRA_SELECTED));
    11111106        }
    1112         else if(!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&
     1107        else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&
    11131108                *pciDa[x]->szFileName &&
    11141109                (pciDa[x]->flags & CNRITEM_OLDER)) {
    1115           if(pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
     1110          if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)
    11161111            WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]),
    11171112                       MPFROM2SHORT(FALSE,CRA_SELECTED));
    11181113        }
    1119         if(!(x % 500))
     1114        if (!(x % 500))
    11201115          DosSleep(1L);
    1121         else if(!(x % 50))
     1116        else if (!(x % 50))
    11221117          DosSleep(0L);
    11231118      }
     
    11281123  }
    11291124
    1130   if(reset) {
    1131     while(numS) {
     1125  if (reset) {
     1126    while (numS) {
    11321127      WinSendMsg(hwndCnrS,CM_INVALIDATERECORD,
    11331128                 MPFROMP(pciSa),
     
    11381133                 MPFROM2SHORT((min(numD,65535)),0));
    11391134      numS -= min(numS,65535);
    1140       if(numS)
     1135      if (numS)
    11411136        DosSleep(0L);
    11421137    }
     
    11831178  register INT z;
    11841179
    1185   for(z = 0;z < numw;z++) {
    1186     if(Cnrs[z].ss)
     1180  for (z = 0;z < numw;z++) {
     1181    if (Cnrs[z].ss)
    11871182      free(Cnrs[z].ss);
    11881183  }
     
    12001195  struct SS  *bsres;
    12011196
    1202   if(!hwndParent)
     1197  if (!hwndParent)
    12031198    return;
    12041199
    12051200  /* count directory containers, build array of hwnds */
    12061201  henum = WinBeginEnumWindows(hwndParent);
    1207   while((hwnd = WinGetNextWindow(henum)) != NULLHANDLE) {
    1208     if(WinWindowFromID(WinWindowFromID(hwnd,FID_CLIENT),DIR_CNR)) {
    1209       Cnrs = realloc(Cnrs,(numwindows + 1) * sizeof(struct Cnr));
    1210       if(!Cnrs) {
     1202  while ((hwnd = WinGetNextWindow(henum)) != NULLHANDLE) {
     1203    if (WinWindowFromID(WinWindowFromID(hwnd,FID_CLIENT),DIR_CNR)) {
     1204      Cnrs = xrealloc(Cnrs,(numwindows + 1) * sizeof(struct Cnr),pszSrcFile,__LINE__);
     1205      if (!Cnrs) {
    12111206        Notify(GetPString(IDS_OUTOFMEMORY));
    12121207        return;
     
    12191214  }
    12201215  WinEndEnumWindows(henum);
    1221   if(numwindows < 2) {
     1216  if (numwindows < 2) {
    12221217    FreeCnrs(Cnrs,numwindows);
    1223     DosBeep(250,100);
     1218    Runtime_Error(pszSrcFile, __LINE__, "expected two windows");
     1219    // fixme DosBeep(250,100);
    12241220    Notify(GetPString(IDS_COMPSEL2ORMORETEXT));
    12251221    return;
    12261222  }
    1227   if(numwindows > 4) {
     1223  if (numwindows > 4) {
    12281224    WinSendMsg(Cnrs[0].
    12291225               hwndCnr,
     
    12351231
    12361232  /* count records, build array of pointers to records */
    1237   for(z = 0;z < numwindows;z++) {
     1233  for (z = 0;z < numwindows;z++) {
    12381234    pci = (PCNRITEM)WinSendMsg(Cnrs[z].hwndCnr,
    12391235                               CM_QUERYRECORD,
     
    12421238                                            CMA_ITEMORDER));
    12431239    x = 0;
    1244     while(pci && (INT)pci != -1) {
    1245       if(!(pci->rc.flRecordAttr & CRA_FILTERED) &&
     1240    while (pci && (INT)pci != -1) {
     1241      if (!(pci->rc.flRecordAttr & CRA_FILTERED) &&
    12461242         !(pci->attrFile & FILE_DIRECTORY)) {
    1247         Cnrs[z].ss = realloc(Cnrs[z].ss,(x + 1) * sizeof(struct SS));
    1248         if(!Cnrs[z].ss) {
     1243        Cnrs[z].ss = xrealloc(Cnrs[z].ss,(x + 1) * sizeof(struct SS),pszSrcFile,__LINE__);
     1244        if (!Cnrs[z].ss) {
    12491245          FreeCnrs(Cnrs,numwindows);
    12501246          Notify(GetPString(IDS_OUTOFMEMORY));
     
    12631259    DosSleep(0L);
    12641260    Cnrs[z].numfiles = x;
    1265     if(Cnrs[z].numfiles)
     1261    if (Cnrs[z].numfiles)
    12661262      qsort(Cnrs[z].ss,Cnrs[z].numfiles,sizeof(struct SS),CompSSNames);
    12671263  }
    12681264
    1269   for(z = 0;z < numwindows;z++) {
    1270     for(x = 0;x < Cnrs[z].numfiles;x++) {
     1265  for (z = 0;z < numwindows;z++) {
     1266    for (x = 0;x < Cnrs[z].numfiles;x++) {
    12711267      Cnrs[z].ss[x].all = Cnrs[z].ss[x].unique = Cnrs[z].ss[x].newest =
    12721268        Cnrs[z].ss[x].oldest = Cnrs[z].ss[x].smallest =
    12731269        Cnrs[z].ss[x].largest = TRUE;
    1274       for(w = 0;w < numwindows;w++) {
    1275         if(w != z && Cnrs[w].numfiles) {
     1270      for (w = 0;w < numwindows;w++) {
     1271        if (w != z && Cnrs[w].numfiles) {
    12761272          bsres = (struct SS *)bsearch(Cnrs[z].ss[x].pci->pszFileName,
    12771273                                        Cnrs[w].ss,Cnrs[w].numfiles,
    12781274                                        sizeof(struct SS),CompSSNamesB);
    1279           if(bsres) {
     1275          if (bsres) {
    12801276            Cnrs[z].ss[x].unique = FALSE;
    1281             if(Cnrs[z].ss[x].pci->cbFile + Cnrs[z].ss[x].pci->easize >
     1277            if (Cnrs[z].ss[x].pci->cbFile + Cnrs[z].ss[x].pci->easize >
    12821278               bsres->pci->cbFile + bsres->pci->easize)
    12831279              Cnrs[z].ss[x].smallest = FALSE;
    1284             if(Cnrs[z].ss[x].pci->cbFile + Cnrs[z].ss[x].pci->easize <
     1280            if (Cnrs[z].ss[x].pci->cbFile + Cnrs[z].ss[x].pci->easize <
    12851281               bsres->pci->cbFile + bsres->pci->easize)
    12861282              Cnrs[z].ss[x].largest = FALSE;
     
    12981294                  (Cnrs[z].ss[x].pci->time.seconds < bsres->pci->time.seconds) ? FALSE :
    12991295                   FALSE;
    1300             if(!cmp)
     1296            if (!cmp)
    13011297              Cnrs[z].ss[x].newest = FALSE;
    13021298            cmp = (Cnrs[z].ss[x].pci->date.year < bsres->pci->date.year) ? TRUE :
     
    13131309                  (Cnrs[z].ss[x].pci->time.seconds > bsres->pci->time.seconds) ? FALSE :
    13141310                   FALSE;
    1315             if(!cmp)
     1311            if (!cmp)
    13161312              Cnrs[z].ss[x].oldest = FALSE;
    13171313            cmp = 0;
     
    13221318        }
    13231319      }
    1324       if(Cnrs[z].ss[x].unique)
     1320      if (Cnrs[z].ss[x].unique)
    13251321        Cnrs[z].ss[x].oldest = Cnrs[z].ss[x].newest = Cnrs[z].ss[x].all =
    13261322          Cnrs[z].ss[x].largest = Cnrs[z].ss[x].smallest = FALSE;
     
    13321328  switch(action) {
    13331329    case IDM_SELECTBOTH:
    1334       for(z = 0;z < numwindows;z++) {
    1335         for(x = 0;x < Cnrs[z].numfiles;x++) {
    1336           if(Cnrs[z].ss[x].all)
     1330      for (z = 0;z < numwindows;z++) {
     1331        for (x = 0;x < Cnrs[z].numfiles;x++) {
     1332          if (Cnrs[z].ss[x].all)
    13371333            WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS,
    13381334                       MPFROMP(Cnrs[z].ss[x].pci),
     
    13431339      break;
    13441340    case IDM_SELECTMORE:
    1345       for(z = 0;z < numwindows;z++) {
    1346         for(x = 0;x < Cnrs[z].numfiles;x++) {
    1347           if(!Cnrs[z].ss[x].unique)
     1341      for (z = 0;z < numwindows;z++) {
     1342        for (x = 0;x < Cnrs[z].numfiles;x++) {
     1343          if (!Cnrs[z].ss[x].unique)
    13481344            WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS,
    13491345                       MPFROMP(Cnrs[z].ss[x].pci),
     
    13541350      break;
    13551351    case IDM_SELECTONE:
    1356       for(z = 0;z < numwindows;z++) {
    1357         for(x = 0;x < Cnrs[z].numfiles;x++) {
    1358           if(Cnrs[z].ss[x].unique)
     1352      for (z = 0;z < numwindows;z++) {
     1353        for (x = 0;x < Cnrs[z].numfiles;x++) {
     1354          if (Cnrs[z].ss[x].unique)
    13591355            WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS,
    13601356                       MPFROMP(Cnrs[z].ss[x].pci),
     
    13651361      break;
    13661362    case IDM_SELECTNEWER:
    1367       for(z = 0;z < numwindows;z++) {
    1368         for(x = 0;x < Cnrs[z].numfiles;x++) {
    1369           if(Cnrs[z].ss[x].newest)
     1363      for (z = 0;z < numwindows;z++) {
     1364        for (x = 0;x < Cnrs[z].numfiles;x++) {
     1365          if (Cnrs[z].ss[x].newest)
    13701366            WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS,
    13711367                       MPFROMP(Cnrs[z].ss[x].pci),
     
    13761372      break;
    13771373    case IDM_SELECTOLDER:
    1378       for(z = 0;z < numwindows;z++) {
    1379         for(x = 0;x < Cnrs[z].numfiles;x++) {
    1380           if(Cnrs[z].ss[x].oldest)
     1374      for (z = 0;z < numwindows;z++) {
     1375        for (x = 0;x < Cnrs[z].numfiles;x++) {
     1376          if (Cnrs[z].ss[x].oldest)
    13811377            WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS,
    13821378                       MPFROMP(Cnrs[z].ss[x].pci),
     
    13871383      break;
    13881384    case IDM_SELECTBIGGER:
    1389       for(z = 0;z < numwindows;z++) {
    1390         for(x = 0;x < Cnrs[z].numfiles;x++) {
    1391           if(Cnrs[z].ss[x].largest)
     1385      for (z = 0;z < numwindows;z++) {
     1386        for (x = 0;x < Cnrs[z].numfiles;x++) {
     1387          if (Cnrs[z].ss[x].largest)
    13921388            WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS,
    13931389                       MPFROMP(Cnrs[z].ss[x].pci),
     
    13981394      break;
    13991395    case IDM_SELECTSMALLER:
    1400       for(z = 0;z < numwindows;z++) {
    1401         for(x = 0;x < Cnrs[z].numfiles;x++) {
    1402           if(Cnrs[z].ss[x].smallest)
     1396      for (z = 0;z < numwindows;z++) {
     1397        for (x = 0;x < Cnrs[z].numfiles;x++) {
     1398          if (Cnrs[z].ss[x].smallest)
    14031399            WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS,
    14041400                       MPFROMP(Cnrs[z].ss[x].pci),
     
    14101406
    14111407    case IDM_DESELECTBOTH:
    1412       for(z = 0;z < numwindows;z++) {
    1413         for(x = 0;x < Cnrs[z].numfiles;x++) {
    1414           if(Cnrs[z].ss[x].all)
     1408      for (z = 0;z < numwindows;z++) {
     1409        for (x = 0;x < Cnrs[z].numfiles;x++) {
     1410          if (Cnrs[z].ss[x].all)
    14151411            WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS,
    14161412                       MPFROMP(Cnrs[z].ss[x].pci),
     
    14211417      break;
    14221418    case IDM_DESELECTMORE:
    1423       for(z = 0;z < numwindows;z++) {
    1424         for(x = 0;x < Cnrs[z].numfiles;x++) {
    1425           if(!Cnrs[z].ss[x].unique)
     1419      for (z = 0;z < numwindows;z++) {
     1420        for (x = 0;x < Cnrs[z].numfiles;x++) {
     1421          if (!Cnrs[z].ss[x].unique)
    14261422            WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS,
    14271423                       MPFROMP(Cnrs[z].ss[x].pci),
     
    14321428      break;
    14331429    case IDM_DESELECTONE:
    1434       for(z = 0;z < numwindows;z++) {
    1435         for(x = 0;x < Cnrs[z].numfiles;x++) {
    1436           if(Cnrs[z].ss[x].unique)
     1430      for (z = 0;z < numwindows;z++) {
     1431        for (x = 0;x < Cnrs[z].numfiles;x++) {
     1432          if (Cnrs[z].ss[x].unique)
    14371433            WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS,
    14381434                       MPFROMP(Cnrs[z].ss[x].pci),
     
    14431439      break;
    14441440    case IDM_DESELECTNEWER:
    1445       for(z = 0;z < numwindows;z++) {
    1446         for(x = 0;x < Cnrs[z].numfiles;x++) {
    1447           if(Cnrs[z].ss[x].newest)
     1441      for (z = 0;z < numwindows;z++) {
     1442        for (x = 0;x < Cnrs[z].numfiles;x++) {
     1443          if (Cnrs[z].ss[x].newest)
    14481444            WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS,
    14491445                       MPFROMP(Cnrs[z].ss[x].pci),
     
    14541450      break;
    14551451    case IDM_DESELECTOLDER:
    1456       for(z = 0;z < numwindows;z++) {
    1457         for(x = 0;x < Cnrs[z].numfiles;x++) {
    1458           if(Cnrs[z].ss[x].oldest)
     1452      for (z = 0;z < numwindows;z++) {
     1453        for (x = 0;x < Cnrs[z].numfiles;x++) {
     1454          if (Cnrs[z].ss[x].oldest)
    14591455            WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS,
    14601456                       MPFROMP(Cnrs[z].ss[x].pci),
     
    14651461      break;
    14661462    case IDM_DESELECTBIGGER:
    1467       for(z = 0;z < numwindows;z++) {
    1468         for(x = 0;x < Cnrs[z].numfiles;x++) {
    1469           if(Cnrs[z].ss[x].largest)
     1463      for (z = 0;z < numwindows;z++) {
     1464        for (x = 0;x < Cnrs[z].numfiles;x++) {
     1465          if (Cnrs[z].ss[x].largest)
    14701466            WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS,
    14711467                       MPFROMP(Cnrs[z].ss[x].pci),
     
    14761472      break;
    14771473    case IDM_DESELECTSMALLER:
    1478       for(z = 0;z < numwindows;z++) {
    1479         for(x = 0;x < Cnrs[z].numfiles;x++) {
    1480           if(Cnrs[z].ss[x].smallest)
     1474      for (z = 0;z < numwindows;z++) {
     1475        for (x = 0;x < Cnrs[z].numfiles;x++) {
     1476          if (Cnrs[z].ss[x].smallest)
    14811477            WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS,
    14821478                       MPFROMP(Cnrs[z].ss[x].pci),
Note: See TracChangeset for help on using the changeset viewer.