Changeset 362 for trunk/dll/select.c
- Timestamp:
- Jul 26, 2006, 11:40:57 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/select.c
r317 r362 3 3 4 4 $Id$ 5 6 Container item selection support routines 5 7 6 8 Copyright (c) 1993-98 M. Kimes … … 11 13 06 Jun 05 SHL Drop unused code 12 14 06 Jul 06 SHL Support compare content (IDM_SELECTSAMECONTENT) 15 13 Jul 06 SHL Use Runtime_Error 13 16 14 17 ***********************************************************************/ … … 32 35 #pragma alloc_text(SELECT1,Deselect,HideAll,RemoveAll,ExpandAll,InvertAll) 33 36 37 static PSZ pszSrcFile = __FILE__; 38 34 39 VOID UnHilite (HWND hwndCnr,BOOL all,CHAR ***list) 35 40 { … … 38 43 INT attribute = CRA_CURSORED; 39 44 40 if (all && list && *list) {45 if (all && list && *list) { 41 46 FreeList(*list); 42 47 *list = NULL; 43 48 } 44 49 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) { 47 52 attribute = CRA_SELECTED; 48 53 pci = WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS,MPFROMLONG(CMA_FIRST), 49 54 MPFROMSHORT(attribute)); 50 55 } 51 while (pci && (INT)pci != -1) {56 while (pci && (INT)pci != -1) { 52 57 WinSendMsg(hwndCnr,CM_SETRECORDEMPHASIS,MPFROMP(pci), 53 58 MPFROM2SHORT(FALSE,CRA_SELECTED)); 54 if (!all)59 if (!all) 55 60 break; 56 if (list)61 if (list) 57 62 AddToList(pci->szFileName,list,&numfiles,&numalloc); 58 63 pci = (PCNRITEM)WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS, … … 64 69 65 70 VOID SelectList (HWND hwndCnr,BOOL partial,BOOL deselect,BOOL clearfirst, 66 PCNRITEM pciParent,CHAR *filename,CHAR **list) { 71 PCNRITEM pciParent,CHAR *filename,CHAR **list) 72 { 67 73 68 74 PCNRITEM pci; … … 71 77 ULONG errs = 0L; 72 78 73 if (clearfirst && !deselect)79 if (clearfirst && !deselect) 74 80 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++) { 77 83 pci = FindCnrRecord(hwndCnr, 78 84 list[x], … … 81 87 partial, 82 88 TRUE); 83 if (pci) {89 if (pci) { 84 90 WinSendMsg(hwndCnr, 85 91 CM_SETRECORDEMPHASIS, … … 90 96 } 91 97 } 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) { 96 102 97 103 FILE *fp; … … 99 105 100 106 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)) 104 110 break; 105 111 input[1023] = 0; 106 112 bstripcr(input); 107 if (*input == '\"') {113 if (*input == '\"') { 108 114 memmove(input,input + 1,strlen(input) + 1); 109 115 lstrip(input); 110 116 p = strchr(input,'\"'); 111 if (p)117 if (p) 112 118 *p = 0; 113 119 rstrip(input); … … 115 121 else { 116 122 p = strchr(input,' '); 117 if (p)123 if (p) 118 124 *p = 0; 119 125 } … … 125 131 partial, 126 132 TRUE); 127 if (pci) /* found it? */133 if (pci) /* found it? */ 128 134 WinSendMsg(hwndCnr, 129 135 CM_SETRECORDEMPHASIS, … … 133 139 else 134 140 errs++; 135 if (errs > 50L) { /* prevent runaway on bad file */141 if (errs > 50L) { /* prevent runaway on bad file */ 136 142 137 143 APIRET ret; … … 142 148 GetPString(IDS_MAYNOTBELISTTEXT), 143 149 filename); 144 if (ret == MBID_NO)150 if (ret == MBID_NO) 145 151 break; 146 152 errs = 0L; … … 153 159 154 160 VOID SelectAll (HWND hwndCnr,BOOL files,BOOL dirs,CHAR *mask, 155 CHAR *text,BOOL arc) { 161 CHAR *text,BOOL is_arc) 162 { 156 163 157 164 PCNRITEM pci; … … 162 169 ULONG textlen = 0; 163 170 164 if (text)171 if (text) 165 172 textlen = strlen(text); 166 173 memset(&Mask,0,sizeof(Mask)); 167 if (mask && *mask)174 if (mask && *mask) 168 175 SetMask(mask,&Mask); 169 176 pci = (PCNRITEM)WinSendMsg(hwndCnr,CM_QUERYRECORD,MPVOID, 170 177 MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER)); 171 while ( pci && (INT)pci != -1 ) {178 while ( pci && (INT)pci != -1 ) { 172 179 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)) 176 183 markit = TRUE; 177 if (dirs && (pci->attrFile & FILE_DIRECTORY))184 if (dirs && (pci->attrFile & FILE_DIRECTORY)) 178 185 markit = TRUE; 179 186 } 180 187 else 181 188 markit = TRUE; 182 if (mask && *mask && markit) {189 if (mask && *mask && markit) { 183 190 markit = FALSE; 184 191 file = strrchr(pci->szFileName,'\\'); 185 if (!file)192 if (!file) 186 193 file = strrchr(pci->szFileName,':'); 187 if (file)194 if (file) 188 195 file++; 189 196 else 190 197 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],'\\') || 195 202 strchr(Mask.pszMasks[x],':')) ? 196 203 pci->szFileName : file,Mask.pszMasks[x],FALSE)) … … 198 205 } 199 206 else { 200 if (wildcard((strchr(Mask.pszMasks[x],'\\') ||207 if (wildcard((strchr(Mask.pszMasks[x],'\\') || 201 208 strchr(Mask.pszMasks[x],':'),FALSE) ? 202 209 pci->szFileName : file,Mask.pszMasks[x] + 1, … … 210 217 } 211 218 } 212 if (markit && text && *text && !(pci->attrFile & FILE_DIRECTORY)) {219 if (markit && text && *text && !(pci->attrFile & FILE_DIRECTORY)) { 213 220 214 221 CHAR *input; 215 222 216 223 markit = FALSE; 217 input = malloc(65537); 218 if(input) { 219 224 input = xmalloc(65537,pszSrcFile,__LINE__); 225 if (input) { 220 226 ULONG pos; 221 227 LONG len; 222 228 FILE *inputFile; 223 229 224 if ((inputFile = _fsopen(pci->szFileName,"rb",SH_DENYNO)) != NULL) {230 if ((inputFile = _fsopen(pci->szFileName,"rb",SH_DENYNO)) != NULL) { 225 231 pos = ftell(inputFile); 226 while (!feof(inputFile)) {227 if (pos)232 while (!feof(inputFile)) { 233 if (pos) 228 234 fseek(inputFile,pos - 256,SEEK_SET); 229 235 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)) { 232 238 markit = TRUE; 233 239 break; … … 243 249 } 244 250 } 245 else if (markit && text && *text && (pci->attrFile & FILE_DIRECTORY))251 else if (markit && text && *text && (pci->attrFile & FILE_DIRECTORY)) 246 252 markit = FALSE; 247 if (markit)253 if (markit) 248 254 WinSendMsg(hwndCnr,CM_SETRECORDEMPHASIS,MPFROMP(pci), 249 255 MPFROM2SHORT(TRUE,CRA_SELECTED)); … … 254 260 255 261 VOID DeselectAll (HWND hwndCnr,BOOL files,BOOL dirs,CHAR *mask,CHAR *text, 256 BOOL arc) {257 262 BOOL is_arc) 263 { 258 264 PCNRITEM pci; 259 265 BOOL unmarkit; … … 263 269 ULONG textlen = 0; 264 270 265 if (text)271 if (text) 266 272 textlen = strlen(text); 267 273 memset(&Mask,0,sizeof(Mask)); 268 if (mask && *mask)274 if (mask && *mask) 269 275 SetMask(mask,&Mask); 270 276 pci = (PCNRITEM)WinSendMsg(hwndCnr,CM_QUERYRECORD,MPVOID, 271 277 MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER)); 272 while ( pci && (INT)pci != -1 ) {278 while ( pci && (INT)pci != -1 ) { 273 279 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)) 277 283 unmarkit = TRUE; 278 if (dirs && (pci->attrFile & FILE_DIRECTORY))284 if (dirs && (pci->attrFile & FILE_DIRECTORY)) 279 285 unmarkit = TRUE; 280 286 } 281 287 else 282 288 unmarkit = TRUE; 283 if (mask && *mask && unmarkit) {289 if (mask && *mask && unmarkit) { 284 290 unmarkit = FALSE; 285 291 file = strrchr(pci->szFileName,'\\'); 286 if (!file)292 if (!file) 287 293 file = strrchr(pci->szFileName,':'); 288 if (file)294 if (file) 289 295 file++; 290 296 else 291 297 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],'\\') || 296 302 strchr(Mask.pszMasks[x],':')) ? 297 303 pci->szFileName : file,Mask.pszMasks[x],FALSE)) … … 299 305 } 300 306 else { 301 if (wildcard((strchr(Mask.pszMasks[x],'\\') ||307 if (wildcard((strchr(Mask.pszMasks[x],'\\') || 302 308 strchr(Mask.pszMasks[x],':')) ? 303 309 pci->szFileName : file,Mask.pszMasks[x] + 1, … … 311 317 } 312 318 } 313 if (unmarkit && text && *text && !(pci->attrFile & FILE_DIRECTORY)) {319 if (unmarkit && text && *text && !(pci->attrFile & FILE_DIRECTORY)) { 314 320 315 321 CHAR *input; 316 322 317 323 unmarkit = FALSE; 318 input = malloc(65537); 319 if(input) { 320 324 input = xmalloc(65537,pszSrcFile,__LINE__); 325 if (input) { 321 326 ULONG pos; 322 327 LONG len; 323 328 FILE *inputFile; 324 329 325 if ((inputFile = _fsopen(pci->szFileName,"rb",SH_DENYNO)) != NULL) {330 if ((inputFile = _fsopen(pci->szFileName,"rb",SH_DENYNO)) != NULL) { 326 331 pos = ftell(inputFile); 327 while (!feof(inputFile)) {328 if (pos)332 while (!feof(inputFile)) { 333 if (pos) 329 334 fseek(inputFile,pos - 256,SEEK_SET); 330 335 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)) { 333 338 unmarkit = TRUE; 334 339 break; … … 344 349 } 345 350 } 346 else if (unmarkit && text && *text && (pci->attrFile & FILE_DIRECTORY))351 else if (unmarkit && text && *text && (pci->attrFile & FILE_DIRECTORY)) 347 352 unmarkit = FALSE; 348 if (unmarkit)353 if (unmarkit) 349 354 WinSendMsg(hwndCnr,CM_SETRECORDEMPHASIS,pci, 350 355 MPFROM2SHORT(FALSE,CRA_SELECTED | CRA_CURSORED | … … 362 367 MPFROMLONG(CMA_FIRST), 363 368 MPFROMSHORT(CRA_SELECTED)); 364 while (pcil && (INT)pcil != -1) {369 while (pcil && (INT)pcil != -1) { 365 370 WinSendMsg(hwndCnr,CM_SETRECORDEMPHASIS,MPFROMP(pcil), 366 371 MPFROM2SHORT(FALSE,CRA_SELECTED)); … … 384 389 MPFROMLONG(sizeof(CNRINFO))); 385 390 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) { 388 393 attribute = CRA_SELECTED; 389 394 pci = WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS,MPFROMLONG(CMA_FIRST), … … 391 396 } 392 397 } 393 while (pci && (INT)pci != -1) {398 while (pci && (INT)pci != -1) { 394 399 pciH = WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS,MPFROMP(pci), 395 400 MPFROMSHORT(attribute)); … … 399 404 pci->rc.flRecordAttr |= CRA_FILTERED; 400 405 didone = TRUE; 401 if (fSyncUpdates) {402 if (cnri.flWindowAttr & CV_DETAIL)406 if (fSyncUpdates) { 407 if (cnri.flWindowAttr & CV_DETAIL) 403 408 WinSendMsg(hwndCnr,CM_INVALIDATERECORD,MPVOID, 404 409 MPFROM2SHORT(0,CMA_REPOSITION | CMA_ERASE)); … … 409 414 pci = pciH; 410 415 } 411 if (didone && !fSyncUpdates)416 if (didone && !fSyncUpdates) 412 417 WinSendMsg(hwndCnr,CM_INVALIDATERECORD,MPVOID, 413 418 MPFROM2SHORT(0,CMA_ERASE | CMA_REPOSITION)); … … 419 424 INT attribute = CRA_CURSORED; 420 425 421 if (quitit)426 if (quitit) 422 427 attribute = (target) ? CRA_TARGET : (source) ? CRA_SOURCE : CRA_INUSE; 423 428 pci = (PCNRITEM)WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS, 424 429 MPFROMLONG(CMA_FIRST), 425 430 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) { 429 434 attribute = CRA_SELECTED; 430 435 pci = WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS,MPFROMLONG(CMA_FIRST), … … 433 438 } 434 439 } 435 while ( pci && (INT)pci != -1) {440 while ( pci && (INT)pci != -1) { 436 441 WinSendMsg(hwndCnr,CM_SETRECORDEMPHASIS,MPFROMP(pci), 437 442 MPFROM2SHORT(!quitit, … … 449 454 450 455 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) { 453 458 attribute = CRA_SELECTED; 454 459 pci = WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS,MPFROMLONG(CMA_FIRST), … … 456 461 } 457 462 } 458 while (pci && (INT)pci != -1) {463 while (pci && (INT)pci != -1) { 459 464 if (!(pci->rc.flRecordAttr & CRA_FILTERED)) 460 465 { … … 466 471 WinSendMsg(hwndCnr,CM_SETRECORDEMPHASIS,MPFROMP(pci), 467 472 MPFROM2SHORT(0,CRA_SELECTED)); 468 if (fSyncUpdates)473 if (fSyncUpdates) 469 474 WinSendMsg(hwndCnr,CM_REMOVERECORD,MPFROMP(&pci), 470 475 MPFROM2SHORT(1,CMA_FREE | CMA_INVALIDATE)); … … 472 477 WinSendMsg(hwndCnr,CM_REMOVERECORD,MPFROMP(&pci), 473 478 MPFROM2SHORT(1,CMA_FREE)); 474 if (attribute == CRA_CURSORED)479 if (attribute == CRA_CURSORED) 475 480 break; 476 481 pci = WinSendMsg(hwndCnr,CM_QUERYRECORDEMPHASIS,MPFROMLONG(CMA_FIRST), … … 481 486 MPFROMSHORT(attribute)); 482 487 } 483 if (didone && !fSyncUpdates)488 if (didone && !fSyncUpdates) 484 489 WinSendMsg(hwndCnr,CM_INVALIDATERECORD,MPVOID, 485 490 MPFROM2SHORT(0,CMA_REPOSITION)); … … 491 496 register CHAR *p; 492 497 493 if (str != mask->szMask)498 if (str != mask->szMask) 494 499 strcpy(mask->szMask,str); 495 500 strcpy(mask->szMaskCopy,mask->szMask); 496 501 memset(mask->pszMasks,0,sizeof(CHAR *) * 26); 497 502 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 != ';') 500 505 p++; 501 if (*p) {506 if (*p) { 502 507 *p = 0; 503 508 p++; … … 516 521 PCNRITEM pci; 517 522 518 if (!pciParent)523 if (!pciParent) 519 524 pciParent = WinSendMsg(hwndCnr,CM_QUERYRECORD,MPFROMP(NULL), 520 525 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)) 523 528 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)) 525 530 WinSendMsg(hwndCnr,CM_COLLAPSETREE,MPFROMP(pciParent),MPVOID); 526 531 pci = (PCNRITEM)WinSendMsg(hwndCnr,CM_QUERYRECORD,MPFROMP(pciParent), 527 532 MPFROM2SHORT(CMA_FIRSTCHILD,CMA_ITEMORDER)); 528 if (pci)533 if (pci) 529 534 DosSleep(1L); 530 while (pci && (INT)pci != -1) {535 while (pci && (INT)pci != -1) { 531 536 ExpandAll(hwndCnr,expand,pci); 532 537 pci = (PCNRITEM)WinSendMsg(hwndCnr,CM_QUERYRECORD,MPFROMP(pci), … … 543 548 pci = (PCNRITEM)WinSendMsg(hwndCnr,CM_QUERYRECORD,MPVOID, 544 549 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)) 548 553 WinSendMsg(hwndCnr,CM_SETRECORDEMPHASIS,MPFROMP(pci), 549 554 MPFROM2SHORT(TRUE,CRA_SELECTED)); … … 567 572 register INT x,numD,numS; 568 573 569 if (!hwndCnrS || !hwndCnrD)574 if (!hwndCnrS || !hwndCnrD) 570 575 return; 571 576 … … 580 585 MPFROMLONG(sizeof(CNRINFO))); 581 586 numS = (INT)cnri.cRecords; 582 if(!numD || numS != numD) { 583 DosBeep(250,100); 587 if (!numD || numS != numD) { 584 588 saymsg(MB_ENTER, 585 589 HWND_DESKTOP, … … 590 594 return; 591 595 } 592 pciDa = malloc(sizeof(PCNRITEM) * numD); 593 if(!pciDa) { 594 DosBeep(250,100); 596 pciDa = xmalloc(sizeof(PCNRITEM) * numD,pszSrcFile,__LINE__); 597 if (!pciDa) 595 598 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); 603 603 return; 604 604 } … … 612 612 MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER)); 613 613 x = 0; 614 while ( pciD && (INT)pciD != -1 && x < numD) {615 if (reset)614 while ( pciD && (INT)pciD != -1 && x < numD) { 615 if (reset) 616 616 pciD->flags = 0; 617 617 pciDa[x] = pciD; 618 618 x++; 619 if (!slow)619 if (!slow) 620 620 pciD = (PCNRITEM)pciD->rc.preccNextRecord; 621 621 else 622 622 pciD = (PCNRITEM)WinSendMsg(hwndCnrD,CM_QUERYRECORD,MPFROMP(pciD), 623 623 MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER)); 624 if (!(x % 500))624 if (!(x % 500)) 625 625 DosSleep(1L); 626 else if (!(x % 50))626 else if (!(x % 50)) 627 627 DosSleep(0L); 628 628 } 629 if (numD != x) {630 if (!slow) {629 if (numD != x) { 630 if (!slow) { 631 631 slow = TRUE; 632 632 goto Restart; … … 634 634 free(pciDa); 635 635 free(pciSa); 636 DosBeep(250,100);637 636 saymsg(MB_ENTER, 638 637 HWND_DESKTOP, … … 647 646 MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER)); 648 647 x = 0; 649 while (pciS && (INT)pciS != -1 && x < numS) {650 if (reset)648 while (pciS && (INT)pciS != -1 && x < numS) { 649 if (reset) 651 650 pciS->flags = 0; 652 651 pciSa[x] = pciS; 653 652 x++; 654 if (!slow)653 if (!slow) 655 654 pciS = (PCNRITEM)pciS->rc.preccNextRecord; 656 655 else 657 656 pciS = (PCNRITEM)WinSendMsg(hwndCnrS,CM_QUERYRECORD,MPFROMP(pciS), 658 657 MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER)); 659 if (!(x % 500))658 if (!(x % 500)) 660 659 DosSleep(1L); 661 else if (!(x % 50))660 else if (!(x % 50)) 662 661 DosSleep(0L); 663 662 } 664 if (numS != x) {665 if (!slow) {663 if (numS != x) { 664 if (!slow) { 666 665 slow = TRUE; 667 666 goto Restart; … … 669 668 free(pciSa); 670 669 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); 678 672 return; 679 673 } 680 674 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) 684 678 continue; 685 679 pciSa[x]->flags |= CNRITEM_EXISTS; 686 680 pciDa[x]->flags |= CNRITEM_EXISTS; 687 if (pciSa[x]->cbFile + pciSa[x]->easize >681 if (pciSa[x]->cbFile + pciSa[x]->easize > 688 682 pciDa[x]->cbFile + pciDa[x]->easize) { 689 683 pciSa[x]->flags |= CNRITEM_LARGER; 690 684 pciDa[x]->flags |= CNRITEM_SMALLER; 691 685 } 692 else if (pciSa[x]->cbFile + pciSa[x]->easize <686 else if (pciSa[x]->cbFile + pciSa[x]->easize < 693 687 pciDa[x]->cbFile + pciDa[x]->easize) { 694 688 pciSa[x]->flags |= CNRITEM_SMALLER; 695 689 pciDa[x]->flags |= CNRITEM_LARGER; 696 690 } 697 if ((pciSa[x]->date.year > pciDa[x]->date.year) ? TRUE :691 if ((pciSa[x]->date.year > pciDa[x]->date.year) ? TRUE : 698 692 (pciSa[x]->date.year < pciDa[x]->date.year) ? FALSE : 699 693 (pciSa[x]->date.month > pciDa[x]->date.month) ? TRUE : … … 710 704 pciDa[x]->flags |= CNRITEM_OLDER; 711 705 } 712 else if ((pciSa[x]->date.year < pciDa[x]->date.year) ? TRUE :706 else if ((pciSa[x]->date.year < pciDa[x]->date.year) ? TRUE : 713 707 (pciSa[x]->date.year > pciDa[x]->date.year) ? FALSE : 714 708 (pciSa[x]->date.month < pciDa[x]->date.month) ? TRUE : … … 726 720 pciDa[x]->flags |= CNRITEM_NEWER; 727 721 } 728 if (!(x % 500))722 if (!(x % 500)) 729 723 DosSleep(1L); 730 else if (!(x % 50))724 else if (!(x % 50)) 731 725 DosSleep(0L); 732 726 } … … 735 729 switch(action) { 736 730 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 && 740 734 (pciSa[x]->flags & CNRITEM_EXISTS) && 741 735 !(pciSa[x]->flags & CNRITEM_SMALLER) && … … 743 737 !(pciSa[x]->flags & CNRITEM_NEWER) && 744 738 !(pciSa[x]->flags & CNRITEM_OLDER)) { 745 if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))739 if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED)) 746 740 WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]), 747 741 MPFROM2SHORT(TRUE,CRA_SELECTED)); 748 if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))742 if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED)) 749 743 WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]), 750 744 MPFROM2SHORT(TRUE,CRA_SELECTED)); 751 745 } 752 if (!(x % 500))746 if (!(x % 500)) 753 747 DosSleep(1L); 754 else if (!(x % 50))748 else if (!(x % 50)) 755 749 DosSleep(0L); 756 750 } … … 759 753 760 754 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) && 763 757 *pciSa[x]->szFileName && 764 758 (pciSa[x]->flags & CNRITEM_EXISTS) && 765 759 !(pciSa[x]->flags & CNRITEM_SMALLER) && 766 760 !(pciSa[x]->flags & CNRITEM_LARGER)) { 767 if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))761 if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED)) 768 762 WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]), 769 763 MPFROM2SHORT(TRUE,CRA_SELECTED)); 770 if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))764 if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED)) 771 765 WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]), 772 766 MPFROM2SHORT(TRUE,CRA_SELECTED)); 773 767 } 774 if (!(x % 500))768 if (!(x % 500)) 775 769 DosSleep(1L); 776 else if (!(x % 50))770 else if (!(x % 50)) 777 771 DosSleep(0L); 778 772 } … … 791 785 FILE *fp2 = NULL; 792 786 BOOL gotMatch = FALSE; 793 BOOL gotError = FALSE; 787 UINT errLineNo = 0; 788 UINT compErrno = 0; 794 789 CHAR buf1[1024]; 795 790 CHAR buf2[1024]; … … 797 792 798 793 fp1 = _fsopen(pciSa[x]->szFileName,"rb",SH_DENYNO); 799 if(!fp1) { 800 gotError = TRUE; 794 if (!fp1) { 795 errLineNo = __LINE__; 796 compErrno = errno; 801 797 } 802 798 else { 803 799 fp2 = _fsopen(pciDa[x]->szFileName,"rb",SH_DENYNO); 804 if(!fp2) { 805 gotError = TRUE; 800 if (!fp2) { 801 errLineNo = __LINE__; 802 compErrno = errno; 806 803 } 807 804 else { … … 815 812 size_t numread2 = fread(buf2,1,1024,fp2); 816 813 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 } 819 818 else if (feof(fp1) && feof(fp2)) 820 819 gotMatch = TRUE; … … 834 833 fclose(fp2); 835 834 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); 843 838 } 844 839 if (gotMatch) { … … 859 854 860 855 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) && 863 858 *pciSa[x]->szFileName && 864 859 (pciSa[x]->flags & CNRITEM_EXISTS)) { 865 if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))860 if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED)) 866 861 WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]), 867 862 MPFROM2SHORT(TRUE,CRA_SELECTED)); 868 if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))863 if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED)) 869 864 WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]), 870 865 MPFROM2SHORT(TRUE,CRA_SELECTED)); 871 866 } 872 if (!(x % 500))867 if (!(x % 500)) 873 868 DosSleep(1L); 874 else if (!(x % 50))869 else if (!(x % 50)) 875 870 DosSleep(0L); 876 871 } … … 878 873 879 874 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) && 882 877 *pciSa[x]->szFileName && 883 878 !(pciSa[x]->flags & CNRITEM_EXISTS)) { 884 if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))879 if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED)) 885 880 WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]), 886 881 MPFROM2SHORT(TRUE,CRA_SELECTED)); 887 882 } 888 else if (*pciDa[x]->szFileName &&883 else if (*pciDa[x]->szFileName && 889 884 !(pciDa[x]->flags & CNRITEM_EXISTS)) { 890 if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))885 if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED)) 891 886 WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]), 892 887 MPFROM2SHORT(TRUE,CRA_SELECTED)); 893 888 } 894 if (!(x % 500))889 if (!(x % 500)) 895 890 DosSleep(1L); 896 else if (!(x % 50))891 else if (!(x % 50)) 897 892 DosSleep(0L); 898 893 } … … 900 895 901 896 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) && 904 899 *pciSa[x]->szFileName && 905 900 (pciSa[x]->flags & CNRITEM_LARGER)) { 906 if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))901 if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED)) 907 902 WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]), 908 903 MPFROM2SHORT(TRUE,CRA_SELECTED)); 909 904 } 910 else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&905 else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) && 911 906 *pciDa[x]->szFileName && 912 907 (pciDa[x]->flags & CNRITEM_LARGER)) { 913 if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))908 if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED)) 914 909 WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]), 915 910 MPFROM2SHORT(TRUE,CRA_SELECTED)); 916 911 } 917 if (!(x % 500))912 if (!(x % 500)) 918 913 DosSleep(1L); 919 else if (!(x % 50))914 else if (!(x % 50)) 920 915 DosSleep(0L); 921 916 } … … 923 918 924 919 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) && 927 922 *pciSa[x]->szFileName && 928 923 (pciSa[x]->flags & CNRITEM_SMALLER)) { 929 if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))924 if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED)) 930 925 WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]), 931 926 MPFROM2SHORT(TRUE,CRA_SELECTED)); 932 927 } 933 else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&928 else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) && 934 929 *pciDa[x]->szFileName && 935 930 (pciDa[x]->flags & CNRITEM_SMALLER)) { 936 if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))931 if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED)) 937 932 WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]), 938 933 MPFROM2SHORT(TRUE,CRA_SELECTED)); 939 934 } 940 if (!(x % 500))935 if (!(x % 500)) 941 936 DosSleep(1L); 942 else if (!(x % 50))937 else if (!(x % 50)) 943 938 DosSleep(0L); 944 939 } … … 946 941 947 942 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) && 950 945 *pciSa[x]->szFileName && 951 946 (pciSa[x]->flags & CNRITEM_NEWER)) { 952 if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))947 if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED)) 953 948 WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]), 954 949 MPFROM2SHORT(TRUE,CRA_SELECTED)); 955 950 } 956 else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&951 else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) && 957 952 *pciDa[x]->szFileName && 958 953 (pciDa[x]->flags & CNRITEM_NEWER)) { 959 if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))954 if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED)) 960 955 WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]), 961 956 MPFROM2SHORT(TRUE,CRA_SELECTED)); 962 957 } 963 if (!(x % 500))958 if (!(x % 500)) 964 959 DosSleep(1L); 965 else if (!(x % 50))960 else if (!(x % 50)) 966 961 DosSleep(0L); 967 962 } … … 969 964 970 965 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) && 973 968 *pciSa[x]->szFileName && 974 969 (pciSa[x]->flags & CNRITEM_OLDER)) { 975 if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED))970 if (!(pciSa[x]->rc.flRecordAttr & CRA_SELECTED)) 976 971 WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]), 977 972 MPFROM2SHORT(TRUE,CRA_SELECTED)); 978 973 } 979 else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&974 else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) && 980 975 *pciDa[x]->szFileName && 981 976 (pciDa[x]->flags & CNRITEM_OLDER)) { 982 if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED))977 if (!(pciDa[x]->rc.flRecordAttr & CRA_SELECTED)) 983 978 WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]), 984 979 MPFROM2SHORT(TRUE,CRA_SELECTED)); 985 980 } 986 if (!(x % 500))981 if (!(x % 500)) 987 982 DosSleep(1L); 988 else if (!(x % 50))983 else if (!(x % 50)) 989 984 DosSleep(0L); 990 985 } … … 992 987 993 988 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) && 996 991 *pciSa[x]->szFileName && 997 992 (pciSa[x]->flags & CNRITEM_EXISTS)) { 998 if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)993 if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED) 999 994 WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]), 1000 995 MPFROM2SHORT(FALSE,CRA_SELECTED)); 1001 if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)996 if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED) 1002 997 WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]), 1003 998 MPFROM2SHORT(FALSE,CRA_SELECTED)); 1004 999 } 1005 if (!(x % 500))1000 if (!(x % 500)) 1006 1001 DosSleep(1L); 1007 else if (!(x % 50))1002 else if (!(x % 50)) 1008 1003 DosSleep(0L); 1009 1004 } … … 1011 1006 1012 1007 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) && 1015 1010 *pciSa[x]->szFileName && 1016 1011 !(pciSa[x]->flags & CNRITEM_EXISTS)) { 1017 if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)1012 if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED) 1018 1013 WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]), 1019 1014 MPFROM2SHORT(FALSE,CRA_SELECTED)); 1020 1015 } 1021 else if (*pciDa[x]->szFileName &&1016 else if (*pciDa[x]->szFileName && 1022 1017 !(pciDa[x]->flags & CNRITEM_EXISTS)) { 1023 if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)1018 if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED) 1024 1019 WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]), 1025 1020 MPFROM2SHORT(FALSE,CRA_SELECTED)); 1026 1021 } 1027 if (!(x % 500))1022 if (!(x % 500)) 1028 1023 DosSleep(1L); 1029 else if (!(x % 50))1024 else if (!(x % 50)) 1030 1025 DosSleep(0L); 1031 1026 } … … 1033 1028 1034 1029 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) && 1037 1032 *pciSa[x]->szFileName && 1038 1033 (pciSa[x]->flags & CNRITEM_LARGER)) { 1039 if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)1034 if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED) 1040 1035 WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]), 1041 1036 MPFROM2SHORT(FALSE,CRA_SELECTED)); 1042 1037 } 1043 else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&1038 else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) && 1044 1039 *pciDa[x]->szFileName && 1045 1040 (pciDa[x]->flags & CNRITEM_LARGER)) { 1046 if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)1041 if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED) 1047 1042 WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]), 1048 1043 MPFROM2SHORT(FALSE,CRA_SELECTED)); 1049 1044 } 1050 if (!(x % 500))1045 if (!(x % 500)) 1051 1046 DosSleep(1L); 1052 else if (!(x % 50))1047 else if (!(x % 50)) 1053 1048 DosSleep(0L); 1054 1049 } … … 1056 1051 1057 1052 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) && 1060 1055 *pciSa[x]->szFileName && 1061 1056 (pciSa[x]->flags & CNRITEM_SMALLER)) { 1062 if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)1057 if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED) 1063 1058 WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]), 1064 1059 MPFROM2SHORT(FALSE,CRA_SELECTED)); 1065 1060 } 1066 else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&1061 else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) && 1067 1062 *pciDa[x]->szFileName && 1068 1063 (pciDa[x]->flags & CNRITEM_SMALLER)) { 1069 if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)1064 if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED) 1070 1065 WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]), 1071 1066 MPFROM2SHORT(FALSE,CRA_SELECTED)); 1072 1067 } 1073 if (!(x % 500))1068 if (!(x % 500)) 1074 1069 DosSleep(1L); 1075 else if (!(x % 50))1070 else if (!(x % 50)) 1076 1071 DosSleep(0L); 1077 1072 } … … 1079 1074 1080 1075 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) && 1083 1078 *pciSa[x]->szFileName && 1084 1079 (pciSa[x]->flags & CNRITEM_NEWER)) { 1085 if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)1080 if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED) 1086 1081 WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]), 1087 1082 MPFROM2SHORT(FALSE,CRA_SELECTED)); 1088 1083 } 1089 else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&1084 else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) && 1090 1085 *pciDa[x]->szFileName && 1091 1086 (pciDa[x]->flags & CNRITEM_NEWER)) { 1092 if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)1087 if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED) 1093 1088 WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]), 1094 1089 MPFROM2SHORT(FALSE,CRA_SELECTED)); 1095 1090 } 1096 if (!(x % 500))1091 if (!(x % 500)) 1097 1092 DosSleep(1L); 1098 else if (!(x % 50))1093 else if (!(x % 50)) 1099 1094 DosSleep(0L); 1100 1095 } … … 1102 1097 1103 1098 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) && 1106 1101 *pciSa[x]->szFileName && 1107 1102 (pciSa[x]->flags & CNRITEM_OLDER)) { 1108 if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED)1103 if (pciSa[x]->rc.flRecordAttr & CRA_SELECTED) 1109 1104 WinSendMsg(hwndCnrS,CM_SETRECORDEMPHASIS,MPFROMP(pciSa[x]), 1110 1105 MPFROM2SHORT(FALSE,CRA_SELECTED)); 1111 1106 } 1112 else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) &&1107 else if (!(pciDa[x]->rc.flRecordAttr & CRA_FILTERED) && 1113 1108 *pciDa[x]->szFileName && 1114 1109 (pciDa[x]->flags & CNRITEM_OLDER)) { 1115 if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED)1110 if (pciDa[x]->rc.flRecordAttr & CRA_SELECTED) 1116 1111 WinSendMsg(hwndCnrD,CM_SETRECORDEMPHASIS,MPFROMP(pciDa[x]), 1117 1112 MPFROM2SHORT(FALSE,CRA_SELECTED)); 1118 1113 } 1119 if (!(x % 500))1114 if (!(x % 500)) 1120 1115 DosSleep(1L); 1121 else if (!(x % 50))1116 else if (!(x % 50)) 1122 1117 DosSleep(0L); 1123 1118 } … … 1128 1123 } 1129 1124 1130 if (reset) {1131 while (numS) {1125 if (reset) { 1126 while (numS) { 1132 1127 WinSendMsg(hwndCnrS,CM_INVALIDATERECORD, 1133 1128 MPFROMP(pciSa), … … 1138 1133 MPFROM2SHORT((min(numD,65535)),0)); 1139 1134 numS -= min(numS,65535); 1140 if (numS)1135 if (numS) 1141 1136 DosSleep(0L); 1142 1137 } … … 1183 1178 register INT z; 1184 1179 1185 for (z = 0;z < numw;z++) {1186 if (Cnrs[z].ss)1180 for (z = 0;z < numw;z++) { 1181 if (Cnrs[z].ss) 1187 1182 free(Cnrs[z].ss); 1188 1183 } … … 1200 1195 struct SS *bsres; 1201 1196 1202 if (!hwndParent)1197 if (!hwndParent) 1203 1198 return; 1204 1199 1205 1200 /* count directory containers, build array of hwnds */ 1206 1201 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) { 1211 1206 Notify(GetPString(IDS_OUTOFMEMORY)); 1212 1207 return; … … 1219 1214 } 1220 1215 WinEndEnumWindows(henum); 1221 if (numwindows < 2) {1216 if (numwindows < 2) { 1222 1217 FreeCnrs(Cnrs,numwindows); 1223 DosBeep(250,100); 1218 Runtime_Error(pszSrcFile, __LINE__, "expected two windows"); 1219 // fixme DosBeep(250,100); 1224 1220 Notify(GetPString(IDS_COMPSEL2ORMORETEXT)); 1225 1221 return; 1226 1222 } 1227 if (numwindows > 4) {1223 if (numwindows > 4) { 1228 1224 WinSendMsg(Cnrs[0]. 1229 1225 hwndCnr, … … 1235 1231 1236 1232 /* count records, build array of pointers to records */ 1237 for (z = 0;z < numwindows;z++) {1233 for (z = 0;z < numwindows;z++) { 1238 1234 pci = (PCNRITEM)WinSendMsg(Cnrs[z].hwndCnr, 1239 1235 CM_QUERYRECORD, … … 1242 1238 CMA_ITEMORDER)); 1243 1239 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) && 1246 1242 !(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) { 1249 1245 FreeCnrs(Cnrs,numwindows); 1250 1246 Notify(GetPString(IDS_OUTOFMEMORY)); … … 1263 1259 DosSleep(0L); 1264 1260 Cnrs[z].numfiles = x; 1265 if (Cnrs[z].numfiles)1261 if (Cnrs[z].numfiles) 1266 1262 qsort(Cnrs[z].ss,Cnrs[z].numfiles,sizeof(struct SS),CompSSNames); 1267 1263 } 1268 1264 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++) { 1271 1267 Cnrs[z].ss[x].all = Cnrs[z].ss[x].unique = Cnrs[z].ss[x].newest = 1272 1268 Cnrs[z].ss[x].oldest = Cnrs[z].ss[x].smallest = 1273 1269 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) { 1276 1272 bsres = (struct SS *)bsearch(Cnrs[z].ss[x].pci->pszFileName, 1277 1273 Cnrs[w].ss,Cnrs[w].numfiles, 1278 1274 sizeof(struct SS),CompSSNamesB); 1279 if (bsres) {1275 if (bsres) { 1280 1276 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 > 1282 1278 bsres->pci->cbFile + bsres->pci->easize) 1283 1279 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 < 1285 1281 bsres->pci->cbFile + bsres->pci->easize) 1286 1282 Cnrs[z].ss[x].largest = FALSE; … … 1298 1294 (Cnrs[z].ss[x].pci->time.seconds < bsres->pci->time.seconds) ? FALSE : 1299 1295 FALSE; 1300 if (!cmp)1296 if (!cmp) 1301 1297 Cnrs[z].ss[x].newest = FALSE; 1302 1298 cmp = (Cnrs[z].ss[x].pci->date.year < bsres->pci->date.year) ? TRUE : … … 1313 1309 (Cnrs[z].ss[x].pci->time.seconds > bsres->pci->time.seconds) ? FALSE : 1314 1310 FALSE; 1315 if (!cmp)1311 if (!cmp) 1316 1312 Cnrs[z].ss[x].oldest = FALSE; 1317 1313 cmp = 0; … … 1322 1318 } 1323 1319 } 1324 if (Cnrs[z].ss[x].unique)1320 if (Cnrs[z].ss[x].unique) 1325 1321 Cnrs[z].ss[x].oldest = Cnrs[z].ss[x].newest = Cnrs[z].ss[x].all = 1326 1322 Cnrs[z].ss[x].largest = Cnrs[z].ss[x].smallest = FALSE; … … 1332 1328 switch(action) { 1333 1329 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) 1337 1333 WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS, 1338 1334 MPFROMP(Cnrs[z].ss[x].pci), … … 1343 1339 break; 1344 1340 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) 1348 1344 WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS, 1349 1345 MPFROMP(Cnrs[z].ss[x].pci), … … 1354 1350 break; 1355 1351 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) 1359 1355 WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS, 1360 1356 MPFROMP(Cnrs[z].ss[x].pci), … … 1365 1361 break; 1366 1362 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) 1370 1366 WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS, 1371 1367 MPFROMP(Cnrs[z].ss[x].pci), … … 1376 1372 break; 1377 1373 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) 1381 1377 WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS, 1382 1378 MPFROMP(Cnrs[z].ss[x].pci), … … 1387 1383 break; 1388 1384 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) 1392 1388 WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS, 1393 1389 MPFROMP(Cnrs[z].ss[x].pci), … … 1398 1394 break; 1399 1395 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) 1403 1399 WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS, 1404 1400 MPFROMP(Cnrs[z].ss[x].pci), … … 1410 1406 1411 1407 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) 1415 1411 WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS, 1416 1412 MPFROMP(Cnrs[z].ss[x].pci), … … 1421 1417 break; 1422 1418 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) 1426 1422 WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS, 1427 1423 MPFROMP(Cnrs[z].ss[x].pci), … … 1432 1428 break; 1433 1429 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) 1437 1433 WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS, 1438 1434 MPFROMP(Cnrs[z].ss[x].pci), … … 1443 1439 break; 1444 1440 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) 1448 1444 WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS, 1449 1445 MPFROMP(Cnrs[z].ss[x].pci), … … 1454 1450 break; 1455 1451 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) 1459 1455 WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS, 1460 1456 MPFROMP(Cnrs[z].ss[x].pci), … … 1465 1461 break; 1466 1462 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) 1470 1466 WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS, 1471 1467 MPFROMP(Cnrs[z].ss[x].pci), … … 1476 1472 break; 1477 1473 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) 1481 1477 WinSendMsg(Cnrs[z].hwndCnr,CM_SETRECORDEMPHASIS, 1482 1478 MPFROMP(Cnrs[z].ss[x].pci),
Note:
See TracChangeset
for help on using the changeset viewer.