Changeset 1321 for trunk/dll/assoc.c


Ignore:
Timestamp:
Dec 7, 2008, 2:48:06 AM (17 years ago)
Author:
Steven Levine
Message:

Rework casts variable types for OpenWatcom 1.8 compatibility
Add more FORTIFY support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/assoc.c

    r1220 r1321  
    234234    PrfWriteProfileString(fmprof, FM3Str, temp->pszCmdLine, szEnviroment);
    235235  pszDisplayStr = xmallocz((CCHMAXPATH * 2) + MaxComLineStrg + 6,
    236                            pszSrcFile, __LINE__);
     236                           pszSrcFile, __LINE__);
    237237  if (pszDisplayStr) {
    238238    sprintf(pszDisplayStr, "%-12s \x1a %-24s %s%s%s", temp->mask,
    239             temp->pszCmdLine, (*temp->sig) ?
    240             "[" : NullStr, (*temp->sig) ? temp->sig : NullStr,
    241             (*temp->sig) ? "]" : NullStr);
     239            temp->pszCmdLine, (*temp->sig) ?
     240            "[" : NullStr, (*temp->sig) ? temp->sig : NullStr,
     241            (*temp->sig) ? "]" : NullStr);
    242242    x = (SHORT) WinSendDlgItemMsg(hwnd,
    243                                   ASS_LISTBOX,
    244                                   LM_INSERTITEM,
    245                                   MPFROM2SHORT(LIT_END, 0), MPFROMP(pszDisplayStr));
     243                                  ASS_LISTBOX,
     244                                  LM_INSERTITEM,
     245                                  MPFROM2SHORT(LIT_END, 0), MPFROMP(pszDisplayStr));
    246246    if (x >= 0) {
    247247      WinSendDlgItemMsg(hwnd,
    248                         ASS_LISTBOX,
    249                         LM_SETITEMHANDLE,
    250                         MPFROMSHORT(x), MPFROMP(info));
     248                        ASS_LISTBOX,
     249                        LM_SETITEMHANDLE,
     250                        MPFROMSHORT(x), MPFROMP(info));
    251251      WinSendDlgItemMsg(hwnd,
    252                         ASS_LISTBOX,
    253                         LM_SELECTITEM,
    254                         MPFROMSHORT(x), MPFROMSHORT(TRUE));
     252                        ASS_LISTBOX,
     253                        LM_SELECTITEM,
     254                        MPFROMSHORT(x), MPFROMSHORT(TRUE));
    255255    }
    256256    free(pszDisplayStr);
     
    297297              ";\n%0.*s\n%0.*s\n%0.*s\n%lu\n%lu\n",
    298298              CCHMAXPATH,
    299               info->mask,
    300               MaxComLineStrg,
     299              info->mask,
     300              MaxComLineStrg,
    301301              info->pszCmdLine,
    302302              CCHMAXPATH,
     
    422422      }
    423423      else
    424         exclude = FALSE;
    425         didmatch = wildcard((strchr(p, '\\') ||
    426                              strchr(p, ':')) ? datafile : file, p, FALSE);
     424        exclude = FALSE;
     425        didmatch = wildcard((strchr(p, '\\') ||
     426                             strchr(p, ':')) ? datafile : file, p, FALSE);
    427427      if (exclude && didmatch)
    428428        didmatch = FALSE;
     
    480480                        info->pszCmdLine,
    481481                        flags,
    482                         NULL, list, GetPString(IDS_EXECASSOCTITLETEXT),
    483                         pszSrcFile, __LINE__);
     482                        NULL, list, GetPString(IDS_EXECASSOCTITLETEXT),
     483                        pszSrcFile, __LINE__);
    484484        if (rc != -1 && dieafter)
    485485          PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
     
    534534
    535535      pszDisplayStr = xmallocz((CCHMAXPATH * 2) + MaxComLineStrg + 6,
    536                                pszSrcFile, __LINE__);
     536                               pszSrcFile, __LINE__);
    537537      if (pszDisplayStr) {
    538         WinSendDlgItemMsg(hwnd, ASS_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
    539         info = asshead;
    540         while (info) {
    541           sprintf(pszDisplayStr,
    542                   "%-12s \x1a %-24s %s%s%s",
    543                   info->mask,
    544                   info->pszCmdLine,
    545                   (info->sig && *info->sig) ?
    546                   "[" : NullStr,
    547                   (info->sig && *info->sig) ? info->sig : NullStr,
    548                   (info->sig && *info->sig) ? "]" : NullStr);
    549           x = (SHORT) WinSendDlgItemMsg(hwnd,
    550                                         ASS_LISTBOX,
    551                                         LM_INSERTITEM,
    552                                         MPFROM2SHORT(LIT_END, 0), MPFROMP(pszDisplayStr));
    553           if (x >= 0)
    554             WinSendDlgItemMsg(hwnd,
    555                               ASS_LISTBOX,
    556                               LM_SETITEMHANDLE, MPFROMSHORT(x), MPFROMP(info));
    557           info = info->next;
    558         }
    559         WinSendDlgItemMsg(hwnd,
    560                           ASS_LISTBOX,
    561                           LM_SELECTITEM, MPFROMSHORT(0), MPFROMSHORT(TRUE));
    562         xfree(pszDisplayStr, pszSrcFile, __LINE__);
     538        WinSendDlgItemMsg(hwnd, ASS_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
     539        info = asshead;
     540        while (info) {
     541          sprintf(pszDisplayStr,
     542                  "%-12s \x1a %-24s %s%s%s",
     543                  info->mask,
     544                  info->pszCmdLine,
     545                  (info->sig && *info->sig) ?
     546                  "[" : NullStr,
     547                  (info->sig && *info->sig) ? info->sig : NullStr,
     548                  (info->sig && *info->sig) ? "]" : NullStr);
     549          x = (SHORT) WinSendDlgItemMsg(hwnd,
     550                                        ASS_LISTBOX,
     551                                        LM_INSERTITEM,
     552                                        MPFROM2SHORT(LIT_END, 0), MPFROMP(pszDisplayStr));
     553          if (x >= 0)
     554            WinSendDlgItemMsg(hwnd,
     555                              ASS_LISTBOX,
     556                              LM_SETITEMHANDLE, MPFROMSHORT(x), MPFROMP(info));
     557          info = info->next;
     558        }
     559        WinSendDlgItemMsg(hwnd,
     560                          ASS_LISTBOX,
     561                          LM_SELECTITEM, MPFROMSHORT(0), MPFROMSHORT(TRUE));
     562        xfree(pszDisplayStr, pszSrcFile, __LINE__);
    563563      }
    564564    }
     
    683683
    684684        *filename = 0;
    685         if (insert_filename(hwnd, filename, 2, FALSE) && *filename) {
    686           BldQuotedFileName(szfilename, filename);
     685        if (insert_filename(hwnd, filename, 2, FALSE) && *filename) {
     686          BldQuotedFileName(szfilename, filename);
    687687          strcat(szfilename, " %a");
    688688          WinSetDlgItemText(hwnd, ASS_CL, szfilename);
     
    694694      {
    695695        ASSOC temp;
    696         CHAR dummy[34];
    697         PSZ pszWorkBuf;
    698         replace = FALSE;
    699 
    700         memset(&temp, 0, sizeof(ASSOC));
    701         temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    702         if (!temp.pszCmdLine)
    703           break; //already complained
     696        CHAR dummy[34];
     697        PSZ pszWorkBuf;
     698        replace = FALSE;
     699
     700        memset(&temp, 0, sizeof(ASSOC));
     701        temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
     702        if (!temp.pszCmdLine)
     703          break; //already complained
    704704
    705705        {
     
    712712                                          LM_SELECTITEM,
    713713                                          MPFROMSHORT(0), MPFROMSHORT(TRUE));
    714         }
    715         pszWorkBuf = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);
    716         if (!pszWorkBuf) {
    717           free(temp.pszCmdLine);
    718           break; //already complained
    719         }
     714        }
     715        pszWorkBuf = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);
     716        if (!pszWorkBuf) {
     717          free(temp.pszCmdLine);
     718          break; //already complained
     719        }
    720720        WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
    721         WinQueryDlgItemText(hwnd, ASS_CL, MaxComLineStrg, temp.pszCmdLine);
    722         if (strcmp(temp.pszCmdLine, "<>")) {
    723           NormalizeCmdLine(pszWorkBuf, temp.pszCmdLine);
    724           memcpy(temp.pszCmdLine, pszWorkBuf, strlen(pszWorkBuf) + 1);
    725         }
    726         free(pszWorkBuf);
     721        WinQueryDlgItemText(hwnd, ASS_CL, MaxComLineStrg, temp.pszCmdLine);
     722        if (strcmp(temp.pszCmdLine, "<>")) {
     723          NormalizeCmdLine(pszWorkBuf, temp.pszCmdLine);
     724          memcpy(temp.pszCmdLine, pszWorkBuf, strlen(pszWorkBuf) + 1);
     725        }
     726        free(pszWorkBuf);
    727727        WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
    728728        rstrip(temp.sig);
     
    748748          temp.flags |= DIEAFTER;
    749749        if (WinQueryButtonCheckstate(hwnd, ASS_PROMPT))
    750           temp.flags |= PROMPT;
    751         if (fCancelAction){
    752           fCancelAction = FALSE;
    753           free(temp.pszCmdLine);
    754           break;
    755         }
    756         else
     750          temp.flags |= PROMPT;
     751        if (fCancelAction){
     752          fCancelAction = FALSE;
     753          free(temp.pszCmdLine);
     754          break;
     755        }
     756        else
    757757        info = add_association(&temp);
    758758        if (!info)
    759759          WinDismissDlg(hwnd, 1);       /* Runtime_Error(pszSrcFile, __LINE__, "add_association"); */
    760         else {
    761           display_associations(hwnd, &temp, info);
     760        else {
     761          display_associations(hwnd, &temp, info);
    762762          save_associations();
    763         }
    764         free(temp.pszCmdLine);
     763        }
     764        free(temp.pszCmdLine);
    765765      }
    766766      WinDismissDlg(hwnd, 1);
     
    780780      {
    781781        ASSOC temp;
    782         CHAR dummy[34];
    783         PSZ pszWorkBuf;
    784         replace = FALSE;
    785 
    786         memset(&temp, 0, sizeof(ASSOC));
    787         temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    788         if (!temp.pszCmdLine)
    789           break; //already complained
    790         pszWorkBuf = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);
    791         if (!pszWorkBuf) {
    792           free(temp.pszCmdLine);
    793           break; //already complained
    794         }
    795         WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
    796         WinQueryDlgItemText(hwnd, ASS_CL, MaxComLineStrg, temp.pszCmdLine);
    797         if (strcmp(temp.pszCmdLine, "<>")) {
    798           NormalizeCmdLine(pszWorkBuf, temp.pszCmdLine);
    799           memcpy(temp.pszCmdLine, pszWorkBuf, strlen(pszWorkBuf) + 1);
    800         }
    801         free(pszWorkBuf);
     782        CHAR dummy[34];
     783        PSZ pszWorkBuf;
     784        replace = FALSE;
     785
     786        memset(&temp, 0, sizeof(ASSOC));
     787        temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
     788        if (!temp.pszCmdLine)
     789          break; //already complained
     790        pszWorkBuf = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);
     791        if (!pszWorkBuf) {
     792          free(temp.pszCmdLine);
     793          break; //already complained
     794        }
     795        WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
     796        WinQueryDlgItemText(hwnd, ASS_CL, MaxComLineStrg, temp.pszCmdLine);
     797        if (strcmp(temp.pszCmdLine, "<>")) {
     798          NormalizeCmdLine(pszWorkBuf, temp.pszCmdLine);
     799          memcpy(temp.pszCmdLine, pszWorkBuf, strlen(pszWorkBuf) + 1);
     800        }
     801        free(pszWorkBuf);
    802802        WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
    803803        rstrip(temp.sig);
     
    823823          temp.flags |= DIEAFTER;
    824824        if (WinQueryButtonCheckstate(hwnd, ASS_PROMPT))
    825           temp.flags |= PROMPT;
    826         if (fCancelAction){
    827           fCancelAction = FALSE;
    828           free(temp.pszCmdLine);
    829           break;
    830         }
    831         else
    832           info = add_association(&temp);
     825          temp.flags |= PROMPT;
     826        if (fCancelAction){
     827          fCancelAction = FALSE;
     828          free(temp.pszCmdLine);
     829          break;
     830        }
     831        else
     832          info = add_association(&temp);
    833833        //Add will fail if mask is not changed
    834834        if (info) {
    835           display_associations(hwnd, &temp, info);
     835          display_associations(hwnd, &temp, info);
    836836          save_associations();
    837837        }
    838         free(temp.pszCmdLine);
     838        free(temp.pszCmdLine);
    839839      }
    840840      break;
     
    843843      {
    844844        ASSOC temp;
    845         CHAR dummy[34];
    846 
    847         memset(&temp, 0, sizeof(ASSOC));
    848         temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    849         if (!temp.pszCmdLine)
    850           break; //already complained
     845        CHAR dummy[34];
     846
     847        memset(&temp, 0, sizeof(ASSOC));
     848        temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
     849        if (!temp.pszCmdLine)
     850          break; //already complained
    851851        WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
    852852        WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
     
    871871          }
    872872          save_associations();
    873         }
    874         free(temp.pszCmdLine);
     873        }
     874        free(temp.pszCmdLine);
    875875      }
    876876
     
    880880      {
    881881        ASSOC temp;
    882         CHAR dummy[34];
    883         PSZ pszWorkBuf;
    884         replace = TRUE;
    885 
    886         memset(&temp, 0, sizeof(ASSOC));
    887         temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    888         if (!temp.pszCmdLine)
    889           break; //already complained
     882        CHAR dummy[34];
     883        PSZ pszWorkBuf;
     884        replace = TRUE;
     885
     886        memset(&temp, 0, sizeof(ASSOC));
     887        temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
     888        if (!temp.pszCmdLine)
     889          break; //already complained
    890890        y = (SHORT) WinSendDlgItemMsg(hwnd,
    891891                                      ASS_LISTBOX,
    892892                                      LM_QUERYSELECTION,
    893                                       MPFROMSHORT(LIT_CURSOR), MPVOID);
    894         pszWorkBuf = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);
    895         if (!pszWorkBuf) {
    896           free(temp.pszCmdLine);
    897           break; //already complained
    898         }
     893                                      MPFROMSHORT(LIT_CURSOR), MPVOID);
     894        pszWorkBuf = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);
     895        if (!pszWorkBuf) {
     896          free(temp.pszCmdLine);
     897          break; //already complained
     898        }
    899899        WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
    900         WinQueryDlgItemText(hwnd, ASS_CL, MaxComLineStrg, temp.pszCmdLine);
    901         if (strcmp(temp.pszCmdLine, "<>")) {
    902           NormalizeCmdLine(pszWorkBuf, temp.pszCmdLine);
    903           memcpy(temp.pszCmdLine, pszWorkBuf, strlen(pszWorkBuf) + 1);
    904         }
    905         free(pszWorkBuf);
     900        WinQueryDlgItemText(hwnd, ASS_CL, MaxComLineStrg, temp.pszCmdLine);
     901        if (strcmp(temp.pszCmdLine, "<>")) {
     902          NormalizeCmdLine(pszWorkBuf, temp.pszCmdLine);
     903          memcpy(temp.pszCmdLine, pszWorkBuf, strlen(pszWorkBuf) + 1);
     904        }
     905        free(pszWorkBuf);
    906906        WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
    907907        rstrip(temp.sig);
     
    927927          temp.flags |= DIEAFTER;
    928928        if (WinQueryButtonCheckstate(hwnd, ASS_PROMPT))
    929           temp.flags |= PROMPT;
    930         if (fCancelAction){
    931           fCancelAction = FALSE;
    932           free(temp.pszCmdLine);
    933           break;
    934         }
    935         else
     929          temp.flags |= PROMPT;
     930        if (fCancelAction){
     931          fCancelAction = FALSE;
     932          free(temp.pszCmdLine);
     933          break;
     934        }
     935        else
    936936          info = add_association(&temp);
    937937        if (info) {
    938           display_associations(hwnd, &temp, info);
     938          display_associations(hwnd, &temp, info);
    939939          save_associations();
    940         }
    941         free(temp.pszCmdLine);
     940        }
     941        free(temp.pszCmdLine);
    942942      }
    943943      {
    944944        ASSOC temp;
    945         CHAR dummy[34];
    946 
    947         temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    948         if (!temp.pszCmdLine)
    949           break; //already complained
     945        CHAR dummy[34];
     946
     947        temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
     948        if (!temp.pszCmdLine)
     949          break; //already complained
    950950        WinSendDlgItemMsg(hwnd,
    951951                          ASS_LISTBOX,
    952952                          LM_SELECTITEM, MPFROMSHORT(y), MPFROMSHORT(TRUE));
    953         memset(temp.sig, 0, sizeof(temp.sig));
    954         memset(temp.mask, 0, sizeof(temp.mask));
    955         temp.offset = 0;
     953        memset(temp.sig, 0, sizeof(temp.sig));
     954        memset(temp.mask, 0, sizeof(temp.mask));
     955        temp.offset = 0;
    956956        WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
    957957        WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
     
    975975          }
    976976          save_associations();
    977         }
    978         free(temp.pszCmdLine);
     977        }
     978        free(temp.pszCmdLine);
    979979      }
    980980      break;
Note: See TracChangeset for help on using the changeset viewer.