=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/awk/main.c,v retrieving revision 1.69 retrieving revision 1.70 diff -u -r1.69 -r1.70 --- src/usr.bin/awk/main.c 2024/04/25 18:33:53 1.69 +++ src/usr.bin/awk/main.c 2024/05/04 22:59:21 1.70 @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.69 2024/04/25 18:33:53 millert Exp $ */ +/* $OpenBSD: main.c,v 1.70 2024/05/04 22:59:21 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved @@ -23,7 +23,7 @@ THIS SOFTWARE. ****************************************************************/ -const char *version = "version 20240422"; +const char *version = "version 20240504"; #define DEBUG #include @@ -66,22 +66,42 @@ { extern Node *curnode; #ifdef SA_SIGINFO - static const char *emsg[] = { - [0] = "Unknown error", - [FPE_INTDIV] = "Integer divide by zero", - [FPE_INTOVF] = "Integer overflow", - [FPE_FLTDIV] = "Floating point divide by zero", - [FPE_FLTOVF] = "Floating point overflow", - [FPE_FLTUND] = "Floating point underflow", - [FPE_FLTRES] = "Floating point inexact result", - [FPE_FLTINV] = "Invalid Floating point operation", - [FPE_FLTSUB] = "Subscript out of range", - }; + const char *mesg = NULL; + + switch (si->si_code) { + case FPE_INTDIV: + mesg = "Integer divide by zero"; + break; + case FPE_INTOVF: + mesg = "Integer overflow"; + break; + case FPE_FLTDIV: + mesg = "Floating point divide by zero"; + break; + case FPE_FLTOVF: + mesg = "Floating point overflow"; + break; + case FPE_FLTUND: + mesg = "Floating point underflow"; + break; + case FPE_FLTRES: + mesg = "Floating point inexact result"; + break; + case FPE_FLTINV: + mesg = "Invalid Floating point operation"; + break; + case FPE_FLTSUB: + mesg = "Subscript out of range"; + break; + case 0: + default: + mesg = "Unknown error"; + break; + } #endif dprintf(STDERR_FILENO, "floating point exception%s%s\n", #ifdef SA_SIGINFO - ": ", (size_t)si->si_code < sizeof(emsg) / sizeof(emsg[0]) && - emsg[si->si_code] ? emsg[si->si_code] : emsg[0] + ": ", mesg #else "", "" #endif