version 1.2, 2025/03/09 15:20:18
|
version 1.6, 2025/04/30 17:19:16
|
Line 1
|
Line 1
|
/* |
/* |
* * |
* $Id$ |
* * * |
|
* * * |
|
* *************** |
|
* * * * * |
|
* * MUMPS * |
|
* * * * * |
|
* *************** |
|
* * * |
|
* * * |
|
* * |
|
* |
|
* merr.c |
|
* stuff for handling program bogosity |
* stuff for handling program bogosity |
* |
* |
* |
* |
* Author: Serena Willis <snw@coherent-logic.com> |
* Author: Serena Willis <snw@coherent-logic.com> |
* Copyright (C) 1998 MUG Deutschland |
* Copyright (C) 1998 MUG Deutschland |
* Copyright (C) 2020 Coherent Logic Development LLC |
* Copyright (C) 2020, 2025 Coherent Logic Development LLC |
* |
* |
* |
* |
* This file is part of FreeM. |
* This file is part of FreeM. |
Line 35
|
Line 23
|
* You should have received a copy of the GNU Affero Public License |
* You should have received a copy of the GNU Affero Public License |
* along with FreeM. If not, see <https://www.gnu.org/licenses/>. |
* along with FreeM. If not, see <https://www.gnu.org/licenses/>. |
* |
* |
|
* $Log$ |
|
* Revision 1.6 2025/04/30 17:19:16 snw |
|
* Improve backtraces in debugger |
|
* |
|
* Revision 1.5 2025/04/13 04:22:43 snw |
|
* Fix snprintf calls |
|
* |
|
* Revision 1.4 2025/04/09 19:52:02 snw |
|
* Eliminate as many warnings as possible while building with -Wall |
|
* |
|
* Revision 1.3 2025/03/09 19:50:47 snw |
|
* Second phase of REUSE compliance and header reformat |
|
* |
|
* |
|
* SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC |
|
* SPDX-License-Identifier: AGPL-3.0-or-later |
**/ |
**/ |
|
|
#include <string.h> |
#include <string.h> |
Line 208 err_lut errtab[] = {
|
Line 212 err_lut errtab[] = {
|
|
|
inline int merr_raise(int num) |
inline int merr_raise(int num) |
{ |
{ |
char place[256]; |
char placebuf[256]; |
char cod[256]; |
char lref[256]; |
|
|
|
if (num != OK) { |
|
lasterr[nstx] = ierr; |
|
} |
|
|
if (merr_in_break ()) { |
if (merr_in_break ()) { |
ierr = num - CTRLB; |
ierr = num - CTRLB; |
Line 226 inline int merr_raise(int num)
|
Line 234 inline int merr_raise(int num)
|
|
|
if (direct_mode == 1 && nstx == 0) { |
if (direct_mode == 1 && nstx == 0) { |
stcpy (merr_stack[nstx].PLACE, "@\201\0"); |
stcpy (merr_stack[nstx].PLACE, "@\201\0"); |
|
stcpy (merr_stack[nstx].MCODE, " \201\0"); |
} |
} |
else { |
else { |
if (!rtn_get_offset (merr_stack[nstx].PLACE)) { |
getraddress (placebuf, nstx); |
stcpy (merr_stack[nstx].PLACE, "???\201"); |
stcpy (merr_stack[nstx].PLACE, &(placebuf[3])); |
|
/* |
|
stcpy (lref, merr_stack[nstx].PLACE); |
|
stcnv_m2c (lref); |
|
|
|
if (m_text (lref, merr_stack[nstx].MCODE) == NULL) { |
|
sprintf (merr_stack[nstx].MCODE, "???\201"); |
} |
} |
|
*/ |
} |
} |
|
|
if (nstx > merr_topstk) merr_topstk = nstx; |
if (nstx > merr_topstk) merr_topstk = nstx; |
} |
} |
|
|
return ierr; |
return ierr; |
} |
} |
Line 308 void merr_set_ecode_ierr (void)
|
Line 324 void merr_set_ecode_ierr (void)
|
char *cod; |
char *cod; |
char *t; |
char *t; |
|
|
cod = (char *) malloc (256 * sizeof (char)); |
cod = (char *) malloc (MERR_COD_LENGTH * sizeof (char)); |
NULLPTRCHK(cod,"merr_set_ecode_ierr"); |
NULLPTRCHK(cod,"merr_set_ecode_ierr"); |
|
|
t = (char *) malloc (256 * sizeof (char)); |
t = (char *) malloc (MERR_COD_LENGTH * sizeof (char)); |
NULLPTRCHK(t,"merr_set_ecode_ierr"); |
NULLPTRCHK(t,"merr_set_ecode_ierr"); |
|
|
if ((merr_num_to_code (merr (), cod)) == -1) goto done; |
if ((merr_num_to_code (merr (), cod)) == -1) goto done; |
|
|
snprintf (t, 255, ",%s,\201", cod); |
snprintf (t, MERR_COD_LENGTH - 1, ",%s,\201", cod); |
merr_set_ecode (t); |
merr_set_ecode (t); |
|
|
job_set_ecode (pid, cod); |
job_set_ecode (pid, cod); |
Line 421 void merr_dump (int num, char *rtn, char
|
Line 437 void merr_dump (int num, char *rtn, char
|
strcpy (real_ecode, p->canonical_name); |
strcpy (real_ecode, p->canonical_name); |
} |
} |
|
|
|
|
|
|
if (!stlen (err_suppl)) { |
if (!stlen (err_suppl)) { |
sprintf (tbuf, "\r\n>> Error %s: %s in %s.%s::%s [$STACK = %d]\r\n\201", real_ecode, nem, shm_env, nsn, nrt, nstx); |
snprintf (tbuf, STRLEN - 1, "\r\n>> Error %s: %s in %s.%s::%s [$STACK = %d]\r\n\201", real_ecode, nem, shm_env, nsn, nrt, nstx); |
} |
} |
else { |
else { |
stcnv_m2c (err_suppl); |
stcnv_m2c (err_suppl); |
sprintf (tbuf, "\r\n>> Error %s: %s (%s) in %s::%s [$STACK = %d]\r\n\201", real_ecode, nem, err_suppl, nsn, nrt, nstx); |
snprintf (tbuf, STRLEN - 1, "\r\n>> Error %s: %s (%s) in %s::%s [$STACK = %d]\r\n\201", real_ecode, nem, err_suppl, nsn, nrt, nstx); |
err_suppl[0] = EOL; |
err_suppl[0] = EOL; |
} |
} |
write_m (tbuf); |
write_m (tbuf); |