Changeset 762 for trunk/dll/comp.c


Ignore:
Timestamp:
Aug 5, 2007, 1:19:21 AM (18 years ago)
Author:
Steven Levine
Message:

Use two pass logic to free CNRITEMs and ARCITEMs
Rename pszLongname to pszLongName
More compare directories rework
Make directory sizes item draw placement deterministic - how did it ever work?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/comp.c

    r756 r762  
    442442                // Other side is not blank - update just this side
    443443                FreeCnrItemData(pci);
    444                 pci->pszFileName = NullStr;
    445444                pci->pszDisplayName = pci->pszFileName;
    446445                pci->rc.pszIcon = pci->pszFileName;
    447                 pci->pszLongname = NullStr;
    448                 pci->pszSubject = NullStr;
    449446                pci->flags = 0;
    450447                WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pci),
     
    503500              }
    504501              // 02 Aug 07 SHL fixme to know Longname transfer is correct?
    505               pciD->pszLongname = pci->pszLongname;
     502              pciD->pszLongName = pci->pszLongName;
    506503              if (pciD->pszSubject != NullStr) {
    507504                xfree(pciD->pszSubject);
     
    510507              pciD->attrFile = pci->attrFile;
    511508              pciD->pszDispAttr = pci->pszDispAttr;
    512               pciD->flags = 0;
     509              pciD->flags = CNRITEM_EXISTS;     // 04 Aug 07 SHL
    513510              pciD->date = pci->date;
    514511              pciD->time = pci->time;
     
    593590              FreeCnrItemData(pciD);
    594591              pciD->pszFileName = xstrdup(newname, pszSrcFile, __LINE__);
    595               pciD->pszLongname = NullStr;
    596               pciD->pszSubject = NullStr;
    597592              if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_RIGHTDIR)) {
    598593                pciD->pszDisplayName = pciD->pszFileName + strlen(cmp->leftdir);
     
    623618              }
    624619              // 02 Aug 07 SHL fixme to know why - should already be set?
    625               pci->flags = CNRITEM_EXISTS;
     620              // pci->flags = CNRITEM_EXISTS;
    626621
    627622              WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pci),
     
    12531248          }
    12541249
    1255 #if 0 //============================ fixme to be gone =================
    1256 
    1257           if (filesl && filesl[l] && filesr && filesr[r]) {
    1258             // Got two names
    1259             x = stricmp(filesl[l]->fname, filesr[r]->fname);
    1260             if (!x) {
    1261               // Names match - insert on both sides
    1262               sprintf(szBuf, "%s%s%s", cmp->leftdir,
    1263                       (cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\') ?
    1264                       NullStr : "\\", filesl[l]->fname);
    1265               // pcil->rc.hptrIcon = hptrFile;
    1266               pcil->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__); // 31 Jul 07 SHL
    1267               pcil->pszDisplayName = pcil->pszFileName + lenl;
    1268               pcil->attrFile = filesl[l]->attrFile;
    1269               y = 0;
    1270               for (x = 0; x < 6; x++) {
    1271                 if (attrstring[x])
    1272                   pcil->szDispAttr[y++] =
    1273                     (CHAR) ((pcil->
    1274                              attrFile & (1 << x)) ? attrstring[x] : '-');
    1275               }
    1276               pcil->szDispAttr[5] = 0;
    1277               pcil->cbFile = filesl[l]->cbFile;
    1278               pcil->easize = filesl[l]->easize;
    1279               pcil->date.day = filesl[l]->date.day;
    1280               pcil->date.month = filesl[l]->date.month;
    1281               pcil->date.year = filesl[l]->date.year + 1980;
    1282               pcil->time.seconds = filesl[l]->time.twosecs * 2;
    1283               pcil->time.minutes = filesl[l]->time.minutes;
    1284               pcil->time.hours = filesl[l]->time.hours;
    1285               pcil->ladate.day = filesl[l]->ladate.day;
    1286               pcil->ladate.month = filesl[l]->ladate.month;
    1287               pcil->ladate.year = filesl[l]->ladate.year + 1980;
    1288               pcil->latime.seconds = filesl[l]->latime.twosecs * 2;
    1289               pcil->latime.minutes = filesl[l]->latime.minutes;
    1290               pcil->latime.hours = filesl[l]->latime.hours;
    1291               pcil->crdate.day = filesl[l]->crdate.day;
    1292               pcil->crdate.month = filesl[l]->crdate.month;
    1293               pcil->crdate.year = filesl[l]->crdate.year + 1980;
    1294               pcil->crtime.seconds = filesl[l]->crtime.twosecs * 2;
    1295               pcil->crtime.minutes = filesl[l]->crtime.minutes;
    1296               pcil->crtime.hours = filesl[l]->crtime.hours;
    1297               if (*cmp->dcd.mask.szMask) {
    1298                 if (!Filter((PMINIRECORDCORE) pcil, (PVOID) & cmp->dcd.mask)) {
    1299                   pcil->rc.flRecordAttr |= CRA_FILTERED;
    1300                   pcir->rc.flRecordAttr |= CRA_FILTERED;
    1301                 }
    1302               }
    1303               sprintf(szBuf, "%s%s%s", cmp->rightdir,
    1304                       (cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\') ?
    1305                       NullStr : "\\", filesr[r]->fname);
    1306               pcir->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__); // 31 Jul 07 SHL
    1307               pcir->pszDisplayName = pcir->pszFileName + lenr;
    1308               pcir->attrFile = filesr[r]->attrFile;
    1309               // pcir->rc.hptrIcon = hptrFile;
    1310               y = 0;
    1311               for (x = 0; x < 6; x++)
    1312                 if (attrstring[x])
    1313                   pcir->szDispAttr[y++] =
    1314                     (CHAR) ((pcir->
    1315                              attrFile & (1 << x)) ? attrstring[x] : '-');
    1316               pcir->szDispAttr[5] = 0;
    1317               pcir->cbFile = filesr[r]->cbFile;
    1318               pcir->easize = filesr[r]->easize;
    1319               pcir->date.day = filesr[r]->date.day;
    1320               pcir->date.month = filesr[r]->date.month;
    1321               pcir->date.year = filesr[r]->date.year + 1980;
    1322               pcir->time.seconds = filesr[r]->time.twosecs * 2;
    1323               pcir->time.minutes = filesr[r]->time.minutes;
    1324               pcir->time.hours = filesr[r]->time.hours;
    1325               pcir->ladate.day = filesr[r]->ladate.day;
    1326               pcir->ladate.month = filesr[r]->ladate.month;
    1327               pcir->ladate.year = filesr[r]->ladate.year + 1980;
    1328               pcir->latime.seconds = filesr[r]->latime.twosecs * 2;
    1329               pcir->latime.minutes = filesr[r]->latime.minutes;
    1330               pcir->latime.hours = filesr[r]->latime.hours;
    1331               pcir->crdate.day = filesr[r]->crdate.day;
    1332               pcir->crdate.month = filesr[r]->crdate.month;
    1333               pcir->crdate.year = filesr[r]->crdate.year + 1980;
    1334               pcir->crtime.seconds = filesr[r]->crtime.twosecs * 2;
    1335               pcir->crtime.minutes = filesr[r]->crtime.minutes;
    1336               pcir->crtime.hours = filesr[r]->crtime.hours;
    1337               pcil->flags |= CNRITEM_EXISTS;
    1338               pcir->flags |= CNRITEM_EXISTS;
    1339               pch = szBuf;
    1340               // Subject field holds status messages
    1341               // pch = pcil->pszSubject;
    1342               *pch = 0;
    1343               if (pcil->cbFile + pcil->easize > pcir->cbFile + pcir->easize) {
    1344                 pcil->flags |= CNRITEM_LARGER;
    1345                 pcir->flags |= CNRITEM_SMALLER;
    1346                 strcpy(pch, GetPString(IDS_LARGERTEXT));
    1347                 pch += 6;
    1348               }
    1349               else if (pcil->cbFile + pcil->easize <
    1350                        pcir->cbFile + pcir->easize) {
    1351                 pcil->flags |= CNRITEM_SMALLER;
    1352                 pcir->flags |= CNRITEM_LARGER;
    1353                 strcpy(pch, GetPString(IDS_SMALLERTEXT));
    1354                 pch += 7;
    1355               }
    1356               if ((pcil->date.year > pcir->date.year) ? TRUE :
    1357                   (pcil->date.year < pcir->date.year) ? FALSE :
    1358                   (pcil->date.month > pcir->date.month) ? TRUE :
    1359                   (pcil->date.month < pcir->date.month) ? FALSE :
    1360                   (pcil->date.day > pcir->date.day) ? TRUE :
    1361                   (pcil->date.day < pcir->date.day) ? FALSE :
    1362                   (pcil->time.hours > pcir->time.hours) ? TRUE :
    1363                   (pcil->time.hours < pcir->time.hours) ? FALSE :
    1364                   (pcil->time.minutes > pcir->time.minutes) ? TRUE :
    1365                   (pcil->time.minutes < pcir->time.minutes) ? FALSE :
    1366                   (pcil->time.seconds > pcir->time.seconds) ? TRUE :
    1367                   (pcil->time.seconds < pcir->time.seconds) ? FALSE : FALSE) {
    1368                 pcil->flags |= CNRITEM_NEWER;
    1369                 pcir->flags |= CNRITEM_OLDER;
    1370                 if (pch != szBuf) {
    1371                   strcpy(pch, ", ");
    1372                   pch += 2;
    1373                 }
    1374                 strcpy(pch, GetPString(IDS_NEWERTEXT));
    1375                 pch += 5;
    1376               }
    1377               else if ((pcil->date.year < pcir->date.year) ? TRUE :
    1378                        (pcil->date.year > pcir->date.year) ? FALSE :
    1379                        (pcil->date.month < pcir->date.month) ? TRUE :
    1380                        (pcil->date.month > pcir->date.month) ? FALSE :
    1381                        (pcil->date.day < pcir->date.day) ? TRUE :
    1382                        (pcil->date.day > pcir->date.day) ? FALSE :
    1383                        (pcil->time.hours < pcir->time.hours) ? TRUE :
    1384                        (pcil->time.hours > pcir->time.hours) ? FALSE :
    1385                        (pcil->time.minutes < pcir->time.minutes) ? TRUE :
    1386                        (pcil->time.minutes > pcir->time.minutes) ? FALSE :
    1387                        (pcil->time.seconds < pcir->time.seconds) ? TRUE :
    1388                        (pcil->time.seconds > pcir->time.seconds) ? FALSE :
    1389                        FALSE) {
    1390                 pcil->flags |= CNRITEM_OLDER;
    1391                 pcir->flags |= CNRITEM_NEWER;
    1392                 if (pch != szBuf) {
    1393                   strcpy(pch, ", ");
    1394                   pch += 2;
    1395                 }
    1396                 strcpy(pch, GetPString(IDS_OLDERTEXT));
    1397                 pch += 5;
    1398               }
    1399               *pch = 0;
    1400               pcil->pszSubject = *szBuf ? strdup(szBuf) : NullStr;
    1401               r++;
    1402               l++;
    1403             }
    1404             else if (x < 0) {
    1405               // Left side name less than right side name
    1406               // Insert name on left, leave blank filler on right
    1407               sprintf(szBuf, "%s%s%s", cmp->leftdir,
    1408                       cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\' ?
    1409                         NullStr : "\\",
    1410                       filesl[l]->fname);
    1411               pcil->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__);
    1412               pcil->pszDisplayName = pcil->pszFileName + lenl;
    1413               pcil->attrFile = filesl[l]->attrFile;
    1414               // pcil->rc.hptrIcon = hptrFile;
    1415               y = 0;
    1416               for (x = 0; x < 6; x++)
    1417                 if (attrstring[x])
    1418                   pcil->szDispAttr[y++] =
    1419                     (CHAR) ((pcil->
    1420                              attrFile & (1 << x)) ? attrstring[x] : '-');
    1421               pcil->szDispAttr[5] = 0;
    1422               pcil->cbFile = filesl[l]->cbFile;
    1423               pcil->easize = filesl[l]->easize;
    1424               pcil->date.day = filesl[l]->date.day;
    1425               pcil->date.month = filesl[l]->date.month;
    1426               pcil->date.year = filesl[l]->date.year + 1980;
    1427               pcil->time.seconds = filesl[l]->time.twosecs * 2;
    1428               pcil->time.minutes = filesl[l]->time.minutes;
    1429               pcil->time.hours = filesl[l]->time.hours;
    1430               pcil->ladate.day = filesl[l]->ladate.day;
    1431               pcil->ladate.month = filesl[l]->ladate.month;
    1432               pcil->ladate.year = filesl[l]->ladate.year + 1980;
    1433               pcil->latime.seconds = filesl[l]->latime.twosecs * 2;
    1434               pcil->latime.minutes = filesl[l]->latime.minutes;
    1435               pcil->latime.hours = filesl[l]->latime.hours;
    1436               pcil->crdate.day = filesl[l]->crdate.day;
    1437               pcil->crdate.month = filesl[l]->crdate.month;
    1438               pcil->crdate.year = filesl[l]->crdate.year + 1980;
    1439               pcil->crtime.seconds = filesl[l]->crtime.twosecs * 2;
    1440               pcil->crtime.minutes = filesl[l]->crtime.minutes;
    1441               pcil->crtime.hours = filesl[l]->crtime.hours;
    1442               if (*cmp->dcd.mask.szMask) {
    1443                 if (!Filter((PMINIRECORDCORE) pcil, (PVOID) & cmp->dcd.mask)) {
    1444                   pcil->rc.flRecordAttr |= CRA_FILTERED;
    1445                   pcir->rc.flRecordAttr |= CRA_FILTERED;
    1446                 }
    1447               }
    1448               free(filesl[l]);
    1449               l++;
    1450             }
    1451             else {
    1452               // Left side name larger than right side name
    1453               // Insert name on right, leave blank filler on left
    1454               sprintf(szBuf, "%s%s%s", cmp->rightdir,
    1455                       cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\' ?
    1456                         NullStr : "\\",
    1457                       filesr[r]->fname);
    1458               pcir->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__);
    1459               pcir->pszDisplayName = pcir->pszFileName + lenr;
    1460               pcir->attrFile = filesr[r]->attrFile;
    1461               // pcir->rc.hptrIcon = hptrFile;
    1462               y = 0;
    1463               for (x = 0; x < 6; x++) {
    1464                 if (attrstring[x])
    1465                   pcir->szDispAttr[y++] =
    1466                     (CHAR) ((pcir->
    1467                              attrFile & (1 << x)) ? attrstring[x] : '-');
    1468               }
    1469               pcir->szDispAttr[5] = 0;
    1470               pcir->cbFile = filesr[r]->cbFile;
    1471               pcir->easize = filesr[r]->easize;
    1472               pcir->date.day = filesr[r]->date.day;
    1473               pcir->date.month = filesr[r]->date.month;
    1474               pcir->date.year = filesr[r]->date.year + 1980;
    1475               pcir->time.seconds = filesr[r]->time.twosecs * 2;
    1476               pcir->time.minutes = filesr[r]->time.minutes;
    1477               pcir->time.hours = filesr[r]->time.hours;
    1478               pcir->ladate.day = filesr[r]->ladate.day;
    1479               pcir->ladate.month = filesr[r]->ladate.month;
    1480               pcir->ladate.year = filesr[r]->ladate.year + 1980;
    1481               pcir->latime.seconds = filesr[r]->latime.twosecs * 2;
    1482               pcir->latime.minutes = filesr[r]->latime.minutes;
    1483               pcir->latime.hours = filesr[r]->latime.hours;
    1484               pcir->crdate.day = filesr[r]->crdate.day;
    1485               pcir->crdate.month = filesr[r]->crdate.month;
    1486               pcir->crdate.year = filesr[r]->crdate.year + 1980;
    1487               pcir->crtime.seconds = filesr[r]->crtime.twosecs * 2;
    1488               pcir->crtime.minutes = filesr[r]->crtime.minutes;
    1489               pcir->crtime.hours = filesr[r]->crtime.hours;
    1490               if (*cmp->dcd.mask.szMask) {
    1491                 if (!Filter((PMINIRECORDCORE) pcir, (PVOID) & cmp->dcd.mask)) {
    1492                   pcir->rc.flRecordAttr |= CRA_FILTERED;
    1493                   pcil->rc.flRecordAttr |= CRA_FILTERED;
    1494                 }
    1495               }
    1496               free(filesr[r]);
    1497               r++;
    1498             }
    1499           }
    1500           else if (filesl && filesl[l]) {
    1501             // Left side list longer than right side list
    1502             // Insert name on left, leave blank filler on right
    1503             sprintf(szBuf, "%s%s%s", cmp->leftdir,
    1504                     cmp->leftdir[strlen(cmp->leftdir) - 1] == '\\' ?
    1505                       NullStr : "\\",
    1506                     filesl[l]->fname);
    1507             pcil->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__);
    1508             pcil->pszDisplayName = pcil->pszFileName + lenl;
    1509             pcil->attrFile = filesl[l]->attrFile;
    1510             // pcil->rc.hptrIcon = hptrFile;
    1511             y = 0;
    1512             for (x = 0; x < 6; x++)
    1513               if (attrstring[x])
    1514                 pcil->szDispAttr[y++] = (CHAR) ((pcil->attrFile & (1 << x)) ?
    1515                                                 attrstring[x] : '-');
    1516             pcil->szDispAttr[5] = 0;
    1517             pcil->cbFile = filesl[l]->cbFile;
    1518             pcil->easize = filesl[l]->easize;
    1519             pcil->date.day = filesl[l]->date.day;
    1520             pcil->date.month = filesl[l]->date.month;
    1521             pcil->date.year = filesl[l]->date.year + 1980;
    1522             pcil->time.seconds = filesl[l]->time.twosecs * 2;
    1523             pcil->time.minutes = filesl[l]->time.minutes;
    1524             pcil->time.hours = filesl[l]->time.hours;
    1525             pcil->ladate.day = filesl[l]->ladate.day;
    1526             pcil->ladate.month = filesl[l]->ladate.month;
    1527             pcil->ladate.year = filesl[l]->ladate.year + 1980;
    1528             pcil->latime.seconds = filesl[l]->latime.twosecs * 2;
    1529             pcil->latime.minutes = filesl[l]->latime.minutes;
    1530             pcil->latime.hours = filesl[l]->latime.hours;
    1531             pcil->crdate.day = filesl[l]->crdate.day;
    1532             pcil->crdate.month = filesl[l]->crdate.month;
    1533             pcil->crdate.year = filesl[l]->crdate.year + 1980;
    1534             pcil->crtime.seconds = filesl[l]->crtime.twosecs * 2;
    1535             pcil->crtime.minutes = filesl[l]->crtime.minutes;
    1536             pcil->crtime.hours = filesl[l]->crtime.hours;
    1537             if (*cmp->dcd.mask.szMask) {
    1538               if (!Filter((PMINIRECORDCORE) pcil, (PVOID) & cmp->dcd.mask)) {
    1539                 pcil->rc.flRecordAttr |= CRA_FILTERED;
    1540                 pcir->rc.flRecordAttr |= CRA_FILTERED;
    1541               }
    1542             }
    1543             free(filesl[l]);
    1544             l++;
    1545           }
    1546           else {
    1547             // filesr && filesr[r]
    1548             // Right side list longer than left side
    1549             // Insert name on right, leave blank filler on left
    1550             sprintf(szBuf, "%s%s%s", cmp->rightdir,
    1551                     cmp->rightdir[strlen(cmp->rightdir) - 1] == '\\' ?
    1552                       NullStr : "\\",
    1553                     filesr[r]->fname);
    1554             pcir->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__);
    1555             pcir->pszDisplayName = pcir->pszFileName + lenr;
    1556             pcir->attrFile = filesr[r]->attrFile;
    1557             // pcir->rc.hptrIcon = hptrFile;
    1558             y = 0;
    1559             for (x = 0; x < 6; x++) {
    1560               if (attrstring[x])
    1561                 pcir->szDispAttr[y++] = (CHAR) ((pcir->attrFile & (1 << x)) ?
    1562                                                 attrstring[x] : '-');
    1563             }
    1564             pcir->szDispAttr[5] = 0;
    1565             pcir->cbFile = filesr[r]->cbFile;
    1566             pcir->easize = filesr[r]->easize;
    1567             pcir->date.day = filesr[r]->date.day;
    1568             pcir->date.month = filesr[r]->date.month;
    1569             pcir->date.year = filesr[r]->date.year + 1980;
    1570             pcir->time.seconds = filesr[r]->time.twosecs * 2;
    1571             pcir->time.minutes = filesr[r]->time.minutes;
    1572             pcir->time.hours = filesr[r]->time.hours;
    1573             pcir->ladate.day = filesr[r]->ladate.day;
    1574             pcir->ladate.month = filesr[r]->ladate.month;
    1575             pcir->ladate.year = filesr[r]->ladate.year + 1980;
    1576             pcir->latime.seconds = filesr[r]->latime.twosecs * 2;
    1577             pcir->latime.minutes = filesr[r]->latime.minutes;
    1578             pcir->latime.hours = filesr[r]->latime.hours;
    1579             pcir->crdate.day = filesr[r]->crdate.day;
    1580             pcir->crdate.month = filesr[r]->crdate.month;
    1581             pcir->crdate.year = filesr[r]->crdate.year + 1980;
    1582             pcir->crtime.seconds = filesr[r]->crtime.twosecs * 2;
    1583             pcir->crtime.minutes = filesr[r]->crtime.minutes;
    1584             pcir->crtime.hours = filesr[r]->crtime.hours;
    1585             if (*cmp->dcd.mask.szMask) {
    1586               if (!Filter((PMINIRECORDCORE) pcir, (PVOID) & cmp->dcd.mask)) {
    1587                 pcir->rc.flRecordAttr |= CRA_FILTERED;
    1588                 pcil->rc.flRecordAttr |= CRA_FILTERED;
    1589               }
    1590             }
    1591             free(filesr[r]);
    1592             r++;
    1593           }
    1594 
    1595 #endif //=========================== fixme to be gone =================
    1596 
    15971250          // Ensure empty buffers point somewhere
    15981251          if (!pcil->pszFileName) {
     
    16091262          pcir->rc.pszIcon = pcir->pszDisplayName;
    16101263
    1611           pcil->pszLongname = NullStr;
    1612           pcir->pszLongname = NullStr;
     1264          pcil->pszLongName = NullStr;
     1265          pcir->pszLongName = NullStr;
    16131266
    16141267          if (!pcil->pszSubject)
Note: See TracChangeset for help on using the changeset viewer.