Changeset 350 for trunk/dll


Ignore:
Timestamp:
Jul 26, 2006, 9:01:20 PM (19 years ago)
Author:
root
Message:

Use Runtime_Error

Location:
trunk/dll
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/dirsize.c

    r239 r350  
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2001, 2005 Steven H. Levine
     9  Copyright (c) 2001, 2006 Steven H. Levine
    1010
    1111  16 Oct 02 SHL Handle large partitions
     
    2020  19 Jun 05 SHL More 64-bit math fixes
    2121  08 Aug 05 SHL Avoid Expand/Collapse hangs while working
     22  17 Jul 06 SHL Use Runtime_Error
    2223
    2324***********************************************************************/
     
    3738#include "fm3dlg.h"
    3839#include "fm3str.h"
    39 
    40 #pragma alloc_text(DIRSIZE,ProcessDir,FillCnrThread,DirSizeProc)
    41 #pragma alloc_text(DIRSIZE2,PrintToFile,FillInRecSizes,SortSizeCnr)
    4240
    4341typedef struct {
     
    5654} tState;
    5755
     56
     57static PSZ pszSrcFile = __FILE__;
     58
     59#pragma alloc_text(DIRSIZE,ProcessDir,FillCnrThread,DirSizeProc)
     60#pragma alloc_text(DIRSIZE2,PrintToFile,FillInRecSizes,SortSizeCnr)
    5861
    5962static SHORT APIENTRY SortSizeCnr (PMINIRECORDCORE p1,PMINIRECORDCORE p2,
     
    9295  *pullTotalBytes = 0;          // In case we fail
    9396
    94   pFFB = malloc(sizeof(FILEFINDBUF4) /* * FilesToGet */);
     97  pFFB = xmalloc(sizeof(FILEFINDBUF4),pszSrcFile,__LINE__);
    9598  if(!pFFB)
    9699    return FALSE;
     
    150153              rc,
    151154              HWND_DESKTOP,
    152               __FILE__,
     155              pszSrcFile,
    153156              __LINE__,
    154157              GetPString(IDS_CANTFINDDIRTEXT),
     
    445448        break;
    446449      }
    447       pState = malloc(sizeof(tState));
     450      pState = xmallocz(sizeof(tState),pszSrcFile,__LINE__);
    448451      if(!pState) {
    449452        WinDismissDlg(hwnd,0);
    450453        break;
    451454      }
    452       memset(pState,0,sizeof(tState));
    453455      strcpy(pState->szDirName,(CHAR *)mp2);
    454456      WinSetWindowPtr(hwnd,0,(PVOID)pState);
     
    466468        DIRSIZE *dirsize;
    467469
    468         dirsize = malloc(sizeof(DIRSIZE));
     470        dirsize = xmalloc(sizeof(DIRSIZE),pszSrcFile,__LINE__);
    469471        if(!dirsize) {
    470472          WinDismissDlg(hwnd,0);
     
    475477        dirsize->hwndCnr = WinWindowFromID(hwnd,DSZ_CNR);
    476478        if(_beginthread(FillCnrThread,NULL,122880L * 5L,(PVOID)dirsize) == -1) {
     479          Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT));
    477480          free(dirsize);
    478481          WinDismissDlg(hwnd,0);
     
    573576      WinSendDlgItemMsg(hwnd,DSZ_CNR,CM_SORTRECORD,MPFROMP(SortSizeCnr),
    574577                        MPVOID);
    575       DosBeep(500,25);
     578      DosBeep(500,25);                  // Wake up user
    576579      return 0;
    577580
     
    853856          // Save button
    854857          pState = INSTDATA(hwnd);
    855           if (pState) {
     858          if (!pState)
     859            Runtime_Error(pszSrcFile, __LINE__, "no data");
     860          else {
    856861
    857862            CHAR  pszFileName[CCHMAXPATH];
     
    867872                strcat(pszFileName,".RPT");
    868873              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 {
    870882                WinSetPointer(HWND_DESKTOP,hptrBusy);
    871883                PrintToFile(WinWindowFromID(hwnd,DSZ_CNR),0,NULL,fp);
     
    873885                WinSetPointer(HWND_DESKTOP,hptrArrow);
    874886              }
    875               else
    876                 saymsg(MB_CANCEL,
    877                        hwnd,
    878                        GetPString(IDS_ERRORTEXT),
    879                        GetPString(IDS_COMPCANTOPENTEXT),
    880                        pszFileName);
    881887            }
    882888          }
    883           else
    884             DosBeep(50,100);
    885889          break;
    886890
     
    917921        case DID_CANCEL:
    918922          pState = INSTDATA(hwnd);
    919           if (pState) {
     923          if (!pState)
     924            Runtime_Error(pszSrcFile, __LINE__, "no data");
     925          else {
    920926            if (pState->working) {
    921927              pState->dying = TRUE;
    922928              pState->chStopFlag = 0xff;
    923               DosBeep(1000,100);
     929              DosBeep(1000,100);                        // Complain?
    924930            }
    925931            else
  • trunk/dll/extract.c

    r186 r350  
    55
    66  Copyright (c) 1993-98 M. Kimes
    7   Copyright (c) 2004, 2005 Steven H. Levine
     7  Copyright (c) 2004, 2006 Steven H. Levine
    88
    99  01 Aug 04 SHL Rework lstrip/rstrip usage
    1010  05 Jun 05 SHL Use QWL_USER
     11  17 Jul 06 SHL Use Runtime_Error
    1112
    1213***********************************************************************/
     
    1415#define INCL_WIN
    1516#define INCL_DOS
    16 
    1717#include <os2.h>
     18
    1819#include <stdlib.h>
    1920#include <stdio.h>
     
    2122#include <time.h>
    2223#include <ctype.h>
     24
    2325#include "fm3dll.h"
    2426#include "fm3dlg.h"
     
    2628
    2729#pragma data_seg(DATA1)
     30
    2831#pragma alloc_text(FMEXTRACT,ExtractTextProc,ExtractDlgProc)
    2932
    30 
    31 MRESULT EXPENTRY ExtractTextProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
    32 
     33static PSZ pszSrcFile = __FILE__;
     34
     35MRESULT EXPENTRY ExtractTextProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     36{
    3337  PFNWP        oldproc = (PFNWP)WinQueryWindowPtr(hwnd,0);
    3438  static BOOL  emphasized = FALSE;
     
    7680
    7781
    78 MRESULT EXPENTRY ExtractDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
    79 
     82MRESULT EXPENTRY ExtractDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     83{
    8084  EXTRDATA    *arcdata = NULL;
    8185
     
    314318            }
    315319          }
    316           DosBeep(50,100);
     320          DosBeep(50,100);              // Complain a refuse to quit
    317321          break;
    318322
     
    347351            WinQueryDlgItemText(hwnd,EXT_COMMAND,256,s);
    348352            lstrip(s);
    349             if(*s) {
     353            if (!*s)
     354              Runtime_Error(pszSrcFile, __LINE__, "no command");
     355            else {
    350356              p = strchr(s,' ');
    351               if(p)
    352                 *p = 0;
     357              if (p)
     358                *p = 0;                 // Drop options
    353359              memset(&ex,0,sizeof(EXECARGS));
    354360              ex.commandline = s;
     
    363369                           MPFROMP(&ex)) &&
    364370                 *s)
     371              {
    365372                runemf2(ex.flags,
    366373                        hwnd,
     
    369376                        "%s",
    370377                        s);
    371             }
    372             else
    373               DosBeep(50,100);
     378              }
     379            }
    374380          }
    375381          break;
  • trunk/dll/grep.c

    r281 r350  
    44  $Id$
    55
    6   Info window
     6  grep tools
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2001, 2005 Steven H. Levine
     9  Copyright (c) 2001, 2006 Steven H. Levine
    1010
    1111  12 Feb 03 SHL insert_grepfile: standardize EA math
     
    1515  06 Jun 05 SHL Drop unused code
    1616  24 Oct 05 SHL dononefile: do not free EA list twice
     17  22 Jul 06 SHL Use Runtime_Error
    1718
    1819***********************************************************************/
     
    3435
    3536#pragma data_seg(DATA2)
     37
     38static PSZ pszSrcFile = __FILE__;
     39
    3640#pragma alloc_text(GREP,SecsSince1980,match,mmatch,dogrep)
    3741#pragma alloc_text(GREP,doallsubdirs,domatchingfiles)
     
    464468  /* process all matching files in a directory */
    465469
    466   PFILEFINDBUF4  findBuffer = malloc(grep->FilesToGet * sizeof(FILEFINDBUF4));
     470  PFILEFINDBUF4  findBuffer;
    467471  PFILEFINDBUF4  pffbFile;
    468472  register PBYTE fb;
     
    473477  APIRET         rc;
    474478
     479  findBuffer = xmalloc(grep->FilesToGet * sizeof(FILEFINDBUF4),pszSrcFile,__LINE__);
    475480  if(!findBuffer)
    476481    return 0;
     
    648653      *p = 0;
    649654      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__);
    652657        if(!grep->insertffb)
    653658          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__);
    657660        if(!grep->dir) {
    658661          free(grep->insertffb);
    659662          return FALSE;
    660663        }
    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__);
    664666      if(!grep->insertffb[grep->toinsert])
    665667        return FALSE;
    666668      memcpy(grep->insertffb[grep->toinsert],f,sizeof(FILEFINDBUF4));
    667       grep->dir[grep->toinsert] = strdup(szDirectory);
     669      grep->dir[grep->toinsert] = xstrdup(szDirectory,pszSrcFile,__LINE__);
    668670      if(!grep->dir) {
    669671        free(grep->insertffb[grep->toinsert]);
     
    856858
    857859  if(grep->searchFiles) {
    858     input = malloc(65537);
     860    input = xmalloc(65537,pszSrcFile,__LINE__);
    859861    if(input) {
    860 
    861862      LONG len;
    862 
    863       if((inputFile = _fsopen(filename,"rb",SH_DENYNO)) != NULL) {
     863      inputFile = _fsopen(filename,"rb",SH_DENYNO);
     864      if (inputFile) {
    864865        pos = ftell(inputFile);
    865866        while(!feof(inputFile)) {
     
    992993
    993994  *error = 0;
    994   buffer = malloc(65535);
    995   if(buffer) {
     995  buffer = xmalloc(65535,pszSrcFile,__LINE__);
     996  if (!buffer)
     997    *error = -1;
     998  else {
    996999    fp = _fsopen(filename,"rb",SH_DENYNO);
    997     if(fp) {
     1000    if (!fp)
     1001      *error = -2;
     1002    else {
    9981003      while(!feof(fp)) {
    9991004        len = fread(buffer,1,65535,fp);
     
    10071012      DosSleep(1L);
    10081013    }
    1009     else
    1010       *error = -2;
    10111014    free(buffer);
    10121015  }
    1013   else
    1014     *error = -1;
    10151016  return CRC;
    10161017}
     
    11801181    cntr = 50;
    11811182  i = g->dupehead;
    1182   while(i) {
     1183  while (i) {
    11831184    x++;
    11841185    i = i->next;
    11851186  }
    1186   if(x) {
     1187  if (x) {
    11871188    WinSetWindowText(g->hwndCurFile,
    11881189                     GetPString(IDS_GREPDUPESORTINGTEXT));
    11891190    DosSleep(1L);
    11901191    g->dupenames = malloc(sizeof(DUPES *) * (x + 1));
    1191     if(!g->nosizedupes)
     1192    if (!g->nosizedupes)
    11921193      g->dupesizes = malloc(sizeof(DUPES *) * (x + 1));
    1193     if(g->dupenames && (g->nosizedupes || g->dupesizes)) {
     1194    if (g->dupenames && (g->nosizedupes || g->dupesizes)) {
    11941195      i = g->dupehead;
    11951196      while(i) {
     
    12011202      }
    12021203      g->dupenames[y] = NULL;
    1203       if(!g->nosizedupes)
     1204      if (!g->nosizedupes)
    12041205        g->dupesizes[y] = NULL;
    12051206      DosSleep(1L);
     
    12111212             comparenamesq));
    12121213      DosSleep(1L);
    1213       if(!g->nosizedupes) {
     1214      if (!g->nosizedupes) {
    12141215        qsort(g->dupesizes,
    12151216              x,
     
    13801381    }
    13811382    else {
     1383      // Insufficient memory - fall back
    13821384      DosBeep(50,100);
    13831385      WinSetWindowText(g->hwndCurFile,
     
    14611463                             &numfiles,
    14621464                             &numalloced))
    1463                   goto BreakOut;
     1465                  goto BreakOut;                // Failed
    14641466                if(!(i->flags & GF_INSERTED)) {
    14651467                  if(AddToList(i->name,
     
    14671469                               &numfiles,
    14681470                               &numalloced))
    1469                     goto BreakOut;
     1471                    goto BreakOut;              // Failed
    14701472                }
    14711473                if(g->sayfiles)
     
    15071509  DUPES *info;
    15081510
    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 {
    15151522        info->size = f->cbFile;
    15161523        info->date = f->fdateLastWrite;
     
    15181525        info->CRC = -1L;
    15191526        g->numfiles++;
    1520         if(!g->dupehead)
     1527        if (!g->dupehead)
    15211528          g->dupehead = info;
    1522         if(g->dupelast)
     1529        if (g->dupelast)
    15231530          g->dupelast->next = info;
    15241531        g->dupelast = info;
    15251532        info->next = NULL;
    1526         return TRUE;
    1527       }
    1528       else
    1529         free(info);
    1530     }
    1531     DosBeep(50,100);
    1532     return FALSE;
     1533      }
     1534    }
    15331535  }
    15341536  return TRUE;
  • trunk/dll/killproc.c

    r161 r350  
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2005 Steven H. Levine
     9  Copyright (c) 2005, 2006 Steven H. Levine
    1010
    1111  24 May 05 SHL Rework Win_Error usage
     12  14 Jul 06 SHL Use Runtime_Error
    1213
    1314***********************************************************************/
     
    1617#define INCL_DOS
    1718#define INCL_WIN
    18 
    1919#include <os2.h>
     20
    2021#include <stdlib.h>
    2122#include <stdio.h>
     
    2526#include <process.h>
    2627#include <limits.h>
     28
    2729#include "procstat.h"
    2830#include "fm3dll.h"
     
    3133
    3234#pragma data_seg(DATA2)
     35
     36static PSZ pszSrcFile = __FILE__;
     37
    3338#pragma alloc_text(KILLPROC,FillKillList,FillKillList2,GetDosPgmName,KillDlgProc)
    3439
    35 
    36 CHAR *GetDosPgmName (PID pid,CHAR *string) {
    37 
     40CHAR *GetDosPgmName (PID pid,CHAR *string)
     41{
    3842  HSWITCH hs;
    3943  SWCNTRL swctl;
     
    6468
    6569
    66 VOID FillKillList2 (VOID *arg) {
    67 
     70VOID FillKillList2 (VOID *arg)
     71{
    6872  HWND          hwnd = *(HWND *)arg;
    6973  CHAR          s[1036];
     
    8084
    8185  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 {
    8491    rc = DosQProcStatus(pbh,USHRT_MAX);
    85     if(!rc) {
     92    if (!rc) {
    8693      ppi = pbh->ppi;
    8794      while(ppi->ulEndIndicator != PROCESS_END_INDICATOR ) {
     
    100107                strcat(s,GetPString(IDS_UNKNOWNPROCTEXT));
    101108            }
    102             if(WinIsWindow(thab,hwnd))
     109            if (WinIsWindow(thab,hwnd)) {
    103110              WinSendDlgItemMsg(hwnd,KILL_LISTBOX,LM_INSERTITEM,
    104111                                MPFROM2SHORT(LIT_SORTASCENDING,0),
    105112                                             MPFROMP(s));
     113            }
    106114            else
    107115              break;
     
    109117        }
    110118        ppi = (PPROCESSINFO)(ppi->ptiFirst + ppi->usThreadCount);
    111       }
     119      } // while
    112120    }
    113121    DosFreeMem(pbh);
    114122  }
    115 Abort:
     123
    116124  if(WinIsWindow(thab,hwnd))
    117125    PostMsg(hwnd,UM_CONTAINER_FILLED,MPVOID,MPVOID);
     
    121129
    122130
    123 VOID FillKillList (VOID *arg) {
    124 
     131VOID FillKillList (VOID *arg)
     132{
    125133  HWND  hwnd = *(HWND *)arg;
    126134  CHAR  s[1036],progname[1027],*p;
     
    149157  unlinkf("%s",s);
    150158  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 {
    152165    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");
    155169    oldstdout = fileno(stdout);
    156170    DosDupHandle(fileno(fp),&oldstdout);
     
    173187    }
    174188  }
    175   else {
    176     Win_Error(NULLHANDLE,HWND_DESKTOP,__FILE__,__LINE__,
    177               GetPString(IDS_REDIRECTERRORTEXT));
    178     goto Abort;
    179   }
    180189  fp = fopen(s,"r");
    181190  if(fp) {
     
    225234
    226235
    227 MRESULT EXPENTRY KillDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
    228 
     236MRESULT EXPENTRY KillDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     237{
    229238  SHORT           sSelect;
    230239  PID             pid;
     
    387396                if(SHORT1FROMMP(mp1) == DID_OK) {
    388397                  error = DosKillProcess(DKP_PROCESS,pid);
    389                   if(error && error != ERROR_INVALID_PROCID)
     398                  if(error && error != ERROR_INVALID_PROCID) {
    390399                    Dos_Error(MB_CANCEL,
    391400                              error,
     
    394403                              __LINE__,
    395404                              GetPString(IDS_DOSKILLFAILEDTEXT));
     405                  }
    396406                  else
    397407                    WinSendDlgItemMsg(hwnd,
     
    409419
    410420        case DID_CANCEL:
    411           if(listdone)
     421          if(!listdone)
     422            Runtime_Error(pszSrcFile, __LINE__, "busy");
     423          else
    412424            WinDismissDlg(hwnd,0);
    413           else
    414             DosBeep(100,100);
    415425          break;
    416426
     
    426436    case WM_CLOSE:
    427437      if(!listdone) {
    428         DosBeep(100,100);
     438        Runtime_Error(pszSrcFile, __LINE__, "busy");
    429439        return 0;
    430440      }
  • trunk/dll/misc.c

    r245 r350  
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2003, 2005 Steven H. Levine
     9  Copyright (c) 2003, 2006 Steven H. Levine
    1010
    1111  11 Jun 03 SHL Add JFS and FAT32 support
     
    1515  24 Jul 05 SHL Beautify
    1616  24 Jul 05 SHL Correct longname display option
     17  17 Jul 06 SHL Use Runtime_Error
    1718
    1819***********************************************************************/
     
    2122#define INCL_WIN
    2223#define INCL_GPI
    23 
    2424#include <os2.h>
     25
    2526#include <stdarg.h>
    2627#include <stdio.h>
     
    2930#include <ctype.h>
    3031#include <share.h>
     32
    3133#include "fm3dll.h"
    3234#include "fm3dlg.h"
     
    3436
    3537#pragma data_seg(DATA1)
     38
     39static PSZ pszSrcFile = __FILE__;
     40
    3641#pragma alloc_text(MAINWND5,SetSysMenu)
    3742#pragma alloc_text(MISC1,BoxWindow,PaintRecessedWindow,PostMsg,PaintSTextWindow)
     
    165170        len = WinQueryWindowTextLength(hwnd);
    166171        if (len)
    167             s = malloc(len + 1);
     172            s = xmalloc(len + 1,pszSrcFile,__LINE__);
    168173        if (s)
    169174        {
     
    756761                    else
    757762                        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 {
    762768                        memset(pfealist, 0, ealen + 1);
    763769                        pfealist -> cbList = ealen;
     
    831837                        *p = 0;
    832838                    bstrip(szData);
    833                     if (IsFullName(szData))
     839                    if (!IsFullName(szData))
     840                        Runtime_Error(pszSrcFile, __LINE__, "bad name");
     841                    else
    834842                    {
    835843                        if (DosQueryPathInfo(szData,
     
    853861                                return (MRESULT) FALSE;
    854862                            }
    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 {
    861866                                CHAR *filename;
    862867
    863                                 filename = strdup(testname);
     868                                filename = xstrdup(testname,pszSrcFile,__LINE__);
    864869                                if (filename)
    865870                                {
     
    876881                                            MPFROMLONG(-1),
    877882                                            MPFROMP(pci));
    878                                     filename = strdup(pci -> szFileName);
     883                                    filename = xstrdup(pci -> szFileName,pszSrcFile,__LINE__);
    879884                                    if (filename)
    880885                                    {
     
    887892                                }
    888893                            }
    889                             else
    890                                 DosBeep(100, 100);
    891894                        }
    892895                    }
    893                     else
    894                         DosBeep(250, 100);
    895896                }
    896897            }
     
    14471448{
    14481449    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
    14511456    {
    14521457        priority_normal();
     
    14581463            DosResetEventSem(CompactSem, &postcount);
    14591464        }
    1460     }
    1461     else
    1462     {
    1463         DosBeep(250, 100);
    1464         DosBeep(1000, 100);
    1465         DosBeep(500, 100);
    1466 //    DosExit(EXIT_PROCESS,1);
    14671465    }
    14681466}
     
    20782076            *var = 0;
    20792077        }
    2080         fp = fopen(configsys, "r");
     2078        fp = xfopen(configsys, "r",pszSrcFile,__LINE__);
    20812079        if (fp)
    20822080        {
     
    21182116    char *s = NULL;
    21192117
    2120     s = malloc(CCHMAXPATH);
     2118    s = xmalloc(CCHMAXPATH,pszSrcFile,__LINE__);
    21212119    if (s)
    21222120    {
     
    21432141    char *s = NULL;
    21442142
    2145     s = malloc(CCHMAXPATH);
     2143    s = xmalloc(CCHMAXPATH,pszSrcFile,__LINE__);
    21462144    if (s)
    21472145    {
     
    21632161    char *s = NULL;
    21642162
    2165     s = malloc(CCHMAXPATH * 2);
     2163    s = xmalloc(CCHMAXPATH * 2,pszSrcFile,__LINE__);
    21662164    if (s)
    21672165    {
     
    23032301            (LONG) sizeof(SWENTRY);
    23042302        /* Allocate memory for list */
    2305         if ((pswb = malloc((unsigned) ulSize)) != NULL)
    2306         {
     2303        pswb = xmalloc(ulSize,pszSrcFile,__LINE__);
     2304        if (pswb) {
    23072305            /* Put the info in the list */
    23082306            ulcEntries = WinQuerySwitchList(0, pswb,
  • trunk/dll/mle.c

    r301 r350  
    77
    88  Copyright (c) 1993-97 M. Kimes
    9   Copyright (c) 2004 Steven H.Levine
     9  Copyright (c) 2004, 2006 Steven H.Levine
    1010
    1111  01 Aug 04 SHL Rework lstrip/rstrip usage
    1212  16 Apr 06 SHL MLEexportfile: rework to avoid wrap problems
     13  14 Jul 06 SHL Use Runtime_Error
    1314
    1415***********************************************************************/
    15 
    16 /* MLE support functions */
    1716
    1817#define INCL_DOS
    1918#define INCL_WIN
    20 
    2119#include <os2.h>
     20
    2221#include <stdlib.h>
    2322#include <stdio.h>
     
    2524#include <ctype.h>
    2625#include <share.h>
     26
    2727#include "fm3dll.h"
    2828#include "fm3dlg.h"
    2929#include "mle.h"
    3030#include "fm3str.h"
     31
     32static PSZ pszSrcFile = __FILE__;
    3133
    3234#pragma alloc_text(FMMLE,MLEgetlinetext,MLEdeleteline,MLEdeletecurline,MLEdeletetoeol)
     
    152154  IPT   ancpos,curpos,here;
    153155  LONG  len,oldlen;
     156  APIRET rc;
    154157
    155158  len = MLEsizeofsel(h);
    156159  len = min(2048,len);
    157160  oldlen = len;
    158   if(len) {
     161  if (len) {
    159162    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 {
    162168      ancpos = MLEancpos(h);
    163169      curpos = MLEcurpos(h);
     
    165171      WinSendMsg(h,MLM_SETIMPORTEXPORT,MPFROMP(temp),MPFROMLONG(len));
    166172      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 {
    168176        if(len > oldlen)
    169177          len--;
     
    189197        }
    190198      }
    191       else
    192         DosBeep(50,100);
    193199      DosFreeMem(temp);
    194200    }
     
    205211  IPT  ancpos,curpos,here;
    206212  LONG sellen,oldlen;
     213  APIRET rc;
    207214
    208215  oldlen = MLEsizeofsel(h);
    209216  if(!oldlen)
    210217    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)
    214220    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));
    221225    free(sel);
    222226    DosPostEventSem(CompactSem);
     
    233237    WinSendMsg(h,MLM_SETIMPORTEXPORT,MPFROMP(temp),MPFROMLONG(sellen));
    234238    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");
    237241      free(sel);
    238242      DosPostEventSem(CompactSem);
     
    260264        fp = fopen(filename,"a+");
    261265        if(!fp)
    262           fp = fopen(filename,"w");
    263         if(fp) {
     266          fp = xfopen(filename,"w",pszSrcFile,__LINE__);
     267        if (fp) {
    264268          fseek(fp,0L,SEEK_END);
    265269          fwrite(sel,1,strlen(sel),fp);
     
    267271        }
    268272#ifdef __DEBUG_ALLOC__
    269     _heap_check();
     273        _heap_check();
    270274#endif
    271275        DosFreeMem(temp);
     
    365369                              MPFROMP(&here),
    366370                              MPFROMLONG(sellen));
    367     if(!sellen) {
    368       DosBeep(50,100);
     371    if (!sellen) {
     372      Runtime_Error(pszSrcFile, __LINE__, "sellen 0");
    369373      break;
    370374    }
     
    373377    if(oldlen && *p == '\n' /* && *(p - 1) == '\r' */)
    374378      p--;
    375   }
     379  } // while
    376380  WinSendMsg(h,MLM_SETSEL,MPFROMLONG(ancpos),MPFROMLONG(curpos));
    377381  MLEenable(h);
     
    454458  XMLEWNDPTR *vw;
    455459  HFILE       handle;
     460  APIRET      rc;
    456461
    457462  *titletext = 0;
     
    463468  *titletext = 0;
    464469  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 {
    470479    DosChgFilePtr(handle, 0L, FILE_END, &len);
    471480    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 {
    478493          MLEclearall(h);
    479494          WinSendMsg(h,MLM_SETIMPORTEXPORT,MPFROMP(hexbuff),
     
    540555              }
    541556              sprintf(s,
    542                       GetPString(IDS_LOADING2TEXT),
     557                      GetPString(IDS_LOADINGMLETEXT),
    543558                      len);
    544559              WinSetWindowText(grandpa,s);
     
    550565          free(buffer);
    551566        }
    552         else {
    553           saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
    554                  HWND_DESKTOP,
    555                  GetPString(IDS_ARGHTEXT),
    556                  GetPString(IDS_OUTOFMEMORY));
    557           ret = FALSE;
    558         }
    559567        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;
    567568      }
    568569    }
     
    571572    DosClose(handle);
    572573  }
    573   else
    574     ret = FALSE;
    575574  if(!first) {
    576575    WinEnableWindowUpdate(h,TRUE);
     
    582581
    583582
     583//== MLEinsertfile() insert a file into the current position in the MLE ==
     584
    584585BOOL MLEinsertfile (HWND h,CHAR *filename)
    585586{
    586   /* insert a file into the current position in the MLE */
    587587
    588588  HAB   hab;
     
    609609                     titletext);
    610610  fp = _fsopen(filename,"r",SH_DENYNO);
    611   if(fp) {
     611  if (!fp)
     612    ret = FALSE;
     613  else {
    612614    setvbuf(fp,NULL,_IONBF,0);
    613615    fseek(fp,0L,SEEK_END);
     
    615617    fseek(fp,0L,SEEK_SET);
    616618    if(len && len != -1) {
    617       if(!DosAllocMem((PVOID)&buffer,
     619      rc = DosAllocMem((PVOID)&buffer,
    618620                       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 {
    621627        WinSendMsg(h,
    622628                   MLM_SETIMPORTEXPORT,
     
    716722            }
    717723            sprintf(s,
    718                     GetPString(IDS_LOADING2TEXT),
     724                    GetPString(IDS_LOADINGMLETEXT),
    719725                    len);
    720726            WinSetWindowText(grandpa,s);
     
    724730        DosFreeMem(buffer);
    725731      }
    726       else {
    727         saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
    728                HWND_DESKTOP,
    729                GetPString(IDS_ARGHTEXT),
    730                GetPString(IDS_OUTOFMEMORY));
    731         ret = FALSE;
    732       }
    733732    }
    734733    if(WinIsWindow(hab,h))
     
    736735    fclose(fp);
    737736  }
    738   else
    739     ret = FALSE;
    740737  if(!first) {
    741738    WinEnableWindowUpdate(h,TRUE);
     
    798795
    799796INT 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   */
    803802
    804803  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;
    818819}
    819820
     
    854855  INT  blanklines = 0;
    855856  BOOL fWrap = MLEgetwrap(h);
     857  APIRET rc;
    856858
    857859  // saymsg(MB_ENTER,h,DEBUG_STRING,"len = %ld",MLEgetlen(h));
     
    881883  }
    882884
    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  {
    886893    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 {
    891899      LONG numlines,ret,len,wl,temp;
    892900      IPT  s;
     
    954962      } // for lines
    955963    }
    956     else
    957       ok = FALSE;
    958   }
    959   else
    960     ok = FALSE;
     964  }
    961965
    962966  MLEsetwrap(h, fWrap);         // Restore
  • trunk/dll/newview.c

    r218 r350  
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2001, 2005 Steven H. Levine
     9  Copyright (c) 2001, 2006 Steven H. Levine
    1010
    1111  01 Dec 03 SHL Comments
     
    1414  06 Jun 05 SHL Indent -i2
    1515  06 Jun 05 SHL Correct reversed wrap logic
     16  17 Jul 06 SHL Use Runtime_Error
    1617
    1718***********************************************************************/
     
    2021#define INCL_WIN
    2122#define INCL_GPI
    22 
    2323#include <os2.h>
     24
    2425#include <stdlib.h>
    2526#include <stdio.h>
     
    2930#include <limits.h>
    3031#include <share.h>
     32
    3133#include "fm3dll.h"
    3234#include "fm3dlg.h"
     
    3537
    3638#pragma data_seg(DATA2)
     39
     40static PSZ pszSrcFile = __FILE__;
     41
    3742#pragma alloc_text(NEWVIEW,ViewStatusProc,FreeViewerMem,LoadFile)
    3843#pragma alloc_text(NEWVIEW,InitWindow,PaintLine,ViewWndProc)
     
    252257        }
    253258      }
    254       DosBeep(250, 100);
     259      Runtime_Error(pszSrcFile, __LINE__, "no data");
    255260      break;
    256261
     
    11291134                  {
    11301135                    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 {
    11331144                      fseek(fp, 0L, SEEK_END);
    11341145                      for (x = 0; list[x]; x++)
     
    11381149                      fclose(fp);
    11391150                    }
    1140                     else
    1141                       saymsg(MB_CANCEL,
    1142                              hwnd,
    1143                              GetPString(IDS_ERRORTEXT),
    1144                              GetPString(IDS_CANTOPENFORWRITETEXT),
    1145                              filename);
    11461151                  }
    11471152                }
     
    11821187  ULONG width, numlines, firstline = 1, cursored = 1;
    11831188
    1184 // DosBeep(50,100);
    11851189  priority_normal();
    11861190  hab2 = WinInitialize(0);
     
    12811285                    CHAR **temp;
    12821286
    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)
    12911290                      break;
     1291                    ad -> lines = temp;
     1292                    ad -> numalloc += 256;
    12921293                  }
    12931294                  ad -> lines[ad -> numlines] = p;
     
    12951296                  if (ad -> numlines == numlines)
    12961297                  {
    1297 
    12981298                    /* display first page */
    1299 
    13001299                    register INT x;
    13011300
     
    13271326                CHAR **temp;
    13281327
    1329                 temp = realloc(ad -> lines, sizeof(CHAR *) * ad -> numlines);
     1328                temp = xrealloc(ad -> lines, sizeof(CHAR *) * ad -> numlines,pszSrcFile,__LINE__);
    13301329                if (temp)
    13311330                {
     
    13431342            if (ad -> numlines)
    13441343            {
    1345               ad -> markedlines = malloc(ad -> numlines);
     1344              ad -> markedlines = xmalloc(ad -> numlines,pszSrcFile,__LINE__);
    13461345              if (ad -> markedlines)
    13471346              {
     
    14221421                         OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYNONE |
    14231422                         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 {
    14261433              DosChgFilePtr(handle, 0L, FILE_END, &len);
    14271434              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__);
    14311444                if (ad -> text)
    14321445                {
    14331446                  *ad -> text = 0;
    14341447                  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) {
    14531450                    Dos_Error(MB_CANCEL,
    14541451                              rc,
    14551452                              hwnd,
    1456                               __FILE__,
     1453                              pszSrcFile,
    14571454                              __LINE__,
    14581455                              GetPString(IDS_ERRORREADINGTEXT),
     
    14621459                    ad -> textsize = 0;
    14631460                  }
     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                  }
    14641477                }
    14651478              }
    1466               else
    1467                 saymsg(MB_CANCEL,
    1468                        hwnd,
    1469                        GetPString(IDS_ERRORTEXT),
    1470                        GetPString(IDS_ZEROLENGTHTEXT),
    1471                        ad -> filename);
    14721479              DosClose(handle);
    14731480            }
    1474             else
    1475               Dos_Error(MB_CANCEL,
    1476                         rc,
    1477                         hwnd,
    1478                         __FILE__,
    1479                         __LINE__,
    1480                         GetPString(IDS_COMPCANTOPENTEXT),
    1481                         ad -> filename);
    14821481          }
    14831482          ad -> busy--;
     
    17301729        if (!*s)
    17311730        {
    1732           DosBeep(250, 100);
     1731          DosBeep(250, 100);            // Complain
    17331732          break;
    17341733        }
     
    18441843
    18451844  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;
    18481851      ad -> hwndMenu = WinWindowFromID(ad -> hwndFrame, FID_MENU);
    18491852      ad -> hvscroll = WinWindowFromID(ad -> hwndFrame, FID_VERTSCROLL);
     
    18571860                 MPFROM2SHORT(1, 1),
    18581861                 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;
    18711873        WinSendMsg(ad -> hvscroll,
    18721874                   SBM_SETSCROLLBAR,
     
    19431945                                         NULL,
    19441946                                         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
    19621961    WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
    19631962    return 0;
     
    20872086          if (_beginthread(ReLine, NULL, 524288, (PVOID) hwnd) == -1)
    20882087          {
    2089             DosBeep(50, 100);
     2088            Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT));
    20902089            DosReleaseMutexSem(ad -> ScanSem);
    20912090            WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
     
    24912490            URLDATA *urld;
    24922491
    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) {
    24972494              urld -> size = sizeof(URLDATA);
    24982495              urld -> line = ad -> lines[whichline];
     
    25002497              ret = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, UrlDlgProc,
    25012498                                       FM3ModHandle, URL_FRAME, urld);
    2502               switch (ret)
    2503               {
     2499              switch (ret) {
    25042500              case 0:
    25052501                free(urld);
     
    25532549          if (!ad -> hex && ad -> lines)
    25542550          {
    2555             s = malloc(width + 2);
     2551            s = xmalloc(width + 2,pszSrcFile,__LINE__);
    25562552            if (!s)
    2557             {
    2558               DosBeep(50, 100);
    25592553              goto NoAdd;
    2560             }
    25612554            strncpy(s, ad -> lines[whichline], width + 1);
    25622555            s[width + 1] = 0;
     
    25792572            width = ad -> textsize - (whichline * 16);
    25802573            width = min(width, 16);
    2581             s = malloc(80);
     2574            s = xmalloc(80,pszSrcFile,__LINE__);
    25822575            if (!s)
    2583             {
    2584               DosBeep(50, 100);
    25852576              goto NoAdd;
    2586             }
    25872577            sprintf(s, "%08lx ", whichline * 16);
    25882578            p = s + 9;
     
    28402830      {
    28412831        if (!ad -> text)
    2842           DosBeep(250, 100);
     2832          Runtime_Error(pszSrcFile, __LINE__, "no data");
    28432833        PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
    28442834      }
     
    36863676                                      (PVOID) ad -> searchtext);
    36873677              if (_beginthread(Search, NULL, 524288, (PVOID) hwnd) == -1)
    3688                 DosBeep(250, 100);
     3678                Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT));
    36893679            }
    36903680          }
     
    39733963          {
    39743964            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));
    39803967          }
    39813968          DosReleaseMutexSem(ad -> ScanSem);
     
    42934280                 MPFROM2SHORT(IDM_SAVETOCLIP, FALSE), MPVOID);
    42944281    }
    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 {
    42994288      ad -> size = sizeof(VIEWDATA);
    43004289      ad -> stopflag = 0;
     
    43674356      memcpy(ad -> colors, Colors, sizeof(LONG) * COLORS_MAX);
    43684357      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);
    43724362        if (!(FrameFlags & FCF_TASKLIST) && !(flags & 2))
    43734363        {
    4374 
    43754364          SWP swp;
    4376 
    43774365          FillClient(hwndParent, &swp, NULL, FALSE);
    43784366          WinSetWindowPos(hwndFrame, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
     
    44084396        }
    44094397      }
    4410       else
    4411         hwndFrame = (HWND) 0;
    4412     }
    4413     else
    4414     {
    4415       WinDestroyWindow(hwndFrame);
    4416       hwndFrame = (HWND) 0;
    44174398    }
    44184399  }
Note: See TracChangeset for help on using the changeset viewer.