Changeset 402 for trunk/dll/grep2.c
- Timestamp:
- Jul 29, 2006, 9:59:34 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/grep2.c
r382 r402 3 3 4 4 $Id$ 5 6 Grep dialog for collector 5 7 6 8 Copyright (c) 1993-98 M. Kimes … … 12 14 06 Jun 05 SHL Rework for VAC3.65 compat, lose excess statics 13 15 17 Jul 06 SHL Use Runtime_Error 16 28 Jul 06 SHL Avoid 0 length malloc, optimize option checks 17 29 Jul 06 SHL Use xfgets 14 18 15 19 fixme for more excess locals to be gone … … 288 292 if (fp) 289 293 { 290 while (!feof(fp)) 291 { 292 if (!fgets(s, 8192 + 4, fp)) 294 while (!feof(fp)) { 295 if (!xfgets_bstripcr(s, 8192 + 4, fp,pszSrcFile,__LINE__)) 293 296 break; 294 bstripcr(s); 295 if (*s && *s != ';') 297 if (*s && *s != ';') { 296 298 WinSendDlgItemMsg(hwnd, 297 299 GREP_LISTBOX, … … 299 301 MPFROM2SHORT(LIT_SORTASCENDING, 0), 300 302 MPFROMP(s)); 303 } 301 304 } 302 305 fclose(fp); … … 305 308 FillPathListBox(hwnd, 306 309 WinWindowFromID(hwnd, GREP_DRIVELIST), 307 (HWND) 310 (HWND)0, 308 311 NULL, 309 312 FALSE); … … 319 322 case UM_SETDIR: 320 323 PaintRecessedWindow(WinWindowFromID(hwnd, GREP_HELP), 321 (HPS) 324 (HPS)0, 322 325 FALSE, 323 326 TRUE); … … 327 330 /* set focus to window hwnd in mp1 */ 328 331 if (mp1) 329 WinSetFocus(HWND_DESKTOP, (HWND) 332 WinSetFocus(HWND_DESKTOP, (HWND)mp1); 330 333 return 0; 331 334 … … 917 920 if (!hwndCollect) 918 921 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT); 919 else 920 { 922 else { 921 923 static GREP g; // Passed to thread 922 924 … … 926 928 memset(&g, 0, sizeof(GREP)); 927 929 g.size = sizeof(GREP); 928 if (WinQueryButtonCheckstate(hwnd, GREP_RECURSE)) 929 recurse = TRUE; 930 else 931 recurse = FALSE; 932 if (WinQueryButtonCheckstate(hwnd, GREP_ABSOLUTE)) 933 absolute = TRUE; 934 else 935 absolute = FALSE; 936 if (WinQueryButtonCheckstate(hwnd, GREP_CASE)) 937 sensitive = TRUE; 938 else 939 sensitive = FALSE; 940 if (WinQueryButtonCheckstate(hwnd, GREP_SAYFILES)) 941 sayfiles = TRUE; 942 else 943 sayfiles = FALSE; 944 if (WinQueryButtonCheckstate(hwnd, GREP_SEARCHEAS)) 945 searchEAs = TRUE; 946 else 947 searchEAs = FALSE; 948 if (WinQueryButtonCheckstate(hwnd, GREP_SEARCHFILES)) 949 searchFiles = TRUE; 950 else 951 searchFiles = FALSE; 952 if (WinQueryButtonCheckstate(hwnd, GREP_FINDIFANY)) 953 findifany = TRUE; 954 else 955 findifany = FALSE; 956 if (WinQueryButtonCheckstate(hwnd, GREP_FINDDUPES)) 957 g.finddupes = TRUE; 958 else 959 g.finddupes = FALSE; 960 if (g.finddupes) 961 { 962 if (WinQueryButtonCheckstate(hwnd, GREP_CRCDUPES)) 963 g.CRCdupes = TRUE; 964 else 965 g.CRCdupes = FALSE; 966 if (WinQueryButtonCheckstate(hwnd, GREP_NOSIZEDUPES)) 967 g.nosizedupes = TRUE; 968 else 969 g.nosizedupes = FALSE; 970 if (WinQueryButtonCheckstate(hwnd, GREP_IGNOREEXTDUPES)) 971 g.ignoreextdupes = TRUE; 972 else 973 g.ignoreextdupes = FALSE; 974 } 930 recurse = WinQueryButtonCheckstate(hwnd, GREP_RECURSE) != 0; 931 absolute = WinQueryButtonCheckstate(hwnd, GREP_ABSOLUTE) != 0; 932 sensitive = WinQueryButtonCheckstate(hwnd, GREP_CASE) != 0; 933 sayfiles = WinQueryButtonCheckstate(hwnd, GREP_SAYFILES) != 0; 934 searchEAs = WinQueryButtonCheckstate(hwnd, GREP_SEARCHEAS) != 0; 935 searchFiles = WinQueryButtonCheckstate(hwnd, GREP_SEARCHFILES) != 0; 936 findifany = WinQueryButtonCheckstate(hwnd, GREP_FINDIFANY) != 0; 937 g.finddupes = WinQueryButtonCheckstate(hwnd, GREP_FINDDUPES) != 0; 938 if (g.finddupes) { 939 g.CRCdupes = WinQueryButtonCheckstate(hwnd, GREP_CRCDUPES) != 0; 940 g.nosizedupes = WinQueryButtonCheckstate(hwnd, GREP_NOSIZEDUPES) != 0; 941 g.ignoreextdupes = WinQueryButtonCheckstate(hwnd, GREP_IGNOREEXTDUPES) != 0; 942 } 943 // Parse file masks 975 944 *p = 0; 976 WinQueryDlgItemText(hwnd, 977 GREP_MASK, 978 8192, 979 p); 945 WinQueryDlgItemText(hwnd,GREP_MASK,8192,p); 980 946 bstrip(p); 981 947 if (!*p) 982 948 { 983 949 DosBeep(50, 100); 984 WinSetFocus(HWND_DESKTOP, 985 WinWindowFromID(hwnd, GREP_MASK)); 950 WinSetFocus(HWND_DESKTOP,WinWindowFromID(hwnd, GREP_MASK)); 986 951 free(p); 987 952 break; … … 989 954 strcpy(g.tosearch, p); 990 955 strcpy(lastmask, p); 956 // Parse search strings 991 957 *p = 0; 992 WinQueryWindowText(hwndMLE, 993 4096, 994 p); 958 WinQueryWindowText(hwndMLE,4096,p); 995 959 strcpy(lasttext, p); 996 960 { … … 1024 988 *pszTo = 0; 1025 989 g.numlines = matched; 1026 g.matched = xmalloc(g.numlines,pszSrcFile,__LINE__); 1027 if (!g.matched) 1028 g.numlines = 0; 990 if (matched) { 991 g.matched = xmalloc(g.numlines,pszSrcFile,__LINE__); 992 if (!g.matched) 993 g.numlines = 0; 994 } 1029 995 } 1030 996 *p = 0; 1031 WinQueryDlgItemText(hwnd, 1032 GREP_GREATER, 1033 34, 1034 p); 997 WinQueryDlgItemText(hwnd,GREP_GREATER,34,p); 1035 998 greater = atol(p); 1036 999 *p = 0; 1037 WinQueryDlgItemText(hwnd, 1038 GREP_LESSER, 1039 34, 1040 p); 1000 WinQueryDlgItemText(hwnd,GREP_LESSER,34,p); 1041 1001 lesser = atol(p); 1042 1002 *p = 0; 1043 WinQueryDlgItemText(hwnd, 1044 GREP_NEWER, 1045 34, 1046 p); 1003 WinQueryDlgItemText(hwnd,GREP_NEWER,34,p); 1047 1004 newer = atoi(p); 1048 1005 *p = 0; 1049 WinQueryDlgItemText(hwnd, 1050 GREP_OLDER, 1051 34, 1052 p); 1006 WinQueryDlgItemText(hwnd,GREP_OLDER,34,p); 1053 1007 older = atoi(p); 1054 if (older || newer) 1055 { 1008 if (older || newer) { 1056 1009 FDATE fdate; 1057 1010 FTIME ftime; … … 1067 1020 ftime.minutes = tm.tm_min; 1068 1021 ftime.twosecs = tm.tm_sec / 2; 1069 if (older) 1070 { 1022 if (older) { 1071 1023 g.olderthan = SecsSince1980(&fdate, &ftime); 1072 1024 g.olderthan -= (older * (24L * 60L * 60L)); 1073 1025 } 1074 if (newer) 1075 { 1026 if (newer) { 1076 1027 g.newerthan = SecsSince1980(&fdate, &ftime); 1077 1028 g.newerthan -= (newer * (24L * 60L * 60L)); … … 1097 1048 g.antiattr = ((DIRCNRDATA *) INSTDATA(hwndCollect)) -> mask.antiattr; 1098 1049 g.stopflag = &((DIRCNRDATA *) INSTDATA(hwndCollect)) -> stopflag; 1099 if (_beginthread(dogrep, NULL, 524280, (PVOID)&g) == -1) 1100 { 1050 if (_beginthread(dogrep, NULL, 524280, (PVOID)&g) == -1) { 1101 1051 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT)); 1102 1052 free(p); … … 1108 1058 free(p); 1109 1059 } 1110 if (changed) 1111 { 1060 if (changed) { 1112 1061 SHORT x; 1113 1114 1062 sSelect = (SHORT) WinSendDlgItemMsg(hwnd, 1115 1063 GREP_LISTBOX, … … 1117 1065 MPVOID, 1118 1066 MPVOID); 1119 if (sSelect > 0) 1120 { 1067 if (sSelect > 0) { 1121 1068 save_dir2(s); 1122 1069 if (s[strlen(s) - 1] != '\\') … … 1124 1071 strcat(s, "GREPMASK.DAT"); 1125 1072 fp = xfopen(s, "w",pszSrcFile,__LINE__); 1126 if (fp) 1127 { 1073 if (fp) { 1128 1074 fputs(GetPString(IDS_GREPFILETEXT), fp); 1129 for (x = 0; x < sSelect; x++) 1130 { 1075 for (x = 0; x < sSelect; x++) { 1131 1076 *s = 0; 1132 1077 WinSendDlgItemMsg(hwnd,
Note:
See TracChangeset
for help on using the changeset viewer.