Changeset 846 for trunk/dll/rename.c


Ignore:
Timestamp:
Sep 27, 2007, 11:16:00 PM (18 years ago)
Author:
Steven Levine
Message:

Correct ULONGLONG size formatting to avoid traps

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/rename.c

    r841 r846  
    1111  22 Mar 07 GKY Use QWL_USER
    1212  20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
     13  27 Sep 07 SHL Correct ULONGLONG size formatting
    1314
    1415***********************************************************************/
     
    3031MRESULT EXPENTRY RenameProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    3132{
    32 
    3333  MOVEIT *mv;
    3434
     
    5252    if (mv->rename || !stricmp(mv->target, mv->source)) {
    5353
    54       CHAR *p;
    55 
    56       p = strrchr(mv->target, '\\');
     54      CHAR *p = strrchr(mv->target, '\\');
    5755      if (p) {
    5856
    5957        USHORT sello, selhi;
    6058
    61         sello = (p - mv->target) + 1;
     59        sello = p - mv->target + 1;
    6260        selhi = strlen(mv->target);
    6361
     
    6664                          EM_SETSEL, MPFROM2SHORT(sello, selhi), MPVOID);
    6765      }
    68 //        WinShowWindow(WinWindowFromID(hwnd,REN_DONTASK),FALSE);
    6966      WinShowWindow(WinWindowFromID(hwnd, REN_OVEROLD), FALSE);
    7067      WinShowWindow(WinWindowFromID(hwnd, REN_OVERNEW), FALSE);
     
    8077        CHAR s[CCHMAXPATH * 2], *p, chkname[CCHMAXPATH];
    8178        INT sourceexists = 0, targetexists = 0,
    82           sourcenewer = 0, sourcesmaller = 0;
     79            sourcenewer = 0, sourcesmaller = 0;
    8380
    8481        p = mv->target;
     
    9390          WinSetDlgItemText(hwnd, REN_SOURCE, mv->source);
    9491        if (!DosQueryPathInfo(mv->source, FIL_STANDARDL, &fs1, sizeof(fs1))) {
     92          // 27 Sep 07 SHL fixme to use CommaFmtULL
    9593          sprintf(s,
    96                   " %s%lu %ss %04u/%02u/%02u %02u:%02u:%02u",
    97                   (fs1.attrFile & FILE_DIRECTORY) ?
    98                   GetPString(IDS_DIRBRKTTEXT) :
    99                   NullStr,
     94                  " %s%llu %ss %04u/%02u/%02u %02u:%02u:%02u",
     95                  fs1.attrFile & FILE_DIRECTORY ?
     96                    GetPString(IDS_DIRBRKTTEXT) : NullStr,
    10097                  fs1.cbFile,
    10198                  GetPString(IDS_BYTETEXT),
     
    107104          WinSetDlgItemText(hwnd, REN_SOURCEINFO, s);
    108105          sourceexists = 1;
    109           if (fs1.attrFile & (FILE_DIRECTORY))
     106          if (fs1.attrFile & FILE_DIRECTORY)
    110107            sourceexists = 3;
    111108        }
     
    120117        }
    121118        if (!DosQueryPathInfo(chkname, FIL_STANDARDL, &fs2, sizeof(fs2))) {
     119          // 27 Sep 07 SHL fixme to use CommaFmtULL
    122120          sprintf(s,
    123                   " %s%lu %ss %04u/%02u/%02u %02u:%02u:%02u",
    124                   (fs2.attrFile & FILE_DIRECTORY) ?
    125                   GetPString(IDS_DIRBRKTTEXT) :
    126                   NullStr,
     121                  " %s%llu %ss %04u/%02u/%02u %02u:%02u:%02u",
     122                  fs2.attrFile & FILE_DIRECTORY ?
     123                    GetPString(IDS_DIRBRKTTEXT) : NullStr,
    127124                  fs2.cbFile,
    128125                  GetPString(IDS_BYTETEXT),
     
    147144          sprintf(s,
    148145                  GetPString(IDS_SOURCEISATEXT),
    149                   (sourceexists & 2) ?
    150                   GetPString(IDS_DIRECTORYTEXT) : GetPString(IDS_FILETEXT));
     146                  sourceexists & 2 ? GetPString(IDS_DIRECTORYTEXT) :
     147                                    GetPString(IDS_FILETEXT));
    151148        {
    152149          FILE *fp = NULL;
    153 
    154           if (!(sourceexists & 2))
     150          if (~sourceexists & 2)
    155151            fp = fopen(mv->source, "ab");
    156           if ((!fp && !(sourceexists & 2)) || !sourceexists)
     152          if ((!fp && ~sourceexists & 2) || !sourceexists)
    157153            strcpy(s, GetPString(IDS_CANTACCESSSOURCETEXT));
    158154          if (fp)
     
    162158          sprintf(&s[strlen(s)],
    163159                  GetPString(IDS_TARGETEXISTSISATEXT),
    164                   (targetexists & 2) ?
    165                   GetPString(IDS_DIRECTORYTEXT) : GetPString(IDS_FILETEXT));
     160                  targetexists & 2 ? GetPString(IDS_DIRECTORYTEXT) :
     161                                    GetPString(IDS_FILETEXT));
    166162        if (targetexists && stricmp(mv->source, mv->target))
    167163          strcpy(&s[strlen(s)], GetPString(IDS_CLICKOVERWRITETEXT));
     
    169165          strcpy(&s[strlen(s)], GetPString(IDS_ENTERNEWTARGETTEXT));
    170166        WinEnableWindow(WinWindowFromID(hwnd, REN_OVERWRITE),
    171                         (stricmp(mv->target, mv->source) &&
    172                          (!mv->rename || strcmp(mv->target, mv->source))));
     167                        stricmp(mv->target, mv->source) &&
     168                          (!mv->rename || strcmp(mv->target, mv->source)));
    173169
    174170        if (targetexists == 1 && sourceexists == 1) {
    175171          sourcenewer =
    176             (fs1.fdateLastWrite.year <
    177              fs2.fdateLastWrite.year) ? 1 : (fs1.fdateLastWrite.year >
    178                                              fs2.fdateLastWrite.
    179                                              year) ? -1 : (fs1.fdateLastWrite.
    180                                                            month <
    181                                                            fs2.fdateLastWrite.
    182                                                            month) ? 1 : (fs1.
    183                                                                          fdateLastWrite.
    184                                                                          month
    185                                                                          >
    186                                                                          fs2.
    187                                                                          fdateLastWrite.
    188                                                                          month)
    189             ? -1 : (fs1.fdateLastWrite.day <
    190                     fs2.fdateLastWrite.day) ? 1 : (fs1.fdateLastWrite.day >
    191                                                    fs2.fdateLastWrite.
    192                                                    day) ? -1 : (fs1.
    193                                                                 ftimeLastWrite.
    194                                                                 hours <
    195                                                                 fs2.
    196                                                                 ftimeLastWrite.
    197                                                                 hours) ? 1
    198             : (fs1.ftimeLastWrite.hours >
    199                fs2.ftimeLastWrite.hours) ? -1 : (fs1.ftimeLastWrite.minutes <
    200                                                  fs2.ftimeLastWrite.
    201                                                  minutes) ? 1 : (fs1.
    202                                                                  ftimeLastWrite.
    203                                                                  minutes >
    204                                                                  fs2.
    205                                                                  ftimeLastWrite.
    206                                                                  minutes) ? -1
    207             : (fs1.ftimeLastWrite.twosecs <
    208                fs2.ftimeLastWrite.twosecs) ? 1 : (fs1.ftimeLastWrite.twosecs >
    209                                                   fs2.ftimeLastWrite.
    210                                                   twosecs) ? -1 : 0;
    211           sourcesmaller =
    212             (fs1.cbFile < fs2.cbFile) ? -1 : (fs1.cbFile >
    213                                               fs2.cbFile) ? 1 : 0;
     172            (fs1.fdateLastWrite.year < fs2.fdateLastWrite.year) ? 1 :
     173              (fs1.fdateLastWrite.year > fs2.fdateLastWrite.year) ? -1 :
     174               (fs1.fdateLastWrite.month < fs2.fdateLastWrite.month) ? 1 :
     175                 (fs1.fdateLastWrite.month > fs2.fdateLastWrite.month) ? -1 :
     176                   (fs1.fdateLastWrite.day < fs2.fdateLastWrite.day) ? 1 :
     177                     (fs1.fdateLastWrite.day > fs2.fdateLastWrite.day) ? -1 :
     178                       (fs1.ftimeLastWrite.hours < fs2. ftimeLastWrite. hours) ? 1 :
     179                         (fs1.ftimeLastWrite.hours > fs2.ftimeLastWrite.hours) ? -1 :
     180                           (fs1.ftimeLastWrite.minutes < fs2.ftimeLastWrite.minutes) ? 1 :
     181                             (fs1.ftimeLastWrite.minutes > fs2.ftimeLastWrite.minutes) ? -1 :
     182                               (fs1.ftimeLastWrite.twosecs < fs2.ftimeLastWrite.twosecs) ? 1 :
     183                                 (fs1.ftimeLastWrite.twosecs > fs2.ftimeLastWrite.twosecs) ? -1 : 0;
     184          sourcesmaller = (fs1.cbFile < fs2.cbFile) ? -1 :
     185                          (fs1.cbFile > fs2.cbFile) ? 1 :
     186                          0;
    214187          sprintf(&s[strlen(s)], GetPString(IDS_SOURCEISTEXT),
    215                   (sourcenewer ==
    216                    -1) ? GetPString(IDS_NEWERTEXT) : (sourcenewer ==
    217                                                       1) ?
    218                   GetPString(IDS_OLDERTEXT) : GetPString(IDS_SAMEDATETEXT),
    219                   (sourcesmaller ==
    220                    -1) ? GetPString(IDS_SMALLERTEXT) : (sourcesmaller ==
    221                                                         1) ?
    222                   GetPString(IDS_LARGERTEXT) : GetPString(IDS_SAMESIZETEXT));
     188                  (sourcenewer == -1) ? GetPString(IDS_NEWERTEXT) :
     189                    (sourcenewer == 1) ? GetPString(IDS_OLDERTEXT) :
     190                      GetPString(IDS_SAMEDATETEXT),
     191                  (sourcesmaller == -1) ? GetPString(IDS_SMALLERTEXT) :
     192                    (sourcesmaller == 1) ? GetPString(IDS_LARGERTEXT) :
     193                      GetPString(IDS_SAMESIZETEXT));
    223194        }
    224195        WinSetDlgItemText(hwnd, REN_INFORMATION, s);
Note: See TracChangeset for help on using the changeset viewer.