Changeset 202 for trunk/dll/grep2.c


Ignore:
Timestamp:
Jun 8, 2005, 7:55:52 AM (20 years ago)
Author:
root
Message:

Rework for VAC3.65 compat, lose excess statics

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/grep2.c

    r190 r202  
    99  01 Aug 04 SHL Rework lstrip/rstrip usage
    1010  23 May 05 SHL Use QWL_USER
    11   06 Jun 05 SHL indent -i2
     11  06 Jun 05 SHL Indent -i2
     12  06 Jun 05 SHL Rework for VAC3.65 compat, lose excess statics
     13
     14  fixme for more excess locals to be gone
    1215
    1316***********************************************************************/
     
    1720#define INCL_GPI
    1821#define INCL_DOSERRORS
    19 
    2022#include <os2.h>
     23
    2124#include <stdarg.h>
    2225#include <stdio.h>
     
    2730#include <share.h>
    2831#include <limits.h>
     32
    2933#include "fm3dll.h"
    3034#include "fm3dlg.h"
     
    3842MRESULT EXPENTRY EnvDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    3943{
     44  SHORT sSelect;
     45  CHAR *p;
     46  CHAR s[CCHMAXPATH];
     47  CHAR szPath[CCHMAXPATH];
     48
    4049  static CHAR lastenv[CCHMAXPATH] = "DPATH";
    4150
     
    4655    {
    4756      WinSetWindowPtr(hwnd, QWL_USER, mp2);
    48       *(CHAR *) mp2 = 0;
     57      *(CHAR *)mp2 = 0;
    4958      {
    5059        CHAR *p;
    5160        CHAR *pp;
    52         CHAR temp[CCHMAXPATH];
    5361
    5462        p = GetPString(IDS_ENVVARNAMES);
     
    5765        while (*p)
    5866        {
    59           *temp = 0;
    60           pp = temp;
     67          *szPath = 0;
     68          pp = szPath;
    6169          while (*p && *p != ' ')
    6270            *pp++ = *p++;
     
    6472          while (*p == ' ')
    6573            p++;
    66           if (*temp)
     74          if (*szPath)
    6775            WinSendDlgItemMsg(hwnd,
    6876                              ENV_LISTBOX,
    6977                              LM_INSERTITEM,
    7078                              MPFROM2SHORT(LIT_END, 0),
    71                               MPFROMP(temp));
     79                              MPFROMP(szPath));
    7280        }
    7381      }
     
    98106      case LN_SELECT:
    99107        {
    100           SHORT sSelect;
    101           CHAR s[CCHMAXPATH];
    102 
    103           sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
    104                                               ENV_LISTBOX,
    105                                               LM_QUERYSELECTION,
    106                                               MPFROMSHORT(LIT_FIRST),
    107                                               MPVOID);
     108          sSelect = (SHORT)WinSendDlgItemMsg(hwnd,
     109                                             ENV_LISTBOX,
     110                                             LM_QUERYSELECTION,
     111                                             MPFROMSHORT(LIT_FIRST),
     112                                             MPVOID);
    108113          if (sSelect >= 0)
    109114          {
     
    139144      break;
    140145    case DID_OK:
    141       {
    142         CHAR *p = WinQueryWindowPtr(hwnd, QWL_USER);
    143 
    144         if (p)
    145         {
    146           WinQueryDlgItemText(hwnd,
    147                               ENV_NAME,
    148                               CCHMAXPATH,
    149                               p);
    150           bstrip(p);
    151           if (*p)
    152           {
    153             strcpy(lastenv, p);
    154             WinDismissDlg(hwnd, 1);
    155           }
    156           else
    157           {
    158             DosBeep(250, 100);
    159             WinSetFocus(HWND_DESKTOP,
    160                         WinWindowFromID(hwnd, ENV_NAME));
    161           }
     146      p = WinQueryWindowPtr(hwnd, QWL_USER);
     147      if (p)
     148      {
     149        WinQueryDlgItemText(hwnd,
     150                            ENV_NAME,
     151                            CCHMAXPATH,
     152                            p);
     153        bstrip(p);
     154        if (*p)
     155        {
     156          strcpy(lastenv, p);
     157          WinDismissDlg(hwnd, 1);
     158        }
     159        else
     160        {
     161          DosBeep(250, 100);
     162          WinSetFocus(HWND_DESKTOP,
     163                      WinWindowFromID(hwnd, ENV_NAME));
    162164        }
    163165      }
     
    180182  HWND hwndCollect;
    181183  HWND hwndMLE = WinWindowFromID(hwnd, GREP_SEARCH);
     184  FILE *fp;
     185  ULONG ul;
     186  LONG lLen;
     187  SHORT sSelect;
     188  CHAR *p;
     189  CHAR s[8192 + 14];
     190  CHAR simple[8192];
     191  CHAR path[CCHMAXPATH];
    182192
    183193  static CHAR lastmask[8192] = "*";
     
    255265    WinCheckButton(hwnd, GREP_SEARCHFILES, searchFiles);
    256266    WinCheckButton(hwnd, GREP_FINDIFANY, findifany);
    257     {
    258       CHAR s[35];
    259 
    260       sprintf(s, "%lu", greater);
    261       WinSetDlgItemText(hwnd, GREP_GREATER, s);
    262       sprintf(s, "%lu", lesser);
    263       WinSetDlgItemText(hwnd, GREP_LESSER, s);
    264       sprintf(s, "%u", newer);
    265       WinSetDlgItemText(hwnd, GREP_NEWER, s);
    266       sprintf(s, "%u", older);
    267       WinSetDlgItemText(hwnd, GREP_OLDER, s);
    268     }
     267
     268    sprintf(s, "%lu", greater);
     269    WinSetDlgItemText(hwnd, GREP_GREATER, s);
     270    sprintf(s, "%lu", lesser);
     271    WinSetDlgItemText(hwnd, GREP_LESSER, s);
     272    sprintf(s, "%u", newer);
     273    WinSetDlgItemText(hwnd, GREP_NEWER, s);
     274    sprintf(s, "%u", older);
     275    WinSetDlgItemText(hwnd, GREP_OLDER, s);
     276
    269277    WinEnableWindow(WinWindowFromID(hwnd, GREP_IGNOREEXTDUPES), FALSE);
    270278    WinEnableWindow(WinWindowFromID(hwnd, GREP_CRCDUPES), FALSE);
    271279    WinEnableWindow(WinWindowFromID(hwnd, GREP_NOSIZEDUPES), FALSE);
     280
     281    save_dir2(s);
     282    if (s[strlen(s) - 1] != '\\')
     283      strcat(s, "\\");
     284    strcat(s, "GREPMASK.DAT");
     285    fp = _fsopen(s, "r", SH_DENYWR);
     286    if (fp)
    272287    {
    273       FILE *fp;
    274       static CHAR s[8192 + 14];
    275 
    276       save_dir2(s);
    277       if (s[strlen(s) - 1] != '\\')
    278         strcat(s, "\\");
    279       strcat(s, "GREPMASK.DAT");
    280       fp = _fsopen(s, "r", SH_DENYWR);
    281       if (fp)
    282       {
    283         while (!feof(fp))
    284         {
    285           if (!fgets(s, 8192 + 4, fp))
    286             break;
    287           bstripcr(s);
    288           if (*s && *s != ';')
    289             WinSendDlgItemMsg(hwnd,
    290                               GREP_LISTBOX,
    291                               LM_INSERTITEM,
    292                               MPFROM2SHORT(LIT_SORTASCENDING, 0),
    293                               MPFROMP(s));
    294         }
    295         fclose(fp);
    296       }
     288      while (!feof(fp))
     289      {
     290        if (!fgets(s, 8192 + 4, fp))
     291          break;
     292        bstripcr(s);
     293        if (*s && *s != ';')
     294          WinSendDlgItemMsg(hwnd,
     295                            GREP_LISTBOX,
     296                            LM_INSERTITEM,
     297                            MPFROM2SHORT(LIT_SORTASCENDING, 0),
     298                            MPFROMP(s));
     299      }
     300      fclose(fp);
    297301    }
     302
    298303    FillPathListBox(hwnd,
    299304                    WinWindowFromID(hwnd, GREP_DRIVELIST),
     
    340345        break;
    341346      case LN_ENTER:
    342         {
    343           SHORT sSelect;
    344           static CHAR s[8192];
    345           static CHAR simple[8192];
    346           static CHAR *p;
    347           LONG len;
    348 
    349           WinQueryDlgItemText(hwnd,
    350                               GREP_MASK,
    351                               8192,
    352                               s);
    353           bstrip(s);
    354           p = strrchr(s, '\\');
    355           if (p)
    356             strcpy(simple, p);
    357           else if (*s)
     347        WinQueryDlgItemText(hwnd,
     348                            GREP_MASK,
     349                            8192,
     350                            s);
     351        bstrip(s);
     352        p = strrchr(s, '\\');
     353        if (p)
     354          strcpy(simple, p);
     355        else if (*s)
     356        {
     357          strcpy(simple, "\\");
     358          strcat(simple, s);
     359          *s = 0;
     360        }
     361        else
     362          strcpy(simple, "\\*");
     363        if (simple[strlen(simple) - 1] == ';')
     364          simple[strlen(simple) - 1] = 0;
     365        lLen = strlen(simple) + 1;
     366        if (strlen(s) > 8192 - lLen)
     367        {
     368          DosBeep(250, 100);
     369          WinSetDlgItemText(hwnd,
     370                            GREP_MASK,
     371                            s);
     372          break;
     373        }
     374
     375        sSelect = (SHORT)WinSendDlgItemMsg(hwnd,
     376                                           GREP_DRIVELIST,
     377                                           LM_QUERYSELECTION,
     378                                           MPFROMSHORT(LIT_FIRST),
     379                                           MPVOID);
     380        if (sSelect >= 0)
     381        {
     382          if (*s && s[strlen(s) - 1] != ';')
     383            strcat(s, ";");
     384          WinSendDlgItemMsg(hwnd,
     385                            GREP_DRIVELIST,
     386                            LM_QUERYITEMTEXT,
     387                            MPFROM2SHORT(sSelect,
     388                                         (8192 - strlen(s)) - lLen),
     389                            MPFROMP(&s[strlen(s)]));
     390          rstrip(s);
     391          if (*s)
    358392          {
    359             strcpy(simple, "\\");
    360             strcat(simple, s);
    361             *s = 0;
    362           }
    363           else
    364             strcpy(simple, "\\*");
    365           if (simple[strlen(simple) - 1] == ';')
    366             simple[strlen(simple) - 1] = 0;
    367           len = strlen(simple) + 1;
    368           if (strlen(s) > 8192 - len)
    369           {
    370             DosBeep(250, 100);
     393            strcat(s, simple);
    371394            WinSetDlgItemText(hwnd,
    372395                              GREP_MASK,
    373396                              s);
    374             break;
     397            WinSendDlgItemMsg(hwnd,
     398                              GREP_MASK,
     399                              EM_SETSEL,
     400                              MPFROM2SHORT(strlen(s) - (lLen + 1),
     401                                           strlen(s)),
     402                              MPVOID);
     403            PostMsg(hwnd,
     404                    UM_FOCUSME,
     405                    MPFROMLONG(WinWindowFromID(hwnd, GREP_MASK)),
     406                    MPVOID);
    375407          }
    376 
    377           sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
    378                                               GREP_DRIVELIST,
    379                                               LM_QUERYSELECTION,
    380                                               MPFROMSHORT(LIT_FIRST),
    381                                               MPVOID);
    382           if (sSelect >= 0)
    383           {
    384             if (*s && s[strlen(s) - 1] != ';')
    385               strcat(s, ";");
    386             WinSendDlgItemMsg(hwnd,
    387                               GREP_DRIVELIST,
    388                               LM_QUERYITEMTEXT,
    389                               MPFROM2SHORT(sSelect,
    390                                            (8192 - strlen(s)) - len),
    391                               MPFROMP(&s[strlen(s)]));
    392             rstrip(s);
    393             if (*s)
    394             {
    395               strcat(s, simple);
    396               WinSetDlgItemText(hwnd,
    397                                 GREP_MASK,
    398                                 s);
    399               WinSendDlgItemMsg(hwnd,
    400                                 GREP_MASK,
    401                                 EM_SETSEL,
    402                                 MPFROM2SHORT(strlen(s) - (len + 1),
    403                                              strlen(s)),
    404                                 MPVOID);
    405               PostMsg(hwnd,
    406                       UM_FOCUSME,
    407                       MPFROMLONG(WinWindowFromID(hwnd, GREP_MASK)),
    408                       MPVOID);
    409             }
    410           }
    411         }
    412         break;
    413       }
    414       break;
     408        }
     409        break; // LN_ENTER
     410      } // switch
     411      break;
     412
    415413    case GREP_LISTBOX:
    416414      switch (SHORT2FROMMP(mp1))
     
    434432          break;
    435433        {
    436           SHORT sSelect;
    437           static CHAR s[8192];
    438 
    439           *s = 0;
    440           sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
    441                                               GREP_LISTBOX,
    442                                               LM_QUERYSELECTION,
    443                                               MPFROMSHORT(LIT_FIRST),
    444                                               MPVOID);
     434          sSelect = (SHORT)WinSendDlgItemMsg(hwnd,
     435                                             GREP_LISTBOX,
     436                                             LM_QUERYSELECTION,
     437                                             MPFROMSHORT(LIT_FIRST),
     438                                             MPVOID);
    445439          if (sSelect >= 0)
    446440          {
     441            *s = 0;
    447442            if (WinQueryButtonCheckstate(hwnd, GREP_APPEND))
    448443            {
     
    470465      }
    471466      break;
     467
    472468    case GREP_MASK:
    473469      if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
     
    562558    case GREP_ENV:
    563559      {
    564         CHAR path[CCHMAXPATH];
    565         CHAR *p;
    566560        CHAR *t;
    567 
    568         static CHAR s[8192];
    569         static CHAR simple[8192];
    570         static CHAR env[8192];
    571         LONG len;
     561        CHAR env[8192];
    572562
    573563        *path = 0;
     
    617607        if (simple[strlen(simple) - 1] == ';')
    618608          simple[strlen(simple) - 1] = 0;
    619         len = strlen(simple) + 1;
     609        lLen = strlen(simple) + 1;
    620610        p = env;
    621611        while (p && *p)
     
    629619          if (isalpha(*path) && path[1] == ':' && path[2] == '\\')
    630620          {
    631             if (strlen(s) > (8192 - len) - (strlen(path) + 1))
     621            if (strlen(s) > (8192 - lLen) - (strlen(path) + 1))
    632622            {
    633623              WinSetDlgItemText(hwnd,
     
    641631                strcat(s, ";");
    642632              strcat(s, path);
    643               len += strlen(path);
     633              lLen += strlen(path);
    644634              if (s[strlen(s) - 1] != '\\')
    645635              {
    646                 len++;
     636                lLen++;
    647637                strcat(s, "\\");
    648638              }
     
    657647                                  GREP_MASK,
    658648                                  EM_SETSEL,
    659                                   MPFROM2SHORT(strlen(s) - (len - 1),
     649                                  MPFROM2SHORT(strlen(s) - (lLen - 1),
    660650                                               strlen(s)),
    661651                                  MPVOID);
     
    671661
    672662    case GREP_WALK:
    673       {
    674         CHAR path[CCHMAXPATH];
    675         CHAR *p;
    676         LONG len;
    677 
    678         static CHAR s[8192];
    679         static CHAR simple[8192];
    680 
    681         WinQueryDlgItemText(hwnd,
     663      WinQueryDlgItemText(hwnd,
     664                          GREP_MASK,
     665                          8192,
     666                          s);
     667      bstrip(s);
     668      if (strlen(s) > 8192 - 5)
     669      {
     670        DosBeep(50, 100);
     671        break;
     672      }
     673      *path = 0;
     674      if (WinDlgBox(HWND_DESKTOP,
     675                    hwnd,
     676                    WalkAllDlgProc,
     677                    FM3ModHandle,
     678                    WALK_FRAME,
     679                    MPFROMP(path)) &&
     680          *path)
     681      {
     682        p = strrchr(s, '\\');
     683        if (p)
     684          strcpy(simple, p + 1);
     685        else if (*s)
     686          strcpy(simple, s);
     687        else
     688          strcpy(simple, "*");
     689        if (!p)
     690          *s = 0;
     691        if (simple[strlen(simple) - 1] == ';')
     692          simple[strlen(simple) - 1] = 0;
     693        lLen = strlen(simple) + 1;
     694        if (strlen(s) > (8192 - lLen) - (strlen(path) + 1))
     695        {
     696          DosBeep(250, 100);
     697          WinSetDlgItemText(hwnd,
    682698                            GREP_MASK,
    683                             8192,
    684699                            s);
    685         bstrip(s);
    686         if (strlen(s) > 8192 - 5)
    687         {
    688           DosBeep(50, 100);
    689700          break;
    690701        }
    691         *path = 0;
    692         if (WinDlgBox(HWND_DESKTOP,
    693                       hwnd,
    694                       WalkAllDlgProc,
    695                       FM3ModHandle,
    696                       WALK_FRAME,
    697                       MPFROMP(path)) &&
    698             *path)
    699         {
    700           p = strrchr(s, '\\');
    701           if (p)
    702             strcpy(simple, p + 1);
    703           else if (*s)
    704             strcpy(simple, s);
    705           else
    706             strcpy(simple, "*");
    707           if (!p)
    708             *s = 0;
    709           if (simple[strlen(simple) - 1] == ';')
    710             simple[strlen(simple) - 1] = 0;
    711           len = strlen(simple) + 1;
    712           if (strlen(s) > (8192 - len) - (strlen(path) + 1))
     702        if (!*s || (*s && s[strlen(s) - 1] != ';'))
     703        {
     704          if (*s)
     705            strcat(s, ";");
     706          strcat(s, path);
     707          lLen += strlen(path);
     708          if (s[strlen(s) - 1] != '\\')
    713709          {
    714             DosBeep(250, 100);
     710            lLen++;
     711            strcat(s, "\\");
     712          }
     713          rstrip(s);
     714          if (*s)
     715          {
     716            strcat(s, simple);
    715717            WinSetDlgItemText(hwnd,
    716718                              GREP_MASK,
    717719                              s);
    718             break;
     720            WinSendDlgItemMsg(hwnd,
     721                              GREP_MASK,
     722                              EM_SETSEL,
     723                              MPFROM2SHORT(strlen(s) - (lLen - 1),
     724                                           strlen(s)),
     725                              MPVOID);
    719726          }
    720           if (!*s || (*s && s[strlen(s) - 1] != ';'))
    721           {
    722             if (*s)
    723               strcat(s, ";");
    724             strcat(s, path);
    725             len += strlen(path);
    726             if (s[strlen(s) - 1] != '\\')
    727             {
    728               len++;
    729               strcat(s, "\\");
    730             }
    731             rstrip(s);
    732             if (*s)
    733             {
    734               strcat(s, simple);
    735               WinSetDlgItemText(hwnd,
    736                                 GREP_MASK,
    737                                 s);
    738               WinSendDlgItemMsg(hwnd,
    739                                 GREP_MASK,
    740                                 EM_SETSEL,
    741                                 MPFROM2SHORT(strlen(s) - (len - 1),
    742                                              strlen(s)),
    743                                 MPVOID);
    744             }
    745           }
    746727        }
    747728      }
     
    749730
    750731    case GREP_ADD:
    751       {
    752         SHORT sSelect;
    753 
    754         static CHAR s[8192];
    755 
    756         *s = 0;
    757         WinQueryDlgItemText(hwnd,
    758                             GREP_MASK,
    759                             8192,
    760                             s);
    761         bstrip(s);
    762         if (*s)
    763         {
    764           sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
    765                                               GREP_LISTBOX,
    766                                               LM_SEARCHSTRING,
    767                                               MPFROM2SHORT(0, LIT_FIRST),
    768                                               MPFROMP(s));
    769           if (sSelect < 0)
    770           {
    771             WinSendDlgItemMsg(hwnd,
    772                               GREP_LISTBOX,
    773                               LM_INSERTITEM,
    774                               MPFROM2SHORT(LIT_SORTASCENDING, 0),
    775                               MPFROMP(s));
    776             changed = TRUE;
    777           }
    778         }
    779       }
    780       break;
    781 
    782     case GREP_DELETE:
    783       {
    784         SHORT sSelect;
    785 
     732      *s = 0;
     733      WinQueryDlgItemText(hwnd,
     734                          GREP_MASK,
     735                          8192,
     736                          s);
     737      bstrip(s);
     738      if (*s)
     739      {
    786740        sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
    787741                                            GREP_LISTBOX,
    788                                             LM_QUERYSELECTION,
    789                                             MPFROMSHORT(LIT_FIRST),
    790                                             MPVOID);
    791         if (sSelect >= 0)
     742                                            LM_SEARCHSTRING,
     743                                            MPFROM2SHORT(0, LIT_FIRST),
     744                                            MPFROMP(s));
     745        if (sSelect < 0)
    792746        {
    793747          WinSendDlgItemMsg(hwnd,
    794748                            GREP_LISTBOX,
    795                             LM_DELETEITEM,
    796                             MPFROM2SHORT(sSelect, 0),
    797                             MPVOID);
     749                            LM_INSERTITEM,
     750                            MPFROM2SHORT(LIT_SORTASCENDING, 0),
     751                            MPFROMP(s));
    798752          changed = TRUE;
    799753        }
     
    801755      break;
    802756
     757    case GREP_DELETE:
     758      sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
     759                                          GREP_LISTBOX,
     760                                          LM_QUERYSELECTION,
     761                                          MPFROMSHORT(LIT_FIRST),
     762                                          MPVOID);
     763      if (sSelect >= 0)
     764      {
     765        WinSendDlgItemMsg(hwnd,
     766                          GREP_LISTBOX,
     767                          LM_DELETEITEM,
     768                          MPFROM2SHORT(sSelect, 0),
     769                          MPVOID);
     770        changed = TRUE;
     771      }
     772      break;
     773
    803774    case GREP_OM:
    804       {
    805         CHAR str[81];
    806         UINT temp;
    807 
    808         *str = 0;
    809         WinQueryDlgItemText(hwnd,
    810                             GREP_OLDER,
    811                             34,
    812                             str);
    813         temp = atoi(str) * 30L;
    814         sprintf(str, "%u", temp);
    815         WinSetDlgItemText(hwnd,
     775      *s = 0;
     776      WinQueryDlgItemText(hwnd,
    816777                          GREP_OLDER,
    817                           str);
    818       }
     778                          34,
     779                          s);
     780      ul = atoi(s) * 30L;
     781      sprintf(s, "%lu", ul);
     782      WinSetDlgItemText(hwnd,
     783                        GREP_OLDER,
     784                        s);
    819785      break;
    820786
    821787    case GREP_NM:
    822       {
    823         CHAR str[81];
    824         UINT temp;
    825 
    826         *str = 0;
    827         WinQueryDlgItemText(hwnd,
    828                             GREP_NEWER,
    829                             34,
    830                             str);
    831         temp = atoi(str) * 30L;
    832         sprintf(str, "%u", temp);
    833         WinSetDlgItemText(hwnd,
     788      *s = 0;
     789      WinQueryDlgItemText(hwnd,
    834790                          GREP_NEWER,
    835                           str);
    836       }
     791                          34,
     792                          s);
     793      ul = atoi(s) * 30L;
     794      sprintf(s, "%lu", ul);
     795      WinSetDlgItemText(hwnd,
     796                        GREP_NEWER,
     797                        s);
    837798      break;
    838799
    839800    case GREP_GK:
    840       {
    841         CHAR str[81];
    842         ULONG temp;
    843 
    844         *str = 0;
    845         WinQueryDlgItemText(hwnd,
    846                             GREP_GREATER,
    847                             34,
    848                             str);
    849         temp = atol(str) * 1024L;
    850         sprintf(str, "%lu", temp);
    851         WinSetDlgItemText(hwnd, GREP_GREATER, str);
    852       }
     801      *s = 0;
     802      WinQueryDlgItemText(hwnd,
     803                          GREP_GREATER,
     804                          34,
     805                          s);
     806      ul = atol(s) * 1024L;
     807      sprintf(s, "%lu", ul);
     808      WinSetDlgItemText(hwnd, GREP_GREATER, s);
    853809      break;
    854810
    855811    case GREP_LK:
    856       {
    857         CHAR str[81];
    858         ULONG temp;
    859 
    860         *str = 0;
    861         WinQueryDlgItemText(hwnd,
    862                             GREP_LESSER,
    863                             34,
    864                             str);
    865         temp = atol(str) * 1024L;
    866         sprintf(str, "%lu", temp);
    867         WinSetDlgItemText(hwnd,
     812      *s = 0;
     813      WinQueryDlgItemText(hwnd,
    868814                          GREP_LESSER,
    869                           str);
    870       }
     815                          34,
     816                          s);
     817      ul = atol(s) * 1024L;
     818      sprintf(s, "%lu", ul);
     819      WinSetDlgItemText(hwnd,
     820                        GREP_LESSER,
     821                        s);
    871822      break;
    872823
     
    887838    case GREP_ALLHDS:
    888839      {
    889         CHAR *p;
    890         CHAR *szDrive = " :\\";
     840        CHAR szDrive[] = " :\\";
    891841        ULONG ulDriveNum;
    892842        ULONG ulDriveMap;
     
    894844        BOOL incl;
    895845
    896         static CHAR str[8192];
    897         static CHAR new[8192];
    898 
    899         *str = *new = 0;
     846        CHAR new[8192];
     847
     848        *s = 0;
    900849        WinQueryDlgItemText(hwnd,
    901850                            GREP_MASK,
    902851                            8192,
    903                             str);
    904         str[8192 - 1] = 0;
    905         p = strchr(str, ';');
     852                            s);
     853        s[8192 - 1] = 0;
     854        p = strchr(s, ';');
    906855        if (p)
    907856          *p = 0;
    908         p = strrchr(str, '\\');
     857        p = strrchr(s, '\\');
    909858        if (!p)
    910           p = strrchr(str, '/');
     859          p = strrchr(s, '/');
    911860        if (!p)
    912           p = strrchr(str, ':');
     861          p = strrchr(s, ':');
    913862        if (p)
    914           strcpy(str, p + 1);
    915         if (!*str)
    916           strcpy(str, "*");
    917         *new = 0;
     863          strcpy(s, p + 1);
     864        if (!*s)
     865          strcpy(s, "*");
    918866        DosError(FERR_DISABLEHARDERR);
    919867        DosQCurDisk(&ulDriveNum,
    920868                    &ulDriveMap);
     869        *new = 0;
    921870        for (x = 2; x < 26; x++)
    922871        {
     
    945894          if (incl)
    946895          {
    947             if (strlen(new) + strlen(str) + 5 < 8192 - 1)
     896            if (strlen(new) + strlen(s) + 5 < 8192 - 1)
    948897            {
    949898              if (*new)
     
    951900              *szDrive = x + 'A';
    952901              strcat(new, szDrive);
    953               strcat(new, str);
     902              strcat(new, s);
    954903            }
    955904          }
     
    968917      else
    969918      {
    970         CHAR *str;
    971 
    972         static GREP g;
    973 
    974         str = malloc(8192 + 512);
    975         if (!str)
     919        static GREP g;          // Passed to thread
     920
     921        p = malloc(8192 + 512);
     922        if (!p)
    976923        {
    977924          DosBeep(50, 100);
     
    979926        }
    980927        memset(&g, 0, sizeof(GREP));
    981         *str = 0;
    982928        g.size = sizeof(GREP);
    983929        if (WinQueryButtonCheckstate(hwnd, GREP_RECURSE))
     
    1028974            g.ignoreextdupes = FALSE;
    1029975        }
    1030         *str = 0;
     976        *p = 0;
    1031977        WinQueryDlgItemText(hwnd,
    1032978                            GREP_MASK,
    1033979                            8192,
    1034                             str);
    1035         bstrip(str);
    1036         if (!*str)
     980                            p);
     981        bstrip(p);
     982        if (!*p)
    1037983        {
    1038984          DosBeep(50, 100);
    1039985          WinSetFocus(HWND_DESKTOP,
    1040986                      WinWindowFromID(hwnd, GREP_MASK));
    1041           free(str);
     987          free(p);
    1042988          break;
    1043989        }
    1044         strcpy(g.tosearch, str);
    1045         strcpy(lastmask, str);
    1046         *str = 0;
     990        strcpy(g.tosearch, p);
     991        strcpy(lastmask, p);
     992        *p = 0;
    1047993        WinQueryWindowText(hwndMLE,
    1048994                           4096,
    1049                            str);
    1050         strcpy(lasttext, str);
    1051         {
    1052           CHAR *p;
    1053           CHAR *pp;
     995                           p);
     996        strcpy(lasttext, p);
     997        {
     998          CHAR *pszFrom;
     999          CHAR *pszTo;
    10541000          ULONG matched = 0;
    10551001
    1056           pp = g.searchPattern;
    1057           p = str;
    1058           while (*p)
     1002          pszTo = g.searchPattern;
     1003          pszFrom = p;
     1004          while (*pszFrom)
    10591005          {
    1060             if (*p == '\r')
     1006            if (*pszFrom == '\r')
    10611007            {
    1062               p++;
     1008              pszFrom++;
    10631009              continue;
    10641010            }
    1065             if (*p == '\n')
     1011            if (*pszFrom == '\n')
    10661012            {
    1067               if (*(p + 1))
     1013              if (*(pszFrom + 1))
    10681014                matched++;
    1069               *pp = 0;
     1015              *pszTo = 0;
    10701016            }
    10711017            else
    1072               *pp = *p;
    1073             pp++;
    1074             p++;
     1018              *pszTo = *pszFrom;
     1019            pszTo++;
     1020            pszFrom++;
    10751021          }
    10761022          if (*g.searchPattern)
    10771023            matched++;
    1078           *pp = 0;
    1079           pp++;
    1080           *pp = 0;
     1024          *pszTo++ = 0;
     1025          *pszTo = 0;
    10811026          g.numlines = matched;
    10821027          g.matched = malloc(g.numlines);
     
    10841029            g.numlines = 0;
    10851030        }
    1086         *str = 0;
     1031        *p = 0;
    10871032        WinQueryDlgItemText(hwnd,
    10881033                            GREP_GREATER,
    10891034                            34,
    1090                             str);
    1091         greater = atol(str);
    1092         *str = 0;
     1035                            p);
     1036        greater = atol(p);
     1037        *p = 0;
    10931038        WinQueryDlgItemText(hwnd,
    10941039                            GREP_LESSER,
    10951040                            34,
    1096                             str);
    1097         lesser = atol(str);
    1098         *str = 0;
     1041                            p);
     1042        lesser = atol(p);
     1043        *p = 0;
    10991044        WinQueryDlgItemText(hwnd,
    11001045                            GREP_NEWER,
    11011046                            34,
    1102                             str);
    1103         newer = atoi(str);
    1104         *str = 0;
     1047                            p);
     1048        newer = atoi(p);
     1049        *p = 0;
    11051050        WinQueryDlgItemText(hwnd,
    11061051                            GREP_OLDER,
    11071052                            34,
    1108                             str);
    1109         older = atoi(str);
     1053                            p);
     1054        older = atoi(p);
    11101055        if (older || newer)
    11111056        {
     
    11531098        g.antiattr = ((DIRCNRDATA *) INSTDATA(hwndCollect)) -> mask.antiattr;
    11541099        g.stopflag = &((DIRCNRDATA *) INSTDATA(hwndCollect)) -> stopflag;
    1155         if (_beginthread(dogrep, NULL, 524280, (PVOID) & g) == -1)
    1156         {
    1157           free(str);
     1100        if (_beginthread(dogrep, NULL, 524280, (PVOID)&g) == -1)
     1101        {
     1102          free(p);
    11581103          DosBeep(50, 100);
    11591104          WinDismissDlg(hwnd, 0);
     
    11611106        }
    11621107        else
    1163           DosSleep(128L);
    1164         free(str);
     1108          DosSleep(128);
     1109        free(p);
    11651110      }
    11661111      if (changed)
    11671112      {
    1168         FILE *fp;
    1169         SHORT sSelect;
    11701113        SHORT x;
    1171 
    1172         static CHAR s[8192 + 14];
    11731114
    11741115        sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
Note: See TracChangeset for help on using the changeset viewer.