Changeset 1891 for trunk/dll/errutil.c


Ignore:
Timestamp:
Jan 31, 2020, 3:47:37 AM (6 years ago)
Author:
Steven Levine
Message:

Rework FreeCnrItem to ensure all CNRITEMs deleted.
Use WinSendMsg CMA_NEXT.
Was using preccNextRecord which is not recommended because control does
not maintain linkage after inserts and deletes.
Note: arccnrs.c still needs to be reworked to use common functions from filldir.c.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/errutil.c

    r1880 r1891  
    66  Error reporting
    77
    8   Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2004, 2015 Steven H. Levine
     8  Copyright (c) 1993-1998 M. Kimes
     9  Copyright (c) 2004-2020 Steven H. Levine
    1010
    1111  12 Aug 04 SHL Comments
     
    4141  15 Feb 14 GKY Improvements to saymsg2 some code cleanup
    4242  16 Feb 14 GKY Rework readonly check on delete code so it actually works in a logical way
    43                 and so it works with move to trashcan inabled.
     43                and so it works with move to trashcan inabled.
    4444  09 Nov 13 SHL Use GetTidForThread in DbgMsg and tweak for for editors that understand file:line
     45  28 Jan 20 SHL Add PmPrintf_Report
    4546
    4647***********************************************************************/
     
    6667#include "fm3dll2.h"
    6768
     69#ifdef PMPRINTF
     70#define _PMPRINTF_                      // Enable debug macros
     71#include "PMPRINTF.H"
     72#endif
     73
    6874#pragma data_seg(DATA1)
    6975
     
    8692  va_list va;
    8793
    88 #if 1 // fixme to be selectable
     94#if 1 // FIXME to be selectable
    8995
    9096  static ULONG ul1stMSec;
     
    94100
    95101  if (!ul1stMSec) {
    96     ul1stMSec = msec;      // Avoid big delta 1st time
     102    ul1stMSec = msec;                   // Avoid big delta 1st time
    97103  }
    98104
     
    124130 */
    125131
    126 // 2010-12-01 SHL fixme for ULONG to be APIRET
     132// 2010-12-01 SHL FIXME for ULONG to be APIRET
    127133
    128134INT Dos_Error(ULONG mb_type, ULONG apiret, HWND hwndOwner,
     
    240246  if (pszBuf[cBufBytes - 1]) {
    241247    fprintf(stderr, "Buffer overflow in formatWinError - need %u bytes\n",
    242             strlen(pszBuf) + 1);
     248            strlen(pszBuf) + 1);
    243249    fflush(stderr);
    244250  }
     
    263269    if (!hwndOwner)
    264270      hwndOwner = HWND_DESKTOP;
    265     // Find message offset in array of message offsets Assume 1 message - fixme?
     271    // Find message offset in array of message offsets Assume 1 message - FIXME?
    266272    pszOffset = ((PSZ) pErrInfoBlk) + pErrInfoBlk->offaoffszMsg;
    267273    // Address error message in array of messages and append error message to source code linenumber
     
    303309}
    304310
     311#ifdef PMPRINTF
     312
     313/**
     314 * Format runtime error message and output using PmPrintf
     315 * @note: Local errors written directly to stderr
     316 * @note: If pszFmt is NULL a No Data error message is returned GKY 20 Feb 09 (Replaces Runtime_Error2)
     317 */
     318
     319VOID PmPrintf_Report(PCSZ pszSrcFile, UINT uSrcLineNo, PCSZ pszFmt, ...)
     320{
     321  CHAR szMsg[4096];
     322  va_list va;
     323
     324  // Format caller's message
     325  if (!pszFmt)
     326    pszFmt = PCSZ_NODATA;
     327  va_start(va, pszFmt);
     328  szMsg[sizeof(szMsg) - 1] = 0;
     329  vsprintf(szMsg, pszFmt, va);
     330  va_end(va);
     331
     332  if (szMsg[sizeof(szMsg) - 1]) {
     333    fprintf(stderr, "Buffer overflow in PmPrintf_Report - need %u bytes\n", strlen(szMsg) + 1);
     334    fflush(stderr);
     335  }
     336
     337  if (strchr(szMsg, ' ') == NULL) {
     338    strcat(szMsg, " ");
     339    strcat(szMsg, GetPString(IDS_FAILEDTEXT));  // Assume simple function name
     340  }
     341
     342  // Avoid leading \n in IDS_GENERR1TEXT
     343  strcat(szMsg, " ");
     344  sprintf(szMsg + strlen(szMsg),
     345          GetPString(IDS_GENERR1TEXT) + 1, pszSrcFile, uSrcLineNo);
     346
     347  PmPrintfString(szMsg);
     348
     349} // PmPrintf_Report
     350
     351#endif
     352
    305353/**
    306354 * Format runtime error message and output using showMsg
     
    369417
    370418APIRET saymsg2(PCSZ pszButtonNames, int DefaultButton, HWND hwnd,
    371                PCSZ pszTitle, PCSZ pszFmt, ...)
     419               PCSZ pszTitle, PCSZ pszFmt, ...)
    372420{
    373421  ULONG i;
     
    412460    rc = WinMessageBox2(HWND_DESKTOP, hwnd,
    413461                        szMsg, pszTitle, SM2_DIALOG,
    414                         pmbInfo);
     462                        pmbInfo);
    415463    WinSetFocus(HWND_DESKTOP, SM2_DIALOG);
    416464    free(pmbInfo);
     
    460508  va_start(va, pszFmt);
    461509  formatWinError(szMsg, sizeof(szMsg), hwndErr, hwndOwner, pszSrcFile,
    462                  uSrcLineNo, pszFmt, va);
     510                 uSrcLineNo, pszFmt, va);
    463511  va_end(va);
    464512
     
    484532  va_start(va, pszFmt);
    485533  formatWinError(szMsg, sizeof(szMsg), hwndErr, hwndOwner, pszSrcFile, uSrcLineNo,
    486                  pszFmt, va);
     534                 pszFmt, va);
    487535  va_end(va);
    488536
Note: See TracChangeset for help on using the changeset viewer.