Changeset 316 for trunk/dll/comp.c


Ignore:
Timestamp:
Jul 13, 2006, 6:17:43 AM (19 years ago)
Author:
root
Message:

Renames and comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/comp.c

    r199 r316  
    77
    88  Copyright (c) 1993-02 M. Kimes
    9   Copyright (c) 2003, 2005 Steven H. Levine
     9  Copyright (c) 2003, 2006 Steven H. Levine
    1010
    1111  16 Oct 02 MK Baseline
     
    1616  25 May 05 SHL Rework with ULONGLONG
    1717  06 Jun 05 SHL Drop unused
     18  12 Jul 06 SHL Renames and comments
    1819
    1920***********************************************************************/
     
    3637#include "fm3str.h"
    3738
    38 #pragma alloc_text(COMPAREDIR,FillCnrs,FillDirList,CompNames)
     39#pragma alloc_text(COMPAREDIR,FillCnrsThread,FillDirList,CompNames)
    3940#pragma alloc_text(COMPAREDIR1,CompareDlgProc)
    40 #pragma alloc_text(COMPAREDIR2,SelectCnrs,ActionCnr)
    41 #pragma alloc_text(COMPAREFILE,CFileDlgProc,CompareFiles)
     41#pragma alloc_text(COMPAREDIR2,SelectCnrsThread,ActionCnrThread)
     42#pragma alloc_text(COMPAREFILE,CFileDlgProc,CompareFilesThread)
    4243#pragma alloc_text(SNAPSHOT,SnapShot,StartSnap)
    4344
     
    4849} SNAPSTUFF;
    4950
    50 
    51 void SnapShot (char *path,FILE *fp,BOOL recurse)
     51//=== SnapShot() Write directory tree to file and recurse if requested ===
     52
     53static VOID SnapShot (char *path,FILE *fp,BOOL recurse)
    5254{
    5355  FILEFINDBUF4 *fb;
     
    104106}
    105107
    106 
    107 VOID StartSnap (VOID *dummy) {
    108 
     108//=== StartSnap() Write directory tree to snapshot file ===
     109
     110static VOID StartSnap (VOID *dummy)
     111{
    109112  SNAPSTUFF  *sf = (SNAPSTUFF *)dummy;
    110113  FILE       *fp;
     
    135138}
    136139
    137 
    138 VOID CompareFiles (VOID *args) {
    139 
     140//=== CompareFilesThread() Compare files and update container select flags ===
     141
     142static VOID CompareFilesThread (VOID *args)
     143{
    140144  FCOMPARE fc;
    141145  HAB      hab2;
     
    261265}
    262266
    263 
    264 MRESULT EXPENTRY CFileDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
    265 
     267//=== CFileDlgProc() Select directories to compare dialog procedure ===
     268
     269MRESULT EXPENTRY CFileDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     270{
    266271  FCOMPARE *fc;
    267272
     
    289294          break;
    290295        }
    291         if(_beginthread(CompareFiles,
     296        if(_beginthread(CompareFilesThread,
    292297                        NULL,
    293298                        65536,
     
    332337}
    333338
    334 
    335 static VOID ActionCnr (VOID *args) {
    336 
     339//=== ActionCnrThread() Do requested action on container contents ===
     340
     341static VOID ActionCnrThread (VOID *args)
     342{
    337343  COMPARE *cmp = (COMPARE *)args;
    338344  HAB      hab;
     
    395401                        MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
    396402      while(pci && (INT)pci != -1 && pciO && (INT)pciO != -1) {
     403
    397404        pcin = WinSendMsg(hwndCnrS,CM_QUERYRECORD,MPFROMP(pci),
    398405                          MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
     
    571578            default:
    572579              break;
    573           }
     580          } // switch
    574581        }
    575582        pci = pcin;
    576583        pciO = pciOn;
    577       }
     584      } // while
    578585Abort:
    579586      WinDestroyMsgQueue(hmq);
     
    586593}
    587594
    588 
    589 static VOID SelectCnrs (VOID *args) {
    590 
     595//=== SelectCnrsThread() Update container selection flags thread ===
     596
     597static VOID SelectCnrsThread (VOID *args)
     598{
    591599  COMPARE *cmp = (COMPARE *)args;
    592600  HAB      hab;
     
    629637  free(cmp);
    630638}
    631 
    632639
    633640static VOID FillDirList (CHAR *str,INT skiplen,BOOL recurse,
     
    716723}
    717724
    718 
    719 static int CompNames (const void *n1,const void *n2) {
    720 
     725//=== CompNames() Compare names for qsort ===
     726
     727static int CompNames (const void *n1,const void *n2)
     728{
    721729  FILELIST *fl1 = *(FILELIST **)n1;
    722730  FILELIST *fl2 = *(FILELIST **)n2;
     
    725733}
    726734
    727 
    728 static VOID FillCnrs (VOID *args) {
    729 
     735//=== FillCnrsThread() Fill left and right containers ===
     736
     737static VOID FillCnrsThread (VOID *args)
     738{
    730739  COMPARE    *cmp = (COMPARE *)args;
    731740  HAB         hab;
     
    745754    if(hmq) {
    746755
    747       register INT    x,l,r,y;
    748       register ULONG  cntr;
    749       FILELIST      **filesl = NULL,**filesr = NULL;
    750       INT             numfilesl = 0,numfilesr = 0,numallocl = 0,numallocr = 0,
    751                       lenl,lenr,high;
    752       PCNRITEM        pcilFirst,pcirFirst,pcil,pcir,pcit;
     756      INT             x;
     757      INT             l;
     758      INT             r;
     759      INT             y;
     760      ULONG           cntr;
     761      FILELIST        **filesl = NULL;
     762      FILELIST        **filesr = NULL;
     763      INT             numfilesl = 0;
     764      INT             numfilesr = 0;
     765      INT             numallocl = 0;
     766      INT             numallocr = 0;
     767      INT             lenl;                     // Directory prefix length
     768      INT             lenr;
     769      UINT            recsNeeded;               // fixme to check ovf
     770      PCNRITEM        pcilFirst;
     771      PCNRITEM        pcirFirst;
     772      PCNRITEM        pcil;
     773      PCNRITEM        pcir;
     774      PCNRITEM        pcit;
    753775      RECORDINSERT    ri;
    754       register CHAR  *cl;
     776      CHAR            *pch;
    755777
    756778      WinCancelShutdown(hmq,TRUE);
     
    790812                    &filesr,&numfilesr,&numallocr);
    791813      }
    792       else {  /* load snapshot file */
    793 
     814      else
     815      {
     816        /* use snapshot file */
    794817        FILE        *fp;
    795818        FILEFINDBUF4 fb4;
     
    799822        fp = fopen(cmp->rightlist,"r");
    800823        if(fp) {
    801           while(!feof(fp)) {  /* first get name of directory */
     824          while(!feof(fp)) {
     825            /* first get name of directory */
    802826            if(!fgets(str,sizeof(str) - 1,fp))
    803               break;
     827              break;            // EOF
    804828            str[sizeof(str) - 1] = 0;
    805829            bstrip(str);
    806830            p = str;
    807831            if(*p == '\"') {
     832              /* Quoted */
    808833              p++;
    809834              if(*p && *p != '\"') {
     
    819844                    p = cmp->rightdir + (strlen(cmp->rightdir) - 1);
    820845                    if(p - cmp->rightdir > 3 && *p == '\\')
    821                       *p = 0;
     846                      *p = 0;           // Chop trailing slash
    822847                    break;
    823848                  }
     
    825850              }
    826851            }
    827           }
     852          } // while !EOF
    828853          {
    829854            CNRINFO cnri;
     
    915940                }
    916941              }
    917             }
    918           }
     942            } // while
     943          } // if have rightdir
    919944          fclose(fp);
    920945        }
    921946        else
    922947          DosBeep(50,100);
    923       }
     948      } // if snapshot file
     949
    924950      if(filesr)
    925951        qsort(filesr,numfilesr,sizeof(CHAR *),CompNames);
     
    928954      /* first, count total number of container entries required */
    929955      l = r = 0;
    930       cntr = 0;
     956      recsNeeded = 0;
    931957      while((filesl && filesl[l]) || (filesr && filesr[r])) {
    932958        if((filesl && filesl[l]) && (filesr && filesr[r])) {
    933959          x = stricmp(filesl[l]->fname,filesr[r]->fname);
    934960          if(!x) {
    935             l++;
     961            l++;                        // In both
    936962            r++;
    937963          }
    938964          else if(x < 0)
    939             l++;
     965            l++;                        // In left only
    940966          else
    941             r++;
     967            r++;                        // In right only
    942968        }
    943969        else if(filesl && filesl[l])
    944           l++;
     970          l++;                          // In left only
    945971        else    /* filesr && filesr[r] */
    946           r++;
    947         cntr++; /* keep count of how many entries req'd */
    948       }
    949       high = cntr;
     972          r++;                          // In right only
     973        recsNeeded++; /* keep count of how many entries req'd */
     974      }
    950975      WinSendMsg(cmp->hwnd,UM_CONTAINERHWND,MPVOID,MPVOID);
    951976      /* now insert records into the containers */
    952977      cntr = 0;
    953978      l = r = 0;
    954       if(high) {
     979      if(recsNeeded) {
    955980        pcilFirst = WinSendMsg(hwndLeft,
    956981                               CM_ALLOCRECORD,
    957982                               MPFROMLONG(EXTRA_RECORD_BYTES2),
    958                                MPFROMLONG(high));
     983                               MPFROMLONG(recsNeeded));
    959984        if(!pcilFirst) {
    960           high = 0;
     985          recsNeeded = 0;
    961986          DosBeep(100,100);
    962987        }
     988      }
     989      if(recsNeeded) {
    963990        pcirFirst = WinSendMsg(hwndRight,CM_ALLOCRECORD,
    964991                               MPFROMLONG(EXTRA_RECORD_BYTES2),
    965                                MPFROMLONG(high));
     992                               MPFROMLONG(recsNeeded));
    966993        if(!pcirFirst) {
    967           high = 0;
     994          recsNeeded = 0;
    968995          DosBeep(100,100);
    969996          pcil = pcilFirst;
     
    9761003        }
    9771004      }
    978       if(high) {
     1005      if(recsNeeded) {
    9791006        pcil = pcilFirst;
    9801007        pcir = pcirFirst;
     
    9971024            x = stricmp(filesl[l]->fname,filesr[r]->fname);
    9981025            if(!x) {
     1026              // Same
    9991027              sprintf(pcil->szFileName,"%s%s%s",cmp->leftdir,
    10001028                      (cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\') ?
     
    10031031              pcil->pszFileName    = pcil->szFileName + lenl;
    10041032              pcil->attrFile       = filesl[l]->attrFile;
     1033              y = 0;
     1034              for(x = 0;x < 6;x++) {
     1035                if(attrstring[x])
     1036                  pcil->szDispAttr[y++] = (CHAR)((pcil->attrFile & (1 << x)) ?
     1037                                                 attrstring[x] : '-');
     1038              }
     1039              pcil->szDispAttr[5]  = 0;
     1040              pcil->cbFile         = filesl[l]->cbFile;
     1041              pcil->easize         = filesl[l]->easize;
     1042              pcil->date.day       = filesl[l]->date.day;
     1043              pcil->date.month     = filesl[l]->date.month;
     1044              pcil->date.year      = filesl[l]->date.year + 1980;
     1045              pcil->time.seconds   = filesl[l]->time.twosecs * 2;
     1046              pcil->time.minutes   = filesl[l]->time.minutes;
     1047              pcil->time.hours     = filesl[l]->time.hours;
     1048              pcil->ladate.day     = filesl[l]->ladate.day;
     1049              pcil->ladate.month   = filesl[l]->ladate.month;
     1050              pcil->ladate.year    = filesl[l]->ladate.year + 1980;
     1051              pcil->latime.seconds = filesl[l]->latime.twosecs * 2;
     1052              pcil->latime.minutes = filesl[l]->latime.minutes;
     1053              pcil->latime.hours   = filesl[l]->latime.hours;
     1054              pcil->crdate.day     = filesl[l]->crdate.day;
     1055              pcil->crdate.month   = filesl[l]->crdate.month;
     1056              pcil->crdate.year    = filesl[l]->crdate.year + 1980;
     1057              pcil->crtime.seconds = filesl[l]->crtime.twosecs * 2;
     1058              pcil->crtime.minutes = filesl[l]->crtime.minutes;
     1059              pcil->crtime.hours   = filesl[l]->crtime.hours;
     1060              if(*cmp->dcd.mask.szMask) {
     1061                if(!Filter((PMINIRECORDCORE)pcil,(PVOID)&cmp->dcd.mask)) {
     1062                  pcil->rc.flRecordAttr |= CRA_FILTERED;
     1063                  pcir->rc.flRecordAttr |= CRA_FILTERED;
     1064                }
     1065              }
     1066              sprintf(pcir->szFileName,"%s%s%s",cmp->rightdir,
     1067                      (cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\') ?
     1068                      NullStr : "\\",filesr[r]->fname);
     1069              pcir->pszFileName    = pcir->szFileName + lenr;
     1070              pcir->attrFile       = filesr[r]->attrFile;
     1071              // pcir->rc.hptrIcon    = hptrFile;
     1072              y = 0;
     1073              for(x = 0;x < 6;x++)
     1074                if(attrstring[x])
     1075                  pcir->szDispAttr[y++] = (CHAR)((pcir->attrFile & (1 << x)) ?
     1076                                                 attrstring[x] : '-');
     1077              pcir->szDispAttr[5]  = 0;
     1078              pcir->cbFile         = filesr[r]->cbFile;
     1079              pcir->easize         = filesr[r]->easize;
     1080              pcir->date.day       = filesr[r]->date.day;
     1081              pcir->date.month     = filesr[r]->date.month;
     1082              pcir->date.year      = filesr[r]->date.year + 1980;
     1083              pcir->time.seconds   = filesr[r]->time.twosecs * 2;
     1084              pcir->time.minutes   = filesr[r]->time.minutes;
     1085              pcir->time.hours     = filesr[r]->time.hours;
     1086              pcir->ladate.day     = filesr[r]->ladate.day;
     1087              pcir->ladate.month   = filesr[r]->ladate.month;
     1088              pcir->ladate.year    = filesr[r]->ladate.year + 1980;
     1089              pcir->latime.seconds = filesr[r]->latime.twosecs * 2;
     1090              pcir->latime.minutes = filesr[r]->latime.minutes;
     1091              pcir->latime.hours   = filesr[r]->latime.hours;
     1092              pcir->crdate.day     = filesr[r]->crdate.day;
     1093              pcir->crdate.month   = filesr[r]->crdate.month;
     1094              pcir->crdate.year    = filesr[r]->crdate.year + 1980;
     1095              pcir->crtime.seconds = filesr[r]->crtime.twosecs * 2;
     1096              pcir->crtime.minutes = filesr[r]->crtime.minutes;
     1097              pcir->crtime.hours   = filesr[r]->crtime.hours;
     1098              pcil->flags |= CNRITEM_EXISTS;
     1099              pcir->flags |= CNRITEM_EXISTS;
     1100              pch = pcil->szSubject;
     1101              if(pcil->cbFile + pcil->easize >
     1102                 pcir->cbFile + pcir->easize) {
     1103                pcil->flags |= CNRITEM_LARGER;
     1104                pcir->flags |= CNRITEM_SMALLER;
     1105                strcpy(pch,GetPString(IDS_LARGERTEXT));
     1106                pch += 6;
     1107              }
     1108              else if(pcil->cbFile + pcil->easize <
     1109                      pcir->cbFile + pcir->easize) {
     1110                pcil->flags |= CNRITEM_SMALLER;
     1111                pcir->flags |= CNRITEM_LARGER;
     1112                strcpy(pch,GetPString(IDS_SMALLERTEXT));
     1113                pch += 7;
     1114              }
     1115              if((pcil->date.year > pcir->date.year) ? TRUE :
     1116                 (pcil->date.year < pcir->date.year) ? FALSE :
     1117                 (pcil->date.month > pcir->date.month) ? TRUE :
     1118                 (pcil->date.month < pcir->date.month) ? FALSE :
     1119                 (pcil->date.day > pcir->date.day) ? TRUE :
     1120                 (pcil->date.day < pcir->date.day) ? FALSE :
     1121                 (pcil->time.hours > pcir->time.hours) ? TRUE :
     1122                 (pcil->time.hours < pcir->time.hours) ? FALSE :
     1123                 (pcil->time.minutes > pcir->time.minutes) ? TRUE :
     1124                 (pcil->time.minutes < pcir->time.minutes) ? FALSE :
     1125                 (pcil->time.seconds > pcir->time.seconds) ? TRUE :
     1126                 (pcil->time.seconds < pcir->time.seconds) ? FALSE : FALSE) {
     1127                pcil->flags |= CNRITEM_NEWER;
     1128                pcir->flags |= CNRITEM_OLDER;
     1129                if(pch != pcil->szSubject) {
     1130                  strcpy(pch,", ");
     1131                  pch += 2;
     1132                }
     1133                strcpy(pch,GetPString(IDS_NEWERTEXT));
     1134                pch += 5;
     1135              }
     1136              else if((pcil->date.year < pcir->date.year) ? TRUE :
     1137                      (pcil->date.year > pcir->date.year) ? FALSE :
     1138                      (pcil->date.month < pcir->date.month) ? TRUE :
     1139                      (pcil->date.month > pcir->date.month) ? FALSE :
     1140                      (pcil->date.day < pcir->date.day) ? TRUE :
     1141                      (pcil->date.day > pcir->date.day) ? FALSE :
     1142                      (pcil->time.hours < pcir->time.hours) ? TRUE :
     1143                      (pcil->time.hours > pcir->time.hours) ? FALSE :
     1144                      (pcil->time.minutes < pcir->time.minutes) ? TRUE :
     1145                      (pcil->time.minutes > pcir->time.minutes) ? FALSE :
     1146                      (pcil->time.seconds < pcir->time.seconds) ? TRUE :
     1147                      (pcil->time.seconds > pcir->time.seconds) ? FALSE :
     1148                      FALSE) {
     1149                pcil->flags |= CNRITEM_OLDER;
     1150                pcir->flags |= CNRITEM_NEWER;
     1151                if(pch != pcil->szSubject) {
     1152                  strcpy(pch,", ");
     1153                  pch += 2;
     1154                }
     1155                strcpy(pch,GetPString(IDS_OLDERTEXT));
     1156                pch += 5;
     1157              }
     1158              *pch = 0;
     1159              r++;
     1160              l++;
     1161            }
     1162            else if(x < 0) {
     1163              // Just on left
     1164              sprintf(pcil->szFileName,"%s%s%s",cmp->leftdir,
     1165                      (cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\') ?
     1166                      NullStr : "\\",filesl[l]->fname);
     1167              pcil->pszFileName = pcil->szFileName + lenl;
     1168              pcil->attrFile       = filesl[l]->attrFile;
     1169              // pcil->rc.hptrIcon    = hptrFile;
    10051170              y = 0;
    10061171              for(x = 0;x < 6;x++)
     
    10351200                }
    10361201              }
     1202              free(filesl[l]);
     1203              l++;
     1204            }
     1205            else {
     1206              // Just on right
    10371207              sprintf(pcir->szFileName,"%s%s%s",cmp->rightdir,
    10381208                      (cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\') ?
     
    10401210              pcir->pszFileName    = pcir->szFileName + lenr;
    10411211              pcir->attrFile       = filesr[r]->attrFile;
    1042 //              pcir->rc.hptrIcon    = hptrFile;
    1043               y = 0;
    1044               for(x = 0;x < 6;x++)
    1045                 if(attrstring[x])
    1046                   pcir->szDispAttr[y++] = (CHAR)((pcir->attrFile & (1 << x)) ?
    1047                                                  attrstring[x] : '-');
    1048               pcir->szDispAttr[5]  = 0;
    1049               pcir->cbFile         = filesr[r]->cbFile;
    1050               pcir->easize         = filesr[r]->easize;
    1051               pcir->date.day       = filesr[r]->date.day;
    1052               pcir->date.month     = filesr[r]->date.month;
    1053               pcir->date.year      = filesr[r]->date.year + 1980;
    1054               pcir->time.seconds   = filesr[r]->time.twosecs * 2;
    1055               pcir->time.minutes   = filesr[r]->time.minutes;
    1056               pcir->time.hours     = filesr[r]->time.hours;
    1057               pcir->ladate.day     = filesr[r]->ladate.day;
    1058               pcir->ladate.month   = filesr[r]->ladate.month;
    1059               pcir->ladate.year    = filesr[r]->ladate.year + 1980;
    1060               pcir->latime.seconds = filesr[r]->latime.twosecs * 2;
    1061               pcir->latime.minutes = filesr[r]->latime.minutes;
    1062               pcir->latime.hours   = filesr[r]->latime.hours;
    1063               pcir->crdate.day     = filesr[r]->crdate.day;
    1064               pcir->crdate.month   = filesr[r]->crdate.month;
    1065               pcir->crdate.year    = filesr[r]->crdate.year + 1980;
    1066               pcir->crtime.seconds = filesr[r]->crtime.twosecs * 2;
    1067               pcir->crtime.minutes = filesr[r]->crtime.minutes;
    1068               pcir->crtime.hours   = filesr[r]->crtime.hours;
    1069               pcil->flags |= CNRITEM_EXISTS;
    1070               pcir->flags |= CNRITEM_EXISTS;
    1071               cl = pcil->szSubject;
    1072               if(pcil->cbFile + pcil->easize >
    1073                  pcir->cbFile + pcir->easize) {
    1074                 pcil->flags |= CNRITEM_LARGER;
    1075                 pcir->flags |= CNRITEM_SMALLER;
    1076                 strcpy(cl,GetPString(IDS_LARGERTEXT));
    1077                 cl += 6;
    1078               }
    1079               else if(pcil->cbFile + pcil->easize <
    1080                       pcir->cbFile + pcir->easize) {
    1081                 pcil->flags |= CNRITEM_SMALLER;
    1082                 pcir->flags |= CNRITEM_LARGER;
    1083                 strcpy(cl,GetPString(IDS_SMALLERTEXT));
    1084                 cl += 7;
    1085               }
    1086               if((pcil->date.year > pcir->date.year) ? TRUE :
    1087                  (pcil->date.year < pcir->date.year) ? FALSE :
    1088                  (pcil->date.month > pcir->date.month) ? TRUE :
    1089                  (pcil->date.month < pcir->date.month) ? FALSE :
    1090                  (pcil->date.day > pcir->date.day) ? TRUE :
    1091                  (pcil->date.day < pcir->date.day) ? FALSE :
    1092                  (pcil->time.hours > pcir->time.hours) ? TRUE :
    1093                  (pcil->time.hours < pcir->time.hours) ? FALSE :
    1094                  (pcil->time.minutes > pcir->time.minutes) ? TRUE :
    1095                  (pcil->time.minutes < pcir->time.minutes) ? FALSE :
    1096                  (pcil->time.seconds > pcir->time.seconds) ? TRUE :
    1097                  (pcil->time.seconds < pcir->time.seconds) ? FALSE : FALSE) {
    1098                 pcil->flags |= CNRITEM_NEWER;
    1099                 pcir->flags |= CNRITEM_OLDER;
    1100                 if(cl != pcil->szSubject) {
    1101                   strcpy(cl,", ");
    1102                   cl += 2;
    1103                 }
    1104                 strcpy(cl,GetPString(IDS_NEWERTEXT));
    1105                 cl += 5;
    1106               }
    1107               else if((pcil->date.year < pcir->date.year) ? TRUE :
    1108                       (pcil->date.year > pcir->date.year) ? FALSE :
    1109                       (pcil->date.month < pcir->date.month) ? TRUE :
    1110                       (pcil->date.month > pcir->date.month) ? FALSE :
    1111                       (pcil->date.day < pcir->date.day) ? TRUE :
    1112                       (pcil->date.day > pcir->date.day) ? FALSE :
    1113                       (pcil->time.hours < pcir->time.hours) ? TRUE :
    1114                       (pcil->time.hours > pcir->time.hours) ? FALSE :
    1115                       (pcil->time.minutes < pcir->time.minutes) ? TRUE :
    1116                       (pcil->time.minutes > pcir->time.minutes) ? FALSE :
    1117                       (pcil->time.seconds < pcir->time.seconds) ? TRUE :
    1118                       (pcil->time.seconds > pcir->time.seconds) ? FALSE :
    1119                       FALSE) {
    1120                 pcil->flags |= CNRITEM_OLDER;
    1121                 pcir->flags |= CNRITEM_NEWER;
    1122                 if(cl != pcil->szSubject) {
    1123                   strcpy(cl,", ");
    1124                   cl += 2;
    1125                 }
    1126                 strcpy(cl,GetPString(IDS_OLDERTEXT));
    1127                 cl += 5;
    1128               }
    1129               *cl = 0;
    1130               r++;
    1131               l++;
    1132             }
    1133             else if(x < 0) {
    1134               sprintf(pcil->szFileName,"%s%s%s",cmp->leftdir,
    1135                       (cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\') ?
    1136                       NullStr : "\\",filesl[l]->fname);
    1137               pcil->pszFileName = pcil->szFileName + lenl;
    1138               pcil->attrFile       = filesl[l]->attrFile;
    1139 //              pcil->rc.hptrIcon    = hptrFile;
    1140               y = 0;
    1141               for(x = 0;x < 6;x++)
    1142                 if(attrstring[x])
    1143                   pcil->szDispAttr[y++] = (CHAR)((pcil->attrFile & (1 << x)) ?
    1144                                                  attrstring[x] : '-');
    1145               pcil->szDispAttr[5]  = 0;
    1146               pcil->cbFile         = filesl[l]->cbFile;
    1147               pcil->easize         = filesl[l]->easize;
    1148               pcil->date.day       = filesl[l]->date.day;
    1149               pcil->date.month     = filesl[l]->date.month;
    1150               pcil->date.year      = filesl[l]->date.year + 1980;
    1151               pcil->time.seconds   = filesl[l]->time.twosecs * 2;
    1152               pcil->time.minutes   = filesl[l]->time.minutes;
    1153               pcil->time.hours     = filesl[l]->time.hours;
    1154               pcil->ladate.day     = filesl[l]->ladate.day;
    1155               pcil->ladate.month   = filesl[l]->ladate.month;
    1156               pcil->ladate.year    = filesl[l]->ladate.year + 1980;
    1157               pcil->latime.seconds = filesl[l]->latime.twosecs * 2;
    1158               pcil->latime.minutes = filesl[l]->latime.minutes;
    1159               pcil->latime.hours   = filesl[l]->latime.hours;
    1160               pcil->crdate.day     = filesl[l]->crdate.day;
    1161               pcil->crdate.month   = filesl[l]->crdate.month;
    1162               pcil->crdate.year    = filesl[l]->crdate.year + 1980;
    1163               pcil->crtime.seconds = filesl[l]->crtime.twosecs * 2;
    1164               pcil->crtime.minutes = filesl[l]->crtime.minutes;
    1165               pcil->crtime.hours   = filesl[l]->crtime.hours;
    1166               if(*cmp->dcd.mask.szMask) {
    1167                 if(!Filter((PMINIRECORDCORE)pcil,(PVOID)&cmp->dcd.mask)) {
    1168                   pcil->rc.flRecordAttr |= CRA_FILTERED;
    1169                   pcir->rc.flRecordAttr |= CRA_FILTERED;
    1170                 }
    1171               }
    1172               free(filesl[l]);
    1173               l++;
    1174             }
    1175             else {
    1176               sprintf(pcir->szFileName,"%s%s%s",cmp->rightdir,
    1177                       (cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\') ?
    1178                       NullStr : "\\",filesr[r]->fname);
    1179               pcir->pszFileName    = pcir->szFileName + lenr;
    1180               pcir->attrFile       = filesr[r]->attrFile;
    1181 //              pcir->rc.hptrIcon    = hptrFile;
     1212              // pcir->rc.hptrIcon    = hptrFile;
    11821213              y = 0;
    11831214              for(x = 0;x < 6;x++)
     
    12171248          }
    12181249          else if(filesl && filesl[l]) {
     1250            // Just on left
    12191251            sprintf(pcil->szFileName,"%s%s%s",cmp->leftdir,
    12201252                    (cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\') ?
     
    12221254            pcil->pszFileName = pcil->szFileName + lenl;
    12231255            pcil->attrFile       = filesl[l]->attrFile;
    1224 //            pcil->rc.hptrIcon    = hptrFile;
     1256            // pcil->rc.hptrIcon    = hptrFile;
    12251257            y = 0;
    12261258            for(x = 0;x < 6;x++)
     
    12581290            l++;
    12591291          }
    1260           else {  /* filesr && filesr[r] */
     1292          else {
     1293            /* filesr && filesr[r] */
     1294            // Just on right
    12611295            sprintf(pcir->szFileName,"%s%s%s",cmp->rightdir,
    12621296                    (cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\') ?
     
    12641298            pcir->pszFileName    = pcir->szFileName + lenr;
    12651299            pcir->attrFile       = filesr[r]->attrFile;
    1266 //            pcir->rc.hptrIcon    = hptrFile;
     1300            // pcir->rc.hptrIcon    = hptrFile;
    12671301            y = 0;
    12681302            for(x = 0;x < 6;x++)
     
    13071341          pcil = (PCNRITEM)pcil->rc.preccNextRecord;
    13081342          pcir = (PCNRITEM)pcir->rc.preccNextRecord;
    1309         }
     1343        } // while
    13101344        if(filesl)
    1311           free(filesl);
     1345          free(filesl);                 // Free header - have already freed elements
    13121346        filesl = NULL;
    13131347        if(filesr)
     
    13211355        ri.pRecordParent      = (PRECORDCORE)NULL;
    13221356        ri.zOrder             = (ULONG)CMA_TOP;
    1323         ri.cRecordsInsert     = high;
     1357        ri.cRecordsInsert     = recsNeeded;
    13241358        ri.fInvalidateRecord  = FALSE;
    13251359        if(!WinSendMsg(hwndLeft,CM_INSERTRECORD,
     
    13391373        ri.pRecordParent      = (PRECORDCORE)NULL;
    13401374        ri.zOrder             = (ULONG)CMA_TOP;
    1341         ri.cRecordsInsert     = high;
     1375        ri.cRecordsInsert     = recsNeeded;
    13421376        ri.fInvalidateRecord  = FALSE;
    13431377        if(!WinSendMsg(hwndRight,CM_INSERTRECORD,
     
    13561390        cmp->cmp->totalleft = numfilesl;
    13571391        cmp->cmp->totalright = numfilesr;
    1358       }
     1392      } // if recsNeeded
    13591393      Deselect(hwndLeft);
    13601394      Deselect(hwndRight);
     
    13631397      notified = TRUE;
    13641398      if(filesl)
    1365         FreeList((CHAR **)filesl);
     1399        FreeList((CHAR **)filesl);      // Must have failed to create container
    13661400      if(filesr)
    13671401        FreeList((CHAR **)filesr);
     
    13831417#define hwndRight (WinWindowFromID(hwnd,COMP_RIGHTDIR))
    13841418
    1385 
    1386 MRESULT EXPENTRY CompareDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
    1387 
     1419//=== CompareDlgProc() Compare directories dialog procedure ===
     1420
     1421MRESULT EXPENTRY CompareDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     1422{
    13881423  COMPARE        *cmp;
    13891424  static HPOINTER hptr = (HPOINTER)0;
     
    16111646        WinEnableWindowUpdate(hwndLeft,TRUE);
    16121647        WinEnableWindowUpdate(hwndRight,TRUE);
    1613 //        if(!mp1) {
     1648        // if(!mp1) {
    16141649        {
    16151650          CHAR s[81];
     
    16401675        WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTSMALLER),TRUE);
    16411676        WinEnableWindow(WinWindowFromID(hwnd,IDM_DESELECTALL),TRUE);
     1677        WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTSAMECONTENT),TRUE);
    16421678        WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTIDENTICAL),TRUE);
    16431679        WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTSAME),TRUE);
     
    17001736              PostMsg(hwnd,UM_SETUP,MPVOID,MPVOID);
    17011737              PostMsg(hwnd,UM_SETDIR,MPVOID,MPVOID);
     1738              break;
     1739          }
     1740          break;
     1741        case COMP_HIDENOTSELECTED:
     1742          switch(SHORT2FROMMP(mp1)) {
     1743            case BN_CLICKED:
     1744              WinSendMsg(hwnd,UM_HIDENOTSELECTED,MPVOID,MPVOID);
    17021745              break;
    17031746          }
     
    19371980              break;
    19381981          }
    1939           break;
    1940       }
    1941       return 0;
     1982          break;                        // COMP_RIGHTDIR
     1983      }
     1984      return 0;                         // WM_CONTROL
    19421985
    19431986    case UM_SETDIR:
     
    19662009          *forthread = *cmp;
    19672010          forthread->cmp = cmp;
    1968           if(_beginthread(FillCnrs,NULL,122880,(PVOID)forthread) != -1) {
     2011          if(_beginthread(FillCnrsThread,NULL,122880,(PVOID)forthread) != -1) {
    19692012            WinEnableWindowUpdate(hwndLeft,FALSE);
    19702013            WinEnableWindowUpdate(hwndRight,FALSE);
     
    20022045            WinEnableWindow(WinWindowFromID(hwnd,COMP_COPYRIGHT),FALSE);
    20032046            WinEnableWindow(WinWindowFromID(hwnd,COMP_MOVERIGHT),FALSE);
     2047            WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTSAMECONTENT),FALSE);
    20042048            WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTIDENTICAL),FALSE);
    20052049            WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTSAME),FALSE);
     
    20312075        WinSendMsg(hwndLeft,CM_FILTER,MPFROMP(Filter),MPFROMP(&cmp->dcd.mask));
    20322076        WinSendMsg(hwndRight,CM_FILTER,MPFROMP(Filter),MPFROMP(&cmp->dcd.mask));
     2077        cmp->dcd.suspendview = 0;
     2078        if(*cmp->dcd.mask.szMask)
     2079          WinSetDlgItemText(hwnd,COMP_NOTE,
     2080                            GetPString(IDS_COMPREADYFILTEREDTEXT));
     2081        else
     2082          WinSetDlgItemText(hwnd,COMP_NOTE,
     2083                            GetPString(IDS_COMPREADYTEXT));
     2084      }
     2085      return 0;
     2086
     2087    case UM_HIDENOTSELECTED:
     2088      cmp = INSTDATA(hwnd);
     2089      if(cmp) {
     2090        USHORT wantHide = WinQueryButtonCheckstate(hwnd,
     2091                                                   COMP_HIDENOTSELECTED);
     2092
     2093        cmp->dcd.suspendview = 1;
     2094        if (wantHide) {
     2095          BOOL needRefresh = FALSE;
     2096          HWND hwndl = WinWindowFromID(cmp->hwnd,COMP_LEFTDIR);
     2097          HWND hwndr = WinWindowFromID(cmp->hwnd,COMP_RIGHTDIR);
     2098          PCNRITEM pcil = WinSendMsg(hwndl,CM_QUERYRECORD,MPVOID,
     2099                                     MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
     2100          PCNRITEM pcir = WinSendMsg(hwndr,CM_QUERYRECORD,MPVOID,
     2101                                     MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
     2102          while(pcil && (INT)pcil != -1 && pcir && (INT)pcir != -1) {
     2103            if (~pcil->rc.flRecordAttr & CRA_SELECTED &&
     2104                ~pcir->rc.flRecordAttr & CRA_SELECTED) {
     2105              pcil->rc.flRecordAttr |= CRA_FILTERED;
     2106              pcir->rc.flRecordAttr |= CRA_FILTERED;
     2107              needRefresh = TRUE;
     2108            }
     2109            pcil = WinSendMsg(hwndl,CM_QUERYRECORD,MPFROMP(pcil),
     2110                              MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
     2111            pcir = WinSendMsg(hwndr,CM_QUERYRECORD,MPFROMP(pcir),
     2112                              MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
     2113          } // while
     2114          if (needRefresh) {
     2115            WinSendMsg(hwndl,CM_INVALIDATERECORD,
     2116                     MPVOID,MPFROM2SHORT(0,CMA_REPOSITION));
     2117            WinSendMsg(hwndr,CM_INVALIDATERECORD,
     2118                     MPVOID,MPFROM2SHORT(0,CMA_REPOSITION));
     2119          }
     2120        }
     2121        else {
     2122          WinSendMsg(hwndLeft,CM_FILTER,MPFROMP(Filter),MPFROMP(&cmp->dcd.mask));
     2123          WinSendMsg(hwndRight,CM_FILTER,MPFROMP(Filter),MPFROMP(&cmp->dcd.mask));
     2124        }
    20332125        cmp->dcd.suspendview = 0;
    20342126        if(*cmp->dcd.mask.szMask)
     
    22472339              forthread->cmp = cmp;
    22482340              forthread->action = SHORT1FROMMP(mp1);
    2249               if(_beginthread(ActionCnr,NULL,122880,(PVOID)forthread) != -1) {
     2341              if(_beginthread(ActionCnrThread,NULL,122880,(PVOID)forthread) != -1) {
    22502342                WinEnableWindowUpdate(hwndLeft,FALSE);
    22512343                WinEnableWindowUpdate(hwndRight,FALSE);
     
    22972389                WinEnableWindow(WinWindowFromID(hwnd,COMP_COPYRIGHT),FALSE);
    22982390                WinEnableWindow(WinWindowFromID(hwnd,COMP_MOVERIGHT),FALSE);
     2391                WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTSAMECONTENT),FALSE);
    22992392                WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTIDENTICAL),FALSE);
    23002393                WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTSAME),FALSE);
     
    23392432        case IDM_SELECTBOTH:
    23402433        case IDM_SELECTONE:
    2341         case IDM_SELECTIDENTICAL:
    2342         case IDM_SELECTSAME:
     2434        case IDM_SELECTSAMECONTENT:
     2435        case IDM_SELECTIDENTICAL:               // name, size and time
     2436        case IDM_SELECTSAME:                    // name and size
    23432437        case IDM_INVERT:
    23442438          cmp = INSTDATA(hwnd);
     
    23532447              forthread->cmp = cmp;
    23542448              forthread->action = SHORT1FROMMP(mp1);
    2355               if(_beginthread(SelectCnrs,NULL,65536,(PVOID)forthread) != -1) {
     2449              if(_beginthread(SelectCnrsThread,NULL,65536,(PVOID)forthread) != -1) {
    23562450                WinEnableWindowUpdate(hwndLeft,FALSE);
    23572451                WinEnableWindowUpdate(hwndRight,FALSE);
     
    24022496                WinEnableWindow(WinWindowFromID(hwnd,COMP_COPYRIGHT),FALSE);
    24032497                WinEnableWindow(WinWindowFromID(hwnd,COMP_MOVERIGHT),FALSE);
     2498                WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTSAMECONTENT),FALSE);
    24042499                WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTIDENTICAL),FALSE);
    24052500                WinEnableWindow(WinWindowFromID(hwnd,IDM_SELECTSAME),FALSE);
    24062501                WinEnableWindow(WinWindowFromID(hwnd,IDM_INVERT),FALSE);
    24072502                WinEnableWindow(WinWindowFromID(hwnd,COMP_FILTER),FALSE);
    2408                 switch(SHORT1FROMMP(mp1)) {
    2409                   case IDM_DESELECTALL:
    2410                   case IDM_INVERT:
    2411                     break;
    2412                   default:
    2413                     break;
    2414                 }
    24152503              }
    24162504              else {
Note: See TracChangeset for help on using the changeset viewer.