Changeset 350
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/dirsize.c
r239 r350 7 7 8 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2001, 200 5Steven H. Levine9 Copyright (c) 2001, 2006 Steven H. Levine 10 10 11 11 16 Oct 02 SHL Handle large partitions … … 20 20 19 Jun 05 SHL More 64-bit math fixes 21 21 08 Aug 05 SHL Avoid Expand/Collapse hangs while working 22 17 Jul 06 SHL Use Runtime_Error 22 23 23 24 ***********************************************************************/ … … 37 38 #include "fm3dlg.h" 38 39 #include "fm3str.h" 39 40 #pragma alloc_text(DIRSIZE,ProcessDir,FillCnrThread,DirSizeProc)41 #pragma alloc_text(DIRSIZE2,PrintToFile,FillInRecSizes,SortSizeCnr)42 40 43 41 typedef struct { … … 56 54 } tState; 57 55 56 57 static PSZ pszSrcFile = __FILE__; 58 59 #pragma alloc_text(DIRSIZE,ProcessDir,FillCnrThread,DirSizeProc) 60 #pragma alloc_text(DIRSIZE2,PrintToFile,FillInRecSizes,SortSizeCnr) 58 61 59 62 static SHORT APIENTRY SortSizeCnr (PMINIRECORDCORE p1,PMINIRECORDCORE p2, … … 92 95 *pullTotalBytes = 0; // In case we fail 93 96 94 pFFB = malloc(sizeof(FILEFINDBUF4) /* * FilesToGet */);97 pFFB = xmalloc(sizeof(FILEFINDBUF4),pszSrcFile,__LINE__); 95 98 if(!pFFB) 96 99 return FALSE; … … 150 153 rc, 151 154 HWND_DESKTOP, 152 __FILE__,155 pszSrcFile, 153 156 __LINE__, 154 157 GetPString(IDS_CANTFINDDIRTEXT), … … 445 448 break; 446 449 } 447 pState = malloc(sizeof(tState));450 pState = xmallocz(sizeof(tState),pszSrcFile,__LINE__); 448 451 if(!pState) { 449 452 WinDismissDlg(hwnd,0); 450 453 break; 451 454 } 452 memset(pState,0,sizeof(tState));453 455 strcpy(pState->szDirName,(CHAR *)mp2); 454 456 WinSetWindowPtr(hwnd,0,(PVOID)pState); … … 466 468 DIRSIZE *dirsize; 467 469 468 dirsize = malloc(sizeof(DIRSIZE));470 dirsize = xmalloc(sizeof(DIRSIZE),pszSrcFile,__LINE__); 469 471 if(!dirsize) { 470 472 WinDismissDlg(hwnd,0); … … 475 477 dirsize->hwndCnr = WinWindowFromID(hwnd,DSZ_CNR); 476 478 if(_beginthread(FillCnrThread,NULL,122880L * 5L,(PVOID)dirsize) == -1) { 479 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT)); 477 480 free(dirsize); 478 481 WinDismissDlg(hwnd,0); … … 573 576 WinSendDlgItemMsg(hwnd,DSZ_CNR,CM_SORTRECORD,MPFROMP(SortSizeCnr), 574 577 MPVOID); 575 DosBeep(500,25); 578 DosBeep(500,25); // Wake up user 576 579 return 0; 577 580 … … 853 856 // Save button 854 857 pState = INSTDATA(hwnd); 855 if (pState) { 858 if (!pState) 859 Runtime_Error(pszSrcFile, __LINE__, "no data"); 860 else { 856 861 857 862 CHAR pszFileName[CCHMAXPATH]; … … 867 872 strcat(pszFileName,".RPT"); 868 873 fp = fopen(pszFileName,"a+"); 869 if (fp) { 874 if (!fp) { 875 saymsg(MB_CANCEL, 876 hwnd, 877 GetPString(IDS_ERRORTEXT), 878 GetPString(IDS_COMPCANTOPENTEXT), 879 pszFileName); 880 } 881 else { 870 882 WinSetPointer(HWND_DESKTOP,hptrBusy); 871 883 PrintToFile(WinWindowFromID(hwnd,DSZ_CNR),0,NULL,fp); … … 873 885 WinSetPointer(HWND_DESKTOP,hptrArrow); 874 886 } 875 else876 saymsg(MB_CANCEL,877 hwnd,878 GetPString(IDS_ERRORTEXT),879 GetPString(IDS_COMPCANTOPENTEXT),880 pszFileName);881 887 } 882 888 } 883 else884 DosBeep(50,100);885 889 break; 886 890 … … 917 921 case DID_CANCEL: 918 922 pState = INSTDATA(hwnd); 919 if (pState) { 923 if (!pState) 924 Runtime_Error(pszSrcFile, __LINE__, "no data"); 925 else { 920 926 if (pState->working) { 921 927 pState->dying = TRUE; 922 928 pState->chStopFlag = 0xff; 923 DosBeep(1000,100); 929 DosBeep(1000,100); // Complain? 924 930 } 925 931 else -
trunk/dll/extract.c
r186 r350 5 5 6 6 Copyright (c) 1993-98 M. Kimes 7 Copyright (c) 2004, 200 5Steven H. Levine7 Copyright (c) 2004, 2006 Steven H. Levine 8 8 9 9 01 Aug 04 SHL Rework lstrip/rstrip usage 10 10 05 Jun 05 SHL Use QWL_USER 11 17 Jul 06 SHL Use Runtime_Error 11 12 12 13 ***********************************************************************/ … … 14 15 #define INCL_WIN 15 16 #define INCL_DOS 16 17 17 #include <os2.h> 18 18 19 #include <stdlib.h> 19 20 #include <stdio.h> … … 21 22 #include <time.h> 22 23 #include <ctype.h> 24 23 25 #include "fm3dll.h" 24 26 #include "fm3dlg.h" … … 26 28 27 29 #pragma data_seg(DATA1) 30 28 31 #pragma alloc_text(FMEXTRACT,ExtractTextProc,ExtractDlgProc) 29 32 30 31 MRESULT EXPENTRY ExtractTextProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { 32 33 static PSZ pszSrcFile = __FILE__; 34 35 MRESULT EXPENTRY ExtractTextProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) 36 { 33 37 PFNWP oldproc = (PFNWP)WinQueryWindowPtr(hwnd,0); 34 38 static BOOL emphasized = FALSE; … … 76 80 77 81 78 MRESULT EXPENTRY ExtractDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {79 82 MRESULT EXPENTRY ExtractDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) 83 { 80 84 EXTRDATA *arcdata = NULL; 81 85 … … 314 318 } 315 319 } 316 DosBeep(50,100); 320 DosBeep(50,100); // Complain a refuse to quit 317 321 break; 318 322 … … 347 351 WinQueryDlgItemText(hwnd,EXT_COMMAND,256,s); 348 352 lstrip(s); 349 if(*s) { 353 if (!*s) 354 Runtime_Error(pszSrcFile, __LINE__, "no command"); 355 else { 350 356 p = strchr(s,' '); 351 if (p)352 *p = 0; 357 if (p) 358 *p = 0; // Drop options 353 359 memset(&ex,0,sizeof(EXECARGS)); 354 360 ex.commandline = s; … … 363 369 MPFROMP(&ex)) && 364 370 *s) 371 { 365 372 runemf2(ex.flags, 366 373 hwnd, … … 369 376 "%s", 370 377 s); 371 } 372 else 373 DosBeep(50,100); 378 } 379 } 374 380 } 375 381 break; -
trunk/dll/grep.c
r281 r350 4 4 $Id$ 5 5 6 Info window6 grep tools 7 7 8 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2001, 200 5Steven H. Levine9 Copyright (c) 2001, 2006 Steven H. Levine 10 10 11 11 12 Feb 03 SHL insert_grepfile: standardize EA math … … 15 15 06 Jun 05 SHL Drop unused code 16 16 24 Oct 05 SHL dononefile: do not free EA list twice 17 22 Jul 06 SHL Use Runtime_Error 17 18 18 19 ***********************************************************************/ … … 34 35 35 36 #pragma data_seg(DATA2) 37 38 static PSZ pszSrcFile = __FILE__; 39 36 40 #pragma alloc_text(GREP,SecsSince1980,match,mmatch,dogrep) 37 41 #pragma alloc_text(GREP,doallsubdirs,domatchingfiles) … … 464 468 /* process all matching files in a directory */ 465 469 466 PFILEFINDBUF4 findBuffer = malloc(grep->FilesToGet * sizeof(FILEFINDBUF4));470 PFILEFINDBUF4 findBuffer; 467 471 PFILEFINDBUF4 pffbFile; 468 472 register PBYTE fb; … … 473 477 APIRET rc; 474 478 479 findBuffer = xmalloc(grep->FilesToGet * sizeof(FILEFINDBUF4),pszSrcFile,__LINE__); 475 480 if(!findBuffer) 476 481 return 0; … … 648 653 *p = 0; 649 654 if(!grep->insertffb) { 650 grep->insertffb = malloc(sizeof(FILEFINDBUF4 *) *651 (grep->FilesToGet + 1));655 grep->insertffb = xmallocz(sizeof(FILEFINDBUF4 *) * 656 (grep->FilesToGet + 1),pszSrcFile,__LINE__); 652 657 if(!grep->insertffb) 653 658 return FALSE; 654 memset(grep->insertffb,0,sizeof(FILEFINDBUF4 *) * 655 (grep->FilesToGet + 1)); 656 grep->dir = malloc(sizeof(CHAR *) * (grep->FilesToGet + 1)); 659 grep->dir = xmallocz(sizeof(CHAR *) * (grep->FilesToGet + 1),pszSrcFile,__LINE__); 657 660 if(!grep->dir) { 658 661 free(grep->insertffb); 659 662 return FALSE; 660 663 } 661 memset(grep->dir,0,sizeof(CHAR *) * (grep->FilesToGet + 1)); 662 } 663 grep->insertffb[grep->toinsert] = malloc(sizeof(FILEFINDBUF4)); 664 } 665 grep->insertffb[grep->toinsert] = xmalloc(sizeof(FILEFINDBUF4),pszSrcFile,__LINE__); 664 666 if(!grep->insertffb[grep->toinsert]) 665 667 return FALSE; 666 668 memcpy(grep->insertffb[grep->toinsert],f,sizeof(FILEFINDBUF4)); 667 grep->dir[grep->toinsert] = strdup(szDirectory);669 grep->dir[grep->toinsert] = xstrdup(szDirectory,pszSrcFile,__LINE__); 668 670 if(!grep->dir) { 669 671 free(grep->insertffb[grep->toinsert]); … … 856 858 857 859 if(grep->searchFiles) { 858 input = malloc(65537);860 input = xmalloc(65537,pszSrcFile,__LINE__); 859 861 if(input) { 860 861 862 LONG len; 862 863 if ((inputFile = _fsopen(filename,"rb",SH_DENYNO)) != NULL) {863 inputFile = _fsopen(filename,"rb",SH_DENYNO); 864 if (inputFile) { 864 865 pos = ftell(inputFile); 865 866 while(!feof(inputFile)) { … … 992 993 993 994 *error = 0; 994 buffer = malloc(65535); 995 if(buffer) { 995 buffer = xmalloc(65535,pszSrcFile,__LINE__); 996 if (!buffer) 997 *error = -1; 998 else { 996 999 fp = _fsopen(filename,"rb",SH_DENYNO); 997 if(fp) { 1000 if (!fp) 1001 *error = -2; 1002 else { 998 1003 while(!feof(fp)) { 999 1004 len = fread(buffer,1,65535,fp); … … 1007 1012 DosSleep(1L); 1008 1013 } 1009 else1010 *error = -2;1011 1014 free(buffer); 1012 1015 } 1013 else1014 *error = -1;1015 1016 return CRC; 1016 1017 } … … 1180 1181 cntr = 50; 1181 1182 i = g->dupehead; 1182 while (i) {1183 while (i) { 1183 1184 x++; 1184 1185 i = i->next; 1185 1186 } 1186 if (x) {1187 if (x) { 1187 1188 WinSetWindowText(g->hwndCurFile, 1188 1189 GetPString(IDS_GREPDUPESORTINGTEXT)); 1189 1190 DosSleep(1L); 1190 1191 g->dupenames = malloc(sizeof(DUPES *) * (x + 1)); 1191 if (!g->nosizedupes)1192 if (!g->nosizedupes) 1192 1193 g->dupesizes = malloc(sizeof(DUPES *) * (x + 1)); 1193 if (g->dupenames && (g->nosizedupes || g->dupesizes)) {1194 if (g->dupenames && (g->nosizedupes || g->dupesizes)) { 1194 1195 i = g->dupehead; 1195 1196 while(i) { … … 1201 1202 } 1202 1203 g->dupenames[y] = NULL; 1203 if (!g->nosizedupes)1204 if (!g->nosizedupes) 1204 1205 g->dupesizes[y] = NULL; 1205 1206 DosSleep(1L); … … 1211 1212 comparenamesq)); 1212 1213 DosSleep(1L); 1213 if (!g->nosizedupes) {1214 if (!g->nosizedupes) { 1214 1215 qsort(g->dupesizes, 1215 1216 x, … … 1380 1381 } 1381 1382 else { 1383 // Insufficient memory - fall back 1382 1384 DosBeep(50,100); 1383 1385 WinSetWindowText(g->hwndCurFile, … … 1461 1463 &numfiles, 1462 1464 &numalloced)) 1463 goto BreakOut; 1465 goto BreakOut; // Failed 1464 1466 if(!(i->flags & GF_INSERTED)) { 1465 1467 if(AddToList(i->name, … … 1467 1469 &numfiles, 1468 1470 &numalloced)) 1469 goto BreakOut; 1471 goto BreakOut; // Failed 1470 1472 } 1471 1473 if(g->sayfiles) … … 1507 1509 DUPES *info; 1508 1510 1509 if(*dir) { 1510 info = malloc(sizeof(DUPES)); 1511 if(info) { 1512 memset(info,0,sizeof(DUPES)); 1513 info->name = strdup(dir); 1514 if(info->name) { 1511 if (*dir) { 1512 info = xmallocz(sizeof(DUPES),pszSrcFile,__LINE__); 1513 if (!info) 1514 return FALSE; 1515 else { 1516 info->name = xstrdup(dir,pszSrcFile,__LINE__); 1517 if (!info->name) { 1518 free(info); 1519 return FALSE; 1520 } 1521 else { 1515 1522 info->size = f->cbFile; 1516 1523 info->date = f->fdateLastWrite; … … 1518 1525 info->CRC = -1L; 1519 1526 g->numfiles++; 1520 if (!g->dupehead)1527 if (!g->dupehead) 1521 1528 g->dupehead = info; 1522 if (g->dupelast)1529 if (g->dupelast) 1523 1530 g->dupelast->next = info; 1524 1531 g->dupelast = info; 1525 1532 info->next = NULL; 1526 return TRUE; 1527 } 1528 else 1529 free(info); 1530 } 1531 DosBeep(50,100); 1532 return FALSE; 1533 } 1534 } 1533 1535 } 1534 1536 return TRUE; -
trunk/dll/killproc.c
r161 r350 7 7 8 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2005 Steven H. Levine9 Copyright (c) 2005, 2006 Steven H. Levine 10 10 11 11 24 May 05 SHL Rework Win_Error usage 12 14 Jul 06 SHL Use Runtime_Error 12 13 13 14 ***********************************************************************/ … … 16 17 #define INCL_DOS 17 18 #define INCL_WIN 18 19 19 #include <os2.h> 20 20 21 #include <stdlib.h> 21 22 #include <stdio.h> … … 25 26 #include <process.h> 26 27 #include <limits.h> 28 27 29 #include "procstat.h" 28 30 #include "fm3dll.h" … … 31 33 32 34 #pragma data_seg(DATA2) 35 36 static PSZ pszSrcFile = __FILE__; 37 33 38 #pragma alloc_text(KILLPROC,FillKillList,FillKillList2,GetDosPgmName,KillDlgProc) 34 39 35 36 CHAR *GetDosPgmName (PID pid,CHAR *string) { 37 40 CHAR *GetDosPgmName (PID pid,CHAR *string) 41 { 38 42 HSWITCH hs; 39 43 SWCNTRL swctl; … … 64 68 65 69 66 VOID FillKillList2 (VOID *arg) {67 70 VOID FillKillList2 (VOID *arg) 71 { 68 72 HWND hwnd = *(HWND *)arg; 69 73 CHAR s[1036]; … … 80 84 81 85 WinSendDlgItemMsg(hwnd,KILL_LISTBOX,LM_DELETEALL,MPVOID,MPVOID); 82 if(!DosAllocMem((PVOID)&pbh,USHRT_MAX + 4096, 83 PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE)) { 86 rc = DosAllocMem((PVOID)&pbh,USHRT_MAX + 4096, 87 PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE); 88 if (rc) 89 Dos_Error(MB_CANCEL,rc,HWND_DESKTOP,pszSrcFile,__LINE__,GetPString(IDS_OUTOFMEMORY)); 90 else { 84 91 rc = DosQProcStatus(pbh,USHRT_MAX); 85 if (!rc) {92 if (!rc) { 86 93 ppi = pbh->ppi; 87 94 while(ppi->ulEndIndicator != PROCESS_END_INDICATOR ) { … … 100 107 strcat(s,GetPString(IDS_UNKNOWNPROCTEXT)); 101 108 } 102 if (WinIsWindow(thab,hwnd))109 if (WinIsWindow(thab,hwnd)) { 103 110 WinSendDlgItemMsg(hwnd,KILL_LISTBOX,LM_INSERTITEM, 104 111 MPFROM2SHORT(LIT_SORTASCENDING,0), 105 112 MPFROMP(s)); 113 } 106 114 else 107 115 break; … … 109 117 } 110 118 ppi = (PPROCESSINFO)(ppi->ptiFirst + ppi->usThreadCount); 111 } 119 } // while 112 120 } 113 121 DosFreeMem(pbh); 114 122 } 115 Abort: 123 116 124 if(WinIsWindow(thab,hwnd)) 117 125 PostMsg(hwnd,UM_CONTAINER_FILLED,MPVOID,MPVOID); … … 121 129 122 130 123 VOID FillKillList (VOID *arg) {124 131 VOID FillKillList (VOID *arg) 132 { 125 133 HWND hwnd = *(HWND *)arg; 126 134 CHAR s[1036],progname[1027],*p; … … 149 157 unlinkf("%s",s); 150 158 fp = fopen(s,"w"); 151 if(fp) { 159 if(!fp) { 160 Win_Error(NULLHANDLE,HWND_DESKTOP,__FILE__,__LINE__, 161 GetPString(IDS_REDIRECTERRORTEXT)); 162 goto Abort; 163 } 164 else { 152 165 newstdout = -1; 153 if(DosDupHandle(fileno(stdout),&newstdout)) 154 DosBeep(50,100); 166 rc = DosDupHandle(fileno(stdout),&newstdout); 167 if (rc) 168 Dos_Error(MB_CANCEL,rc,hwnd,__FILE__,__LINE__,"DosDupHandle"); 155 169 oldstdout = fileno(stdout); 156 170 DosDupHandle(fileno(fp),&oldstdout); … … 173 187 } 174 188 } 175 else {176 Win_Error(NULLHANDLE,HWND_DESKTOP,__FILE__,__LINE__,177 GetPString(IDS_REDIRECTERRORTEXT));178 goto Abort;179 }180 189 fp = fopen(s,"r"); 181 190 if(fp) { … … 225 234 226 235 227 MRESULT EXPENTRY KillDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {228 236 MRESULT EXPENTRY KillDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) 237 { 229 238 SHORT sSelect; 230 239 PID pid; … … 387 396 if(SHORT1FROMMP(mp1) == DID_OK) { 388 397 error = DosKillProcess(DKP_PROCESS,pid); 389 if(error && error != ERROR_INVALID_PROCID) 398 if(error && error != ERROR_INVALID_PROCID) { 390 399 Dos_Error(MB_CANCEL, 391 400 error, … … 394 403 __LINE__, 395 404 GetPString(IDS_DOSKILLFAILEDTEXT)); 405 } 396 406 else 397 407 WinSendDlgItemMsg(hwnd, … … 409 419 410 420 case DID_CANCEL: 411 if(listdone) 421 if(!listdone) 422 Runtime_Error(pszSrcFile, __LINE__, "busy"); 423 else 412 424 WinDismissDlg(hwnd,0); 413 else414 DosBeep(100,100);415 425 break; 416 426 … … 426 436 case WM_CLOSE: 427 437 if(!listdone) { 428 DosBeep(100,100);438 Runtime_Error(pszSrcFile, __LINE__, "busy"); 429 439 return 0; 430 440 } -
trunk/dll/misc.c
r245 r350 7 7 8 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2003, 200 5Steven H. Levine9 Copyright (c) 2003, 2006 Steven H. Levine 10 10 11 11 11 Jun 03 SHL Add JFS and FAT32 support … … 15 15 24 Jul 05 SHL Beautify 16 16 24 Jul 05 SHL Correct longname display option 17 17 Jul 06 SHL Use Runtime_Error 17 18 18 19 ***********************************************************************/ … … 21 22 #define INCL_WIN 22 23 #define INCL_GPI 23 24 24 #include <os2.h> 25 25 26 #include <stdarg.h> 26 27 #include <stdio.h> … … 29 30 #include <ctype.h> 30 31 #include <share.h> 32 31 33 #include "fm3dll.h" 32 34 #include "fm3dlg.h" … … 34 36 35 37 #pragma data_seg(DATA1) 38 39 static PSZ pszSrcFile = __FILE__; 40 36 41 #pragma alloc_text(MAINWND5,SetSysMenu) 37 42 #pragma alloc_text(MISC1,BoxWindow,PaintRecessedWindow,PostMsg,PaintSTextWindow) … … 165 170 len = WinQueryWindowTextLength(hwnd); 166 171 if (len) 167 s = malloc(len + 1);172 s = xmalloc(len + 1,pszSrcFile,__LINE__); 168 173 if (s) 169 174 { … … 756 761 else 757 762 ealen = sizeof(FEALIST) + 9; 758 if (!DosAllocMem((PPVOID) & pfealist, 759 ealen + 64L, 760 OBJ_TILE | PAG_COMMIT | PAG_READ | PAG_WRITE)) 761 { 763 rc = DosAllocMem((PPVOID) & pfealist,ealen + 64L, 764 OBJ_TILE | PAG_COMMIT | PAG_READ | PAG_WRITE); 765 if (rc) 766 Dos_Error(MB_CANCEL,rc,HWND_DESKTOP,pszSrcFile,__LINE__,GetPString(IDS_OUTOFMEMORY)); 767 else { 762 768 memset(pfealist, 0, ealen + 1); 763 769 pfealist -> cbList = ealen; … … 831 837 *p = 0; 832 838 bstrip(szData); 833 if (IsFullName(szData)) 839 if (!IsFullName(szData)) 840 Runtime_Error(pszSrcFile, __LINE__, "bad name"); 841 else 834 842 { 835 843 if (DosQueryPathInfo(szData, … … 853 861 return (MRESULT) FALSE; 854 862 } 855 if (!docopyf(MOVE, 856 szData, 857 "%s", 858 testname)) 859 { 860 863 if (docopyf(MOVE,szData,"%s",testname)) 864 Runtime_Error(pszSrcFile, __LINE__, "docopyf"); 865 else { 861 866 CHAR *filename; 862 867 863 filename = strdup(testname);868 filename = xstrdup(testname,pszSrcFile,__LINE__); 864 869 if (filename) 865 870 { … … 876 881 MPFROMLONG(-1), 877 882 MPFROMP(pci)); 878 filename = strdup(pci -> szFileName);883 filename = xstrdup(pci -> szFileName,pszSrcFile,__LINE__); 879 884 if (filename) 880 885 { … … 887 892 } 888 893 } 889 else890 DosBeep(100, 100);891 894 } 892 895 } 893 else894 DosBeep(250, 100);895 896 } 896 897 } … … 1447 1448 { 1448 1449 ULONG postcount; 1449 1450 if (!DosCreateEventSem(NULL, &CompactSem, 0L, FALSE)) 1450 APIRET rc; 1451 1452 rc = DosCreateEventSem(NULL, &CompactSem, 0L, FALSE); 1453 if (rc) 1454 Dos_Error(MB_CANCEL,rc,HWND_DESKTOP,pszSrcFile,__LINE__,"DosCreateEventSem"); 1455 else 1451 1456 { 1452 1457 priority_normal(); … … 1458 1463 DosResetEventSem(CompactSem, &postcount); 1459 1464 } 1460 }1461 else1462 {1463 DosBeep(250, 100);1464 DosBeep(1000, 100);1465 DosBeep(500, 100);1466 // DosExit(EXIT_PROCESS,1);1467 1465 } 1468 1466 } … … 2078 2076 *var = 0; 2079 2077 } 2080 fp = fopen(configsys, "r");2078 fp = xfopen(configsys, "r",pszSrcFile,__LINE__); 2081 2079 if (fp) 2082 2080 { … … 2118 2116 char *s = NULL; 2119 2117 2120 s = malloc(CCHMAXPATH);2118 s = xmalloc(CCHMAXPATH,pszSrcFile,__LINE__); 2121 2119 if (s) 2122 2120 { … … 2143 2141 char *s = NULL; 2144 2142 2145 s = malloc(CCHMAXPATH);2143 s = xmalloc(CCHMAXPATH,pszSrcFile,__LINE__); 2146 2144 if (s) 2147 2145 { … … 2163 2161 char *s = NULL; 2164 2162 2165 s = malloc(CCHMAXPATH * 2);2163 s = xmalloc(CCHMAXPATH * 2,pszSrcFile,__LINE__); 2166 2164 if (s) 2167 2165 { … … 2303 2301 (LONG) sizeof(SWENTRY); 2304 2302 /* Allocate memory for list */ 2305 if ((pswb = malloc((unsigned) ulSize)) != NULL)2306 {2303 pswb = xmalloc(ulSize,pszSrcFile,__LINE__); 2304 if (pswb) { 2307 2305 /* Put the info in the list */ 2308 2306 ulcEntries = WinQuerySwitchList(0, pswb, -
trunk/dll/mle.c
r301 r350 7 7 8 8 Copyright (c) 1993-97 M. Kimes 9 Copyright (c) 2004 Steven H.Levine9 Copyright (c) 2004, 2006 Steven H.Levine 10 10 11 11 01 Aug 04 SHL Rework lstrip/rstrip usage 12 12 16 Apr 06 SHL MLEexportfile: rework to avoid wrap problems 13 14 Jul 06 SHL Use Runtime_Error 13 14 14 15 ***********************************************************************/ 15 16 /* MLE support functions */17 16 18 17 #define INCL_DOS 19 18 #define INCL_WIN 20 21 19 #include <os2.h> 20 22 21 #include <stdlib.h> 23 22 #include <stdio.h> … … 25 24 #include <ctype.h> 26 25 #include <share.h> 26 27 27 #include "fm3dll.h" 28 28 #include "fm3dlg.h" 29 29 #include "mle.h" 30 30 #include "fm3str.h" 31 32 static PSZ pszSrcFile = __FILE__; 31 33 32 34 #pragma alloc_text(FMMLE,MLEgetlinetext,MLEdeleteline,MLEdeletecurline,MLEdeletetoeol) … … 152 154 IPT ancpos,curpos,here; 153 155 LONG len,oldlen; 156 APIRET rc; 154 157 155 158 len = MLEsizeofsel(h); 156 159 len = min(2048,len); 157 160 oldlen = len; 158 if (len) {161 if (len) { 159 162 len++; 160 if(!DosAllocMem((PVOID)&temp,4096, 161 PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE) && temp) { 163 rc = DosAllocMem((PVOID)&temp,4096, 164 PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE); 165 if (rc || !temp) 166 Dos_Error(MB_CANCEL,rc,h,pszSrcFile,__LINE__,GetPString(IDS_OUTOFMEMORY)); 167 else { 162 168 ancpos = MLEancpos(h); 163 169 curpos = MLEcurpos(h); … … 165 171 WinSendMsg(h,MLM_SETIMPORTEXPORT,MPFROMP(temp),MPFROMLONG(len)); 166 172 len = (LONG)WinSendMsg(h,MLM_EXPORT,MPFROMP(&here),MPFROMP(&len)); 167 if(len > 1) { 173 if (len <= 1) 174 Runtime_Error(pszSrcFile, __LINE__, "len <= 1"); 175 else { 168 176 if(len > oldlen) 169 177 len--; … … 189 197 } 190 198 } 191 else192 DosBeep(50,100);193 199 DosFreeMem(temp); 194 200 } … … 205 211 IPT ancpos,curpos,here; 206 212 LONG sellen,oldlen; 213 APIRET rc; 207 214 208 215 oldlen = MLEsizeofsel(h); 209 216 if(!oldlen) 210 217 return TRUE; 211 sel = malloc((INT)(oldlen + 2)); 212 if(!sel) { 213 DosBeep(50,100); 218 sel = xmallocz((size_t)(oldlen + 2),pszSrcFile,__LINE__); 219 if (!sel) 214 220 return FALSE; 215 } 216 memset(sel,0,(INT)(oldlen + 2)); 217 if(DosAllocMem((PVOID)&temp,32768L, 218 PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE) || 219 !temp) { 220 DosBeep(50,100); 221 rc = DosAllocMem((PVOID)&temp,32768L, 222 PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE); 223 if (rc || !temp) { 224 Dos_Error(MB_CANCEL,rc,h,pszSrcFile,__LINE__,GetPString(IDS_OUTOFMEMORY)); 221 225 free(sel); 222 226 DosPostEventSem(CompactSem); … … 233 237 WinSendMsg(h,MLM_SETIMPORTEXPORT,MPFROMP(temp),MPFROMLONG(sellen)); 234 238 sellen = (LONG)WinSendMsg(h,MLM_EXPORT,MPFROMP(&here),MPFROMP(&sellen)); 235 if (sellen < 1) {236 DosBeep(50,100);239 if (sellen < 1) { 240 Runtime_Error(pszSrcFile, __LINE__, "len < 1"); 237 241 free(sel); 238 242 DosPostEventSem(CompactSem); … … 260 264 fp = fopen(filename,"a+"); 261 265 if(!fp) 262 fp = fopen(filename,"w");263 if (fp) {266 fp = xfopen(filename,"w",pszSrcFile,__LINE__); 267 if (fp) { 264 268 fseek(fp,0L,SEEK_END); 265 269 fwrite(sel,1,strlen(sel),fp); … … 267 271 } 268 272 #ifdef __DEBUG_ALLOC__ 269 _heap_check();273 _heap_check(); 270 274 #endif 271 275 DosFreeMem(temp); … … 365 369 MPFROMP(&here), 366 370 MPFROMLONG(sellen)); 367 if (!sellen) {368 DosBeep(50,100);371 if (!sellen) { 372 Runtime_Error(pszSrcFile, __LINE__, "sellen 0"); 369 373 break; 370 374 } … … 373 377 if(oldlen && *p == '\n' /* && *(p - 1) == '\r' */) 374 378 p--; 375 } 379 } // while 376 380 WinSendMsg(h,MLM_SETSEL,MPFROMLONG(ancpos),MPFROMLONG(curpos)); 377 381 MLEenable(h); … … 454 458 XMLEWNDPTR *vw; 455 459 HFILE handle; 460 APIRET rc; 456 461 457 462 *titletext = 0; … … 463 468 *titletext = 0; 464 469 WinQueryWindowText(grandpa,512,titletext); 465 if(!DosOpen(filename,&handle,&action,0L,0L, 466 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, 467 OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NOINHERIT | 468 OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYNONE | 469 OPEN_ACCESS_READONLY,0L)) { 470 rc = DosOpen(filename,&handle,&action,0L,0L, 471 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, 472 OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NOINHERIT | 473 OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYNONE | 474 OPEN_ACCESS_READONLY,0L); 475 if (rc) { 476 ret = FALSE; 477 } 478 else { 470 479 DosChgFilePtr(handle, 0L, FILE_END, &len); 471 480 DosChgFilePtr(handle, 0L, FILE_BEGIN, &action); 472 if(len) { 473 if(!DosAllocMem((PVOID)&hexbuff,50001L, 474 PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE) && 475 hexbuff) { 476 buffer = malloc(10000); 477 if(buffer) { 481 if (len) { 482 rc = DosAllocMem((PVOID)&hexbuff,50001L, 483 PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE); 484 if (rc || !hexbuff) { 485 Dos_Error(MB_CANCEL,rc,h,pszSrcFile,__LINE__,GetPString(IDS_OUTOFMEMORY)); 486 ret = FALSE; 487 } 488 else { 489 buffer = xmalloc(10000,pszSrcFile,__LINE__); 490 if (!buffer) 491 ret = FALSE; 492 else { 478 493 MLEclearall(h); 479 494 WinSendMsg(h,MLM_SETIMPORTEXPORT,MPFROMP(hexbuff), … … 540 555 } 541 556 sprintf(s, 542 GetPString(IDS_LOADING 2TEXT),557 GetPString(IDS_LOADINGMLETEXT), 543 558 len); 544 559 WinSetWindowText(grandpa,s); … … 550 565 free(buffer); 551 566 } 552 else {553 saymsg(MB_CANCEL | MB_ICONEXCLAMATION,554 HWND_DESKTOP,555 GetPString(IDS_ARGHTEXT),556 GetPString(IDS_OUTOFMEMORY));557 ret = FALSE;558 }559 567 DosFreeMem(hexbuff); 560 }561 else {562 saymsg(MB_CANCEL | MB_ICONEXCLAMATION,563 HWND_DESKTOP,564 GetPString(IDS_ARGHTEXT),565 GetPString(IDS_OUTOFMEMORY));566 ret = FALSE;567 568 } 568 569 } … … 571 572 DosClose(handle); 572 573 } 573 else574 ret = FALSE;575 574 if(!first) { 576 575 WinEnableWindowUpdate(h,TRUE); … … 582 581 583 582 583 //== MLEinsertfile() insert a file into the current position in the MLE == 584 584 585 BOOL MLEinsertfile (HWND h,CHAR *filename) 585 586 { 586 /* insert a file into the current position in the MLE */587 587 588 588 HAB hab; … … 609 609 titletext); 610 610 fp = _fsopen(filename,"r",SH_DENYNO); 611 if(fp) { 611 if (!fp) 612 ret = FALSE; 613 else { 612 614 setvbuf(fp,NULL,_IONBF,0); 613 615 fseek(fp,0L,SEEK_END); … … 615 617 fseek(fp,0L,SEEK_SET); 616 618 if(len && len != -1) { 617 if(!DosAllocMem((PVOID)&buffer,619 rc = DosAllocMem((PVOID)&buffer, 618 620 50000L, 619 PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE) && 620 buffer) { 621 PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE); 622 if (rc || !buffer) { 623 Dos_Error(MB_CANCEL,rc,h,pszSrcFile,__LINE__,GetPString(IDS_OUTOFMEMORY)); 624 ret = FALSE; 625 } 626 else { 621 627 WinSendMsg(h, 622 628 MLM_SETIMPORTEXPORT, … … 716 722 } 717 723 sprintf(s, 718 GetPString(IDS_LOADING 2TEXT),724 GetPString(IDS_LOADINGMLETEXT), 719 725 len); 720 726 WinSetWindowText(grandpa,s); … … 724 730 DosFreeMem(buffer); 725 731 } 726 else {727 saymsg(MB_CANCEL | MB_ICONEXCLAMATION,728 HWND_DESKTOP,729 GetPString(IDS_ARGHTEXT),730 GetPString(IDS_OUTOFMEMORY));731 ret = FALSE;732 }733 732 } 734 733 if(WinIsWindow(hab,h)) … … 736 735 fclose(fp); 737 736 } 738 else739 ret = FALSE;740 737 if(!first) { 741 738 WinEnableWindowUpdate(h,TRUE); … … 798 795 799 796 INT MLEbackgroundload (HWND hwndReport,ULONG msg,HWND h,CHAR *filename, 800 INT hex) { 801 802 /* load a file into the MLE in the background (via a separate thread) */ 797 INT hex) 798 { 799 /* load a file into the MLE in the background (via a separate thread) 800 * return _beginthread status 801 */ 803 802 804 803 BKGLOAD *bkg; 805 806 bkg = malloc(sizeof(BKGLOAD)); 807 if(bkg) { 808 memset(bkg,0,sizeof(BKGLOAD)); 809 bkg->size = sizeof(BKGLOAD); 810 bkg->hex = (USHORT)hex; 811 bkg->hwndReport = hwndReport; 812 bkg->msg = msg; 813 bkg->h = h; 814 strcpy(bkg->filename,filename); 815 return _beginthread(LoadThread,NULL,65536,bkg); 816 } 817 return -1; 804 INT rc; 805 806 bkg = xmallocz(sizeof(BKGLOAD),pszSrcFile,__LINE__); 807 if (!bkg) 808 return -1; 809 bkg->size = sizeof(BKGLOAD); 810 bkg->hex = (USHORT)hex; 811 bkg->hwndReport = hwndReport; 812 bkg->msg = msg; 813 bkg->h = h; 814 strcpy(bkg->filename,filename); 815 rc = _beginthread(LoadThread,NULL,65536,bkg); 816 if (rc == -1) 817 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT)); 818 return rc; 818 819 } 819 820 … … 854 855 INT blanklines = 0; 855 856 BOOL fWrap = MLEgetwrap(h); 857 APIRET rc; 856 858 857 859 // saymsg(MB_ENTER,h,DEBUG_STRING,"len = %ld",MLEgetlen(h)); … … 881 883 } 882 884 883 if(!DosAllocMem((PVOID)&buffer,4096L, 884 PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE) && 885 buffer) { 885 rc = DosAllocMem((PVOID)&buffer,4096L, 886 PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE); 887 if (rc || !buffer) { 888 Dos_Error(MB_CANCEL,rc,h,pszSrcFile,__LINE__,GetPString(IDS_OUTOFMEMORY)); 889 ok = FALSE; 890 } 891 else 892 { 886 893 fp = fopen(filename,"a+"); 887 if(!fp) 888 fp = fopen(filename,"w"); 889 if(fp) { 890 894 if (!fp) 895 fp = xfopen(filename,"w",pszSrcFile,__LINE__); 896 if (!fp) 897 ok = FALSE; 898 else { 891 899 LONG numlines,ret,len,wl,temp; 892 900 IPT s; … … 954 962 } // for lines 955 963 } 956 else 957 ok = FALSE; 958 } 959 else 960 ok = FALSE; 964 } 961 965 962 966 MLEsetwrap(h, fWrap); // Restore -
trunk/dll/newview.c
r218 r350 7 7 8 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2001, 200 5Steven H. Levine9 Copyright (c) 2001, 2006 Steven H. Levine 10 10 11 11 01 Dec 03 SHL Comments … … 14 14 06 Jun 05 SHL Indent -i2 15 15 06 Jun 05 SHL Correct reversed wrap logic 16 17 Jul 06 SHL Use Runtime_Error 16 17 17 18 ***********************************************************************/ … … 20 21 #define INCL_WIN 21 22 #define INCL_GPI 22 23 23 #include <os2.h> 24 24 25 #include <stdlib.h> 25 26 #include <stdio.h> … … 29 30 #include <limits.h> 30 31 #include <share.h> 32 31 33 #include "fm3dll.h" 32 34 #include "fm3dlg.h" … … 35 37 36 38 #pragma data_seg(DATA2) 39 40 static PSZ pszSrcFile = __FILE__; 41 37 42 #pragma alloc_text(NEWVIEW,ViewStatusProc,FreeViewerMem,LoadFile) 38 43 #pragma alloc_text(NEWVIEW,InitWindow,PaintLine,ViewWndProc) … … 252 257 } 253 258 } 254 DosBeep(250, 100);259 Runtime_Error(pszSrcFile, __LINE__, "no data"); 255 260 break; 256 261 … … 1129 1134 { 1130 1135 fp = _fsopen(filename, "a+", SH_DENYWR); 1131 if (fp) 1132 { 1136 if (!fp) { 1137 saymsg(MB_CANCEL, 1138 hwnd, 1139 GetPString(IDS_ERRORTEXT), 1140 GetPString(IDS_CANTOPENFORWRITETEXT), 1141 filename); 1142 } 1143 else { 1133 1144 fseek(fp, 0L, SEEK_END); 1134 1145 for (x = 0; list[x]; x++) … … 1138 1149 fclose(fp); 1139 1150 } 1140 else1141 saymsg(MB_CANCEL,1142 hwnd,1143 GetPString(IDS_ERRORTEXT),1144 GetPString(IDS_CANTOPENFORWRITETEXT),1145 filename);1146 1151 } 1147 1152 } … … 1182 1187 ULONG width, numlines, firstline = 1, cursored = 1; 1183 1188 1184 // DosBeep(50,100);1185 1189 priority_normal(); 1186 1190 hab2 = WinInitialize(0); … … 1281 1285 CHAR **temp; 1282 1286 1283 temp = realloc(ad -> lines, sizeof(CHAR *) * 1284 (ad -> numalloc + 256)); 1285 if (temp) 1286 { 1287 ad -> lines = temp; 1288 ad -> numalloc += 256; 1289 } 1290 else 1287 temp = xrealloc(ad -> lines, sizeof(CHAR *) * 1288 (ad -> numalloc + 256),pszSrcFile,__LINE__); 1289 if (!temp) 1291 1290 break; 1291 ad -> lines = temp; 1292 ad -> numalloc += 256; 1292 1293 } 1293 1294 ad -> lines[ad -> numlines] = p; … … 1295 1296 if (ad -> numlines == numlines) 1296 1297 { 1297 1298 1298 /* display first page */ 1299 1300 1299 register INT x; 1301 1300 … … 1327 1326 CHAR **temp; 1328 1327 1329 temp = realloc(ad -> lines, sizeof(CHAR *) * ad -> numlines);1328 temp = xrealloc(ad -> lines, sizeof(CHAR *) * ad -> numlines,pszSrcFile,__LINE__); 1330 1329 if (temp) 1331 1330 { … … 1343 1342 if (ad -> numlines) 1344 1343 { 1345 ad -> markedlines = malloc(ad -> numlines);1344 ad -> markedlines = xmalloc(ad -> numlines,pszSrcFile,__LINE__); 1346 1345 if (ad -> markedlines) 1347 1346 { … … 1422 1421 OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYNONE | 1423 1422 OPEN_ACCESS_READONLY, 0L); 1424 if (!rc) 1425 { 1423 if (rc) { 1424 Dos_Error(MB_CANCEL, 1425 rc, 1426 hwnd, 1427 pszSrcFile, 1428 __LINE__, 1429 GetPString(IDS_COMPCANTOPENTEXT), 1430 ad -> filename); 1431 } 1432 else { 1426 1433 DosChgFilePtr(handle, 0L, FILE_END, &len); 1427 1434 DosChgFilePtr(handle, 0L, FILE_BEGIN, &action); 1428 if (len) 1429 { 1430 ad -> text = malloc(len + 2); 1435 if (!len) { 1436 saymsg(MB_CANCEL, 1437 hwnd, 1438 GetPString(IDS_ERRORTEXT), 1439 GetPString(IDS_ZEROLENGTHTEXT), 1440 ad -> filename); 1441 } 1442 else { 1443 ad -> text = xmalloc(len + 2,pszSrcFile,__LINE__); 1431 1444 if (ad -> text) 1432 1445 { 1433 1446 *ad -> text = 0; 1434 1447 ad -> text[len] = 0; 1435 if (!DosRead(handle, ad -> text, len, &ad -> textsize)) 1436 { 1437 ad -> text[ad -> textsize] = 0; 1438 if (!ad -> hex && !(ad -> flags & (8 | 16)) && ad -> textsize) 1439 { 1440 1441 ULONG x; 1442 1443 x = min(512, ad -> textsize); 1444 if (fGuessType && IsBinary(ad -> text, x)) 1445 ad -> hex = TRUE; 1446 } 1447 if (ad -> textsize && 1448 _beginthread(ReLine, NULL, 524288, (PVOID) hwnd) != -1) 1449 error = FALSE; 1450 } 1451 else 1452 { 1448 rc = DosRead(handle, ad -> text, len, &ad -> textsize); 1449 if (rc) { 1453 1450 Dos_Error(MB_CANCEL, 1454 1451 rc, 1455 1452 hwnd, 1456 __FILE__,1453 pszSrcFile, 1457 1454 __LINE__, 1458 1455 GetPString(IDS_ERRORREADINGTEXT), … … 1462 1459 ad -> textsize = 0; 1463 1460 } 1461 else { 1462 ad -> text[ad -> textsize] = 0; 1463 if (!ad -> hex && !(ad -> flags & (8 | 16)) && ad -> textsize) 1464 { 1465 ULONG x; 1466 x = min(512, ad -> textsize); 1467 if (fGuessType && IsBinary(ad -> text, x)) 1468 ad -> hex = TRUE; 1469 } 1470 if (ad -> textsize) { 1471 if (_beginthread(ReLine, NULL, 524288, (PVOID) hwnd) == -1) 1472 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT)); 1473 else 1474 error = FALSE; 1475 } 1476 } 1464 1477 } 1465 1478 } 1466 else1467 saymsg(MB_CANCEL,1468 hwnd,1469 GetPString(IDS_ERRORTEXT),1470 GetPString(IDS_ZEROLENGTHTEXT),1471 ad -> filename);1472 1479 DosClose(handle); 1473 1480 } 1474 else1475 Dos_Error(MB_CANCEL,1476 rc,1477 hwnd,1478 __FILE__,1479 __LINE__,1480 GetPString(IDS_COMPCANTOPENTEXT),1481 ad -> filename);1482 1481 } 1483 1482 ad -> busy--; … … 1730 1729 if (!*s) 1731 1730 { 1732 DosBeep(250, 100); 1731 DosBeep(250, 100); // Complain 1733 1732 break; 1734 1733 } … … 1844 1843 1845 1844 case UM_SETUP: 1846 if (ad) 1847 { 1845 if (!ad) { 1846 Runtime_Error(pszSrcFile, __LINE__, "no data"); 1847 } 1848 else { 1849 CHAR s[CCHMAXPATH + 8]; 1850 APIRET rc; 1848 1851 ad -> hwndMenu = WinWindowFromID(ad -> hwndFrame, FID_MENU); 1849 1852 ad -> hvscroll = WinWindowFromID(ad -> hwndFrame, FID_VERTSCROLL); … … 1857 1860 MPFROM2SHORT(1, 1), 1858 1861 MPVOID); 1859 { 1860 CHAR s[CCHMAXPATH + 8]; 1861 1862 sprintf(s, 1863 "%s: %s", 1864 FM2Str, 1865 ad -> filename); 1866 WinSetWindowText(ad -> hwndFrame, 1867 s); 1868 } 1869 if (!DosCreateMutexSem(NULL, &ad -> ScanSem, 0L, FALSE)) 1870 { 1862 sprintf(s, 1863 "%s: %s", 1864 FM2Str, 1865 ad -> filename); 1866 WinSetWindowText(ad -> hwndFrame, 1867 s); 1868 rc = DosCreateMutexSem(NULL, &ad -> ScanSem, 0L, FALSE); 1869 if (rc) 1870 Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,"DosCreateMutexSem"); 1871 else { 1872 PFNWP oldproc; 1871 1873 WinSendMsg(ad -> hvscroll, 1872 1874 SBM_SETSCROLLBAR, … … 1943 1945 NULL, 1944 1946 NULL); 1945 { 1946 PFNWP oldproc; 1947 1948 oldproc = WinSubclassWindow(ad -> hwndFrame, (PFNWP) ViewFrameWndProc); 1949 if (oldproc) 1950 WinSetWindowPtr(ad -> hwndFrame, QWL_USER, (PVOID) oldproc); 1951 ad -> hps = InitWindow(hwnd); 1952 if (_beginthread(LoadFile, NULL, 524288, (PVOID) hwnd) != -1) 1953 { 1954 WinSendMsg(hwnd, UM_SETUP5, MPVOID, MPVOID); 1955 DosSleep(32L); 1956 return (MRESULT) 1; 1957 } 1958 } 1959 } 1960 } 1961 DosBeep(250, 100); 1947 oldproc = WinSubclassWindow(ad -> hwndFrame, (PFNWP) ViewFrameWndProc); 1948 if (oldproc) 1949 WinSetWindowPtr(ad -> hwndFrame, QWL_USER, (PVOID) oldproc); 1950 ad -> hps = InitWindow(hwnd); 1951 if (_beginthread(LoadFile, NULL, 524288, (PVOID) hwnd) == -1) 1952 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT)); 1953 else { 1954 WinSendMsg(hwnd, UM_SETUP5, MPVOID, MPVOID); 1955 DosSleep(32L); 1956 return (MRESULT)1; 1957 } 1958 } 1959 } 1960 // Oops 1962 1961 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT)); 1963 1962 return 0; … … 2087 2086 if (_beginthread(ReLine, NULL, 524288, (PVOID) hwnd) == -1) 2088 2087 { 2089 DosBeep(50, 100);2088 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT)); 2090 2089 DosReleaseMutexSem(ad -> ScanSem); 2091 2090 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT)); … … 2491 2490 URLDATA *urld; 2492 2491 2493 urld = malloc(sizeof(URLDATA)); 2494 if (urld) 2495 { 2496 memset(urld, 0, sizeof(URLDATA)); 2492 urld = xmallocz(sizeof(URLDATA),pszSrcFile,__LINE__); 2493 if (urld) { 2497 2494 urld -> size = sizeof(URLDATA); 2498 2495 urld -> line = ad -> lines[whichline]; … … 2500 2497 ret = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, UrlDlgProc, 2501 2498 FM3ModHandle, URL_FRAME, urld); 2502 switch (ret) 2503 { 2499 switch (ret) { 2504 2500 case 0: 2505 2501 free(urld); … … 2553 2549 if (!ad -> hex && ad -> lines) 2554 2550 { 2555 s = malloc(width + 2);2551 s = xmalloc(width + 2,pszSrcFile,__LINE__); 2556 2552 if (!s) 2557 {2558 DosBeep(50, 100);2559 2553 goto NoAdd; 2560 }2561 2554 strncpy(s, ad -> lines[whichline], width + 1); 2562 2555 s[width + 1] = 0; … … 2579 2572 width = ad -> textsize - (whichline * 16); 2580 2573 width = min(width, 16); 2581 s = malloc(80);2574 s = xmalloc(80,pszSrcFile,__LINE__); 2582 2575 if (!s) 2583 {2584 DosBeep(50, 100);2585 2576 goto NoAdd; 2586 }2587 2577 sprintf(s, "%08lx ", whichline * 16); 2588 2578 p = s + 9; … … 2840 2830 { 2841 2831 if (!ad -> text) 2842 DosBeep(250, 100);2832 Runtime_Error(pszSrcFile, __LINE__, "no data"); 2843 2833 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID); 2844 2834 } … … 3686 3676 (PVOID) ad -> searchtext); 3687 3677 if (_beginthread(Search, NULL, 524288, (PVOID) hwnd) == -1) 3688 DosBeep(250, 100);3678 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT)); 3689 3679 } 3690 3680 } … … 3973 3963 { 3974 3964 ad -> cliptype = SHORT1FROMMP(mp1); 3975 if (_beginthread(Clipboard, 3976 NULL, 3977 524288, 3978 (PVOID) hwnd) == -1) 3979 DosBeep(50, 100); 3965 if (_beginthread(Clipboard,NULL,524288,(PVOID) hwnd) == -1) 3966 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT)); 3980 3967 } 3981 3968 DosReleaseMutexSem(ad -> ScanSem); … … 4293 4280 MPFROM2SHORT(IDM_SAVETOCLIP, FALSE), MPVOID); 4294 4281 } 4295 ad = malloc(sizeof(VIEWDATA)); 4296 if (ad) 4297 { 4298 memset(ad, 0, sizeof(VIEWDATA)); 4282 ad = xmallocz(sizeof(VIEWDATA),pszSrcFile,__LINE__); 4283 if (!ad) { 4284 WinDestroyWindow(hwndFrame); 4285 hwndFrame = (HWND) 0; 4286 } 4287 else { 4299 4288 ad -> size = sizeof(VIEWDATA); 4300 4289 ad -> stopflag = 0; … … 4367 4356 memcpy(ad -> colors, Colors, sizeof(LONG) * COLORS_MAX); 4368 4357 WinSetWindowPtr(hwndClient, QWL_USER, (PVOID) ad); 4369 if (WinSendMsg(hwndClient, UM_SETUP, MPVOID, MPVOID)) 4370 { 4371 // DosSleep(64L); 4358 if (!WinSendMsg(hwndClient, UM_SETUP, MPVOID, MPVOID)) 4359 hwndFrame = (HWND)0; 4360 else { 4361 // DosSleep(64L); 4372 4362 if (!(FrameFlags & FCF_TASKLIST) && !(flags & 2)) 4373 4363 { 4374 4375 4364 SWP swp; 4376 4377 4365 FillClient(hwndParent, &swp, NULL, FALSE); 4378 4366 WinSetWindowPos(hwndFrame, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, … … 4408 4396 } 4409 4397 } 4410 else4411 hwndFrame = (HWND) 0;4412 }4413 else4414 {4415 WinDestroyWindow(hwndFrame);4416 hwndFrame = (HWND) 0;4417 4398 } 4418 4399 }
Note:
See TracChangeset
for help on using the changeset viewer.
