From ff90bc0e3aaa10c2de02e0153f8f06afdc6aa817 Mon Sep 17 00:00:00 2001 From: Landon Curt Noll Date: Tue, 19 Sep 2023 18:34:21 -0700 Subject: [PATCH] add E_STRING to error, errno, strerror, change multiple E_STRING's While help/errstr has been added, the errstr builtin function is not yet written. In anticipation of the new errstr builtin the rest of the calc error system has been updated to associated errsym E_STRING's with errnum error codes and errmsg error messages. Minor improvements to help/rand. The verify_error_table() function that does a verification the error_table[] array and setup private_error_alias[] array is now called by libcalc_call_me_first(). Fix comment about wrong include file in have_sys_mount.h. Removed unused booltostr() and strtobool() macros from bool.h. Moved define of math_error(char *, ...) from zmath.h to errtbl.h. The errtbl.h include file, unless ERRCODE_SRC is defined also includes attribute.h and errsym.h. Group calc error related builtin support functions together in func.c. Make switch indenting in func.c consistent. Passing an invalid argument to error(), errno() or strerror() will set errno AND throw a math error. Before errno would be set and an error value was returned. Before there was no way to tell if the error value was a result of the arg or if an error detected. Added E_STRING to error([errnum | "E_STRING"]) builtin function. Added E_STRING to errno([errnum | "E_STRING"]) builtin function. Added E_STRING to strerror([errnum | "E_STRING"]) builtin function. Calling these functions with an E_STRING errsym is the same as calling them with the matching errnum code. Standardized on calc computation error related E_STRING strings where there are a set of related codes. Changed "E_...digits" into "E_..._digits". For example, E_FPUTC1 became E_FPUTC_1, E_FPUTC2 became E_FPUTC_2, and E_FPUTC3 became E_FPUTC_3. In a few cases such as E_APPR became E_APPR_1, because there was a E_APPR2 (which became E_APPR_2) and E_APPR3 (which became E_APPR_3). To other special cases, E_ILOG10 became E_IBASE10_LOG and E_ILOG2 became E_IBASE2_LOG because E_ILOG10 and E_ILOG2 are both independent calc computation error related E_STRING strings. Now related sets of E_STRING strings end in _ (underscore) followed by digits. The following is the list of E_STRING strings changes: E_APPR ==> E_APPR_1 E_ROUND ==> E_ROUND_1 E_SQRT ==> E_SQRT_1 E_ROOT ==> E_ROOT_1 E_SHIFT ==> E_SHIFT_1 E_SCALE ==> E_SCALE_1 E_POWI ==> E_POWI_1 E_POWER ==> E_POWER_1 E_QUO ==> E_QUO_1 E_MOD ==> E_MOD_1 E_ABS ==> E_ABS_1 E_APPR2 ==> E_APPR_2 E_APPR3 ==> E_APPR_3 E_ROUND2 ==> E_ROUND_2 E_ROUND3 ==> E_ROUND_3 E_BROUND2 ==> E_BROUND_2 E_BROUND3 ==> E_BROUND_3 E_SQRT2 ==> E_SQRT_2 E_SQRT3 ==> E_SQRT_3 E_ROOT2 ==> E_ROOT_2 E_ROOT3 ==> E_ROOT_3 E_SHIFT2 ==> E_SHIFT_2 E_SCALE2 ==> E_SCALE_2 E_POWI2 ==> E_POWI_2 E_POWER2 ==> E_POWER_2 E_POWER3 ==> E_POWER_3 E_QUO2 ==> E_QUO_2 E_QUO3 ==> E_QUO_3 E_MOD2 ==> E_MOD_2 E_MOD3 ==> E_MOD_3 E_ABS2 ==> E_ABS_2 E_EXP1 ==> E_EXP_1 E_EXP2 ==> E_EXP_2 E_FPUTC1 ==> E_FPUTC_1 E_FPUTC2 ==> E_FPUTC_2 E_FPUTC3 ==> E_FPUTC_3 E_FGETC1 ==> E_FGETC_1 E_FGETC2 ==> E_FGETC_2 E_FOPEN1 ==> E_FOPEN_1 E_FOPEN2 ==> E_FOPEN_2 E_FREOPEN1 ==> E_FREOPEN_1 E_FREOPEN2 ==> E_FREOPEN_2 E_FREOPEN3 ==> E_FREOPEN_3 E_FCLOSE1 ==> E_FCLOSE_1 E_FPUTS1 ==> E_FPUTS_1 E_FPUTS2 ==> E_FPUTS_2 E_FPUTS3 ==> E_FPUTS_3 E_FGETS1 ==> E_FGETS_1 E_FGETS2 ==> E_FGETS_2 E_FPUTSTR1 ==> E_FPUTSTR_1 E_FPUTSTR2 ==> E_FPUTSTR_2 E_FPUTSTR3 ==> E_FPUTSTR_3 E_FGETSTR1 ==> E_FGETSTR_1 E_FGETSTR2 ==> E_FGETSTR_2 E_FGETLINE1 ==> E_FGETLINE_1 E_FGETLINE2 ==> E_FGETLINE_2 E_FGETFIELD1 ==> E_FGETFIELD_1 E_FGETFIELD2 ==> E_FGETFIELD_2 E_REWIND1 ==> E_REWIND_1 E_PRINTF1 ==> E_PRINTF_1 E_PRINTF2 ==> E_PRINTF_2 E_FPRINTF1 ==> E_FPRINTF_1 E_FPRINTF2 ==> E_FPRINTF_2 E_FPRINTF3 ==> E_FPRINTF_3 E_STRPRINTF1 ==> E_STRPRINTF_1 E_STRPRINTF2 ==> E_STRPRINTF_2 E_FSCAN1 ==> E_FSCAN_1 E_FSCAN2 ==> E_FSCAN_2 E_FSCANF1 ==> E_FSCANF_1 E_FSCANF2 ==> E_FSCANF_2 E_FSCANF3 ==> E_FSCANF_3 E_FSCANF4 ==> E_FSCANF_4 E_STRSCANF1 ==> E_STRSCANF_1 E_STRSCANF2 ==> E_STRSCANF_2 E_STRSCANF3 ==> E_STRSCANF_3 E_STRSCANF4 ==> E_STRSCANF_4 E_SCANF1 ==> E_SCANF_1 E_SCANF2 ==> E_SCANF_2 E_SCANF3 ==> E_SCANF_3 E_FTELL1 ==> E_FTELL_1 E_FTELL2 ==> E_FTELL_2 E_FSEEK1 ==> E_FSEEK_1 E_FSEEK2 ==> E_FSEEK_2 E_FSEEK3 ==> E_FSEEK_3 E_FSIZE1 ==> E_FSIZE_1 E_FSIZE2 ==> E_FSIZE_2 E_FEOF1 ==> E_FEOF_1 E_FEOF2 ==> E_FEOF_2 E_FERROR1 ==> E_FERROR_1 E_FERROR2 ==> E_FERROR_2 E_UNGETC1 ==> E_UNGETC_1 E_UNGETC2 ==> E_UNGETC_2 E_UNGETC3 ==> E_UNGETC_3 E_ISATTY1 ==> E_ISATTY_1 E_ISATTY2 ==> E_ISATTY_2 E_ACCESS1 ==> E_ACCESS_1 E_ACCESS2 ==> E_ACCESS_2 E_SEARCH1 ==> E_SEARCH_1 E_SEARCH2 ==> E_SEARCH_2 E_SEARCH3 ==> E_SEARCH_3 E_SEARCH4 ==> E_SEARCH_4 E_SEARCH5 ==> E_SEARCH_5 E_SEARCH6 ==> E_SEARCH_6 E_RSEARCH1 ==> E_RSEARCH_1 E_RSEARCH2 ==> E_RSEARCH_2 E_RSEARCH3 ==> E_RSEARCH_3 E_RSEARCH4 ==> E_RSEARCH_4 E_RSEARCH5 ==> E_RSEARCH_5 E_RSEARCH6 ==> E_RSEARCH_6 E_REWIND2 ==> E_REWIND_2 E_STRERROR1 ==> E_STRERROR_1 E_STRERROR2 ==> E_STRERROR_2 E_COS1 ==> E_COS_1 E_COS2 ==> E_COS_2 E_SIN1 ==> E_SIN_1 E_SIN2 ==> E_SIN_2 E_EVAL2 ==> E_EVAL_2 E_ARG1 ==> E_ARG_1 E_ARG2 ==> E_ARG_2 E_POLAR1 ==> E_POLAR_1 E_POLAR2 ==> E_POLAR_2 E_MATFILL1 ==> E_MATFILL_1 E_MATFILL2 ==> E_MATFILL_2 E_MATTRANS1 ==> E_MATTRANS_1 E_MATTRANS2 ==> E_MATTRANS_2 E_DET1 ==> E_DET_1 E_DET2 ==> E_DET_2 E_DET3 ==> E_DET_3 E_MATMIN1 ==> E_MATMIN_1 E_MATMIN2 ==> E_MATMIN_2 E_MATMIN3 ==> E_MATMIN_3 E_MATMAX1 ==> E_MATMAX_1 E_MATMAX2 ==> E_MATMAX_2 E_MATMAX3 ==> E_MATMAX_3 E_CP1 ==> E_CP_1 E_CP2 ==> E_CP_2 E_CP3 ==> E_CP_3 E_DP1 ==> E_DP_1 E_DP2 ==> E_DP_2 E_DP3 ==> E_DP_3 E_SUBSTR1 ==> E_SUBSTR_1 E_SUBSTR2 ==> E_SUBSTR_2 E_INSERT1 ==> E_INSERT_1 E_INSERT2 ==> E_INSERT_2 E_DELETE1 ==> E_DELETE_1 E_DELETE2 ==> E_DELETE_2 E_LN1 ==> E_LN_1 E_LN2 ==> E_LN_2 E_ERROR1 ==> E_ERROR_1 E_ERROR2 ==> E_ERROR_2 E_EVAL3 ==> E_EVAL_3 E_EVAL4 ==> E_EVAL_4 E_RM1 ==> E_RM_1 E_RM2 ==> E_RM_2 E_BLK1 ==> E_BLK_1 E_BLK2 ==> E_BLK_2 E_BLK3 ==> E_BLK_3 E_BLK4 ==> E_BLK_4 E_BLKFREE1 ==> E_BLKFREE_1 E_BLKFREE2 ==> E_BLKFREE_2 E_BLKFREE3 ==> E_BLKFREE_3 E_BLKFREE4 ==> E_BLKFREE_4 E_BLKFREE5 ==> E_BLKFREE_5 E_BLOCKS1 ==> E_BLOCKS_1 E_BLOCKS2 ==> E_BLOCKS_2 E_COPY1 ==> E_COPY_01 E_COPY2 ==> E_COPY_02 E_COPY3 ==> E_COPY_03 E_COPY4 ==> E_COPY_04 E_COPY5 ==> E_COPY_05 E_COPY6 ==> E_COPY_06 E_COPY7 ==> E_COPY_07 E_COPY8 ==> E_COPY_08 E_COPY9 ==> E_COPY_09 E_COPY10 ==> E_COPY_10 E_COPY11 ==> E_COPY_11 E_COPY12 ==> E_COPY_12 E_COPY13 ==> E_COPY_13 E_COPY14 ==> E_COPY_14 E_COPY15 ==> E_COPY_15 E_COPY16 ==> E_COPY_16 E_COPY17 ==> E_COPY_17 E_COPYF1 ==> E_COPYF_1 E_COPYF2 ==> E_COPYF_2 E_COPYF3 ==> E_COPYF_3 E_COPYF4 ==> E_COPYF_4 E_PROTECT1 ==> E_PROTECT_1 E_PROTECT2 ==> E_PROTECT_2 E_PROTECT3 ==> E_PROTECT_3 E_MATFILL3 ==> E_MATFILL_3 E_MATFILL4 ==> E_MATFILL_4 E_MATTRACE1 ==> E_MATTRACE_1 E_MATTRACE2 ==> E_MATTRACE_2 E_MATTRACE3 ==> E_MATTRACE_3 E_TAN1 ==> E_TAN_1 E_TAN2 ==> E_TAN_2 E_COT1 ==> E_COT_1 E_COT2 ==> E_COT_2 E_SEC1 ==> E_SEC_1 E_SEC2 ==> E_SEC_2 E_CSC1 ==> E_CSC_1 E_CSC2 ==> E_CSC_2 E_SINH1 ==> E_SINH_1 E_SINH2 ==> E_SINH_2 E_COSH1 ==> E_COSH_1 E_COSH2 ==> E_COSH_2 E_TANH1 ==> E_TANH_1 E_TANH2 ==> E_TANH_2 E_COTH1 ==> E_COTH_1 E_COTH2 ==> E_COTH_2 E_SECH1 ==> E_SECH_1 E_SECH2 ==> E_SECH_2 E_CSCH1 ==> E_CSCH_1 E_CSCH2 ==> E_CSCH_2 E_ASIN1 ==> E_ASIN_1 E_ASIN2 ==> E_ASIN_2 E_ACOS1 ==> E_ACOS_1 E_ACOS2 ==> E_ACOS_2 E_ATAN1 ==> E_ATAN_1 E_ATAN2 ==> E_ATAN_2 E_ACOT1 ==> E_ACOT_1 E_ACOT2 ==> E_ACOT_2 E_ASEC1 ==> E_ASEC_1 E_ASEC2 ==> E_ASEC_2 E_ACSC1 ==> E_ACSC_1 E_ACSC2 ==> E_ACSC_2 E_ASINH1 ==> E_ASINH_1 E_ASINH2 ==> E_ASINH_2 E_ACOSH1 ==> E_ACOSH_1 E_ACOSH2 ==> E_ACOSH_2 E_ATANH1 ==> E_ATANH_1 E_ATANH2 ==> E_ATANH_2 E_ACOTH1 ==> E_ACOTH_1 E_ACOTH2 ==> E_ACOTH_2 E_ASECH1 ==> E_ASECH_1 E_ASECH2 ==> E_ASECH_2 E_ACSCH1 ==> E_ACSCH_1 E_ACSCH2 ==> E_ACSCH_2 E_GD1 ==> E_GD_1 E_GD2 ==> E_GD_2 E_AGD1 ==> E_AGD_1 E_AGD2 ==> E_AGD_2 E_BIT1 ==> E_BIT_1 E_BIT2 ==> E_BIT_2 E_SETBIT1 ==> E_SETBIT_1 E_SETBIT2 ==> E_SETBIT_2 E_SETBIT3 ==> E_SETBIT_3 E_SEG1 ==> E_SEG_1 E_SEG2 ==> E_SEG_2 E_SEG3 ==> E_SEG_3 E_HIGHBIT1 ==> E_HIGHBIT_1 E_HIGHBIT2 ==> E_HIGHBIT_2 E_LOWBIT1 ==> E_LOWBIT_1 E_LOWBIT2 ==> E_LOWBIT_2 E_HEAD1 ==> E_HEAD_1 E_HEAD2 ==> E_HEAD_2 E_TAIL1 ==> E_TAIL_1 E_TAIL2 ==> E_TAIL_2 E_XOR1 ==> E_XOR_1 E_XOR2 ==> E_XOR_2 E_INDICES1 ==> E_INDICES_1 E_INDICES2 ==> E_INDICES_2 E_EXP3 ==> E_EXP_3 E_SINH3 ==> E_SINH_3 E_COSH3 ==> E_COSH_3 E_SIN3 ==> E_SIN_3 E_COS3 ==> E_COS_3 E_GD3 ==> E_GD_3 E_AGD3 ==> E_AGD_3 E_POWER4 ==> E_POWER_4 E_ROOT4 ==> E_ROOT_4 E_DGT1 ==> E_DGT_1 E_DGT2 ==> E_DGT_2 E_DGT3 ==> E_DGT_3 E_PLCS1 ==> E_PLCS_1 E_PLCS2 ==> E_PLCS_2 E_DGTS1 ==> E_DGTS_1 E_DGTS2 ==> E_DGTS_2 E_ILOG10 ==> E_IBASE10_LOG E_ILOG2 ==> E_IBASE2_LOG E_COMB1 ==> E_COMB_1 E_COMB2 ==> E_COMB_2 E_ASSIGN1 ==> E_ASSIGN_1 E_ASSIGN2 ==> E_ASSIGN_2 E_ASSIGN3 ==> E_ASSIGN_3 E_ASSIGN4 ==> E_ASSIGN_4 E_ASSIGN5 ==> E_ASSIGN_5 E_ASSIGN6 ==> E_ASSIGN_6 E_ASSIGN7 ==> E_ASSIGN_7 E_ASSIGN8 ==> E_ASSIGN_8 E_ASSIGN9 ==> E_ASSIGN_9 E_SWAP1 ==> E_SWAP_1 E_SWAP2 ==> E_SWAP_2 E_SWAP3 ==> E_SWAP_3 E_QUOMOD1 ==> E_QUOMOD_1 E_QUOMOD2 ==> E_QUOMOD_2 E_QUOMOD3 ==> E_QUOMOD_3 E_PREINC1 ==> E_PREINC_1 E_PREINC2 ==> E_PREINC_2 E_PREINC3 ==> E_PREINC_3 E_PREDEC1 ==> E_PREDEC_1 E_PREDEC2 ==> E_PREDEC_2 E_PREDEC3 ==> E_PREDEC_3 E_POSTINC1 ==> E_POSTINC_1 E_POSTINC2 ==> E_POSTINC_2 E_POSTINC3 ==> E_POSTINC_3 E_POSTDEC1 ==> E_POSTDEC_1 E_POSTDEC2 ==> E_POSTDEC_2 E_POSTDEC3 ==> E_POSTDEC_3 E_INIT1 ==> E_INIT_01 E_INIT2 ==> E_INIT_02 E_INIT3 ==> E_INIT_03 E_INIT4 ==> E_INIT_04 E_INIT5 ==> E_INIT_05 E_INIT6 ==> E_INIT_06 E_INIT7 ==> E_INIT_07 E_INIT8 ==> E_INIT_08 E_INIT9 ==> E_INIT_09 E_INIT10 ==> E_INIT_10 E_LIST1 ==> E_LIST_1 E_LIST2 ==> E_LIST_2 E_LIST3 ==> E_LIST_3 E_LIST4 ==> E_LIST_4 E_LIST5 ==> E_LIST_5 E_LIST6 ==> E_LIST_6 E_MODIFY1 ==> E_MODIFY_1 E_MODIFY2 ==> E_MODIFY_2 E_MODIFY3 ==> E_MODIFY_3 E_MODIFY4 ==> E_MODIFY_4 E_MODIFY5 ==> E_MODIFY_5 E_FPATHOPEN1 ==> E_FPATHOPEN_1 E_FPATHOPEN2 ==> E_FPATHOPEN_2 E_LOG1 ==> E_LOG_1 E_LOG2 ==> E_LOG_2 E_LOG3 ==> E_LOG_3 E_FGETFILE1 ==> E_FGETFILE_1 E_FGETFILE2 ==> E_FGETFILE_2 E_FGETFILE3 ==> E_FGETFILE_3 E_TAN3 ==> E_TAN_3 E_TAN4 ==> E_TAN_4 E_COT3 ==> E_COT_3 E_COT4 ==> E_COT_4 E_SEC3 ==> E_SEC_3 E_CSC3 ==> E_CSC_3 E_TANH3 ==> E_TANH_3 E_TANH4 ==> E_TANH_4 E_COTH3 ==> E_COTH_3 E_COTH4 ==> E_COTH_4 E_SECH3 ==> E_SECH_3 E_CSCH3 ==> E_CSCH_3 E_ASIN3 ==> E_ASIN_3 E_ACOS3 ==> E_ACOS_3 E_ASINH3 ==> E_ASINH_3 E_ACOSH3 ==> E_ACOSH_3 E_ATAN3 ==> E_ATAN_3 E_ACOT3 ==> E_ACOT_3 E_ASEC3 ==> E_ASEC_3 E_ACSC3 ==> E_ACSC_3 E_ATANH3 ==> E_ATANH_3 E_ACOTH3 ==> E_ACOTH_3 E_ASECH3 ==> E_ASECH_3 E_ACSCH3 ==> E_ACSCH_3 E_D2R1 ==> E_D2R_1 E_D2R2 ==> E_D2R_2 E_R2D1 ==> E_R2D_1 E_R2D2 ==> E_R2D_2 E_G2R1 ==> E_G2R_1 E_G2R2 ==> E_G2R_2 E_R2G1 ==> E_R2G_1 E_R2G2 ==> E_R2G_2 E_D2G1 ==> E_D2G_1 E_G2D1 ==> E_G2D_1 E_D2DMS1 ==> E_D2DMS_1 E_D2DMS2 ==> E_D2DMS_2 E_D2DMS3 ==> E_D2DMS_3 E_D2DMS4 ==> E_D2DMS_4 E_D2DM1 ==> E_D2DM_1 E_D2DM2 ==> E_D2DM_2 E_D2DM3 ==> E_D2DM_3 E_D2DM4 ==> E_D2DM_4 E_G2GMS1 ==> E_G2GMS_1 E_G2GMS2 ==> E_G2GMS_2 E_G2GMS3 ==> E_G2GMS_3 E_G2GMS4 ==> E_G2GMS_4 E_G2GM1 ==> E_G2GM_1 E_G2GM2 ==> E_G2GM_2 E_G2GM3 ==> E_G2GM_3 E_G2GM4 ==> E_G2GM_4 E_H2HMS1 ==> E_H2HMS_1 E_H2HMS2 ==> E_H2HMS_2 E_H2HMS3 ==> E_H2HMS_3 E_H2HMS4 ==> E_H2HMS_4 E_H2HM1 ==> E_H2HM_1 E_H2HM2 ==> E_H2HM_2 E_H2HM3 ==> E_H2HM_3 E_H2HM4 ==> E_H2HM_4 E_DMS2D1 ==> E_DMS2D_1 E_DMS2D2 ==> E_DMS2D_2 E_DM2D1 ==> E_DM2D_1 E_DM2D2 ==> E_DM2D_2 E_GMS2G1 ==> E_GMS2G_1 E_GMS2G2 ==> E_GMS2G_2 E_GM2G1 ==> E_GM2G_1 E_GM2G2 ==> E_GM2G_2 E_HMS2H1 ==> E_HMS2H_1 E_HMS2H2 ==> E_HMS2H_2 E_HM2H1 ==> E_HM2H_1 E_HM2H2 ==> E_HM2H_2 E_VERSIN1 ==> E_VERSIN_1 E_VERSIN2 ==> E_VERSIN_2 E_VERSIN3 ==> E_VERSIN_3 E_AVERSIN1 ==> E_AVERSIN_1 E_AVERSIN2 ==> E_AVERSIN_2 E_AVERSIN3 ==> E_AVERSIN_3 E_COVERSIN1 ==> E_COVERSIN_1 E_COVERSIN2 ==> E_COVERSIN_2 E_COVERSIN3 ==> E_COVERSIN_3 E_ACOVERSIN1 ==> E_ACOVERSIN_1 E_ACOVERSIN2 ==> E_ACOVERSIN_2 E_ACOVERSIN3 ==> E_ACOVERSIN_3 E_VERCOS1 ==> E_VERCOS_1 E_VERCOS2 ==> E_VERCOS_2 E_VERCOS3 ==> E_VERCOS_3 E_AVERCOS1 ==> E_AVERCOS_1 E_AVERCOS2 ==> E_AVERCOS_2 E_AVERCOS3 ==> E_AVERCOS_3 E_COVERCOS1 ==> E_COVERCOS_1 E_COVERCOS2 ==> E_COVERCOS_2 E_COVERCOS3 ==> E_COVERCOS_3 E_ACOVERCOS1 ==> E_ACOVERCOS_1 E_ACOVERCOS2 ==> E_ACOVERCOS_2 E_ACOVERCOS3 ==> E_ACOVERCOS_3 E_TAN5 ==> E_TAN_5 E_COT5 ==> E_COT_5 E_COT6 ==> E_COT_6 E_SEC5 ==> E_SEC_5 E_CSC5 ==> E_CSC_5 E_CSC6 ==> E_CSC_6 --- .gitignore | 20 + CHANGES | 38 +- Makefile | 98 +- addop.c | 2 +- assocfunc.c | 2 +- blkcpy.c | 144 +-- block.c | 7 +- bool.h | 16 - byteswap.c | 2 +- calc.c | 2 +- codegen.c | 2 +- comfunc.c | 2 +- commath.c | 2 +- config.c | 2 +- const.c | 2 +- custom.c | 2 +- custom/Makefile | 8 + custom/c_help.c | 2 +- custom/c_pmodm127.c | 2 +- custom/c_pzasusb8.c | 2 +- custom/c_register.c | 2 +- custom/c_sysinfo.c | 2 +- custom/custtbl.c | 1 + errtbl.c | 2362 +++++++++++++++++++++++++--------- errtbl.h | 49 +- file.c | 3 +- func.c | 2972 +++++++++++++++++++++++-------------------- func.h | 1 + hash.c | 2 +- help/Makefile | 4 +- help/errcount | 5 +- help/errmax | 5 +- help/errno | 36 +- help/error | 37 +- help/errstr | 176 +++ help/iserror | 5 +- help/newerror | 3 +- help/rand | 22 +- help/stoponerror | 2 +- help/strerror | 27 +- hist.c | 2 +- input.c | 4 +- lib_calc.c | 7 +- lib_util.c | 4 +- listfunc.c | 2 +- matfunc.c | 11 +- obj.c | 2 +- opcodes.c | 101 +- qfunc.c | 2 +- qio.c | 2 +- qmath.c | 2 +- qmod.c | 2 +- qtrans.c | 2 +- quickhash.c | 2 +- sample_many.c | 4 +- sample_rand.c | 4 +- sha1.c | 2 +- size.c | 4 +- str.c | 2 +- symbol.c | 2 +- token.c | 2 +- value.c | 103 +- value.h | 40 +- zfunc.c | 2 +- zio.c | 2 +- zmath.c | 2 +- zmath.h | 9 - zmod.c | 2 +- zmul.c | 2 +- zprime.c | 2 +- zrand.c | 2 +- zrandom.c | 2 +- 72 files changed, 4081 insertions(+), 2325 deletions(-) create mode 100644 help/errstr diff --git a/.gitignore b/.gitignore index 6392173..2f2a9d5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ *.BAK *.dSYM/ *.exe +*.o.tmp *.[oa] *~ .*.swp @@ -25,6 +26,8 @@ core* .static align32 align32.h +align32_tmp +arc4random_tmp args.h cal/.all cal/test082.cal @@ -53,13 +56,19 @@ custom/libcustcalc* debug.out endian endian_calc.h +environ_tmp errcode errsym.h fposval fposval.h +fposval_tmp +fpos_tmp func.show func.sort getpgid_tmp +getprid_tmp +getsid_tmp +gettime_tmp have_arc4random have_arc4random.h have_ban_pragma @@ -76,6 +85,7 @@ have_getpgid have_getpgid.h have_getprid have_getprid.h +have_getsid have_getsid.h have_gettime have_gettime.h @@ -148,19 +158,29 @@ help/type help/usage libcalc.* libcustcalc.* +ll_tmp longbits longbits.h Makefile.our +memmv_tmp +newstr_tmp NOTES +offscl_tmp outfile +posscl_tmp +rusage_tmp sample_many sample_many-static sample_rand sample_rand-static +statfs_tmp status.chk_c.h strdup_tmp tags terminal.h +uid_tmp unused_tmp +ustat_tmp ver_calc +vs_tmp win32/ diff --git a/CHANGES b/CHANGES index ebffc3b..c2acff3 100644 --- a/CHANGES +++ b/CHANGES @@ -295,6 +295,40 @@ The following are the changes from calc version 2.14.3.5 to date: Renamed "E_1OVER0" to "E_DIVBYZERO". Renamed "E_0OVER0" to "E_ZERODIVZERO". + The verify_error_table() function that does a verification + the error_table[] array and setup private_error_alias[] array + is now called by libcalc_call_me_first(). + + Fix comment about wrong include file in have_sys_mount.h. + + Removed unused booltostr() and strtobool() macros from bool.h. + + Moved define of math_error(char *, ...) from zmath.h to errtbl.h. + The errtbl.h include file, unless ERRCODE_SRC is defined + also includes attribute.h and errsym.h. + + Passing an invalid argument to error(), errno() or strerror() will + set errno AND throw a math error. Before errno would be set and + an error value was returned. Before there was no way to tell if + the error value was a result of the arg or if an error detected. + + Added E_STRING to error([errnum | "E_STRING"]) builtin function. + Added E_STRING to errno([errnum | "E_STRING"]) builtin function. + Added E_STRING to strerror([errnum | "E_STRING"]) builtin function. + Calling these functions with an E_STRING errsym is the same as calling + them with the matching errnum code. + + Standardized on calc computation error related E_STRING strings + where there are a set of related codes. Changed "E_...digits" into + "E_..._digits". For example, E_FPUTC1 became E_FPUTC_1, E_FPUTC2 + became E_FPUTC_2, and E_FPUTC3 became E_FPUTC_3. In a few cases + such as E_APPR became E_APPR_1, because there was a E_APPR2 (which + became E_APPR_2) and E_APPR3 (which became E_APPR_3). To other + special cases, E_ILOG10 became E_IBASE10_LOG and E_ILOG2 became + E_IBASE2_LOG because E_ILOG10 and E_ILOG2 are both independent calc + computation error related E_STRING strings. Now related sets of + E_STRING strings end in _ (underscore) followed by digits. + The following are the changes from calc version 2.14.3.4 to 2.14.3.5: @@ -1108,7 +1142,7 @@ The following are the changes from calc version 2.14.0.9 to 2.14.0.10: Remove unnecessary spaces in-between or next to tabs. - Update Copyright dates to account for 2021 modifications. + Update copyright dates to account for 2021 modifications. The following are the changes from calc version 2.14.0.7 to 2.14.0.8: @@ -3299,7 +3333,7 @@ The following are the changes from calc version 2.12.0 to 2.12.0.8: Added a "make uninstall" rule which will attempt to remove everything that was installed by a "make install". - Changed the "Copyright" line in the rpm spec file to a "License" line + Changed the copyright line in the rpm spec file to a "License" line as per new rpm v4.4 syntax. The quomod() builtin function does not allow constants for its 3rd diff --git a/Makefile b/Makefile index 60c61fc..29046fa 100644 --- a/Makefile +++ b/Makefile @@ -1806,7 +1806,7 @@ have_sys_mount.h: ${MK_SET} ${Q} echo '#define CALC_HAVE_SYS_MOUNT_H' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ - ${Q} echo '/* do we have ? */' >> $@ + ${Q} echo '/* do we have ? */' >> $@ -${Q} if [ X"${HAVE_SYS_MOUNT_H}" = X"YES" ]; then \ echo '#define HAVE_SYS_MOUNT_H /* yes */' >> $@; \ elif [ X"${HAVE_SYS_MOUNT_H}" = X"NO" ]; then \ @@ -2186,7 +2186,8 @@ errsym.h: errcode${EXT} ${TRUE}; \ fi -errcode${EXT}: errtbl.c errtbl.h have_const.h ${MK_SET} +errcode${EXT}: errtbl.c attribute.h bool.h errtbl.h have_const.h have_stdbool.h have_newstr.h \ + have_memmv.h endian_calc.h longbits.h ${MK_SET} ${RM} -f $@ ${LCC} ${ICFLAGS} ${ILDFLAGS} -DERRCODE_SRC errtbl.c -o $@ @@ -3998,6 +3999,7 @@ addop.o: config.h addop.o: decl.h addop.o: endian_calc.h addop.o: errsym.h +addop.o: errtbl.h addop.o: func.h addop.o: hash.h addop.o: have_ban_pragma.h @@ -4039,6 +4041,7 @@ assocfunc.o: config.h assocfunc.o: decl.h assocfunc.o: endian_calc.h assocfunc.o: errsym.h +assocfunc.o: errtbl.h assocfunc.o: hash.h assocfunc.o: have_ban_pragma.h assocfunc.o: have_const.h @@ -4070,6 +4073,7 @@ blkcpy.o: config.h blkcpy.o: decl.h blkcpy.o: endian_calc.h blkcpy.o: errsym.h +blkcpy.o: errtbl.h blkcpy.o: file.h blkcpy.o: hash.h blkcpy.o: have_ban_pragma.h @@ -4101,6 +4105,7 @@ block.o: config.h block.o: decl.h block.o: endian_calc.h block.o: errsym.h +block.o: errtbl.h block.o: hash.h block.o: have_ban_pragma.h block.o: have_const.h @@ -4127,6 +4132,8 @@ byteswap.o: charbit.h byteswap.o: cmath.h byteswap.o: decl.h byteswap.o: endian_calc.h +byteswap.o: errsym.h +byteswap.o: errtbl.h byteswap.o: have_ban_pragma.h byteswap.o: have_const.h byteswap.o: have_limits.h @@ -4155,6 +4162,7 @@ calc.o: custom.h calc.o: decl.h calc.o: endian_calc.h calc.o: errsym.h +calc.o: errtbl.h calc.o: func.h calc.o: hash.h calc.o: have_ban_pragma.h @@ -4211,6 +4219,7 @@ codegen.o: config.h codegen.o: decl.h codegen.o: endian_calc.h codegen.o: errsym.h +codegen.o: errtbl.h codegen.o: func.h codegen.o: hash.h codegen.o: have_ban_pragma.h @@ -4248,6 +4257,8 @@ comfunc.o: comfunc.c comfunc.o: config.h comfunc.o: decl.h comfunc.o: endian_calc.h +comfunc.o: errsym.h +comfunc.o: errtbl.h comfunc.o: have_ban_pragma.h comfunc.o: have_const.h comfunc.o: have_limits.h @@ -4270,6 +4281,8 @@ commath.o: cmath.h commath.o: commath.c commath.o: decl.h commath.o: endian_calc.h +commath.o: errsym.h +commath.o: errtbl.h commath.o: have_ban_pragma.h commath.o: have_const.h commath.o: have_limits.h @@ -4296,6 +4309,7 @@ config.o: custom.h config.o: decl.h config.o: endian_calc.h config.o: errsym.h +config.o: errtbl.h config.o: hash.h config.o: have_ban_pragma.h config.o: have_const.h @@ -4333,6 +4347,7 @@ const.o: const.c const.o: decl.h const.o: endian_calc.h const.o: errsym.h +const.o: errtbl.h const.o: hash.h const.o: have_ban_pragma.h const.o: have_const.h @@ -4364,6 +4379,7 @@ custom.o: custom.h custom.o: decl.h custom.o: endian_calc.h custom.o: errsym.h +custom.o: errtbl.h custom.o: hash.h custom.o: have_ban_pragma.h custom.o: have_const.h @@ -4385,10 +4401,37 @@ endian.o: endian.c endian.o: have_ban_pragma.h endian.o: have_stdlib.h endian.o: have_unistd.h +errtbl.o: alloc.h +errtbl.o: attribute.h +errtbl.o: block.h +errtbl.o: bool.h +errtbl.o: byteswap.h +errtbl.o: calc.h +errtbl.o: charbit.h +errtbl.o: cmath.h +errtbl.o: config.h errtbl.o: decl.h +errtbl.o: endian_calc.h +errtbl.o: errsym.h errtbl.o: errtbl.c errtbl.o: errtbl.h +errtbl.o: func.h +errtbl.o: hash.h errtbl.o: have_const.h +errtbl.o: have_limits.h +errtbl.o: have_memmv.h +errtbl.o: have_newstr.h +errtbl.o: have_stdbool.h +errtbl.o: have_stdlib.h +errtbl.o: have_string.h +errtbl.o: label.h +errtbl.o: longbits.h +errtbl.o: nametype.h +errtbl.o: qmath.h +errtbl.o: sha1.h +errtbl.o: str.h +errtbl.o: value.h +errtbl.o: zmath.h file.o: alloc.h file.o: attribute.h file.o: banned.h @@ -4402,6 +4445,7 @@ file.o: config.h file.o: decl.h file.o: endian_calc.h file.o: errsym.h +file.o: errtbl.h file.o: file.c file.o: file.h file.o: fposval.h @@ -4428,7 +4472,6 @@ file.o: strl.h file.o: value.h file.o: zmath.h fposval.o: alloc.h -fposval.o: attribute.h fposval.o: banned.h fposval.o: bool.h fposval.o: byteswap.h @@ -4514,6 +4557,7 @@ hash.o: config.h hash.o: decl.h hash.o: endian_calc.h hash.o: errsym.h +hash.o: errtbl.h hash.o: hash.c hash.o: hash.h hash.o: have_ban_pragma.h @@ -4643,6 +4687,7 @@ help.o: config.h help.o: decl.h help.o: endian_calc.h help.o: errsym.h +help.o: errtbl.h help.o: hash.h help.o: have_ban_pragma.h help.o: have_const.h @@ -4675,6 +4720,7 @@ hist.o: config.h hist.o: decl.h hist.o: endian_calc.h hist.o: errsym.h +hist.o: errtbl.h hist.o: hash.h hist.o: have_ban_pragma.h hist.o: have_const.h @@ -4714,6 +4760,7 @@ input.o: config.h input.o: decl.h input.o: endian_calc.h input.o: errsym.h +input.o: errtbl.h input.o: hash.h input.o: have_ban_pragma.h input.o: have_const.h @@ -4755,6 +4802,7 @@ label.o: config.h label.o: decl.h label.o: endian_calc.h label.o: errsym.h +label.o: errtbl.h label.o: func.h label.o: hash.h label.o: have_ban_pragma.h @@ -4791,6 +4839,7 @@ lib_calc.o: custom.h lib_calc.o: decl.h lib_calc.o: endian_calc.h lib_calc.o: errsym.h +lib_calc.o: errtbl.h lib_calc.o: func.h lib_calc.o: hash.h lib_calc.o: have_ban_pragma.h @@ -4828,6 +4877,8 @@ lib_util.o: byteswap.h lib_util.o: charbit.h lib_util.o: decl.h lib_util.o: endian_calc.h +lib_util.o: errsym.h +lib_util.o: errtbl.h lib_util.o: have_ban_pragma.h lib_util.o: have_const.h lib_util.o: have_limits.h @@ -4852,6 +4903,7 @@ listfunc.o: config.h listfunc.o: decl.h listfunc.o: endian_calc.h listfunc.o: errsym.h +listfunc.o: errtbl.h listfunc.o: hash.h listfunc.o: have_ban_pragma.h listfunc.o: have_const.h @@ -4889,6 +4941,7 @@ matfunc.o: config.h matfunc.o: decl.h matfunc.o: endian_calc.h matfunc.o: errsym.h +matfunc.o: errtbl.h matfunc.o: hash.h matfunc.o: have_ban_pragma.h matfunc.o: have_const.h @@ -4922,6 +4975,7 @@ math_error.o: config.h math_error.o: decl.h math_error.o: endian_calc.h math_error.o: errsym.h +math_error.o: errtbl.h math_error.o: hash.h math_error.o: have_ban_pragma.h math_error.o: have_const.h @@ -4953,6 +5007,7 @@ obj.o: config.h obj.o: decl.h obj.o: endian_calc.h obj.o: errsym.h +obj.o: errtbl.h obj.o: func.h obj.o: hash.h obj.o: have_ban_pragma.h @@ -4991,6 +5046,7 @@ opcodes.o: custom.h opcodes.o: decl.h opcodes.o: endian_calc.h opcodes.o: errsym.h +opcodes.o: errtbl.h opcodes.o: file.h opcodes.o: func.h opcodes.o: hash.h @@ -5020,7 +5076,6 @@ opcodes.o: zmath.h opcodes.o: zrand.h opcodes.o: zrandom.h pix.o: alloc.h -pix.o: attribute.h pix.o: banned.h pix.o: bool.h pix.o: byteswap.h @@ -5052,6 +5107,7 @@ poly.o: config.h poly.o: decl.h poly.o: endian_calc.h poly.o: errsym.h +poly.o: errtbl.h poly.o: hash.h poly.o: have_ban_pragma.h poly.o: have_const.h @@ -5070,7 +5126,6 @@ poly.o: str.h poly.o: value.h poly.o: zmath.h prime.o: alloc.h -prime.o: attribute.h prime.o: banned.h prime.o: bool.h prime.o: byteswap.h @@ -5100,6 +5155,8 @@ qfunc.o: charbit.h qfunc.o: config.h qfunc.o: decl.h qfunc.o: endian_calc.h +qfunc.o: errsym.h +qfunc.o: errtbl.h qfunc.o: have_ban_pragma.h qfunc.o: have_const.h qfunc.o: have_limits.h @@ -5124,6 +5181,8 @@ qio.o: charbit.h qio.o: config.h qio.o: decl.h qio.o: endian_calc.h +qio.o: errsym.h +qio.o: errtbl.h qio.o: have_ban_pragma.h qio.o: have_const.h qio.o: have_limits.h @@ -5147,6 +5206,8 @@ qmath.o: charbit.h qmath.o: config.h qmath.o: decl.h qmath.o: endian_calc.h +qmath.o: errsym.h +qmath.o: errtbl.h qmath.o: have_ban_pragma.h qmath.o: have_const.h qmath.o: have_limits.h @@ -5169,6 +5230,8 @@ qmod.o: charbit.h qmod.o: config.h qmod.o: decl.h qmod.o: endian_calc.h +qmod.o: errsym.h +qmod.o: errtbl.h qmod.o: have_ban_pragma.h qmod.o: have_const.h qmod.o: have_limits.h @@ -5190,6 +5253,8 @@ qtrans.o: byteswap.h qtrans.o: charbit.h qtrans.o: decl.h qtrans.o: endian_calc.h +qtrans.o: errsym.h +qtrans.o: errtbl.h qtrans.o: have_ban_pragma.h qtrans.o: have_const.h qtrans.o: have_limits.h @@ -5214,6 +5279,7 @@ quickhash.o: config.h quickhash.o: decl.h quickhash.o: endian_calc.h quickhash.o: errsym.h +quickhash.o: errtbl.h quickhash.o: hash.h quickhash.o: have_ban_pragma.h quickhash.o: have_const.h @@ -5246,6 +5312,7 @@ sample_many.o: config.h sample_many.o: decl.h sample_many.o: endian_calc.h sample_many.o: errsym.h +sample_many.o: errtbl.h sample_many.o: hash.h sample_many.o: have_ban_pragma.h sample_many.o: have_const.h @@ -5278,6 +5345,7 @@ sample_rand.o: config.h sample_rand.o: decl.h sample_rand.o: endian_calc.h sample_rand.o: errsym.h +sample_rand.o: errtbl.h sample_rand.o: hash.h sample_rand.o: have_ban_pragma.h sample_rand.o: have_const.h @@ -5298,7 +5366,6 @@ sample_rand.o: value.h sample_rand.o: zmath.h sample_rand.o: zrandom.h seed.o: alloc.h -seed.o: attribute.h seed.o: banned.h seed.o: bool.h seed.o: byteswap.h @@ -5346,6 +5413,7 @@ sha1.o: config.h sha1.o: decl.h sha1.o: endian_calc.h sha1.o: errsym.h +sha1.o: errtbl.h sha1.o: hash.h sha1.o: have_ban_pragma.h sha1.o: have_const.h @@ -5375,6 +5443,7 @@ size.o: config.h size.o: decl.h size.o: endian_calc.h size.o: errsym.h +size.o: errtbl.h size.o: hash.h size.o: have_ban_pragma.h size.o: have_const.h @@ -5407,6 +5476,7 @@ str.o: config.h str.o: decl.h str.o: endian_calc.h str.o: errsym.h +str.o: errtbl.h str.o: hash.h str.o: have_ban_pragma.h str.o: have_const.h @@ -5452,6 +5522,7 @@ symbol.o: config.h symbol.o: decl.h symbol.o: endian_calc.h symbol.o: errsym.h +symbol.o: errtbl.h symbol.o: func.h symbol.o: hash.h symbol.o: have_ban_pragma.h @@ -5488,6 +5559,7 @@ token.o: config.h token.o: decl.h token.o: endian_calc.h token.o: errsym.h +token.o: errtbl.h token.o: hash.h token.o: have_ban_pragma.h token.o: have_const.h @@ -5559,6 +5631,7 @@ version.o: config.h version.o: decl.h version.o: endian_calc.h version.o: errsym.h +version.o: errtbl.h version.o: hash.h version.o: have_ban_pragma.h version.o: have_const.h @@ -5588,6 +5661,8 @@ zfunc.o: byteswap.h zfunc.o: charbit.h zfunc.o: decl.h zfunc.o: endian_calc.h +zfunc.o: errsym.h +zfunc.o: errtbl.h zfunc.o: have_ban_pragma.h zfunc.o: have_const.h zfunc.o: have_limits.h @@ -5609,6 +5684,8 @@ zio.o: charbit.h zio.o: config.h zio.o: decl.h zio.o: endian_calc.h +zio.o: errsym.h +zio.o: errtbl.h zio.o: have_ban_pragma.h zio.o: have_const.h zio.o: have_limits.h @@ -5630,6 +5707,8 @@ zmath.o: byteswap.h zmath.o: charbit.h zmath.o: decl.h zmath.o: endian_calc.h +zmath.o: errsym.h +zmath.o: errtbl.h zmath.o: have_ban_pragma.h zmath.o: have_const.h zmath.o: have_limits.h @@ -5653,6 +5732,8 @@ zmod.o: charbit.h zmod.o: config.h zmod.o: decl.h zmod.o: endian_calc.h +zmod.o: errsym.h +zmod.o: errtbl.h zmod.o: have_ban_pragma.h zmod.o: have_const.h zmod.o: have_limits.h @@ -5675,6 +5756,8 @@ zmul.o: charbit.h zmul.o: config.h zmul.o: decl.h zmul.o: endian_calc.h +zmul.o: errsym.h +zmul.o: errtbl.h zmul.o: have_ban_pragma.h zmul.o: have_const.h zmul.o: have_limits.h @@ -5700,6 +5783,7 @@ zprime.o: config.h zprime.o: decl.h zprime.o: endian_calc.h zprime.o: errsym.h +zprime.o: errtbl.h zprime.o: hash.h zprime.o: have_ban_pragma.h zprime.o: have_const.h @@ -5732,6 +5816,7 @@ zrand.o: config.h zrand.o: decl.h zrand.o: endian_calc.h zrand.o: errsym.h +zrand.o: errtbl.h zrand.o: hash.h zrand.o: have_ban_pragma.h zrand.o: have_const.h @@ -5763,6 +5848,7 @@ zrandom.o: config.h zrandom.o: decl.h zrandom.o: endian_calc.h zrandom.o: errsym.h +zrandom.o: errtbl.h zrandom.o: hash.h zrandom.o: have_ban_pragma.h zrandom.o: have_const.h diff --git a/addop.c b/addop.c index b3aa18e..779e8c0 100644 --- a/addop.c +++ b/addop.c @@ -37,7 +37,7 @@ #include "symbol.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/assocfunc.c b/assocfunc.c index 191f8e7..9e91b6d 100644 --- a/assocfunc.c +++ b/assocfunc.c @@ -36,7 +36,7 @@ #include "value.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/blkcpy.c b/blkcpy.c index 9c40e0a..e4f484c 100644 --- a/blkcpy.c +++ b/blkcpy.c @@ -36,7 +36,7 @@ #include "str.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ @@ -65,9 +65,9 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi) * check protections */ if (svp->v_subtype & V_NOCOPYFROM) - return E_COPY13; + return E_COPY_13; if (dvp->v_subtype & V_NOCOPYTO) - return E_COPY14; + return E_COPY_14; noreloc = ((dvp->v_subtype & V_NOREALLOC) != 0); /* @@ -76,10 +76,10 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi) switch(svp->v_type) { case V_NBLOCK: if (svp->v_nblock->subtype & V_NOCOPYFROM) - return E_COPY15; + return E_COPY_15; sblk = svp->v_nblock->blk; if (sblk->data == NULL) - return E_COPY8; + return E_COPY_08; break; case V_BLOCK: sblk = svp->v_block; @@ -92,7 +92,7 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi) case V_LIST: break; default: - return E_COPY9; + return E_COPY_09; } /* @@ -101,11 +101,11 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi) switch(dvp->v_type) { case V_NBLOCK: if (dvp->v_nblock->subtype & V_NOCOPYTO) - return E_COPY16; + return E_COPY_16; noreloc |=((dvp->v_nblock->subtype & V_NOREALLOC) != 0); dblk = dvp->v_nblock->blk; if (dblk->data == NULL) - return E_COPY10; + return E_COPY_10; break; case V_BLOCK: noreloc = ((dvp->v_subtype & V_NOREALLOC) != 0); @@ -118,7 +118,7 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi) case V_LIST: break; default: - return E_COPY11; + return E_COPY_11; } /* @@ -154,7 +154,7 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi) case V_STR: return copyblk2str(sblk, ssi, num, dvp->v_str, dsi); } - return E_COPY12; + return E_COPY_12; case V_STR: switch(dvp->v_type) { @@ -170,7 +170,7 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi) return copystr2str(svp->v_str, ssi, num, dvp->v_str, dsi); } - return E_COPY12; + return E_COPY_12; case V_OCTET: switch(dvp->v_type) { @@ -182,7 +182,7 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi) return copyostr2str((char *) svp->v_octet, ssi, num, dvp->v_str, dsi); } - return E_COPY12; + return E_COPY_12; case V_NUM: @@ -197,10 +197,10 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi) switch (dvp->v_type) { case V_MAT: /* copy to a matrix */ - return E_COPY12; /* not yet - XXX */ + return E_COPY_12; /* not yet - XXX */ case V_LIST: /* copy to a list */ - return E_COPY12; /* not yet - XXX */ + return E_COPY_12; /* not yet - XXX */ } break; case V_FILE: @@ -216,7 +216,7 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi) switch (dvp->v_type) { case V_NUM: /* copy to a number */ - return E_COPY12; /* not yet - XXX */ + return E_COPY_12; /* not yet - XXX */ } break; @@ -249,7 +249,7 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi) */ if (dblk != NULL) { /* copy to a block */ - return E_COPY12; /* not yet - XXX */ + return E_COPY_12; /* not yet - XXX */ } switch (dvp->v_type) { case V_MAT: @@ -267,7 +267,7 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi) /* * unsupported copy combination */ - return E_COPY12; + return E_COPY_12; } @@ -284,18 +284,18 @@ copymat2mat(MATRIX *smat, long ssi, long num, MATRIX *dmat, long dsi) unsigned short subtype; if (ssi > smat->m_size) - return E_COPY2; + return E_COPY_02; if (num < 0) num = smat->m_size - ssi; if (ssi + num > smat->m_size) - return E_COPY5; + return E_COPY_05; if (num == 0) return 0; if (dsi < 0) dsi = 0; if (dsi + num > dmat->m_size) - return E_COPY7; + return E_COPY_07; vtemp = (VALUE *) malloc(num * sizeof(VALUE)); if (vtemp == NULL) { math_error("Out of memory for mat-to-mat copy"); @@ -333,17 +333,17 @@ copyblk2mat(BLOCK *blk, long ssi, long num, MATRIX *dmat, long dsi) unsigned short subtype; if (ssi > blk->datalen) - return E_COPY2; + return E_COPY_02; if (num < 0) num = blk->datalen - ssi; if (ssi + num > blk->datalen) - return E_COPY5; + return E_COPY_05; if (num == 0) return 0; if (dsi < 0) dsi = 0; if (dsi + num > dmat->m_size) - return E_COPY7; + return E_COPY_07; op = blk->data + ssi; vtemp = (VALUE *) malloc(num * sizeof(VALUE)); if (vtemp == NULL) { @@ -386,21 +386,21 @@ copymat2blk(MATRIX *smat, long ssi, long num, BLOCK *dblk, long dsi, OCTET *op; if (ssi > smat->m_size) - return E_COPY2; + return E_COPY_02; if (num < 0) num = smat->m_size - ssi; if (num == 0) return 0; if (ssi + num > smat->m_size) - return E_COPY5; + return E_COPY_05; if (dsi < 0) dsi = dblk->datalen; newlen = dsi + num; if (newlen <= 0) - return E_COPY7; + return E_COPY_07; if (newlen >= dblk->maxsize) { if (noreloc) - return E_COPY17; + return E_COPY_17; newsize = (1 + newlen/dblk->blkchunk) * dblk->blkchunk; newdata = (USB8*) realloc(dblk->data, newsize); if (newdata == NULL) { @@ -434,17 +434,17 @@ copymat2list(MATRIX *smat, long ssi, long num, LIST *lp, long dsi) unsigned short subtype; if (ssi > smat->m_size) - return E_COPY2; + return E_COPY_02; if (num < 0) num = smat->m_size - ssi; if (num == 0) return 0; if (ssi + num > smat->m_size) - return E_COPY5; + return E_COPY_05; if (dsi < 0) dsi = 0; if (dsi + num > lp->l_count) - return E_COPY7; + return E_COPY_07; vtemp = (VALUE *) malloc(num * sizeof(VALUE)); if (vtemp == NULL) { math_error("Out of memory for matrix-to-list copy"); @@ -484,17 +484,17 @@ copylist2mat(LIST *lp, long ssi, long num, MATRIX *dmat, long dsi) unsigned short subtype; if (ssi > lp->l_count) - return E_COPY2; + return E_COPY_02; if (num < 0) num = lp->l_count - ssi; if (num == 0) return 0; if (ssi + num > lp->l_count) - return E_COPY5; + return E_COPY_05; if (dsi < 0) dsi = 0; if (dsi + num > dmat->m_size) - return E_COPY7; + return E_COPY_07; vtemp = (VALUE *) malloc(num * sizeof(VALUE)); if (vtemp == NULL) { math_error("Out of memory for list-to-matrix copy"); @@ -534,17 +534,17 @@ copylist2list(LIST *slp, long ssi, long num, LIST *dlp, long dsi) unsigned short subtype; if (ssi > slp->l_count) - return E_COPY2; + return E_COPY_02; if (num < 0) num = slp->l_count - ssi; if (num == 0) return 0; if (ssi + num > slp->l_count) - return E_COPY5; + return E_COPY_05; if (dsi < 0) dsi = 0; if (dsi + num > dlp->l_count) - return E_COPY7; + return E_COPY_07; vtemp = (VALUE *) malloc(num * sizeof(VALUE)); if (vtemp == NULL) { math_error("Out of memory for list-to-list copy"); @@ -583,7 +583,7 @@ copyblk2file(BLOCK *sblk, long ssi, long num, FILEID id, long dsi) long numw; if (ssi > sblk->datalen) - return E_COPY2; + return E_COPY_02; if (num < 0) num = sblk->datalen - ssi; if (num == 0) @@ -591,7 +591,7 @@ copyblk2file(BLOCK *sblk, long ssi, long num, FILEID id, long dsi) fiop = findid(id, true); if (fiop == NULL) - return E_COPYF1; + return E_COPYF_1; fp = fiop->fp; if (id == 1 || id == 2) { numw = idfputstr(id, (char *)sblk->data + ssi); /* XXX */ @@ -599,11 +599,11 @@ copyblk2file(BLOCK *sblk, long ssi, long num, FILEID id, long dsi) } if (dsi >= 0) { if (fseek(fp, dsi, 0)) - return E_COPYF2; + return E_COPYF_2; } numw = fwrite(sblk->data + ssi, 1, num, fp); if (numw < num) - return E_COPYF3; + return E_COPYF_3; fflush(fp); return 0; } @@ -625,40 +625,40 @@ copyfile2blk(FILEID id, long ssi, long num, BLOCK *dblk, long dsi, bool noreloc) OCTET *newdata; if (id < 3) /* excludes copying from stdin */ - return E_COPYF1; + return E_COPYF_1; fiop = findid(id, false); if (fiop == NULL) - return E_COPYF1; + return E_COPYF_1; fp = fiop->fp; if (get_open_siz(fp, &fsize)) - return E_COPYF2; + return E_COPYF_2; if (zge31b(fsize)) { zfree(fsize); - return E_COPY5; + return E_COPY_05; } filelen = ztoi(fsize); zfree(fsize); if (ssi > filelen) - return E_COPY2; + return E_COPY_02; if (num < 0) num = filelen - ssi; if (num == 0) return 0; if (ssi + num > filelen) - return E_COPY5; + return E_COPY_05; if (fseek(fp, ssi, 0)) /* using system fseek XXX */ - return E_COPYF2; + return E_COPYF_2; if (dsi < 0) dsi = dblk->datalen; newlen = dsi + num; if (newlen <= 0) - return E_COPY7; + return E_COPY_07; if (newlen >= dblk->maxsize) { if (noreloc) - return E_COPY17; + return E_COPY_17; newsize = (1 + newlen/dblk->blkchunk) * dblk->blkchunk; newdata = (USB8*) realloc(dblk->data, newsize); if (newdata == NULL) { @@ -670,7 +670,7 @@ copyfile2blk(FILEID id, long ssi, long num, BLOCK *dblk, long dsi, bool noreloc) } numw = fread(dblk->data + dsi, 1, num, fp); if (numw < num) - return E_COPYF4; + return E_COPYF_4; if (newlen > dblk->datalen) dblk->datalen = newlen; return 0; @@ -691,16 +691,16 @@ copystr2file(STRING *str, long ssi, long num, FILEID id, long dsi) len = str->s_len; if (ssi >= len) - return E_COPY2; + return E_COPY_02; if (num < 0) num = len - ssi; if (num <= 0) /* Nothing to be copied */ return 0; if (ssi + num > len) - return E_COPY5; /* Insufficient memory in str */ + return E_COPY_05; /* Insufficient memory in str */ fiop = findid(id, true); if (fiop == NULL) - return E_COPYF1; + return E_COPYF_1; fp = fiop->fp; if (id == 1 || id == 2) { numw = idfputstr(id, str->s_str + ssi); /* XXX */ @@ -708,11 +708,11 @@ copystr2file(STRING *str, long ssi, long num, FILEID id, long dsi) } if (dsi >= 0) { if (fseek(fp, dsi, 0)) - return E_COPYF2; + return E_COPYF_2; } numw = fwrite(str->s_str + ssi, 1, num, fp); if (numw < num) - return E_COPYF3; + return E_COPYF_3; fflush(fp); return 0; } @@ -730,21 +730,21 @@ copyblk2blk(BLOCK *sblk, long ssi, long num, BLOCK *dblk, long dsi, USB8 *newdata; if (ssi > sblk->datalen) - return E_COPY2; + return E_COPY_02; if (num < 0) num = sblk->datalen - ssi; if (num == 0) /* Nothing to be copied */ return 0; if (ssi + num > sblk->datalen) - return E_COPY5; + return E_COPY_05; if (dsi < 0) dsi = dblk->datalen; newlen = dsi + num; if (newlen <= 0) - return E_COPY7; + return E_COPY_07; if (newlen >= dblk->maxsize) { if (noreloc) - return E_COPY17; + return E_COPY_17; newsize = (1 + newlen/dblk->blkchunk) * dblk->blkchunk; newdata = (USB8*) realloc(dblk->data, newsize); if (newdata == NULL) { @@ -776,7 +776,7 @@ copystr2blk(STRING *str, long ssi, long num, BLOCK *dblk, long dsi, len = str->s_len; if (ssi >= len) - return E_COPY2; + return E_COPY_02; if (num < 0) num = len - ssi; if (num <= 0) /* Nothing to be copied */ @@ -785,10 +785,10 @@ copystr2blk(STRING *str, long ssi, long num, BLOCK *dblk, long dsi, dsi = dblk->datalen; newlen = dsi + num + 1; if (newlen <= 0) - return E_COPY7; + return E_COPY_07; if (newlen >= dblk->maxsize) { if (noreloc) - return E_COPY17; + return E_COPY_17; newsize = (1 + newlen/dblk->blkchunk) * dblk->blkchunk; newdata = (USB8*) realloc(dblk->data, newsize); if (newdata == NULL) { @@ -897,7 +897,7 @@ copyostr2blk(char *str,long ssi,long num,BLOCK *dblk,long dsi,bool noreloc) len = strlen(str) + 1; if (ssi > 0 && (size_t)ssi > len) - return E_COPY2; + return E_COPY_02; if (num < 0 || (size_t)(ssi + num) > len) num = len - ssi; if (num <= 0) /* Nothing to be copied */ @@ -906,10 +906,10 @@ copyostr2blk(char *str,long ssi,long num,BLOCK *dblk,long dsi,bool noreloc) dsi = dblk->datalen; /* Default destination index */ newlen = dsi + num; if (newlen <= 0) - return E_COPY7; + return E_COPY_07; if (newlen >= (size_t)dblk->maxsize) { if (noreloc) - return E_COPY17; + return E_COPY_17; newsize = (1 + newlen/dblk->blkchunk) * dblk->blkchunk; newdata = (USB8*) realloc(dblk->data, newsize); if (newdata == NULL) { @@ -997,21 +997,21 @@ copynum2blk(NUMBER *snum, long ssi, long num, BLOCK *dblk, long dsi, #endif if (ssi > snum->num.len) - return E_COPY2; + return E_COPY_02; if (num < 0) num = snum->num.len - ssi; if (num == 0) /* Nothing to be copied */ return 0; if (ssi + num > snum->num.len) - return E_COPY5; + return E_COPY_05; if (dsi < 0) dsi = dblk->datalen; newlen = dsi + (num*sizeof(HALF)); if (newlen <= 0) - return E_COPY7; + return E_COPY_07; if (newlen >= (size_t)dblk->maxsize) { if (noreloc) - return E_COPY17; + return E_COPY_17; newsize = (1 + newlen/dblk->blkchunk) * dblk->blkchunk; newdata = (USB8*) realloc(dblk->data, newsize); if (newdata == NULL) { @@ -1051,18 +1051,18 @@ copyblk2num(BLOCK *sblk, long ssi, long num, NUMBER *dnum, long dsi, #endif if (ssi > sblk->datalen) - return E_COPY2; + return E_COPY_02; if (num < 0) num = sblk->datalen - ssi; if (num == 0) /* Nothing to be copied */ return 0; if (ssi + num > sblk->datalen) - return E_COPY5; + return E_COPY_05; if (dsi < 0) dsi = dnum->num.len; newlen = dsi + ((num+sizeof(HALF)-1)/sizeof(HALF)); if (newlen <= 0) - return E_COPY7; + return E_COPY_07; /* quasi-clone the numerator to the new size */ ret = qalloc(); diff --git a/block.c b/block.c index 5a3b569..463384c 100644 --- a/block.c +++ b/block.c @@ -39,10 +39,9 @@ #include "block.h" #include "nametype.h" #include "str.h" -#include "errsym.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ @@ -653,12 +652,12 @@ removenblock(int id) NBLOCK *nblk; if (id < 0 || id >= nblockcount) - return E_BLKFREE3; + return E_BLKFREE_3; nblk = nblocks[id]; if (nblk->blk->data == NULL) return 0; if (nblk->subtype & V_NOREALLOC) - return E_BLKFREE5; + return E_BLKFREE_5; free(nblk->blk->data); nblk->blk->data = NULL; nblk->blk->maxsize = 0; diff --git a/bool.h b/bool.h index e769b1e..0346baf 100644 --- a/bool.h +++ b/bool.h @@ -62,20 +62,4 @@ typedef unsigned char bool; /* fake boolean typedef */ #define BOOL bool -/* - * booltostr - convert a boolean to a string - */ -#if !defined(booltostr) -#define booltostr(x) ((x) ? "true" : "false") -#endif - - -/* - * strtobool - convert a string to a boolean - */ -#if !defined(strtobool) -#define strtobool(x) ((bool) ((x) != NULL && strcmp((x), "true") == 0)) -#endif - - #endif /* !INCLUDE_BOOL_H*/ diff --git a/byteswap.c b/byteswap.c index 8dd1aae..a995111 100644 --- a/byteswap.c +++ b/byteswap.c @@ -29,7 +29,7 @@ #include "byteswap.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/calc.c b/calc.c index ae6aa13..7573f6d 100644 --- a/calc.c +++ b/calc.c @@ -82,7 +82,7 @@ #include "have_unused.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/codegen.c b/codegen.c index ecff052..6040007 100644 --- a/codegen.c +++ b/codegen.c @@ -51,7 +51,7 @@ #endif -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/comfunc.c b/comfunc.c index 9f587cc..d2c335f 100644 --- a/comfunc.c +++ b/comfunc.c @@ -30,7 +30,7 @@ #include "cmath.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/commath.c b/commath.c index c1400c5..d0e7ad1 100644 --- a/commath.c +++ b/commath.c @@ -27,7 +27,7 @@ #include "cmath.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/config.c b/config.c index 4b0fde9..b3ddc89 100644 --- a/config.c +++ b/config.c @@ -62,7 +62,7 @@ #endif /* HAVE_STRDUP */ -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/const.c b/const.c index b0c70d5..3af3a74 100644 --- a/const.c +++ b/const.c @@ -29,7 +29,7 @@ #include "qmath.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/custom.c b/custom.c index 00a9cce..7305f3e 100644 --- a/custom.c +++ b/custom.c @@ -50,7 +50,7 @@ EXTERN CONST struct custom cust[]; /* custom interface table */ #endif /* CUSTOM */ -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/custom/Makefile b/custom/Makefile index 97e8cb9..2b9f7bb 100644 --- a/custom/Makefile +++ b/custom/Makefile @@ -701,6 +701,7 @@ c_argv.o: ../custom.h c_argv.o: ../decl.h c_argv.o: ../endian_calc.h c_argv.o: ../errsym.h +c_argv.o: ../errtbl.h c_argv.o: ../hash.h c_argv.o: ../have_ban_pragma.h c_argv.o: ../have_const.h @@ -733,6 +734,7 @@ c_devnull.o: ../custom.h c_devnull.o: ../decl.h c_devnull.o: ../endian_calc.h c_devnull.o: ../errsym.h +c_devnull.o: ../errtbl.h c_devnull.o: ../hash.h c_devnull.o: ../have_ban_pragma.h c_devnull.o: ../have_const.h @@ -766,6 +768,7 @@ c_help.o: ../custom.h c_help.o: ../decl.h c_help.o: ../endian_calc.h c_help.o: ../errsym.h +c_help.o: ../errtbl.h c_help.o: ../hash.h c_help.o: ../have_ban_pragma.h c_help.o: ../have_const.h @@ -799,6 +802,7 @@ c_pmodm127.o: ../custom.h c_pmodm127.o: ../decl.h c_pmodm127.o: ../endian_calc.h c_pmodm127.o: ../errsym.h +c_pmodm127.o: ../errtbl.h c_pmodm127.o: ../hash.h c_pmodm127.o: ../have_ban_pragma.h c_pmodm127.o: ../have_const.h @@ -831,6 +835,7 @@ c_pzasusb8.o: ../custom.h c_pzasusb8.o: ../decl.h c_pzasusb8.o: ../endian_calc.h c_pzasusb8.o: ../errsym.h +c_pzasusb8.o: ../errtbl.h c_pzasusb8.o: ../hash.h c_pzasusb8.o: ../have_ban_pragma.h c_pzasusb8.o: ../have_const.h @@ -864,6 +869,7 @@ c_register.o: ../custom.h c_register.o: ../decl.h c_register.o: ../endian_calc.h c_register.o: ../errsym.h +c_register.o: ../errtbl.h c_register.o: ../hash.h c_register.o: ../have_ban_pragma.h c_register.o: ../have_const.h @@ -898,6 +904,7 @@ c_sysinfo.o: ../custom.h c_sysinfo.o: ../decl.h c_sysinfo.o: ../endian_calc.h c_sysinfo.o: ../errsym.h +c_sysinfo.o: ../errtbl.h c_sysinfo.o: ../fposval.h c_sysinfo.o: ../hash.h c_sysinfo.o: ../have_ban_pragma.h @@ -936,6 +943,7 @@ custtbl.o: ../custom.h custtbl.o: ../decl.h custtbl.o: ../endian_calc.h custtbl.o: ../errsym.h +custtbl.o: ../errtbl.h custtbl.o: ../hash.h custtbl.o: ../have_ban_pragma.h custtbl.o: ../have_const.h diff --git a/custom/c_help.c b/custom/c_help.c index 538a707..21cca12 100644 --- a/custom/c_help.c +++ b/custom/c_help.c @@ -50,7 +50,7 @@ int c_help_allowed = 0; /* CUSTOM undefined */ #include "../have_unused.h" -#include "../attribute.h" +#include "../errtbl.h" #include "../banned.h" /* include after system header <> includes */ diff --git a/custom/c_pmodm127.c b/custom/c_pmodm127.c index 346156a..9ca3934 100644 --- a/custom/c_pmodm127.c +++ b/custom/c_pmodm127.c @@ -47,7 +47,7 @@ int c_pmodm127_allowed = 0; /* CUSTOM undefined */ #include "../have_unused.h" -#include "../attribute.h" +#include "../errtbl.h" #include "../banned.h" /* include after system header <> includes */ diff --git a/custom/c_pzasusb8.c b/custom/c_pzasusb8.c index 7db143e..bab280e 100644 --- a/custom/c_pzasusb8.c +++ b/custom/c_pzasusb8.c @@ -47,7 +47,7 @@ int c_pzasusb8_allowed = 0; /* CUSTOM undefined */ #include "../have_unused.h" -#include "../attribute.h" +#include "../errtbl.h" #include "../banned.h" /* include after system header <> includes */ diff --git a/custom/c_register.c b/custom/c_register.c index 72553c3..3b13ddb 100644 --- a/custom/c_register.c +++ b/custom/c_register.c @@ -50,7 +50,7 @@ int c_register_allowed = 0; /* CUSTOM undefined */ #include "../have_unused.h" -#include "../attribute.h" +#include "../errtbl.h" #include "../banned.h" /* include after system header <> includes */ diff --git a/custom/c_sysinfo.c b/custom/c_sysinfo.c index ccddfec..5b52ce6 100644 --- a/custom/c_sysinfo.c +++ b/custom/c_sysinfo.c @@ -67,7 +67,7 @@ int c_sysinfo_allowed = 0; /* CUSTOM undefined */ #include "../have_unused.h" -#include "../attribute.h" +#include "../errtbl.h" #include "../banned.h" /* include after system header <> includes */ diff --git a/custom/custtbl.c b/custom/custtbl.c index 6f3cd7b..6d0b018 100644 --- a/custom/custtbl.c +++ b/custom/custtbl.c @@ -32,6 +32,7 @@ #include "../custom.h" +#include "../errtbl.h" #include "../banned.h" /* include after system header <> includes */ diff --git a/errtbl.c b/errtbl.c index 65a342b..2db3ac6 100644 --- a/errtbl.c +++ b/errtbl.c @@ -4,8 +4,6 @@ * This code is used to generate errsym.h and help/errorcodes. * This code also verifies the consistency of the error_table[] array. * - * NOTE: This file was once called calcerr.tbl. - * * Copyright (C) 1999-2006,2021,2023 Ernest Bowen and Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under @@ -26,29 +24,73 @@ * File existed as early as: 1996 * * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ + * + * HISTORIC NOTE: + * + * This file was once called calcerr.tbl. It once was a simple table of: + * + * SYMBOL meaning + * + * until 2023 when the new calc computation error code system was introduced. */ + +/* special comments for the seqcexit tool */ +/* exit code out of numerical order - ignore in sequencing - ooo */ +/* exit code change of order - use new value in sequencing - coo */ + + #include +#include +#include +#include +#include +#include +#include "func.h" #include "errtbl.h" +#include "bool.h" -#define ERRTBL_COPYRIGHT_YEAR 2023 /* Copyright (C) year for generated files */ -/* number of calc computation error codes */ +/* + * Copyright (C) year for generated files + */ +#define ERRTBL_COPYRIGHT_YEAR 2023 + +/* + * number of calc computation error codes in the error_table[] array + * + * This count does NOT include the initial E__BASE entry NOR + * the final NULL entry. + */ #define MY_ECOUNT ((sizeof(error_table) / sizeof(error_table[0])) - 2) +/* + * number of calc computation error codes in the private_error_alias[] array + * + * This count does NOT include the final NULL entry. + */ +#define MY_PRIV_ECOUNT ((sizeof(private_error_alias) / sizeof(private_error_alias[0])) - 1) + /* highest assigned calc computation error code */ #define MY_E__HIGHEST (E__BASE + MY_ECOUNT) +/* + * errnum waiting to be replaced by E__HIGHEST + * + * The INV_ERRNUM must be < 0, AND != NULL_ERRNUM + */ +#define INV_ERRNUM (-2) /* errnum is waiting to be replaced by E__HIGHEST */ + /************************************************************************/ /* */ -/* WARNING: The order of the lines below is critical! If you change */ -/* the order, you will break code that depends on the return */ -/* value of the errno() builtin function. */ +/* WARNING: The order of ierror_table[] arrays critical! If you */ +/* change the order, you will break code that depends on the */ +/* return value of the errno() builtin function. */ /* */ -/* When adding entries to this table add then just before the */ -/* NULL pointer (* must be last *) entry. */ +/* When adding entries to this table add then just before */ +/* the NULL pointer (* must be last *) entry. */ /* */ /************************************************************************/ @@ -61,7 +103,8 @@ * All errnum for the following entries just be consecutive, * except for the final NULL entry. * - * The final entry must have an errnum of -1, errsym of NULL and errmsg of NULL. + * The final entry must have an errnum of NULL_ERRNUM (-1), + * errsym of NULL and errmsg of NULL. * * With exception to the 1st E__BASE entry, all other errsym strings * must match the following regular expression: @@ -69,14 +112,38 @@ * ^E_[A-Z][A-Z0-9_]+$ * * NOTE: The above regular expression is more restrictive them the - * "E_STRING" regular expression from help/errno, help/error, + * E_STRING regular expression from help/errno, help/error, * and help/strerror. This is because errsym strings that * start with "E__" are special symbols that #define-d in errtbl.h, * AND because errsym strings that are "^E_[0-9]+$" reserved for * numeric aliases for errnum. * + * If multiple computation error codes are needed for a similar purpose, + * use E_STRING errsym codes followed by _digit(s). + * * Keep the errmsg short enough that lines in this table are not too long. * You might want to keep the length of the errmsg to 80 characters or less. + * + * IMPORTANT NOTE: + * + * The list of errnum values in error_table[], and the consecutive values + * starting from the 10000 (E__BASE) entry) is important to maintain for + * compatibility. DO NOT change the values of existing errnum codes once + * a new code is released in a calc stable version. If a different code + * is needed, add a new code to the bottom (just above the final NULL entry). + * + * Starting with calc version 2.15 the E_STRING errsym values became visible + * via the error, errno, errstr and strerror builtin interface. DO NOT change + * the existing E_STRING errsym codes once a new code is released in a calc + * stable version. If a different E_STRING errsym code is needed, add a new + * entry to the bottom (just above the final NULL entry). + * + * These is NO requirement for the errmsg error message to be backward compatible. + * + * There is a convention that when a computation error code is no longer needed, + * that the phrase: "UNUSED ERROR: " be prepended to the errmsg error message. + * Do not remove such computation error codes, nor change their errnum values, + * not change their E_STRING errsym codes. */ CONST struct errtbl error_table[] = { @@ -96,182 +163,182 @@ CONST struct errtbl error_table[] = { { 10012, "E_INT", "Bad argument for int" }, { 10013, "E_FRAC", "Bad argument for frac" }, { 10014, "E_CONJ", "Bad argument for conj" }, - { 10015, "E_APPR", "Bad first argument for appr" }, - { 10016, "E_APPR2", "Bad second argument for appr" }, - { 10017, "E_APPR3", "Bad third argument for appr" }, - { 10018, "E_ROUND", "Bad first argument for round" }, - { 10019, "E_ROUND2", "Bad second argument for round" }, - { 10020, "E_ROUND3", "Bad third argument for round" }, + { 10015, "E_APPR_1", "Bad first argument for appr" }, + { 10016, "E_APPR_2", "Bad second argument for appr" }, + { 10017, "E_APPR_3", "Bad third argument for appr" }, + { 10018, "E_ROUND_1", "Bad first argument for round" }, + { 10019, "E_ROUND_2", "Bad second argument for round" }, + { 10020, "E_ROUND_3", "Bad third argument for round" }, { 10021, "E_BROUND", "Bad first argument for bround" }, - { 10022, "E_BROUND2", "Bad second argument for bround" }, - { 10023, "E_BROUND3", "Bad third argument for bround" }, - { 10024, "E_SQRT", "Bad first argument for sqrt" }, - { 10025, "E_SQRT2", "Bad second argument for sqrt" }, - { 10026, "E_SQRT3", "Bad third argument for sqrt" }, - { 10027, "E_ROOT", "Bad first argument for root" }, - { 10028, "E_ROOT2", "Bad second argument for root" }, - { 10029, "E_ROOT3", "Bad third argument for root" }, + { 10022, "E_BROUND_2", "Bad second argument for bround" }, + { 10023, "E_BROUND_3", "Bad third argument for bround" }, + { 10024, "E_SQRT_1", "Bad first argument for sqrt" }, + { 10025, "E_SQRT_2", "Bad second argument for sqrt" }, + { 10026, "E_SQRT_3", "Bad third argument for sqrt" }, + { 10027, "E_ROOT_1", "Bad first argument for root" }, + { 10028, "E_ROOT_2", "Bad second argument for root" }, + { 10029, "E_ROOT_3", "Bad third argument for root" }, { 10030, "E_NORM", "Bad argument for norm" }, - { 10031, "E_SHIFT", "Bad first argument for << or >>" }, - { 10032, "E_SHIFT2", "Bad second argument for << or >>" }, - { 10033, "E_SCALE", "Bad first argument for scale" }, - { 10034, "E_SCALE2", "Bad second argument for scale" }, - { 10035, "E_POWI", "Bad first argument for ^" }, - { 10036, "E_POWI2", "Bad second argument for ^" }, - { 10037, "E_POWER", "Bad first argument for power" }, - { 10038, "E_POWER2", "Bad second argument for power" }, - { 10039, "E_POWER3", "Bad third argument for power" }, - { 10040, "E_QUO", "Bad first argument for quo or //" }, - { 10041, "E_QUO2", "Bad second argument for quo or //" }, - { 10042, "E_QUO3", "Bad third argument for quo" }, - { 10043, "E_MOD", "Bad first argument for mod or %" }, - { 10044, "E_MOD2", "Bad second argument for mod or %" }, - { 10045, "E_MOD3", "Bad third argument for mod" }, + { 10031, "E_SHIFT_1", "Bad first argument for << or >>" }, + { 10032, "E_SHIFT_2", "Bad second argument for << or >>" }, + { 10033, "E_SCALE_1", "Bad first argument for scale" }, + { 10034, "E_SCALE_2", "Bad second argument for scale" }, + { 10035, "E_POWI_1", "Bad first argument for ^" }, + { 10036, "E_POWI_2", "Bad second argument for ^" }, + { 10037, "E_POWER_1", "Bad first argument for power" }, + { 10038, "E_POWER_2", "Bad second argument for power" }, + { 10039, "E_POWER_3", "Bad third argument for power" }, + { 10040, "E_QUO_1", "Bad first argument for quo or //" }, + { 10041, "E_QUO_2", "Bad second argument for quo or //" }, + { 10042, "E_QUO_3", "Bad third argument for quo" }, + { 10043, "E_MOD_1", "Bad first argument for mod or %" }, + { 10044, "E_MOD_2", "Bad second argument for mod or %" }, + { 10045, "E_MOD_3", "Bad third argument for mod" }, { 10046, "E_SGN", "Bad argument for sgn" }, - { 10047, "E_ABS", "Bad first argument for abs" }, - { 10048, "E_ABS2", "Bad second argument for abs" }, + { 10047, "E_ABS_1", "Bad first argument for abs" }, + { 10048, "E_ABS_2", "Bad second argument for abs" }, { 10049, "E_EVAL", "Scan error in argument for eval" }, { 10050, "E_STR", "Non-simple type for str" }, - { 10051, "E_EXP1", "Non-real epsilon for exp" }, - { 10052, "E_EXP2", "Bad first argument for exp" }, - { 10053, "E_FPUTC1", "Non-file first argument for fputc" }, - { 10054, "E_FPUTC2", "Bad second argument for fputc" }, - { 10055, "E_FPUTC3", "File not open for writing for fputc" }, - { 10056, "E_FGETC1", "Non-file first argument for fgetc" }, - { 10057, "E_FGETC2", "File not open for reading for fgetc" }, - { 10058, "E_FOPEN1", "Non-string arguments for fopen" }, - { 10059, "E_FOPEN2", "Unrecognized mode for fopen" }, - { 10060, "E_FREOPEN1", "Non-file first argument for freopen" }, - { 10061, "E_FREOPEN2", "Non-string or unrecognized mode for freopen" }, - { 10062, "E_FREOPEN3", "Non-string third argument for freopen" }, - { 10063, "E_FCLOSE1", "Non-file argument for fclose" }, + { 10051, "E_EXP_1", "Non-real epsilon for exp" }, + { 10052, "E_EXP_2", "Bad first argument for exp" }, + { 10053, "E_FPUTC_1", "Non-file first argument for fputc" }, + { 10054, "E_FPUTC_2", "Bad second argument for fputc" }, + { 10055, "E_FPUTC_3", "File not open for writing for fputc" }, + { 10056, "E_FGETC_1", "Non-file first argument for fgetc" }, + { 10057, "E_FGETC_2", "File not open for reading for fgetc" }, + { 10058, "E_FOPEN_1", "Non-string arguments for fopen" }, + { 10059, "E_FOPEN_2", "Unrecognized mode for fopen" }, + { 10060, "E_FREOPEN_1", "Non-file first argument for freopen" }, + { 10061, "E_FREOPEN_2", "Non-string or unrecognized mode for freopen" }, + { 10062, "E_FREOPEN_3", "Non-string third argument for freopen" }, + { 10063, "E_FCLOSE_1", "Non-file argument for fclose" }, { 10064, "E_FFLUSH", "Non-file argument for fflush" }, - { 10065, "E_FPUTS1", "Non-file first argument for fputs" }, - { 10066, "E_FPUTS2", "Non-string argument after first for fputs" }, - { 10067, "E_FPUTS3", "File not open for writing for fputs" }, - { 10068, "E_FGETS1", "Non-file argument for fgets" }, - { 10069, "E_FGETS2", "File not open for reading for fgets" }, - { 10070, "E_FPUTSTR1", "Non-file first argument for fputstr" }, - { 10071, "E_FPUTSTR2", "Non-string argument after first for fputstr" }, - { 10072, "E_FPUTSTR3", "File not open for writing for fputstr" }, - { 10073, "E_FGETSTR1", "Non-file first argument for fgetstr" }, - { 10074, "E_FGETSTR2", "File not open for reading for fgetstr" }, - { 10075, "E_FGETLINE1", "Non-file argument for fgetline" }, - { 10076, "E_FGETLINE2", "File not open for reading for fgetline" }, - { 10077, "E_FGETFIELD1", "Non-file argument for fgetfield" }, - { 10078, "E_FGETFIELD2", "File not open for reading for fgetfield" }, - { 10079, "E_REWIND1", "Non-file argument for rewind" }, + { 10065, "E_FPUTS_1", "Non-file first argument for fputs" }, + { 10066, "E_FPUTS_2", "Non-string argument after first for fputs" }, + { 10067, "E_FPUTS_3", "File not open for writing for fputs" }, + { 10068, "E_FGETS_1", "Non-file argument for fgets" }, + { 10069, "E_FGETS_2", "File not open for reading for fgets" }, + { 10070, "E_FPUTSTR_1", "Non-file first argument for fputstr" }, + { 10071, "E_FPUTSTR_2", "Non-string argument after first for fputstr" }, + { 10072, "E_FPUTSTR_3", "File not open for writing for fputstr" }, + { 10073, "E_FGETSTR_1", "Non-file first argument for fgetstr" }, + { 10074, "E_FGETSTR_2", "File not open for reading for fgetstr" }, + { 10075, "E_FGETLINE_1", "Non-file argument for fgetline" }, + { 10076, "E_FGETLINE_2", "File not open for reading for fgetline" }, + { 10077, "E_FGETFIELD_1", "Non-file argument for fgetfield" }, + { 10078, "E_FGETFIELD_2", "File not open for reading for fgetfield" }, + { 10079, "E_REWIND_1", "Non-file argument for rewind" }, { 10080, "E_FILES", "Non-integer argument for files" }, - { 10081, "E_PRINTF1", "Non-string fmt argument for fprint" }, - { 10082, "E_PRINTF2", "Stdout not open for writing to ???" }, - { 10083, "E_FPRINTF1", "Non-file first argument for fprintf" }, - { 10084, "E_FPRINTF2", "Non-string second (fmt) argument for fprintf" }, - { 10085, "E_FPRINTF3", "File not open for writing for fprintf" }, - { 10086, "E_STRPRINTF1", "Non-string first (fmt) argument for strprintf" }, - { 10087, "E_STRPRINTF2", "Error in attempting strprintf ???" }, - { 10088, "E_FSCAN1", "Non-file first argument for fscan" }, - { 10089, "E_FSCAN2", "File not open for reading for fscan" }, + { 10081, "E_PRINTF_1", "Non-string fmt argument for fprint" }, + { 10082, "E_PRINTF_2", "Stdout not open for writing to ???" }, + { 10083, "E_FPRINTF_1", "Non-file first argument for fprintf" }, + { 10084, "E_FPRINTF_2", "Non-string second (fmt) argument for fprintf" }, + { 10085, "E_FPRINTF_3", "File not open for writing for fprintf" }, + { 10086, "E_STRPRINTF_1", "Non-string first (fmt) argument for strprintf" }, + { 10087, "E_STRPRINTF_2", "Error in attempting strprintf ???" }, + { 10088, "E_FSCAN_1", "Non-file first argument for fscan" }, + { 10089, "E_FSCAN_2", "File not open for reading for fscan" }, { 10090, "E_STRSCAN", "Non-string first argument for strscan" }, - { 10091, "E_FSCANF1", "Non-file first argument for fscanf" }, - { 10092, "E_FSCANF2", "Non-string second (fmt) argument for fscanf" }, - { 10093, "E_FSCANF3", "Non-lvalue argument after second for fscanf" }, - { 10094, "E_FSCANF4", "File not open for reading or other error for fscanf" }, - { 10095, "E_STRSCANF1", "Non-string first argument for strscanf" }, - { 10096, "E_STRSCANF2", "Non-string second (fmt) argument for strscanf" }, - { 10097, "E_STRSCANF3", "Non-lvalue argument after second for strscanf" }, - { 10098, "E_STRSCANF4", "Some error in attempting strscanf ???" }, - { 10099, "E_SCANF1", "Non-string first (fmt) argument for scanf" }, - { 10100, "E_SCANF2", "Non-lvalue argument after first for scanf" }, - { 10101, "E_SCANF3", "Some error in attempting scanf ???" }, - { 10102, "E_FTELL1", "Non-file argument for ftell" }, - { 10103, "E_FTELL2", "File not open or other error for ftell" }, - { 10104, "E_FSEEK1", "Non-file first argument for fseek" }, - { 10105, "E_FSEEK2", "Non-integer or negative second argument for fseek" }, - { 10106, "E_FSEEK3", "File not open or other error for fseek" }, - { 10107, "E_FSIZE1", "Non-file argument for fsize" }, - { 10108, "E_FSIZE2", "File not open or other error for fsize" }, - { 10109, "E_FEOF1", "Non-file argument for feof" }, - { 10110, "E_FEOF2", "File not open or other error for feof" }, - { 10111, "E_FERROR1", "Non-file argument for ferror" }, - { 10112, "E_FERROR2", "File not open or other error for ferror" }, - { 10113, "E_UNGETC1", "Non-file argument for ungetc" }, - { 10114, "E_UNGETC2", "File not open for reading for ungetc" }, - { 10115, "E_UNGETC3", "Bad second argument or other error for ungetc" }, + { 10091, "E_FSCANF_1", "Non-file first argument for fscanf" }, + { 10092, "E_FSCANF_2", "Non-string second (fmt) argument for fscanf" }, + { 10093, "E_FSCANF_3", "Non-lvalue argument after second for fscanf" }, + { 10094, "E_FSCANF_4", "File not open for reading or other error for fscanf" }, + { 10095, "E_STRSCANF_1", "Non-string first argument for strscanf" }, + { 10096, "E_STRSCANF_2", "Non-string second (fmt) argument for strscanf" }, + { 10097, "E_STRSCANF_3", "Non-lvalue argument after second for strscanf" }, + { 10098, "E_STRSCANF_4", "Some error in attempting strscanf ???" }, + { 10099, "E_SCANF_1", "Non-string first (fmt) argument for scanf" }, + { 10100, "E_SCANF_2", "Non-lvalue argument after first for scanf" }, + { 10101, "E_SCANF_3", "Some error in attempting scanf ???" }, + { 10102, "E_FTELL_1", "Non-file argument for ftell" }, + { 10103, "E_FTELL_2", "File not open or other error for ftell" }, + { 10104, "E_FSEEK_1", "Non-file first argument for fseek" }, + { 10105, "E_FSEEK_2", "Non-integer or negative second argument for fseek" }, + { 10106, "E_FSEEK_3", "File not open or other error for fseek" }, + { 10107, "E_FSIZE_1", "Non-file argument for fsize" }, + { 10108, "E_FSIZE_2", "File not open or other error for fsize" }, + { 10109, "E_FEOF_1", "Non-file argument for feof" }, + { 10110, "E_FEOF_2", "File not open or other error for feof" }, + { 10111, "E_FERROR_1", "Non-file argument for ferror" }, + { 10112, "E_FERROR_2", "File not open or other error for ferror" }, + { 10113, "E_UNGETC_1", "Non-file argument for ungetc" }, + { 10114, "E_UNGETC_2", "File not open for reading for ungetc" }, + { 10115, "E_UNGETC_3", "Bad second argument or other error for ungetc" }, { 10116, "E_BIGEXP", "Exponent too big in scanning" }, - { 10117, "E_ISATTY1", "UNUSED ERROR: E_ISATTY1 is no longer used" }, - { 10118, "E_ISATTY2", "UNUSED ERROR: E_ISATTY2 is no longer used" }, - { 10119, "E_ACCESS1", "Non-string first argument for access" }, - { 10120, "E_ACCESS2", "Bad second argument for access" }, - { 10121, "E_SEARCH1", "Bad first argument for search" }, - { 10122, "E_SEARCH2", "Bad second argument for search" }, - { 10123, "E_SEARCH3", "Bad third argument for search" }, - { 10124, "E_SEARCH4", "Bad fourth argument for search" }, - { 10125, "E_SEARCH5", "Cannot find fsize or fpos for search" }, - { 10126, "E_SEARCH6", "File not readable for search" }, - { 10127, "E_RSEARCH1", "Bad first argument for rsearch" }, - { 10128, "E_RSEARCH2", "Bad second argument for rsearch" }, - { 10129, "E_RSEARCH3", "Bad third argument for rsearch" }, - { 10130, "E_RSEARCH4", "Bad fourth argument for rsearch" }, - { 10131, "E_RSEARCH5", "Cannot find fsize or fpos for rsearch" }, - { 10132, "E_RSEARCH6", "File not readable for rsearch" }, + { 10117, "E_ISATTY_1", "UNUSED ERROR: E_ISATTY_1 is no longer used" }, + { 10118, "E_ISATTY_2", "UNUSED ERROR: E_ISATTY_2 is no longer used" }, + { 10119, "E_ACCESS_1", "Non-string first argument for access" }, + { 10120, "E_ACCESS_2", "Bad second argument for access" }, + { 10121, "E_SEARCH_1", "Bad first argument for search" }, + { 10122, "E_SEARCH_2", "Bad second argument for search" }, + { 10123, "E_SEARCH_3", "Bad third argument for search" }, + { 10124, "E_SEARCH_4", "Bad fourth argument for search" }, + { 10125, "E_SEARCH_5", "Cannot find fsize or fpos for search" }, + { 10126, "E_SEARCH_6", "File not readable for search" }, + { 10127, "E_RSEARCH_1", "Bad first argument for rsearch" }, + { 10128, "E_RSEARCH_2", "Bad second argument for rsearch" }, + { 10129, "E_RSEARCH_3", "Bad third argument for rsearch" }, + { 10130, "E_RSEARCH_4", "Bad fourth argument for rsearch" }, + { 10131, "E_RSEARCH_5", "Cannot find fsize or fpos for rsearch" }, + { 10132, "E_RSEARCH_6", "File not readable for rsearch" }, { 10133, "E_MANYOPEN", "Too many open files" }, - { 10134, "E_REWIND2", "Attempt to rewind a file that is not open" }, - { 10135, "E_STRERROR1", "Bad argument type for strerror" }, - { 10136, "E_STRERROR2", "Index out of range for strerror" }, - { 10137, "E_COS1", "Bad epsilon for cos" }, - { 10138, "E_COS2", "Bad first argument for cos" }, - { 10139, "E_SIN1", "Bad epsilon for sin" }, - { 10140, "E_SIN2", "Bad first argument for sin" }, - { 10141, "E_EVAL2", "Non-string argument for eval" }, - { 10142, "E_ARG1", "Bad epsilon for arg" }, - { 10143, "E_ARG2", "Bad first argument for arg" }, - { 10144, "E_POLAR1", "Non-real argument for polar" }, - { 10145, "E_POLAR2", "Bad epsilon for polar" }, + { 10134, "E_REWIND_2", "Attempt to rewind a file that is not open" }, + { 10135, "E_STRERROR_1", "Bad argument type for strerror" }, + { 10136, "E_STRERROR_2", "Numeric argument is outside valid errnum range for strerror" }, + { 10137, "E_COS_1", "Bad epsilon for cos" }, + { 10138, "E_COS_2", "Bad first argument for cos" }, + { 10139, "E_SIN_1", "Bad epsilon for sin" }, + { 10140, "E_SIN_2", "Bad first argument for sin" }, + { 10141, "E_EVAL_2", "Non-string argument for eval" }, + { 10142, "E_ARG_1", "Bad epsilon for arg" }, + { 10143, "E_ARG_2", "Bad first argument for arg" }, + { 10144, "E_POLAR_1", "Non-real argument for polar" }, + { 10145, "E_POLAR_2", "Bad epsilon for polar" }, { 10146, "E_FCNT", "UNUSED ERROR: Non-integral argument for fcnt" }, - { 10147, "E_MATFILL1", "Non-variable first argument for matfill" }, - { 10148, "E_MATFILL2", "Non-matrix first argument-value for matfill" }, + { 10147, "E_MATFILL_1", "Non-variable first argument for matfill" }, + { 10148, "E_MATFILL_2", "Non-matrix first argument-value for matfill" }, { 10149, "E_MATDIM", "Non-matrix argument for matdim" }, { 10150, "E_MATSUM", "Non-matrix argument for matsum" }, { 10151, "E_ISIDENT", "UNUSED ERROR: E_ISIDENT is no longer used" }, - { 10152, "E_MATTRANS1", "Non-matrix argument for mattrans" }, - { 10153, "E_MATTRANS2", "Non-two-dimensional matrix for mattrans" }, - { 10154, "E_DET1", "Non-matrix argument for det" }, - { 10155, "E_DET2", "Matrix for det not of dimension 2" }, - { 10156, "E_DET3", "Non-square matrix for det" }, - { 10157, "E_MATMIN1", "Non-matrix first argument for matmin" }, - { 10158, "E_MATMIN2", "Non-positive-integer second argument for matmin" }, - { 10159, "E_MATMIN3", "Second argument for matmin exceeds dimension" }, - { 10160, "E_MATMAX1", "Non-matrix first argument for matmin" }, - { 10161, "E_MATMAX2", "Second argument for matmax not positive integer" }, - { 10162, "E_MATMAX3", "Second argument for matmax exceeds dimension" }, - { 10163, "E_CP1", "Non-matrix argument for cp" }, - { 10164, "E_CP2", "Non-one-dimensional matrix for cp" }, - { 10165, "E_CP3", "Matrix size not 3 for cp" }, - { 10166, "E_DP1", "Non-matrix argument for dp" }, - { 10167, "E_DP2", "Non-one-dimensional matrix for dp" }, - { 10168, "E_DP3", "Different-size matrices for dp" }, + { 10152, "E_MATTRANS_1", "Non-matrix argument for mattrans" }, + { 10153, "E_MATTRANS_2", "Non-two-dimensional matrix for mattrans" }, + { 10154, "E_DET_1", "Non-matrix argument for det" }, + { 10155, "E_DET_2", "Matrix for det not of dimension 2" }, + { 10156, "E_DET_3", "Non-square matrix for det" }, + { 10157, "E_MATMIN_1", "Non-matrix first argument for matmin" }, + { 10158, "E_MATMIN_2", "Non-positive-integer second argument for matmin" }, + { 10159, "E_MATMIN_3", "Second argument for matmin exceeds dimension" }, + { 10160, "E_MATMAX_1", "Non-matrix first argument for matmin" }, + { 10161, "E_MATMAX_2", "Second argument for matmax not positive integer" }, + { 10162, "E_MATMAX_3", "Second argument for matmax exceeds dimension" }, + { 10163, "E_CP_1", "Non-matrix argument for cp" }, + { 10164, "E_CP_2", "Non-one-dimensional matrix for cp" }, + { 10165, "E_CP_3", "Matrix size not 3 for cp" }, + { 10166, "E_DP_1", "Non-matrix argument for dp" }, + { 10167, "E_DP_2", "Non-one-dimensional matrix for dp" }, + { 10168, "E_DP_3", "Different-size matrices for dp" }, { 10169, "E_STRLEN", "Non-string argument for strlen" }, { 10170, "E_STRCAT", "Non-string argument for strcat" }, - { 10171, "E_SUBSTR1", "Non-string first argument for strcat" }, - { 10172, "E_SUBSTR2", "Non-non-negative integer second argument for strcat" }, + { 10171, "E_SUBSTR_1", "Non-string first argument for strcat" }, + { 10172, "E_SUBSTR_2", "Non-non-negative integer second argument for strcat" }, { 10173, "E_CHAR", "Bad argument for char" }, { 10174, "E_ORD", "Non-string argument for ord" }, - { 10175, "E_INSERT1", "Non-list-variable first argument for insert" }, - { 10176, "E_INSERT2", "Non-integral second argument for insert" }, + { 10175, "E_INSERT_1", "Non-list-variable first argument for insert" }, + { 10176, "E_INSERT_2", "Non-integral second argument for insert" }, { 10177, "E_PUSH", "Non-list-variable first argument for push" }, { 10178, "E_APPEND", "Non-list-variable first argument for append" }, - { 10179, "E_DELETE1", "Non-list-variable first argument for delete" }, - { 10180, "E_DELETE2", "Non-integral second argument for delete" }, + { 10179, "E_DELETE_1", "Non-list-variable first argument for delete" }, + { 10180, "E_DELETE_2", "Non-integral second argument for delete" }, { 10181, "E_POP", "Non-list-variable argument for pop" }, { 10182, "E_REMOVE", "Non-list-variable argument for remove" }, - { 10183, "E_LN1", "Bad epsilon argument for ln" }, - { 10184, "E_LN2", "Non-numeric first argument for ln" }, - { 10185, "E_ERROR1", "Non-integer argument for error" }, - { 10186, "E_ERROR2", "Argument outside range for error" }, - { 10187, "E_EVAL3", "Attempt to eval at maximum input depth" }, - { 10188, "E_EVAL4", "Unable to open string for reading" }, - { 10189, "E_RM1", "First argument for rm is not a non-empty string" }, - { 10190, "E_RM2", "UNUSED ERROR: Unable to remove a file" }, + { 10183, "E_LN_1", "Bad epsilon argument for ln" }, + { 10184, "E_LN_2", "Non-numeric first argument for ln" }, + { 10185, "E_ERROR_1", "Invalid argument type for error" }, + { 10186, "E_ERROR_2", "Numeric argument is outside valid errnum range for error" }, + { 10187, "E_EVAL_3", "Attempt to eval at maximum input depth" }, + { 10188, "E_EVAL_4", "Unable to open string for reading" }, + { 10189, "E_RM_1", "First argument for rm is not a non-empty string" }, + { 10190, "E_RM_2", "UNUSED ERROR: Unable to remove a file" }, { 10191, "E_RDPERM", "UNUSED ERROR: Operation allowed because calc mode disallows read operations" }, { 10192, "E_WRPERM", "Operation allowed because calc mode disallows write operations" }, { 10193, "E_EXPERM", "UNUSED ERROR: Operation allowed because calc mode disallows exec operations" }, @@ -283,104 +350,104 @@ CONST struct errtbl error_table[] = { { 10199, "E_NO_C_ARG", "Calc must be run with a -C argument to use custom function" }, { 10200, "E_NO_CUSTOM", "Calc was built with custom functions disabled" }, { 10201, "E_UNK_CUSTOM", "Custom function unknown, try: show custom" }, - { 10202, "E_BLK1", "Non-integral length for block" }, - { 10203, "E_BLK2", "Negative or too-large length for block" }, - { 10204, "E_BLK3", "Non-integral chunksize for block" }, - { 10205, "E_BLK4", "Negative or too-large chunksize for block" }, - { 10206, "E_BLKFREE1", "Named block does not exist for blkfree" }, - { 10207, "E_BLKFREE2", "Non-integral id specification for blkfree" }, - { 10208, "E_BLKFREE3", "Block with specified id does not exist" }, - { 10209, "E_BLKFREE4", "Block already freed" }, - { 10210, "E_BLKFREE5", "No-realloc protection prevents blkfree" }, - { 10211, "E_BLOCKS1", "Non-integer argument for blocks" }, - { 10212, "E_BLOCKS2", "Non-allocated index number for blocks" }, - { 10213, "E_COPY1", "Non-integer or negative source index for copy" }, - { 10214, "E_COPY2", "Source index too large for copy" }, - { 10215, "E_COPY3", "UNUSED ERROR: E_COPY3 is no longer used" }, - { 10216, "E_COPY4", "Non-integer or negative number for copy" }, - { 10217, "E_COPY5", "Number too large for copy" }, - { 10218, "E_COPY6", "Non-integer or negative destination index for copy" }, - { 10219, "E_COPY7", "Destination index too large for copy" }, - { 10220, "E_COPY8", "Freed block source for copy" }, - { 10221, "E_COPY9", "Unsuitable source type for copy" }, - { 10222, "E_COPY10", "Freed block destination for copy" }, - { 10223, "E_COPY11", "Unsuitable destination type for copy" }, - { 10224, "E_COPY12", "Incompatible source and destination for copy" }, - { 10225, "E_COPY13", "No-copy-from source variable" }, - { 10226, "E_COPY14", "No-copy-to destination variable" }, - { 10227, "E_COPY15", "No-copy-from source named block" }, - { 10228, "E_COPY16", "No-copy-to destination named block" }, - { 10229, "E_COPY17", "No-relocate destination for copy" }, - { 10230, "E_COPYF1", "File not open for copy" }, - { 10231, "E_COPYF2", "fseek or fsize failure for copy" }, - { 10232, "E_COPYF3", "fwrite error for copy" }, - { 10233, "E_COPYF4", "fread error for copy" }, - { 10234, "E_PROTECT1", "Non-variable first argument for protect" }, - { 10235, "E_PROTECT2", "Bad second argument for protect" }, - { 10236, "E_PROTECT3", "Bad third argument for protect" }, - { 10237, "E_MATFILL3", "No-copy-to destination for matfill" }, - { 10238, "E_MATFILL4", "No-assign-from source for matfill" }, - { 10239, "E_MATTRACE1", "Non-matrix argument for mattrace" }, - { 10240, "E_MATTRACE2", "Non-two-dimensional argument for mattrace" }, - { 10241, "E_MATTRACE3", "Non-square argument for mattrace" }, - { 10242, "E_TAN1", "Bad epsilon for tan" }, - { 10243, "E_TAN2", "Bad argument for tan" }, - { 10244, "E_COT1", "Bad epsilon for cot" }, - { 10245, "E_COT2", "Bad argument for cot" }, - { 10246, "E_SEC1", "Bad epsilon for sec" }, - { 10247, "E_SEC2", "Bad argument for sec" }, - { 10248, "E_CSC1", "Bad epsilon for csc" }, - { 10249, "E_CSC2", "Bad argument for csc" }, - { 10250, "E_SINH1", "Bad epsilon for sinh" }, - { 10251, "E_SINH2", "Bad argument for sinh" }, - { 10252, "E_COSH1", "Bad epsilon for cosh" }, - { 10253, "E_COSH2", "Bad argument for cosh" }, - { 10254, "E_TANH1", "Bad epsilon for tanh" }, - { 10255, "E_TANH2", "Bad argument for tanh" }, - { 10256, "E_COTH1", "Bad epsilon for coth" }, - { 10257, "E_COTH2", "Bad argument for coth" }, - { 10258, "E_SECH1", "Bad epsilon for sech" }, - { 10259, "E_SECH2", "Bad argument for sech" }, - { 10260, "E_CSCH1", "Bad epsilon for csch" }, - { 10261, "E_CSCH2", "Bad argument for csch" }, - { 10262, "E_ASIN1", "Bad epsilon for asin" }, - { 10263, "E_ASIN2", "Bad argument for asin" }, - { 10264, "E_ACOS1", "Bad epsilon for acos" }, - { 10265, "E_ACOS2", "Bad argument for acos" }, - { 10266, "E_ATAN1", "Bad epsilon for atan" }, - { 10267, "E_ATAN2", "Bad argument for atan" }, - { 10268, "E_ACOT1", "Bad epsilon for acot" }, - { 10269, "E_ACOT2", "Bad argument for acot" }, - { 10270, "E_ASEC1", "Bad epsilon for asec" }, - { 10271, "E_ASEC2", "Bad argument for asec" }, - { 10272, "E_ACSC1", "Bad epsilon for acsc" }, - { 10273, "E_ACSC2", "Bad argument for acsc" }, - { 10274, "E_ASINH1", "Bad epsilon for asin" }, - { 10275, "E_ASINH2", "Bad argument for asinh" }, - { 10276, "E_ACOSH1", "Bad epsilon for acosh" }, - { 10277, "E_ACOSH2", "Bad argument for acosh" }, - { 10278, "E_ATANH1", "Bad epsilon for atanh" }, - { 10279, "E_ATANH2", "Bad argument for atanh" }, - { 10280, "E_ACOTH1", "Bad epsilon for acoth" }, - { 10281, "E_ACOTH2", "Bad argument for acoth" }, - { 10282, "E_ASECH1", "UNUSED ERROR: Bad epsilon for asech" }, - { 10283, "E_ASECH2", "Bad argument for asech" }, - { 10284, "E_ACSCH1", "Bad epsilon for acsch" }, - { 10285, "E_ACSCH2", "Bad argument for acsch" }, - { 10286, "E_GD1", "Bad epsilon for gd" }, - { 10287, "E_GD2", "Bad argument for gd" }, - { 10288, "E_AGD1", "Bad epsilon for agd" }, - { 10289, "E_AGD2", "Bad argument for agd" }, + { 10202, "E_BLK_1", "Non-integral length for block" }, + { 10203, "E_BLK_2", "Negative or too-large length for block" }, + { 10204, "E_BLK_3", "Non-integral chunksize for block" }, + { 10205, "E_BLK_4", "Negative or too-large chunksize for block" }, + { 10206, "E_BLKFREE_1", "Named block does not exist for blkfree" }, + { 10207, "E_BLKFREE_2", "Non-integral id specification for blkfree" }, + { 10208, "E_BLKFREE_3", "Block with specified id does not exist" }, + { 10209, "E_BLKFREE_4", "Block already freed" }, + { 10210, "E_BLKFREE_5", "No-realloc protection prevents blkfree" }, + { 10211, "E_BLOCKS_1", "Non-integer argument for blocks" }, + { 10212, "E_BLOCKS_2", "Non-allocated index number for blocks" }, + { 10213, "E_COPY_01", "Non-integer or negative source index for copy" }, + { 10214, "E_COPY_02", "Source index too large for copy" }, + { 10215, "E_COPY_03", "UNUSED ERROR: E_COPY_03 is no longer used" }, + { 10216, "E_COPY_04", "Non-integer or negative number for copy" }, + { 10217, "E_COPY_05", "Number too large for copy" }, + { 10218, "E_COPY_06", "Non-integer or negative destination index for copy" }, + { 10219, "E_COPY_07", "Destination index too large for copy" }, + { 10220, "E_COPY_08", "Freed block source for copy" }, + { 10221, "E_COPY_09", "Unsuitable source type for copy" }, + { 10222, "E_COPY_10", "Freed block destination for copy" }, + { 10223, "E_COPY_11", "Unsuitable destination type for copy" }, + { 10224, "E_COPY_12", "Incompatible source and destination for copy" }, + { 10225, "E_COPY_13", "No-copy-from source variable" }, + { 10226, "E_COPY_14", "No-copy-to destination variable" }, + { 10227, "E_COPY_15", "No-copy-from source named block" }, + { 10228, "E_COPY_16", "No-copy-to destination named block" }, + { 10229, "E_COPY_17", "No-relocate destination for copy" }, + { 10230, "E_COPYF_1", "File not open for copy" }, + { 10231, "E_COPYF_2", "fseek or fsize failure for copy" }, + { 10232, "E_COPYF_3", "fwrite error for copy" }, + { 10233, "E_COPYF_4", "fread error for copy" }, + { 10234, "E_PROTECT_1", "Non-variable first argument for protect" }, + { 10235, "E_PROTECT_2", "Bad second argument for protect" }, + { 10236, "E_PROTECT_3", "Bad third argument for protect" }, + { 10237, "E_MATFILL_3", "No-copy-to destination for matfill" }, + { 10238, "E_MATFILL_4", "No-assign-from source for matfill" }, + { 10239, "E_MATTRACE_1", "Non-matrix argument for mattrace" }, + { 10240, "E_MATTRACE_2", "Non-two-dimensional argument for mattrace" }, + { 10241, "E_MATTRACE_3", "Non-square argument for mattrace" }, + { 10242, "E_TAN_1", "Bad epsilon for tan" }, + { 10243, "E_TAN_2", "Bad argument for tan" }, + { 10244, "E_COT_1", "Bad epsilon for cot" }, + { 10245, "E_COT_2", "Bad argument for cot" }, + { 10246, "E_SEC_1", "Bad epsilon for sec" }, + { 10247, "E_SEC_2", "Bad argument for sec" }, + { 10248, "E_CSC_1", "Bad epsilon for csc" }, + { 10249, "E_CSC_2", "Bad argument for csc" }, + { 10250, "E_SINH_1", "Bad epsilon for sinh" }, + { 10251, "E_SINH_2", "Bad argument for sinh" }, + { 10252, "E_COSH_1", "Bad epsilon for cosh" }, + { 10253, "E_COSH_2", "Bad argument for cosh" }, + { 10254, "E_TANH_1", "Bad epsilon for tanh" }, + { 10255, "E_TANH_2", "Bad argument for tanh" }, + { 10256, "E_COTH_1", "Bad epsilon for coth" }, + { 10257, "E_COTH_2", "Bad argument for coth" }, + { 10258, "E_SECH_1", "Bad epsilon for sech" }, + { 10259, "E_SECH_2", "Bad argument for sech" }, + { 10260, "E_CSCH_1", "Bad epsilon for csch" }, + { 10261, "E_CSCH_2", "Bad argument for csch" }, + { 10262, "E_ASIN_1", "Bad epsilon for asin" }, + { 10263, "E_ASIN_2", "Bad argument for asin" }, + { 10264, "E_ACOS_1", "Bad epsilon for acos" }, + { 10265, "E_ACOS_2", "Bad argument for acos" }, + { 10266, "E_ATAN_1", "Bad epsilon for atan" }, + { 10267, "E_ATAN_2", "Bad argument for atan" }, + { 10268, "E_ACOT_1", "Bad epsilon for acot" }, + { 10269, "E_ACOT_2", "Bad argument for acot" }, + { 10270, "E_ASEC_1", "Bad epsilon for asec" }, + { 10271, "E_ASEC_2", "Bad argument for asec" }, + { 10272, "E_ACSC_1", "Bad epsilon for acsc" }, + { 10273, "E_ACSC_2", "Bad argument for acsc" }, + { 10274, "E_ASINH_1", "Bad epsilon for asin" }, + { 10275, "E_ASINH_2", "Bad argument for asinh" }, + { 10276, "E_ACOSH_1", "Bad epsilon for acosh" }, + { 10277, "E_ACOSH_2", "Bad argument for acosh" }, + { 10278, "E_ATANH_1", "Bad epsilon for atanh" }, + { 10279, "E_ATANH_2", "Bad argument for atanh" }, + { 10280, "E_ACOTH_1", "Bad epsilon for acoth" }, + { 10281, "E_ACOTH_2", "Bad argument for acoth" }, + { 10282, "E_ASECH_1", "UNUSED ERROR: Bad epsilon for asech" }, + { 10283, "E_ASECH_2", "Bad argument for asech" }, + { 10284, "E_ACSCH_1", "Bad epsilon for acsch" }, + { 10285, "E_ACSCH_2", "Bad argument for acsch" }, + { 10286, "E_GD_1", "Bad epsilon for gd" }, + { 10287, "E_GD_2", "Bad argument for gd" }, + { 10288, "E_AGD_1", "Bad epsilon for agd" }, + { 10289, "E_AGD_2", "Bad argument for agd" }, { 10290, "E_LOGINF", "Log of zero or infinity" }, { 10291, "E_STRADD", "String addition failure" }, { 10292, "E_STRMUL", "String multiplication failure" }, { 10293, "E_STRNEG", "String reversal failure" }, { 10294, "E_STRSUB", "String subtraction failure" }, - { 10295, "E_BIT1", "Bad argument type for bit" }, - { 10296, "E_BIT2", "Index too large for bit" }, - { 10297, "E_SETBIT1", "Non-integer second argument for setbit" }, - { 10298, "E_SETBIT2", "Out-of-range index for setbit" }, - { 10299, "E_SETBIT3", "Non-string first argument for setbit" }, + { 10295, "E_BIT_1", "Bad argument type for bit" }, + { 10296, "E_BIT_2", "Index too large for bit" }, + { 10297, "E_SETBIT_1", "Non-integer second argument for setbit" }, + { 10298, "E_SETBIT_2", "Out-of-range index for setbit" }, + { 10299, "E_SETBIT_3", "Non-string first argument for setbit" }, { 10300, "E_OR", "Bad argument for or" }, { 10301, "E_AND", "Bad argument for and" }, { 10302, "E_STROR", "Allocation failure for string or" }, @@ -389,116 +456,116 @@ CONST struct errtbl error_table[] = { { 10305, "E_COMP", "Bad argument for comp" }, { 10306, "E_STRDIFF", "Allocation failure for string diff" }, { 10307, "E_STRCOMP", "Allocation failure for string comp" }, - { 10308, "E_SEG1", "Bad first argument for segment" }, - { 10309, "E_SEG2", "Bad second argument for segment" }, - { 10310, "E_SEG3", "Bad third argument for segment" }, + { 10308, "E_SEG_1", "Bad first argument for segment" }, + { 10309, "E_SEG_2", "Bad second argument for segment" }, + { 10310, "E_SEG_3", "Bad third argument for segment" }, { 10311, "E_STRSEG", "Failure for string segment" }, - { 10312, "E_HIGHBIT1", "Bad argument type for highbit" }, - { 10313, "E_HIGHBIT2", "Non-integer argument for highbit" }, - { 10314, "E_LOWBIT1", "Bad argument type for lowbit" }, - { 10315, "E_LOWBIT2", "Non-integer argument for lowbit" }, + { 10312, "E_HIGHBIT_1", "Bad argument type for highbit" }, + { 10313, "E_HIGHBIT_2", "Non-integer argument for highbit" }, + { 10314, "E_LOWBIT_1", "Bad argument type for lowbit" }, + { 10315, "E_LOWBIT_2", "Non-integer argument for lowbit" }, { 10316, "E_CONTENT", "Bad argument type for unary hash op" }, { 10317, "E_HASHOP", "Bad argument type for binary hash op" }, - { 10318, "E_HEAD1", "Bad first argument for head" }, - { 10319, "E_HEAD2", "Bad second argument for head" }, + { 10318, "E_HEAD_1", "Bad first argument for head" }, + { 10319, "E_HEAD_2", "Bad second argument for head" }, { 10320, "E_STRHEAD", "Failure for strhead" }, - { 10321, "E_TAIL1", "Bad first argument for tail" }, - { 10322, "E_TAIL2", "UNUSED ERROR: Bad second argument for tail" }, + { 10321, "E_TAIL_1", "Bad first argument for tail" }, + { 10322, "E_TAIL_2", "UNUSED ERROR: Bad second argument for tail" }, { 10323, "E_STRTAIL", "Failure for strtail" }, { 10324, "E_STRSHIFT", "Failure for strshift" }, { 10325, "E_STRCMP", "Non-string argument for strcmp" }, { 10326, "E_STRNCMP", "Bad argument type for strncmp" }, - { 10327, "E_XOR1", "Varying types of argument for xor" }, - { 10328, "E_XOR2", "Bad argument type for xor" }, + { 10327, "E_XOR_1", "Varying types of argument for xor" }, + { 10328, "E_XOR_2", "Bad argument type for xor" }, { 10329, "E_STRCPY", "Bad argument type for strcpy" }, { 10330, "E_STRNCPY", "Bad argument type for strncpy" }, { 10331, "E_BACKSLASH", "Bad argument type for unary backslash" }, { 10332, "E_SETMINUS", "Bad argument type for setminus" }, - { 10333, "E_INDICES1", "Bad first argument type for indices" }, - { 10334, "E_INDICES2", "Bad second argument for indices" }, - { 10335, "E_EXP3", "Too-large re(argument) for exp" }, - { 10336, "E_SINH3", "Too-large re(argument) for sinh" }, - { 10337, "E_COSH3", "Too-large re(argument) for cosh" }, - { 10338, "E_SIN3", "Too-large im(argument) for sin" }, - { 10339, "E_COS3", "Too-large im(argument) for cos" }, - { 10340, "E_GD3", "Infinite or too-large result for gd" }, - { 10341, "E_AGD3", "Infinite or too-large result for agd" }, - { 10342, "E_POWER4", "Too-large value for power" }, - { 10343, "E_ROOT4", "Too-large value for root" }, - { 10344, "E_DGT1", "Non-real first arg for digit" }, - { 10345, "E_DGT2", "Non-integral second arg for digit" }, - { 10346, "E_DGT3", "Bad third arg for digit" }, - { 10347, "E_PLCS1", "Bad first argument for places" }, - { 10348, "E_PLCS2", "Bad second argument for places" }, - { 10349, "E_DGTS1", "Bad first argument for digits" }, - { 10350, "E_DGTS2", "Bad second argument for digits" }, + { 10333, "E_INDICES_1", "Bad first argument type for indices" }, + { 10334, "E_INDICES_2", "Bad second argument for indices" }, + { 10335, "E_EXP_3", "Too-large re(argument) for exp" }, + { 10336, "E_SINH_3", "Too-large re(argument) for sinh" }, + { 10337, "E_COSH_3", "Too-large re(argument) for cosh" }, + { 10338, "E_SIN_3", "Too-large im(argument) for sin" }, + { 10339, "E_COS_3", "Too-large im(argument) for cos" }, + { 10340, "E_GD_3", "Infinite or too-large result for gd" }, + { 10341, "E_AGD_3", "Infinite or too-large result for agd" }, + { 10342, "E_POWER_4", "Too-large value for power" }, + { 10343, "E_ROOT_4", "Too-large value for root" }, + { 10344, "E_DGT_1", "Non-real first arg for digit" }, + { 10345, "E_DGT_2", "Non-integral second arg for digit" }, + { 10346, "E_DGT_3", "Bad third arg for digit" }, + { 10347, "E_PLCS_1", "Bad first argument for places" }, + { 10348, "E_PLCS_2", "Bad second argument for places" }, + { 10349, "E_DGTS_1", "Bad first argument for digits" }, + { 10350, "E_DGTS_2", "Bad second argument for digits" }, { 10351, "E_ILOG", "Bad first argument for ilog" }, { 10352, "E_ILOGB", "Bad second argument for ilog" }, - { 10353, "E_ILOG10", "Bad argument for ilog10" }, - { 10354, "E_ILOG2", "Bad argument for ilog2" }, - { 10355, "E_COMB1", "Non-integer second arg for comb" }, - { 10356, "E_COMB2", "Too-large second arg for comb" }, + { 10353, "E_IBASE10_LOG", "Bad argument for ilog10" }, + { 10354, "E_IBASE2_LOG", "Bad argument for ilog2" }, + { 10355, "E_COMB_1", "Non-integer second arg for comb" }, + { 10356, "E_COMB_2", "Too-large second arg for comb" }, { 10357, "E_CTLN", "Bad argument for catalan" }, { 10358, "E_BERN", "Bad argument for bern" }, { 10359, "E_EULER", "Bad argument for euler" }, { 10360, "E_SLEEP", "Bad argument for sleep" }, { 10361, "E_TTY", "calc_tty failure" }, - { 10362, "E_ASSIGN1", "No-copy-to destination for octet assign" }, - { 10363, "E_ASSIGN2", "No-copy-from source for octet assign" }, - { 10364, "E_ASSIGN3", "No-change destination for octet assign" }, - { 10365, "E_ASSIGN4", "Non-variable destination for assign" }, - { 10366, "E_ASSIGN5", "No-assign-to destination for assign" }, - { 10367, "E_ASSIGN6", "No-assign-from source for assign" }, - { 10368, "E_ASSIGN7", "No-change destination for assign" }, - { 10369, "E_ASSIGN8", "No-type-change destination for assign" }, - { 10370, "E_ASSIGN9", "No-error-value destination for assign" }, - { 10371, "E_SWAP1", "No-copy argument for octet swap" }, - { 10372, "E_SWAP2", "No-assign-to-or-from argument for swap" }, - { 10373, "E_SWAP3", "Non-lvalue argument for swap" }, - { 10374, "E_QUOMOD1", "Non-lvalue argument 3 or 4 for quomod" }, - { 10375, "E_QUOMOD2", "Non-real-number arg 1 or 2 or bad arg 5 for quomod" }, - { 10376, "E_QUOMOD3", "No-assign-to argument 3 or 4 for quomod" }, - { 10377, "E_PREINC1", "No-copy-to or no-change argument for octet preinc" }, - { 10378, "E_PREINC2", "Non-variable argument for preinc" }, - { 10379, "E_PREINC3", "No-assign-to or no-change argument for preinc" }, - { 10380, "E_PREDEC1", "No-copy-to or no-change argument for octet predec" }, - { 10381, "E_PREDEC2", "Non-variable argument for predec" }, - { 10382, "E_PREDEC3", "No-assign-to or no-change argument for predec" }, - { 10383, "E_POSTINC1", "No-copy-to or no-change argument for octet postinc" }, - { 10384, "E_POSTINC2", "Non-variable argument for postinc" }, - { 10385, "E_POSTINC3", "No-assign-to or no-change argument for postinc" }, - { 10386, "E_POSTDEC1", "No-copy-to or no-change argument for octet postdec" }, - { 10387, "E_POSTDEC2", "Non-variable argument for postdec" }, - { 10388, "E_POSTDEC3", "No-assign-to or no-change argument for postdec" }, - { 10389, "E_INIT1", "Error-type structure for initialization" }, - { 10390, "E_INIT2", "No-copy-to structure for initialization" }, - { 10391, "E_INIT3", "Too many initializer values" }, - { 10392, "E_INIT4", "Attempt to initialize freed named block" }, - { 10393, "E_INIT5", "Bad structure type for initialization" }, - { 10394, "E_INIT6", "No-assign-to element for initialization" }, - { 10395, "E_INIT7", "No-change element for initialization" }, - { 10396, "E_INIT8", "No-type-change element for initialization" }, - { 10397, "E_INIT9", "No-error-value element for initialization" }, - { 10398, "E_INIT10", "No-assign-or-copy-from source for initialization" }, - { 10399, "E_LIST1", "No-relocate for list insert" }, - { 10400, "E_LIST2", "No-relocate for list delete" }, - { 10401, "E_LIST3", "No-relocate for list push" }, - { 10402, "E_LIST4", "No-relocate for list append" }, - { 10403, "E_LIST5", "No-relocate for list pop" }, - { 10404, "E_LIST6", "No-relocate for list remove" }, - { 10405, "E_MODIFY1", "Non-variable first argument for modify" }, - { 10406, "E_MODIFY2", "Non-string second argument for modify" }, - { 10407, "E_MODIFY3", "No-change first argument for modify" }, - { 10408, "E_MODIFY4", "Undefined function for modify" }, - { 10409, "E_MODIFY5", "Unacceptable type first argument for modify" }, - { 10410, "E_FPATHOPEN1", "Non-string arguments for fpathopen" }, - { 10411, "E_FPATHOPEN2", "Unrecognized mode for fpathopen" }, - { 10412, "E_LOG1", "Bad epsilon argument for log" }, - { 10413, "E_LOG2", "Non-numeric first argument for log" }, - { 10414, "E_LOG3", "Cannot calculate log for this value" }, - { 10415, "E_FGETFILE1", "Non-file argument for fgetfile" }, - { 10416, "E_FGETFILE2", "File argument for fgetfile not open for reading" }, - { 10417, "E_FGETFILE3", "Unable to set file position in fgetfile" }, + { 10362, "E_ASSIGN_1", "No-copy-to destination for octet assign" }, + { 10363, "E_ASSIGN_2", "No-copy-from source for octet assign" }, + { 10364, "E_ASSIGN_3", "No-change destination for octet assign" }, + { 10365, "E_ASSIGN_4", "Non-variable destination for assign" }, + { 10366, "E_ASSIGN_5", "No-assign-to destination for assign" }, + { 10367, "E_ASSIGN_6", "No-assign-from source for assign" }, + { 10368, "E_ASSIGN_7", "No-change destination for assign" }, + { 10369, "E_ASSIGN_8", "No-type-change destination for assign" }, + { 10370, "E_ASSIGN_9", "No-error-value destination for assign" }, + { 10371, "E_SWAP_1", "No-copy argument for octet swap" }, + { 10372, "E_SWAP_2", "No-assign-to-or-from argument for swap" }, + { 10373, "E_SWAP_3", "Non-lvalue argument for swap" }, + { 10374, "E_QUOMOD_1", "Non-lvalue argument 3 or 4 for quomod" }, + { 10375, "E_QUOMOD_2", "Non-real-number arg 1 or 2 or bad arg 5 for quomod" }, + { 10376, "E_QUOMOD_3", "No-assign-to argument 3 or 4 for quomod" }, + { 10377, "E_PREINC_1", "No-copy-to or no-change argument for octet preinc" }, + { 10378, "E_PREINC_2", "Non-variable argument for preinc" }, + { 10379, "E_PREINC_3", "No-assign-to or no-change argument for preinc" }, + { 10380, "E_PREDEC_1", "No-copy-to or no-change argument for octet predec" }, + { 10381, "E_PREDEC_2", "Non-variable argument for predec" }, + { 10382, "E_PREDEC_3", "No-assign-to or no-change argument for predec" }, + { 10383, "E_POSTINC_1", "No-copy-to or no-change argument for octet postinc" }, + { 10384, "E_POSTINC_2", "Non-variable argument for postinc" }, + { 10385, "E_POSTINC_3", "No-assign-to or no-change argument for postinc" }, + { 10386, "E_POSTDEC_1", "No-copy-to or no-change argument for octet postdec" }, + { 10387, "E_POSTDEC_2", "Non-variable argument for postdec" }, + { 10388, "E_POSTDEC_3", "No-assign-to or no-change argument for postdec" }, + { 10389, "E_INIT_01", "Error-type structure for initialization" }, + { 10390, "E_INIT_02", "No-copy-to structure for initialization" }, + { 10391, "E_INIT_03", "Too many initializer values" }, + { 10392, "E_INIT_04", "Attempt to initialize freed named block" }, + { 10393, "E_INIT_05", "Bad structure type for initialization" }, + { 10394, "E_INIT_06", "No-assign-to element for initialization" }, + { 10395, "E_INIT_07", "No-change element for initialization" }, + { 10396, "E_INIT_08", "No-type-change element for initialization" }, + { 10397, "E_INIT_09", "No-error-value element for initialization" }, + { 10398, "E_INIT_10", "No-assign-or-copy-from source for initialization" }, + { 10399, "E_LIST_1", "No-relocate for list insert" }, + { 10400, "E_LIST_2", "No-relocate for list delete" }, + { 10401, "E_LIST_3", "No-relocate for list push" }, + { 10402, "E_LIST_4", "No-relocate for list append" }, + { 10403, "E_LIST_5", "No-relocate for list pop" }, + { 10404, "E_LIST_6", "No-relocate for list remove" }, + { 10405, "E_MODIFY_1", "Non-variable first argument for modify" }, + { 10406, "E_MODIFY_2", "Non-string second argument for modify" }, + { 10407, "E_MODIFY_3", "No-change first argument for modify" }, + { 10408, "E_MODIFY_4", "Undefined function for modify" }, + { 10409, "E_MODIFY_5", "Unacceptable type first argument for modify" }, + { 10410, "E_FPATHOPEN_1", "Non-string arguments for fpathopen" }, + { 10411, "E_FPATHOPEN_2", "Unrecognized mode for fpathopen" }, + { 10412, "E_LOG_1", "Bad epsilon argument for log" }, + { 10413, "E_LOG_2", "Non-numeric first argument for log" }, + { 10414, "E_LOG_3", "Cannot calculate log for this value" }, + { 10415, "E_FGETFILE_1", "Non-file argument for fgetfile" }, + { 10416, "E_FGETFILE_2", "File argument for fgetfile not open for reading" }, + { 10417, "E_FGETFILE_3", "Unable to set file position in fgetfile" }, { 10418, "E_ESTR", "UNUSED ERROR: Non-representable type for estr" }, { 10419, "E_STRCASECMP", "Non-string argument for strcasecmp" }, { 10420, "E_STRNCASECMP", "Bad argument type for strncasecmp" }, @@ -516,76 +583,76 @@ CONST struct errtbl error_table[] = { { 10432, "E_ISXDIGIT", "Bad argument for isxdigit" }, { 10433, "E_STRTOUPPER", "Bad argument type for strtoupper" }, { 10434, "E_STRTOLOWER", "Bad argument type for strtolower" }, - { 10435, "E_TAN3", "UNUSED ERROR: Invalid value for calculating the sin numerator for tan" }, - { 10436, "E_TAN4", "UNUSED ERROR: Invalid value for calculating the cos denominator for tan" }, - { 10437, "E_COT3", "UNUSED ERROR: Invalid value for calculating the sin numerator for cot" }, - { 10438, "E_COT4", "UNUSED ERROR: Invalid value for calculating the cos denominator for cot" }, - { 10439, "E_SEC3", "UNUSED ERROR: Invalid value for calculating the cos reciprocal for sec" }, - { 10440, "E_CSC3", "UNUSED ERROR: Invalid value for calculating the sin reciprocal for csc" }, - { 10441, "E_TANH3", "Invalid value for calculating the sinh numerator for tanh" }, - { 10442, "E_TANH4", "Invalid value for calculating the cosh denominator for tanh" }, - { 10443, "E_COTH3", "Invalid value for calculating the sinh numerator for coth" }, - { 10444, "E_COTH4", "Invalid value for calculating the cosh denominator for coth" }, - { 10445, "E_SECH3", "Invalid value for calculating the cosh reciprocal for sech" }, - { 10446, "E_CSCH3", "Invalid value for calculating the sinh reciprocal for csch" }, - { 10447, "E_ASIN3", "Invalid value for calculating asin" }, - { 10448, "E_ACOS3", "Invalid value for calculating acos" }, - { 10449, "E_ASINH3", "Invalid value for calculating asinh" }, - { 10450, "E_ACOSH3", "Invalid value for calculating acosn" }, - { 10451, "E_ATAN3", "Invalid value for calculating atan" }, - { 10452, "E_ACOT3", "Invalid value for calculating acot" }, - { 10453, "E_ASEC3", "Invalid value for calculating asec" }, - { 10454, "E_ACSC3", "Invalid value for calculating acsc" }, - { 10455, "E_ATANH3", "Invalid value for calculating atan" }, - { 10456, "E_ACOTH3", "Invalid value for calculating acot" }, - { 10457, "E_ASECH3", "Invalid value for calculating asec" }, - { 10458, "E_ACSCH3", "Invalid value for calculating acsc" }, - { 10459, "E_D2R1", "Bad epsilon for converting degrees to radians" }, - { 10460, "E_D2R2", "Bad first argument converting degrees to radians" }, - { 10461, "E_R2D1", "Bad epsilon for converting radians to degrees" }, - { 10462, "E_R2D2", "Bad first argument converting radians to degrees" }, - { 10463, "E_G2R1", "Bad epsilon for converting gradians to radians" }, - { 10464, "E_G2R2", "Bad first argument converting gradians to radians" }, - { 10465, "E_R2G1", "Bad epsilon for converting radians to gradians" }, - { 10466, "E_R2G2", "Bad first argument converting radians to gradians" }, - { 10467, "E_D2G1", "Bad first argument converting degrees to gradians" }, - { 10468, "E_G2D1", "Bad first argument converting gradians to degrees" }, - { 10469, "E_D2DMS1", "Non-lvalue arguments 2, 3 or 4 for d2dms" }, - { 10470, "E_D2DMS2", "Non-real-number arg 1 for d2dms" }, - { 10471, "E_D2DMS3", "No-assign-to argument 2, 3 or 4 for d2dms" }, - { 10472, "E_D2DMS4", "Invalid rounding arg 5 for d2dms" }, - { 10473, "E_D2DM1", "Non-lvalue arguments 2 or 3 for d2dm" }, - { 10474, "E_D2DM2", "Non-real-number arg 1 for d2dm" }, - { 10475, "E_D2DM3", "No-assign-to argument 2 or 3 for d2dm" }, - { 10476, "E_D2DM4", "Invalid rounding arg 4 for d2dm" }, - { 10477, "E_G2GMS1", "Non-lvalue arguments 2, 3 or 4 for g2gms" }, - { 10478, "E_G2GMS2", "Non-real-number arg 1 for g2gms" }, - { 10479, "E_G2GMS3", "No-assign-to argument 2 or 3 for g2gms" }, - { 10480, "E_G2GMS4", "Invalid rounding arg 5 for g2gms" }, - { 10481, "E_G2GM1", "Non-lvalue arguments 2 or 3 for g2gm" }, - { 10482, "E_G2GM2", "Non-real-number arg 1 for g2gm" }, - { 10483, "E_G2GM3", "No-assign-to argument 2, 3 or 4 for g2gm" }, - { 10484, "E_G2GM4", "Invalid rounding arg 4 for g2gm" }, - { 10485, "E_H2HMS1", "Non-lvalue arguments 2, 3 or 4 for h2hms" }, - { 10486, "E_H2HMS2", "Non-real-number arg 1 for h2hms" }, - { 10487, "E_H2HMS3", "No-assign-to argument 2, 3 or 4 for h2hms" }, - { 10488, "E_H2HMS4", "Invalid rounding arg 5 for h2hms" }, - { 10489, "E_H2HM1", "Non-lvalue arguments 2 or 3 for h2hm" }, - { 10490, "E_H2HM2", "Non-real-number arg 1 for h2hm" }, - { 10491, "E_H2HM3", "No-assign-to argument 2 or 3 for h2hm" }, - { 10492, "E_H2HM4", "Invalid rounding arg 4 for h2hm" }, - { 10493, "E_DMS2D1", "Non-real-number arguments 1, 2 or 3 for dms2d" }, - { 10494, "E_DMS2D2", "Invalid rounding arg 4 for dms2d" }, - { 10495, "E_DM2D1", "Non-real-number arguments 1 or 2 for dm2d" }, - { 10496, "E_DM2D2", "Invalid rounding arg 4 for dm2d" }, - { 10497, "E_GMS2G1", "Non-real-number arguments 1, 2 or 3 for gms2g" }, - { 10498, "E_GMS2G2", "Invalid rounding arg 4 for gms2g" }, - { 10499, "E_GM2G1", "Non-real-number arguments 1 or 2 for gm2g" }, - { 10500, "E_GM2G2", "Invalid rounding arg 4 for gm2g" }, - { 10501, "E_HMS2H1", "Non-real-number arguments 1, 2 or 3 for hms2h" }, - { 10502, "E_HMS2H2", "Invalid rounding arg 4 for hms2h" }, - { 10503, "E_HM2H1", "UNUSED ERROR: Non-real-number arguments 1 or 2 for hm2h" }, - { 10504, "E_HM2H2", "UNUSED ERROR: Invalid rounding arg 4 for hm2h" }, + { 10435, "E_TAN_3", "UNUSED ERROR: Invalid value for calculating the sin numerator for tan" }, + { 10436, "E_TAN_4", "UNUSED ERROR: Invalid value for calculating the cos denominator for tan" }, + { 10437, "E_COT_3", "UNUSED ERROR: Invalid value for calculating the sin numerator for cot" }, + { 10438, "E_COT_4", "UNUSED ERROR: Invalid value for calculating the cos denominator for cot" }, + { 10439, "E_SEC_3", "UNUSED ERROR: Invalid value for calculating the cos reciprocal for sec" }, + { 10440, "E_CSC_3", "UNUSED ERROR: Invalid value for calculating the sin reciprocal for csc" }, + { 10441, "E_TANH_3", "Invalid value for calculating the sinh numerator for tanh" }, + { 10442, "E_TANH_4", "Invalid value for calculating the cosh denominator for tanh" }, + { 10443, "E_COTH_3", "Invalid value for calculating the sinh numerator for coth" }, + { 10444, "E_COTH_4", "Invalid value for calculating the cosh denominator for coth" }, + { 10445, "E_SECH_3", "Invalid value for calculating the cosh reciprocal for sech" }, + { 10446, "E_CSCH_3", "Invalid value for calculating the sinh reciprocal for csch" }, + { 10447, "E_ASIN_3", "Invalid value for calculating asin" }, + { 10448, "E_ACOS_3", "Invalid value for calculating acos" }, + { 10449, "E_ASINH_3", "Invalid value for calculating asinh" }, + { 10450, "E_ACOSH_3", "Invalid value for calculating acosn" }, + { 10451, "E_ATAN_3", "Invalid value for calculating atan" }, + { 10452, "E_ACOT_3", "Invalid value for calculating acot" }, + { 10453, "E_ASEC_3", "Invalid value for calculating asec" }, + { 10454, "E_ACSC_3", "Invalid value for calculating acsc" }, + { 10455, "E_ATANH_3", "Invalid value for calculating atan" }, + { 10456, "E_ACOTH_3", "Invalid value for calculating acot" }, + { 10457, "E_ASECH_3", "Invalid value for calculating asec" }, + { 10458, "E_ACSCH_3", "Invalid value for calculating acsc" }, + { 10459, "E_D2R_1", "Bad epsilon for converting degrees to radians" }, + { 10460, "E_D2R_2", "Bad first argument converting degrees to radians" }, + { 10461, "E_R2D_1", "Bad epsilon for converting radians to degrees" }, + { 10462, "E_R2D_2", "Bad first argument converting radians to degrees" }, + { 10463, "E_G2R_1", "Bad epsilon for converting gradians to radians" }, + { 10464, "E_G2R_2", "Bad first argument converting gradians to radians" }, + { 10465, "E_R2G_1", "Bad epsilon for converting radians to gradians" }, + { 10466, "E_R2G_2", "Bad first argument converting radians to gradians" }, + { 10467, "E_D2G_1", "Bad first argument converting degrees to gradians" }, + { 10468, "E_G2D_1", "Bad first argument converting gradians to degrees" }, + { 10469, "E_D2DMS_1", "Non-lvalue arguments 2, 3 or 4 for d2dms" }, + { 10470, "E_D2DMS_2", "Non-real-number arg 1 for d2dms" }, + { 10471, "E_D2DMS_3", "No-assign-to argument 2, 3 or 4 for d2dms" }, + { 10472, "E_D2DMS_4", "Invalid rounding arg 5 for d2dms" }, + { 10473, "E_D2DM_1", "Non-lvalue arguments 2 or 3 for d2dm" }, + { 10474, "E_D2DM_2", "Non-real-number arg 1 for d2dm" }, + { 10475, "E_D2DM_3", "No-assign-to argument 2 or 3 for d2dm" }, + { 10476, "E_D2DM_4", "Invalid rounding arg 4 for d2dm" }, + { 10477, "E_G2GMS_1", "Non-lvalue arguments 2, 3 or 4 for g2gms" }, + { 10478, "E_G2GMS_2", "Non-real-number arg 1 for g2gms" }, + { 10479, "E_G2GMS_3", "No-assign-to argument 2 or 3 for g2gms" }, + { 10480, "E_G2GMS_4", "Invalid rounding arg 5 for g2gms" }, + { 10481, "E_G2GM_1", "Non-lvalue arguments 2 or 3 for g2gm" }, + { 10482, "E_G2GM_2", "Non-real-number arg 1 for g2gm" }, + { 10483, "E_G2GM_3", "No-assign-to argument 2, 3 or 4 for g2gm" }, + { 10484, "E_G2GM_4", "Invalid rounding arg 4 for g2gm" }, + { 10485, "E_H2HMS_1", "Non-lvalue arguments 2, 3 or 4 for h2hms" }, + { 10486, "E_H2HMS_2", "Non-real-number arg 1 for h2hms" }, + { 10487, "E_H2HMS_3", "No-assign-to argument 2, 3 or 4 for h2hms" }, + { 10488, "E_H2HMS_4", "Invalid rounding arg 5 for h2hms" }, + { 10489, "E_H2HM_1", "Non-lvalue arguments 2 or 3 for h2hm" }, + { 10490, "E_H2HM_2", "Non-real-number arg 1 for h2hm" }, + { 10491, "E_H2HM_3", "No-assign-to argument 2 or 3 for h2hm" }, + { 10492, "E_H2HM_4", "Invalid rounding arg 4 for h2hm" }, + { 10493, "E_DMS2D_1", "Non-real-number arguments 1, 2 or 3 for dms2d" }, + { 10494, "E_DMS2D_2", "Invalid rounding arg 4 for dms2d" }, + { 10495, "E_DM2D_1", "Non-real-number arguments 1 or 2 for dm2d" }, + { 10496, "E_DM2D_2", "Invalid rounding arg 4 for dm2d" }, + { 10497, "E_GMS2G_1", "Non-real-number arguments 1, 2 or 3 for gms2g" }, + { 10498, "E_GMS2G_2", "Invalid rounding arg 4 for gms2g" }, + { 10499, "E_GM2G_1", "Non-real-number arguments 1 or 2 for gm2g" }, + { 10500, "E_GM2G_2", "Invalid rounding arg 4 for gm2g" }, + { 10501, "E_HMS2H_1", "Non-real-number arguments 1, 2 or 3 for hms2h" }, + { 10502, "E_HMS2H_2", "Invalid rounding arg 4 for hms2h" }, + { 10503, "E_HM2H_1", "UNUSED ERROR: Non-real-number arguments 1 or 2 for hm2h" }, + { 10504, "E_HM2H_2", "UNUSED ERROR: Invalid rounding arg 4 for hm2h" }, { 10505, "E_LOG2_1", "Bad epsilon argument for log2" }, { 10506, "E_LOG2_2", "Non-numeric first argument for log2" }, { 10507, "E_LOG2_3", "Cannot calculate log2 for this value" }, @@ -594,43 +661,1278 @@ CONST struct errtbl error_table[] = { { 10510, "E_LOGN_3", "Cannot calculate logn for this value" }, { 10511, "E_LOGN_4", "Cannot calculate logn for this log base" }, { 10512, "E_LOGN_5", "Non-numeric second argument for logn" }, - { 10513, "E_VERSIN1", "Bad epsilon for versin" }, - { 10514, "E_VERSIN2", "Bad first argument for versin" }, - { 10515, "E_VERSIN3", "Too-large im(argument) for versin" }, - { 10516, "E_AVERSIN1", "Bad epsilon for aversin" }, - { 10517, "E_AVERSIN2", "Bad first argument for aversin" }, - { 10518, "E_AVERSIN3", "Too-large im(argument) for aversin" }, - { 10519, "E_COVERSIN1", "Bad epsilon for coversin" }, - { 10520, "E_COVERSIN2", "Bad first argument for coversin" }, - { 10521, "E_COVERSIN3", "Too-large im(argument) for coversin" }, - { 10522, "E_ACOVERSIN1", "Bad epsilon for acoversin" }, - { 10523, "E_ACOVERSIN2", "Bad first argument for acoversin" }, - { 10524, "E_ACOVERSIN3", "Too-large im(argument) for acoversin" }, - { 10525, "E_VERCOS1", "Bad epsilon for vercos" }, - { 10526, "E_VERCOS2", "Bad first argument for vercos" }, - { 10527, "E_VERCOS3", "Too-large im(argument) for vercos" }, - { 10528, "E_AVERCOS1", "Bad epsilon for avercos" }, - { 10529, "E_AVERCOS2", "Bad first argument for avercos" }, - { 10530, "E_AVERCOS3", "Too-large im(argument) for avercos" }, - { 10531, "E_COVERCOS1", "Bad epsilon for covercos" }, - { 10532, "E_COVERCOS2", "Bad first argument for covercos" }, - { 10533, "E_COVERCOS3", "Too-large im(argument) for covercos" }, - { 10534, "E_ACOVERCOS1", "Bad epsilon for acovercos" }, - { 10535, "E_ACOVERCOS2", "Bad first argument for acovercos" }, - { 10536, "E_ACOVERCOS3", "Too-large im(argument) for acovercos" }, - { 10537, "E_TAN5", "Invalid complex argument for tan" }, - { 10538, "E_COT5", "Invalid zero argument for cot" }, - { 10539, "E_COT6", "Invalid complex argument for cot" }, - { 10540, "E_SEC5", "Invalid complex argument for sec" }, - { 10541, "E_CSC5", "Invalid zero argument for cot" }, - { 10542, "E_CSC6", "Invalid complex argument for csc" }, - /* add new entries above here and be sure their errnum numeric value is consecutive */ + { 10513, "E_VERSIN_1", "Bad epsilon for versin" }, + { 10514, "E_VERSIN_2", "Bad first argument for versin" }, + { 10515, "E_VERSIN_3", "Too-large im(argument) for versin" }, + { 10516, "E_AVERSIN_1", "Bad epsilon for aversin" }, + { 10517, "E_AVERSIN_2", "Bad first argument for aversin" }, + { 10518, "E_AVERSIN_3", "Too-large im(argument) for aversin" }, + { 10519, "E_COVERSIN_1", "Bad epsilon for coversin" }, + { 10520, "E_COVERSIN_2", "Bad first argument for coversin" }, + { 10521, "E_COVERSIN_3", "Too-large im(argument) for coversin" }, + { 10522, "E_ACOVERSIN_1", "Bad epsilon for acoversin" }, + { 10523, "E_ACOVERSIN_2", "Bad first argument for acoversin" }, + { 10524, "E_ACOVERSIN_3", "Too-large im(argument) for acoversin" }, + { 10525, "E_VERCOS_1", "Bad epsilon for vercos" }, + { 10526, "E_VERCOS_2", "Bad first argument for vercos" }, + { 10527, "E_VERCOS_3", "Too-large im(argument) for vercos" }, + { 10528, "E_AVERCOS_1", "Bad epsilon for avercos" }, + { 10529, "E_AVERCOS_2", "Bad first argument for avercos" }, + { 10530, "E_AVERCOS_3", "Too-large im(argument) for avercos" }, + { 10531, "E_COVERCOS_1", "Bad epsilon for covercos" }, + { 10532, "E_COVERCOS_2", "Bad first argument for covercos" }, + { 10533, "E_COVERCOS_3", "Too-large im(argument) for covercos" }, + { 10534, "E_ACOVERCOS_1", "Bad epsilon for acovercos" }, + { 10535, "E_ACOVERCOS_2", "Bad first argument for acovercos" }, + { 10536, "E_ACOVERCOS_3", "Too-large im(argument) for acovercos" }, + { 10537, "E_TAN_5", "Invalid complex argument for tan" }, + { 10538, "E_COT_5", "Invalid zero argument for cot" }, + { 10539, "E_COT_6", "Invalid complex argument for cot" }, + { 10540, "E_SEC_5", "Invalid complex argument for sec" }, + { 10541, "E_CSC_5", "Invalid zero argument for cot" }, + { 10542, "E_CSC_6", "Invalid complex argument for csc" }, + { 10543, "E_ERROR_3", "String argument is not a valid E_STRING for error" }, + { 10544, "E_STRERROR_3", "String argument is not a valid E_STRING for strerror" }, + { 10545, "E_STRERROR_4", "errnum_2_errmsg returned NULL as called from strerror" }, + { 10546, "E_ERRNO_1", "Invalid argument type for errno" }, + { 10547, "E_ERRNO_2", "Numeric argument is outside valid errnum range for errno" }, + { 10548, "E_ERRNO_3", "String argument is not a valid E_STRING for errno" }, + /* IMPORTANT NOTE: add new entries above here and be sure their errnum numeric value is consecutive! */ /* The next NULL entry must be last */ - { -1, NULL, NULL } + { NULL_ERRNUM, NULL, NULL } }; +/* + * The error_table[] array represents the special "E__" E_STRING related + * error codes, symbols and messages. + * + * The purpose of this internal table is to allow functions below to convert + * between E__" E_STRING related errsym, and their respective errnum + * calc computation error codes and their respective errmsg messages. + * + * In this table, the errnum values must starting with 0 and ascending until + * the final NULL entry's NULL_ERRNUM (-1) value. Unlike error_table[], + * the errnum values in private_error_alias[] do not need to be consecutive. + * + * In this table the E_STRING related errsym must match the regular expression: + * + * ^E__[A-Z][A-Z0-9_]+$ + * + * IMPORTANT: DO NOT ADD NEW calc computation TO THIS TABLE!!! + * Add new calc computation to the error_table[] above. + */ +STATIC struct errtbl private_error_alias[] = { + + /* The E__NONE entry below must start with E__NONE (0) and must be first!! */ + { E__NONE, "E__NONE", "calc_errno cleared: libc errno codes above here" }, + { E__BASE, "E__BASE", "calc errors start above here" }, + /* In the next E__HIGHEST entry, errnum and errmsg are changed when verify_error_table() is called */ + { INV_ERRNUM, "E__HIGHEST", "replace this with the E__HIGHEST errmsg" }, + { E__USERDEF, "E__USERDEF", "user defined error codes start here" }, + { E__USERMAX, "E__USERMAX", "maximum user defined error code" }, + + /* The next NULL entry must be last */ + { NULL_ERRNUM, NULL, NULL } +}; + + +/* + * external values + */ +EXTERN char *program; /* our name */ + + +/* + * is_e_digits - E_STRING is of the form E_ followed by digits + * + * This function determines of errsym matches the regular expression: + * + * ^E_[0-9][0-9]*$ + * + * There is NO attempt to determine if the number type of digits + * that follow the E_ forms a valid numeric E_STRING. + * + * NOTE: See also e_digits_2_errnum() below. + * + * given: + * errsym E_STRING to check + * + * returns: + * true ==> E_STRING is of the form E_ followed by digits + * false ==> E_STRING is NULL and/or not E_ followed by digits + */ +bool +is_e_digits(CONST char *errsym) +{ + CONST char *p; + + /* + * firewall + */ + if (errsym == NULL) { + return false; + } + + /* + * must start with E_ + */ + if (strncmp(errsym, "E_", 2) != 0) { + return false; + } + + /* + * length must be >= 3 + */ + if (errsym[2] == '\0') { + return false; + } + + /* + * check for only digits remaining + */ + for (p = errsym+2; *p != '\0'; ++p) { + if (!isascii(*p) || !isdigit(*p)) { + return false; + } + } + + /* + * errsym matches: ^E_[0-9][0-9]*$ + */ + return true; +} + + +/* + * is_valid_errnum - determine if errnum is within the proper range + * + * A valid errnum must be: + * + * E__NONE <= errnum <= E__USERMAX + * + * NOTE: This functions does NOT check of the errnum is in + * some struct errtbl array. For that see find_estring_in_errtbl(). + * + * given: + * errnum errnum to check + * + * returns: + * true ==> errnum is valid + * false ==> errnum is NOT valid + */ +bool +is_valid_errnum(int errnum) +{ + /* + * check for range + */ + if (errnum < E__NONE) { + return false; + } + if (errnum > E__USERMAX) { + return false; + } + /* errnum is valid */ + return true; +} + + +/* + * is_errnum_in_error_table - determine if errnum falls within the error_table[] array bounds + * + * This function determines if the errnum is a value that is in the range + * that the error_table[] array holds. This function does NOT perform a + * lookup within the error_table[] array, only a errnum value range check. + * + * returns: + * true ==> errnum falls within the error_table[] array bounds + * false ==> errnum does NOT fall within the error_table[] array bounds + */ +bool +is_errnum_in_error_table(int errnum) +{ + /* + * firewall - errnum must be valid + */ + if (is_valid_errnum(errnum) == false) { + /* errnum is not a valid value */ + return false; + } + + /* + * case: errnum is too low for error_table[] array + */ + if (errnum < E__BASE) { + /* errnum is too low */ + return false; + } + + /* + * case: errnum is too high for error_table[] array + */ + if ((unsigned long)errnum > MY_E__HIGHEST) { + /* errnum is too high */ + return false; + } + + /* + * return error_table[] array matching the errnum value + */ + return true; +} + + +/* + * e_digits_2_errnum - convert an E_STRING of digits into a valid errnum + * + * Given an E_STRING errsym matching the regular expression: + * + * ^E_[0-9][0-9]*$ + * + * this function attempts to convert those digits into an errnum, and + * if successful, that the resulting errnum is valid: + * + * E__NONE <= errnum <= E__USERMAX + * + * NOTE: Leading zeros in digits are not allowed. So the E_STRING errsym + * must match the regular expression: + * + * ^(0|[1-9][0-9]*)$ + * + * This function calls is_e_digits() first to determine that E_STRING + * is E_ followed by digits. + * + * given: + * errsym E_STRING to convert + * + * returns: + * == NULL_ERRNUM ==> errsym is NULL, or not E_STRING of digits, or + * the resulting errnum would be invald + * != NULL_ERRNUM == valid errnum corresponding to errsym + */ +int +e_digits_2_errnum(CONST char *errsym) +{ + long errnum; /* digits converted into a possible errnum */ + + /* + * firewall + */ + if (errsym == NULL) { + /* errsym is NULL */ + return NULL_ERRNUM; + } + + /* + * must be an E_STRING of digits + */ + if (is_e_digits(errsym) == false) { + /* errsym doesn't match: ^E_[0-9][0-9]*$ */ + return NULL_ERRNUM; + } + + /* + * case: for E_0, return E__NONE + */ + if (strcmp(errsym, "E_0") == 0) { + /* quick return for E_0 */ + return E__NONE; + } + + /* + * errnum is not E_0, digits cannot start with "0" + */ + if (errsym[2] == '0') { + /* digits cannot start with 0 unless it is E_0 */ + return NULL_ERRNUM; + } + + /* + * try to convert digits into long + */ + errno = 0; + errnum = strtol(errsym+2, NULL, 10); + if (errno != 0) { + /* failed to convert digits in base 10 */ + return NULL_ERRNUM; + } + + /* + * errnum, to be valid, just be in the range [E__NONE,E__USERMAX] + */ + if (is_valid_errnum(errnum) == false) { + /* errnum is out of range */ + return NULL_ERRNUM; + } + + /* + * return converted errnum + */ + return errnum; +} + + +/* + * is_e_1string - E_STRING is of the form E_ followed by letters and digits and underscores + * + * This function determines of errsym matches the regular expression: + * + * ^E_[A-Z][A-Z0-9_]+$ + * + * This function will not match the special E_STRING is of the form E__ followed by + * letters and digits and underscores. For that see is_e_2string(). + * + * given: + * errsym E_STRING to check + * + * returns: + * true ==> E_STRING matches the regular expression: ^E_[A-Z][A-Z0-9_]+$ + * false ==> E_STRING is NULL and/or does not match expression: ^E_[A-Z][A-Z0-9_]+$ + */ +bool +is_e_1string(CONST char *errsym) +{ + CONST char *p; + + /* + * firewall + */ + if (errsym == NULL) { + return false; + } + + /* + * must start with E_ + */ + if (strncmp(errsym, "E_", 2) != 0) { + return false; + } + + /* + * length must be >= 3 + */ + if (errsym[2] == '\0') { + return false; + } + + /* + * errsym, after E_, must be an UPPER case letter + */ + if (!isascii(errsym[2]) || !isupper(errsym[2])) { + return false; + } + + /* + * must match regular expression: ^E_[A-Z][A-Z0-9_]+$ + */ + for (p = errsym+3; *p != '\0'; ++p) { + if (!isascii(*p) || !(isupper(*p) || isdigit(*p) || *p == '_')) { + return false; + } + } + + /* + * errsym matches: ^E_[A-Z][A-Z0-9_]+$ + */ + return true; +} + + +/* + * is_e_2string - E_STRING is of the form E__ followed by letters and digits and underscores + * + * This function determines of errsym matches the regular expression: + * + * ^E__[A-Z][A-Z0-9_]+$ + * + * This function will not match the special E_STRING is of the form E_ followed by + * letters and digits and underscores. For that see is_e_1string(). + * + * given: + * errsym E_STRING to check + * + * returns: + * true ==> E_STRING matches the regular expression: ^E__[A-Z][A-Z0-9_]+$ + * false ==> E_STRING is NULL and/or does not match expression: ^E__[A-Z][A-Z0-9_]+$ + */ +bool +is_e_2string(CONST char *errsym) +{ + CONST char *p; + + /* + * firewall + */ + if (errsym == NULL) { + return false; + } + + /* + * must start with E_ + */ + if (strncmp(errsym, "E__", 3) != 0) { + return false; + } + + /* + * length must be >= 4 + */ + if (errsym[3] == '\0') { + return false; + } + + /* + * errsym, after E__, must be an UPPER case letter + */ + if (!isascii(errsym[3]) || !isupper(errsym[3])) { + return false; + } + + /* + * must match regular expression: ^E__[A-Z][A-Z0-9_]+$ + */ + for (p = errsym+4; *p != '\0'; ++p) { + if (!isascii(*p) || !(isupper(*p) || isdigit(*p) || *p == '_')) { + return false; + } + } + + /* + * errsym matches: ^E__[A-Z][A-Z0-9_]+$ + */ + return true; +} + + +/* + * find_estring_in_errtbl - given an E_STRING find it in a struct errtbl array + * + * given: + * errsym E_STRING to check + * tbl pointer to a NULL an array of struct errtbl with a final NULL entry + * + * returns: + * != NULL ==> pointer to entry in tbl struct errtbl entry with matching errsym + * NULL ==> NULL arg, or errsym not found + */ +struct errtbl * +find_estring_in_errtbl(CONST char *errsym, CONST struct errtbl *tbl) +{ + CONST struct errtbl *ret; /* pointer to struct errtbl entry with matching errsym */ + + /* + * firewall + */ + if (errsym == NULL || tbl == NULL) { + /* invalid NULL arg(s) */ + return NULL; + } + + /* + * scan tbl until final NULL entry + */ + for (ret = tbl; ret->errsym != NULL; ++ret) { + if (strcmp(ret->errsym, errsym) == 0) { + /* found matching errsym */ + return (struct errtbl *)ret; + } + } + /* no match */ + return NULL; +} + + +/* + * find_errnum_in_errtbl - given a valid errnum, search for it in a struct errtbl array + * + * This function assumes that the errnum values in a struct errtbl array are + * both valid errnum and ascending. The function verify_error_table() will verify that + * this is the case for both error_table[] and private_error_alias[]. + * + * See also lookup_errnum_in_error_table() for a faster way to do: + * + * find_errnum_in_errtbl(errnum, error_table); (* use lookup_errnum_in_error_table() instead *) + * + * given: + * errnum the errnum code to seach for + * tbl pointer to a NULL an array of struct errtbl with a final NULL entry + * + * returns: + * != NULL ==> pointer to entry in tbl struct errtbl entry with matching + * NULL ==> NULL arg, or matching errnum not foun + */ +struct errtbl * +find_errnum_in_errtbl(int errnum, CONST struct errtbl *tbl) +{ + CONST struct errtbl *ret; /* pointer to struct errtbl entry with matching errsym */ + + /* + * firewall + */ + if (tbl == NULL) { + /* invalid NULL arg */ + return NULL; + } + if (is_valid_errnum(errnum) == false) { + /* invalid errnum */ + return NULL; + } + + /* + * scan tbl until final NULL entry + */ + for (ret = tbl; ret->errsym != NULL; ++ret) { + + /* case: found errnum match */ + if (ret->errnum == errnum) { + /* found matching errnum */ + return (struct errtbl *)ret; + } + + /* case: we passed errnum in struct errtbl array */ + if (ret->errnum > errnum) { + /* we have searched beyond errnum: everthing else is > errnum */ + return NULL; + } + } + /* no match */ + return NULL; +} + + +/* + * lookup_errnum_in_error_table - lookup errnum within error_table[] array + * + * This function searches for errnum within the error_table[] array + * by using the fact that the error_table[] array contains a compact + * sequential set of errnum values from E__BASE thru and including E__HIGHEST. + * + * This function performs the equivalent of: + * + * find_errnum_in_errtbl(errnum, error_table); (* use lookup_errnum_in_error_table() instead *) + * + * given: + * errnum the errnum code to seach for + * + * returns: + * != NULL ==> pointer to entry in error_table[] array with matching errnum + * NULL ==> NULL arg, or no matching errnum in error_table[] array + */ +CONST struct errtbl * +lookup_errnum_in_error_table(int errnum) +{ + CONST struct errtbl *ret; /* pointer to struct errtbl entry with matching errsym */ + int offset; /* offset within the error_table[] array */ + + /* + * firewall - errnum must be valid + */ + if (is_errnum_in_error_table(errnum) == false) { + /* errnum is not a valid or not within the error_table[] array range */ + return NULL; + } + + /* + * paranoia + */ + if (errnum < E__BASE || errnum > (long)MY_E__HIGHEST) { + /* errnum is outside of the error_table[] array range */ + return NULL; + } + offset = errnum - E__BASE; + if (offset < 0 || offset > (long)(sizeof(error_table)/sizeof(error_table[0]))) { + /* offset is outside of the error_table[] array */ + return NULL; + } + + /* + * fetch entry from error_table[] array that should have the errnum value + */ + ret = &error_table[offset]; + if (ret->errnum != errnum) { + /* error_table[] entry has the wrong errnum */ + return NULL; + } + + /* + * return error_table[] array matching the errnum value + */ + return ret; +} + + +/* + * verify_error_table - verify the consistency of the error_table + * + * For error_table[]: + * + * The errnum must start with E__BASE and be consecutive until the final entry. + * + * With the exception of the 1st "E__BASE" entry, the errsym must be a non-NULL string that + * matches, up until the last entry, the regular expression: + * + * ^E_[A-Z][A-Z0-9_]+$ + * + * The errmsg must be a non-NULL non-empty string until the last entry. + * + * The final entry must have an errnum of NULL_ERRNUM (-1), errsym of NULL and errmsg of NULL. + * + * For private_error_alias[]: + * + * This function also verifies the private_error_alias[] array. + * + * With the exception of the last entry, the errsym must be a non-NULL string that + * matches regular expression: + * + * ^E__[A-Z][A-Z0-9_]+$ + * + * The errmsg of the E__HIGHEST errsym entry points to the + * corresponding error_table[] entry's MY_E__HIGHEST errsym + * so that E__HIGHEST becomes an alias for the highest assigned + * calc computation error code. + * + * The errmsg must be a non-NULL non-empty string until the last entry. + * + * The final entry must have an errnum of NULL_ERRNUM (-1), errsym of NULL and errmsg of NULL. + * + * This function does not return on error or if the error_table is invalid. + * + * Use the seqcexit tool to keep the exit codes for this function unique, starting with 10. + * Apply the following command in this soure code: + * + * seqcexit errtbl.c + * + * For more information on the seqcexit tool, see: + * + * https://github.com/lcn2/seqcexit + */ +void +verify_error_table(void) +{ + size_t len; /* length of the error_table[] */ + size_t e__count; /* computed ECOUNT value */ + size_t priv_len; /* length of the private_error_alias[] */ + size_t priv_e__count; /* computed MY_PRIV_ECOUNT value */ + struct errtbl *found; /* pointer to E__HIGHEST errsym entry in private_error_alias[] or NULL */ + int prev_errnum; /* previous errnum found in private_error_alias[] */ + long ten; /* used to try an compute 10^USERMAX_DIGITS */ + VALUE test; /* value to test if E__USERMAX fits into a v_type */ + size_t i; + + /* + * verify error_table[] size + */ + len = sizeof(error_table) / sizeof(error_table[0]); + e__count = len - 2; + if (e__count != MY_ECOUNT) { + fprintf(stderr, "**** %s ERROR: error_table length: %zu != MY_ECOUNT+2: %lu\n", + program, len, MY_ECOUNT+2); + exit(10); /*coo*/ + } + + /* + * verify the initial errnum of the 1st error_table[] entry + */ + if (error_table[0].errnum != E__BASE) { + fprintf(stderr, "**** %s ERROR: initial entry error_table[0].errnum: %d must == E__BASE: %d\n", + program, error_table[0].errnum, E__BASE); + exit(11); + } + if (error_table[0].errsym == NULL) { + fprintf(stderr, "**** %s ERROR: error_table[0].errsym must != NULL\n", + program); + exit(12); + } + if (strcmp(error_table[0].errsym, "E__BASE") != 0) { + fprintf(stderr, "**** %s ERROR: error_table[0].errsym: %s must be E__BASE\n", + program, error_table[0].errsym); + exit(13); + } + if (error_table[0].errmsg == NULL) { + fprintf(stderr, "**** %s ERROR: error_table[0].errmsg must != NULL\n", + program); + exit(14); + } + if (strlen(error_table[0].errmsg) <= 0) { + fprintf(stderr, "**** %s ERROR: error_table[0].errmsg length: %zu must be > 0\n", + program, strlen(error_table[0].errmsg)); + exit(15); + } + + /* + * verify 2nd thru end to last entry of error_table[] + */ + for (i=1; i < len-1; ++i) { + + /* + * check errnum - must be consecutive starting with E__BASE + */ + if ((unsigned long)(error_table[i].errnum) != E__BASE+i) { + fprintf(stderr, "**** %s ERROR: error_table[%zu].errnum: %d != %ld\n", + program, i, error_table[i].errnum, E__BASE+i); + exit(16); + } + + /* + * check if errsym is non-NULL + */ + if (error_table[i].errsym == NULL) { + fprintf(stderr, "**** %s ERROR: error_table[%zu]..errsym must != NULL\n", + program, i); + exit(17); + } + + /* + * check if errsym is matches the regular expression: ^E_[A-Z][A-Z0-9_]+$ + */ + if (is_e_1string(error_table[i].errsym) == false) { + fprintf(stderr, "**** %s ERROR: error_table[%zu].errsym: %s " + "must match the regular expression: %s\n", + program, i, error_table[i].errsym, "^E_[A-Z][A-Z0-9_]+$"); + exit(18); + } + + /* + * verify error_table[] entry errmsg is not NULL + */ + if (error_table[i].errmsg == NULL) { + fprintf(stderr, "**** %s ERROR: error_table[%zu].errmsg must != NULL\n", + program, i); + exit(19); + } + + /* + * verify error_table[] entry errmsg is not empty + */ + if (error_table[i].errmsg[0] == '\0') { + fprintf(stderr, "**** %s ERROR: error_table[%zu].errmsg length: %zu must be > 0\n", + program, i, strlen(error_table[i].errmsg)); + exit(20); + } + } + + /* + * verify 2nd to last error_table[] entry has the MY_E__HIGHEST errnum + */ + if (error_table[len-2].errnum != MY_E__HIGHEST) { + fprintf(stderr, "**** %s ERROR: highest assigned calc computation error code entry " + "error_table[%zu].errnum: %d must == %ld\n", + program, len-2, error_table[len-2].errnum, MY_E__HIGHEST); + exit(21); + } + + /* + * verify the last error_table[] entry + */ + if (error_table[len-1].errnum != NULL_ERRNUM) { + fprintf(stderr, "**** %s ERROR: final NULL entry error_table[%zu].errnum: %d must == %d\n", + program, len-1, error_table[len-1].errnum, NULL_ERRNUM); + exit(22); + } + if (error_table[len-1].errsym != NULL) { + fprintf(stderr, "**** %s ERROR: final NULL entry error_table[%zu].errsym must == NULL\n", + program, len-1); + exit(23); + } + if (error_table[len-1].errmsg != NULL) { + fprintf(stderr, "**** %s ERROR: final NULL entry error_table[%zu].errmsg must == NULL\n", + program, len-1); + exit(24); + } + + /* + * verify private_error_alias[] size + */ + priv_len = sizeof(private_error_alias) / sizeof(private_error_alias[0]); + priv_e__count = priv_len - 1; + if (priv_e__count != MY_PRIV_ECOUNT) { + fprintf(stderr, "**** %s ERROR: private_error_alias length: %zu must == MY_PRIV_ECOUNT+1: %lu\n", + program, priv_len, MY_PRIV_ECOUNT+1); + exit(25); + } + + /* + * setup the E__HIGHEST entry in private_error_alias[] to be an alias for + * the highest assigned calc computation error code from error_table[]. + */ + found = find_estring_in_errtbl("E__HIGHEST", private_error_alias); + if (found == NULL) { + fprintf(stderr, "**** %s ERROR: private_error_alias missing E__HIGHEST errsym entry", + program); + exit(26); + } + found->errnum = error_table[len-2].errnum; + found->errmsg = error_table[len-2].errmsg; + + /* + * verify 1st private_error_alias[] entry == (E__NONE) 0 + */ + if (private_error_alias[0].errnum != 0) { + fprintf(stderr, "**** %s ERROR: initial entry error_table[0].errnum: %d myst == 0\n", + program, error_table[0].errnum); + exit(27); + } + if (private_error_alias[0].errnum != E__NONE) { + fprintf(stderr, "**** %s ERROR: initial entry error_table[0].errnum: %d must == E__NONE: %d\n", + program, error_table[0].errnum, E__NONE); + exit(28); + } + + /* + * verify all but the final private_error_alias[] entry + */ + prev_errnum = INV_ERRNUM; /* preset previous errnum to INV_ERRNUM, and <0 value */ + for (i=0; i < priv_len-1; ++i) { + + /* + * The private_error_alias[] entry errnum must be >= 0 + */ + if (private_error_alias[i].errnum < 0) { + fprintf(stderr, "**** %s ERROR: entry private_error_alias[%zu].errnum: %d must be >= 0\n", + program, i, private_error_alias[i].errnum); + exit(29); + } + if (i > 0) { + if (private_error_alias[i].errnum <= prev_errnum) { + fprintf(stderr, "**** %s ERROR: entry private_error_alias[%zu].errnum: %d " + "must be > private_error_alias[%zu].errnum: %d\n", + program, i, private_error_alias[i].errnum, i-1, prev_errnum); + exit(30); + } + } + prev_errnum = private_error_alias[i].errnum; + + /* + * The private_error_alias[] entry errsym must not be NULL + */ + if (private_error_alias[i].errsym == NULL) { + fprintf(stderr, "**** %s ERROR: entry private_error_alias[%zu].errsym must != NULL\n", + program, i); + exit(31); + } + + /* + * check errsym that is string matching the regular expression: ^E__[A-Z][A-Z0-9_]+$ + */ + if (is_e_2string(private_error_alias[i].errsym) == false) { + fprintf(stderr, "**** %s ERROR: private_error_alias[%zu].errsym: %s " + "E_STRING must match the regular expression: %s\n", + program, i, private_error_alias[i].errsym, "^E__[A-Z][A-Z0-9_]+$"); + exit(32); + } + + /* + * verify private_error_alias[] entry errmsg is not NULL + */ + if (private_error_alias[i].errmsg == NULL) { + fprintf(stderr, "**** %s ERROR: private_error_alias[%zu].errmsg must != NULL\n", + program, i); + exit(33); + } + + /* + * verify private_error_alias[] entry errmsg is not empty + */ + if (private_error_alias[i].errmsg[0] == '\0') { + fprintf(stderr, "**** %s ERROR: private_error_alias[%zu].errmsg length: %zu must be > 0\n", + program, i, strlen(private_error_alias[i].errmsg)); + exit(34); + } + } + + /* + * verify the last private_error_alias[] entry + */ + if (private_error_alias[priv_len-1].errnum != NULL_ERRNUM) { + fprintf(stderr, "**** %s ERROR: final NULL entry private_error_alias[%zu].errnum: %d must == %d\n", + program, priv_len-1, private_error_alias[priv_len-1].errnum, NULL_ERRNUM); + exit(35); + } + if (private_error_alias[priv_len-1].errsym != NULL) { + fprintf(stderr, "**** %s ERROR: final NULL entry private_error_alias[%zu].errsym must == NULL\n", + program, priv_len-1); + exit(36); + } + if (private_error_alias[priv_len-1].errmsg != NULL) { + fprintf(stderr, "**** %s ERROR: final NULL entry private_error_alias[%zu].errmsg must == NULL\n", + program, priv_len-1); + exit(37); + } + + /* + * verify USERMAX_DIGITS is correct with respect to the size of E__USERMAX + */ + if (USERMAX_DIGITS <= 0) { + fprintf(stderr, "**** %s ERROR: USERMAX_DIGITS: %d must be > 0\n", + program, USERMAX_DIGITS); + exit(38); + } + if (USERMAX_DIGITS > 20) { + fprintf(stderr, "**** %s ERROR: USERMAX_DIGITS: %d must be <= 20\n", + program, USERMAX_DIGITS); + exit(39); + } + for (i = 0, ten = 1; ten > 0 && ten <= E__USERMAX; ++i) { + ten *= 10; + } + if (i != USERMAX_DIGITS) { + fprintf(stderr, "**** %s ERROR: USERMAX_DIGITS: %d must be == %ld\n", + program, USERMAX_DIGITS, i); + exit(40); + } + + /* + * verify that E__USERMAX can fit into a value.v_type + * + * When a VALUE indicates an error, value.v_type is set to < 0. + * So we need to test if -E__USERMAX can be stored into a test.v_type. + */ + test.v_type = -E__USERMAX; + if (-E__USERMAX != test.v_type) { + fprintf(stderr, "**** %s ERROR: E__USERMAX: %d cannot fit into a value.v_type of size: %lu\n", + program, E__USERMAX, sizeof(test.v_type)); + exit(41); + } + return; +} + + +/* + * errsym_2_errnum - convert a valid errsym to errnum + * + * We will convert E_STRING of E_digits into errnum if digits as a valid errnum, + * otherwise we will search private_error_alias[] if E_STRING is of E__ form, + * otherwise we will search error_table[] if E_STRING is of E_ form, + * otherwise we will return NULL_ERRNUM. + * + * given: + * errsym pointer to a E_STRING + * + * returns: + * != NULL_ERRNUM ==> valid errnum corresponding to a valid E_STRING errsym + * == NULL_ERRNUM ==> errsym is NULL, not valid E_STRING errsym, + * or no corresponding errnum found + */ +int +errsym_2_errnum(CONST char *errsym) +{ + struct errtbl *found; /* pointer to entry in struct errtbl array with matching errsym */ + int errnum; /* errnum to return */ + + /* + * firewall + */ + if (errsym == NULL) { + /* errsym is NULL */ + return NULL_ERRNUM; + } + + /* + * case: E_STRING is a E_digits errsym + */ + errnum = e_digits_2_errnum(errsym); + if (is_valid_errnum(errnum) == true) { + /* digits of E_digits is a valid errnum */ + return errnum; + } + + /* + * case: E_STRING is a E_digits but errnum is not valid + */ + if (is_e_digits(errsym) == true) { + /* E_digits but digits to not form a valid errnum */ + return NULL_ERRNUM; + } + + /* + * case: E_STRING is a known E__ errsym + */ + if (is_e_2string(errsym) == true) { + + /* + * look in private_error_alias[] for E__ errsym + */ + found = find_estring_in_errtbl(errsym, private_error_alias); + if (found != NULL) { + /* return matching errnum */ + return found->errnum; + } + } + + /* + * case: E_STRING is a known E_ errsym + */ + if (is_e_1string(errsym) == true) { + + /* + * look in error_table[] for E_ errsym + */ + found = find_estring_in_errtbl(errsym, error_table); + if (found != NULL) { + /* return matching errnum */ + return found->errnum; + } + } + + /* + * cannot convert errsym to a valid errnum + */ + return NULL_ERRNUM; +} + + +/* + * errnum_2_errsym - convert an errnum value into an errsym E_STRING, possibly malloced + * + * given: + * errnum errnum code to convert + * palloced pointer to bool to be set if errsym E_STRING was malloced + * + * return: + * != NULL ==> E_STRING for errnum (malloced if *palloced == true, static is not) + * == NULL ==> errnum is not valid, or palloced is NULL + */ +char * +errnum_2_errsym(int errnum, bool *palloced) +{ + char *ret; /* return string, possibly malloced */ + CONST struct errtbl *entry; /* struct errtbl entry lookup found or NULL */ + size_t snprintf_len; /* malloced snprintf buffer length */ + + /* + * firewall + */ + if (palloced == NULL) { + /* palloced is NULL */ + return NULL; + } + if (is_valid_errnum(errnum) == false) { + /* errnum is not a valid code */ + *palloced = false; + return NULL; + } + + /* + * case: errnum is within in the error_table[] array bounds + */ + if (is_errnum_in_error_table(errnum) == true) { + + /* + * struct errtbl entry found + */ + entry = lookup_errnum_in_error_table(errnum); + if (entry == NULL) { + /* lookup failed, return NULL */ + *palloced = false; + return NULL; + } + + /* + * return non-malloced errsym + */ + *palloced = false; + ret = entry->errsym; + return ret; + } + + /* + * case: form a malloced E_STRING of E_digits + */ + snprintf_len = sizeof("E_")-1 + USERMAX_DIGITS + 1; /* + 1 for trailing NUL */ + ret = calloc(snprintf_len+1, 1); /* +1 for paranoia */ + if (ret == NULL) { + math_error("Out of memory for errnum_2_errsym"); + not_reached(); + } + *palloced = true; + snprintf(ret, snprintf_len, "E_%d", errnum); + ret[snprintf_len] = '\0'; /* paranoia */ + + /* + * return alloced E_STRING of E_digits + */ + return ret; +} + + +/* + * errnum_2_errmsg - convert an errnum value into an errmsg string, possibly malloced + * + * given: + * errnum errnum code to convert + * palloced pointer to bool to be set if errmsg string was malloced + * + * return: + * != NULL ==> errmsg string for errnum (malloced if *palloced == true, static is not) + * == NULL ==> errnum is not valid, or palloced is NULL + */ +char * +errnum_2_errmsg(int errnum, bool *palloced) +{ + char *ret; /* return string, possibly malloced */ + CONST struct errtbl *entry; /* struct errtbl entry lookup found or NULL */ + size_t snprintf_len; /* malloced snprintf buffer length */ + + /* + * firewall + */ + if (palloced == NULL) { + /* palloced is NULL */ + return NULL; + } + if (is_valid_errnum(errnum) == false) { + /* errnum is not a valid code */ + *palloced = false; + return NULL; + } + + /* + * case: errnum is within in the error_table[] array bounds + */ + if (is_errnum_in_error_table(errnum) == true) { + + /* + * struct errtbl entry found + */ + entry = lookup_errnum_in_error_table(errnum); + if (entry == NULL) { + /* lookup failed, return NULL */ + *palloced = false; + return NULL; + } + + /* + * return non-malloced errmsg + */ + *palloced = false; + ret = entry->errmsg; + + /* + * case: errnum is a user-described errno + */ + } else if (errnum >= E__USERDEF && errnum <= E__USERMAX) { + + /* + * return non-malloced errmsg + */ + *palloced = false; + ret = name_newerrorstr(errnum); + if (ret == NULL) { + snprintf_len = sizeof("Unknown user error ")-1 + USERMAX_DIGITS + 1; /* + 1 for trailing NUL */ + ret = calloc(snprintf_len+1, 1); /* +1 for paranoia */ + if (ret == NULL) { + math_error("Out of memory #0 for errnum_2_errmsg"); + not_reached(); + } + *palloced = true; + snprintf(ret, snprintf_len, "Unknown user error %d", errnum); + ret[snprintf_len] = '\0'; /* paranoia */ + } + + /* + * case: errnum is 0 + */ + } else if (errnum == E__NONE) { + + /* + * return "No error" + */ + *palloced = false; + ret = "No error"; + + /* + * case: errnum is a system errno + */ + } else if (errnum > E__NONE && errnum < E__BASE) { + + /* + * return non-malloced result of strerror() + */ + *palloced = false; + ret = strerror(errnum); + if (ret == NULL) { + snprintf_len = sizeof("Unknown system error ")-1 + USERMAX_DIGITS + 1; /* + 1 for trailing NUL */ + ret = calloc(snprintf_len+1, 1); /* +1 for paranoia */ + if (ret == NULL) { + math_error("Out of memory #1 for errnum_2_errmsg"); + not_reached(); + } + *palloced = true; + snprintf(ret, snprintf_len, "Unknown system error %d", errnum); + ret[snprintf_len] = '\0'; /* paranoia */ + } + + /* + * case: unknown errnum + */ + } else { + snprintf_len = sizeof("Unknown error ")-1 + USERMAX_DIGITS + 1; /* + 1 for trailing NUL */ + ret = calloc(snprintf_len+1, 1); /* +1 for paranoia */ + if (ret == NULL) { + math_error("Out of memory #2 for errnum_2_errmsg"); + not_reached(); + } + *palloced = true; + snprintf(ret, snprintf_len, "Unknown error %d", errnum); + ret[snprintf_len] = '\0'; /* paranoia */ + } + + /* + * return possibly allocated errmsg string + */ + return ret; +} + + +/* + * errsym_2_errmsg - convert convert an E_STRING into an errmsg string, possibly malloced + * + * given: + * errsym E_STRING to convert + * palloced pointer to bool to be set if errmsg string was malloced + * + * return: + * != NULL ==> errmsg string for errsym (malloced if *palloced == true, static is not) + * == NULL ==> errsym is not valid, or palloced is NULL, or errsym is NULL + */ +char * +errsym_2_errmsg(CONST char *errsym, bool *palloced) +{ + int errnum; /* errsym E_STRING converted to errnum code or NULL_ERRNUM */ + char *ret; /* errmsg string, possibly malloced, or NULL */ + + /* + * firewall + */ + if (palloced == NULL) { + /* palloced is NULL */ + return NULL; + } + if (errsym == NULL) { + /* errsym is NULL */ + *palloced = false; + return NULL; + } + + /* + * convert errsym E_STRING to errnum + */ + errnum = errsym_2_errnum(errsym); + if (is_valid_errnum(errnum) == false) { + /* errsym did not convert into a valid errnum code */ + *palloced = false; + return NULL; + } + + /* + * return errnum value into an errmsg string, possibly malloced or return NULL + */ + ret = errnum_2_errmsg(errnum, palloced); + return ret; +} + /* * The code below is used to form the errcode executable and is NOT part of libcalc @@ -638,12 +1940,6 @@ CONST struct errtbl error_table[] = { #if defined(ERRCODE_SRC) -#include -#include -#include -#include - - /* * errcode command line */ @@ -658,154 +1954,12 @@ CONST char *usage = " 0\t\tall is OK\n" " 2\t\t-h and help string\n" " 3\t\tcommand line error\n" - " >=10\t\terror_table is invalid\n"; + " >=10\t\terror_table[] and/or private_error_alias[] is invalid\n"; char *program = "((NULL))"; /* our name */ -/* - * verify_error_table - verify the consistency of the error_table - * - * The errnum must start with E__BASE and be consecutive until the final entry. - * - * The errsym must be a non-NULL string that matches regular expression: ^E_[A-Z0-9_]+$ until the last entry. - * - * The errnsf must be a non-NULL non-empty string until the last entry. - * - * The final entry must have an errnum of -1, errsym of NULL and errmsg of NULL. - * - * This function does not return on error or if the error_table is invalid. - */ -S_FUNC void -verify_error_table(void) -{ - size_t len; /* length of the error_table */ - size_t e__count; /* computed ECOUNT value */ - char *p; - size_t i; - - /* - * verify error_table size - */ - len = sizeof(error_table) / sizeof(error_table[0]); - e__count = len - 2; - if (e__count != MY_ECOUNT) { - fprintf(stderr, "**** %s ERROR: error_table length: %zu != MY_ECOUNT+2: %lu\n", - program, len, MY_ECOUNT+2); - exit(10); - } - - /* - * verify the initial errnum of the 1st error_table entry - */ - if (error_table[0].errnum != E__BASE) { - fprintf(stderr, "**** %s ERROR: initial entry error_table[0].errnum: %d != E__BASE: %d\n", - program, error_table[0].errnum, E__BASE); - exit(11); - } - if (error_table[0].errsym == NULL) { - fprintf(stderr, "**** %s ERROR: error_table[0].errsym is NULL\n", - program); - exit(12); - } - if (strcmp(error_table[0].errsym, "E__BASE") != 0) { - fprintf(stderr, "**** %s ERROR: error_table[0].errsym: %s != E__BASE\n", - program, error_table[0].errsym); - exit(13); - } - if (error_table[0].errmsg == NULL) { - fprintf(stderr, "**** %s ERROR: error_table[0].errmsg is NULL\n", - program); - exit(14); - } - if (strlen(error_table[0].errmsg) <= 0) { - fprintf(stderr, "**** %s ERROR: error_table[0].errmsg length: %zu must be > 0\n", - program, strlen(error_table[0].errmsg)); - exit(15); - } - - /* - * verify 2nd thru end to last entry of error_table - */ - for (i=1; i < len-1; ++i) { - - /* - * check errnum - must be consecutive beyond E__BASE - */ - if ((unsigned long)(error_table[i].errnum) != E__BASE+i) { - fprintf(stderr, "**** %s ERROR: error_table[%zu].errnum: %d != %ld\n", - program, i, error_table[i].errnum, E__BASE+i); - exit(16); - } - - /* - * check errsym is a non-NULL string matching the regular expression: ^E_[A-Z0-9_]+$ - */ - if (error_table[i].errsym == NULL) { - fprintf(stderr, "**** %s ERROR: error_table[%zu].errsym is NULL\n", - program, i); - exit(17); - } - if (strlen(error_table[i].errsym) < 3) { - fprintf(stderr, "**** %s ERROR: error_table[%zu].errsym length: %zu must be >= 3\n", - program, i, strlen(error_table[i].errsym)); - exit(18); - } - if (strncmp(error_table[i].errsym, "E_", 2) != 0) { - fprintf(stderr, "**** %s ERROR: error_table[%zu].errsym: %s must start with E_\n", - program, i, error_table[i].errsym); - exit(19); - } - p = error_table[i].errsym+2; - if (!isascii(*p) || !isupper(*p)) { - fprintf(stderr, "**** %s ERROR: error_table[%zu].errsym: %s " - "3rd E_STRING char is not UPPER letter, " - "must match the regular expression: %s\n", - program, i, error_table[i].errsym, "^E_[A-Z][A-Z0-9_]+$"); - exit(20); - } - for (p = error_table[i].errsym+3; *p != '\0'; ++p) { - if (!isascii(*p) || !(isupper(*p) || isdigit(*p) || *p == '_')) { - fprintf(stderr, "**** %s ERROR: error_table[%zu].errsym: %s " - "E_STRING must match the regular expression: %s\n", - program, i, error_table[i].errsym, "^E_[A-Z0-9_]+$"); - exit(21); - } - } - - /* - * verify errmsg is not empty - */ - if (strlen(error_table[i].errmsg) <= 0) { - fprintf(stderr, "**** %s ERROR: error_table[%zu].errmsg length: %zu must be > 0\n", - program, i, strlen(error_table[i].errmsg)); - exit(22); - } - } - - /* - * verify the last error_table entry - */ - if (error_table[len-1].errnum != -1) { - fprintf(stderr, "**** %s ERROR: final NULL entry error_table[%zu].errnum: %d != -1\n", - program, len-1, error_table[len-1].errnum); - exit(23); - } - if (error_table[len-1].errsym != NULL) { - fprintf(stderr, "**** %s ERROR: final NULL entry error_table[%zu].errsym != NULL\n", - program, len-1); - exit(24); - } - if (error_table[len-1].errmsg != NULL) { - fprintf(stderr, "**** %s ERROR: final NULL entry error_table[%zu].errmsg != NULL\n", - program, len-1); - exit(25); - } - return; -} - - /* * print_errorcodes - print the help/errorcodes file */ @@ -972,7 +2126,7 @@ main(int argc, char *argv[]) switch (i) { case 'h': fprintf(stderr, usage, program); - exit(2); + exit(2); /*ooo*/ case 'e': e_flag = 1; break; @@ -982,13 +2136,13 @@ main(int argc, char *argv[]) default: fprintf(stderr, "**** %s ERROR: invalid command line\n", program); fprintf(stderr, usage, program); - exit(3); + exit(3); /*ooo*/ } } if (e_flag && d_flag) { fprintf(stderr, "**** %s ERROR: -e and -d conflict\n", program); fprintf(stderr, usage, program); - exit(3); + exit(3); /*ooo*/ } /* @@ -1013,7 +2167,7 @@ main(int argc, char *argv[]) /* * All Done!!! -- Jessica Noll, Age 2 */ - exit(0); + exit(0); /*ooo*/ } diff --git a/errtbl.h b/errtbl.h index e90d829..e5757c2 100644 --- a/errtbl.h +++ b/errtbl.h @@ -28,10 +28,22 @@ #define INCLUDE_ERRTBL_H +#include "attribute.h" #include "have_const.h" +#include "bool.h" #include "decl.h" +/* + * NOTE: See also errsym.h, the file that this code, via errcode -d, via the Makefile, creates + * + * We cannot use errsym.h when compiling for errcode (ERRCODE_SRC defined) + */ +#if !defined(ERRCODE_SRC) +#include "errsym.h" +#endif /* !ERRCODE_SRC */ + + /* * primary error code defines */ @@ -40,13 +52,27 @@ #define E__USERDEF 20000 /* user defined error codes start here */ #define E__USERMAX 32767 /* maximum user defined error code */ +#define USERMAX_DIGITS 5 /* number of decimal digits in E__USERMAX */ + +/* + * invalid errnum + */ +#define NULL_ERRNUM (-1) /* errnum for the final table terminating NULL entry */ + + +/* + * The error routine. + */ +E_FUNC void math_error(char *, ...) \ + __attribute__((format(printf, 1, 2))) __attribute__((noreturn)); + /* * calc error code, error symbol and error message */ struct errtbl { - int errnum; /* calc error code or -1 */ - char *errsym; /* error symbol string - must match the regular expression: ^E_[A-Z0-9_]+$ or NULL */ + int errnum; /* calc computation error codes or -1 */ + char *errsym; /* E_STRING - must match regexp: ^E_[A-Z0-9_]+$ or NULL */ char *errmsg; /* calc error message or NULL */ }; @@ -65,4 +91,23 @@ struct errtbl { EXTERN CONST struct errtbl error_table[]; /* calc error codes, error symbols and error messages */ +/* + * external functions + */ +E_FUNC bool is_e_digits(CONST char *errsym); +E_FUNC bool is_valid_errnum(int errnum); +E_FUNC bool is_errnum_in_error_table(int errnum); +E_FUNC int e_digits_2_errnum(CONST char *errsym); +E_FUNC bool is_e_1string(CONST char *errsym); +E_FUNC bool is_e_2string(CONST char *errsym); +E_FUNC struct errtbl *find_estring_in_errtbl(CONST char *errsym, CONST struct errtbl *tbl); +E_FUNC struct errtbl *find_errnum_in_errtbl(int errnum, CONST struct errtbl *tbl); +E_FUNC CONST struct errtbl *lookup_errnum_in_error_table(int errnum); +E_FUNC void verify_error_table(void); +E_FUNC int errsym_2_errnum(CONST char *errsym); +E_FUNC char *errnum_2_errsym(int errnum, bool *palloced); +E_FUNC char *errnum_2_errmsg(int errnum, bool *palloced); +E_FUNC char *errsym_2_errmsg(CONST char *errsym, bool *palloced); + + #endif /* !INCLUDE_ERRTBL_H */ diff --git a/file.c b/file.c index adf6a78..33b633f 100644 --- a/file.c +++ b/file.c @@ -43,7 +43,6 @@ #include "have_fpos_pos.h" #include "fposval.h" #include "file.h" -#include "errsym.h" #include "strl.h" #if defined(_WIN32) || defined(_WIN64) @@ -51,7 +50,7 @@ #endif -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/func.c b/func.c index a6eef13..796605c 100644 --- a/func.c +++ b/func.c @@ -93,8 +93,6 @@ #include "have_const.h" #include "have_unused.h" #include "calc.h" -#include "errsym.h" -#include "errtbl.h" #include "opcodes.h" #include "token.h" #include "func.h" @@ -114,7 +112,7 @@ #endif -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ @@ -231,6 +229,7 @@ struct builtin { #if !defined(FUNCLIST) + /* * verify_eps - verify that the eps argument is a valid error value * @@ -276,6 +275,61 @@ verify_eps(VALUE CONST *veps) } +/* + * name_newerrorstr - obtain the name string for a user-described error code + * + * given: + * errnum errnum code to convert + * + * returns: + * != NULL ==> non-empty name string for a user-described error + * == NULL ==> errnum is not valid, or name string is empty, or name string not found + */ +char * +name_newerrorstr(int errnum) +{ + char *cp; /* name string lookup result */ + + /* + * firewall + */ + if (is_valid_errnum(errnum) == false) { + /* errnum is not a valid code */ + return NULL; + } + + /* + * case: errnum is not a user-described code + */ + if (errnum < E__USERDEF || errnum > E__USERMAX) { + /* errnum is not a user-described code */ + return NULL; + } + + /* + * case: errnum is outside the current range of user-described codes + */ + if (errnum >= nexterrnum) { + /* errnum is refers to an unassigned user-described code */ + return NULL; + } + + /* + * attempt to fetch the name string for a user-described error code + */ + cp = namestr(&newerrorstr, errnum - E__USERDEF); + if (cp == NULL || cp[0] == '\0') { + /* name string was not found or was empty for the user-described error code */ + return NULL; + } + + /* + * return the name string for the user-described error code + */ + return cp; +} + + S_FUNC VALUE f_eval(VALUE *vp) { @@ -287,14 +341,14 @@ f_eval(VALUE *vp) long temp_stoponerror; /* temp value of stoponerror */ if (vp->v_type != V_STR) - return error_value(E_EVAL2); + return error_value(E_EVAL_2); str = vp->v_str->s_str; num = vp->v_str->s_len; switch (openstring(str, num)) { case -2: - return error_value(E_EVAL3); + return error_value(E_EVAL_3); case -1: - return error_value(E_EVAL4); + return error_value(E_EVAL_4); } oldfunc = curfunc; enterfilescope(); @@ -1358,14 +1412,14 @@ f_setbit(int count, VALUE **vals) r = (count == 3) ? testvalue(vals[2]) : 1; if (vals[1]->v_type != V_NUM || qisfrac(vals[1]->v_num)) - return error_value(E_SETBIT1); + return error_value(E_SETBIT_1); if (zge31b(vals[1]->v_num->num)) - return error_value(E_SETBIT2); + return error_value(E_SETBIT_2); if (vals[0]->v_type != V_STR) - return error_value(E_SETBIT3); + return error_value(E_SETBIT_3); index = qtoi(vals[1]->v_num); if (stringsetbit(vals[0]->v_str, index, r)) - return error_value(E_SETBIT2); + return error_value(E_SETBIT_2); return result; } @@ -1377,14 +1431,14 @@ f_digit(int count, VALUE **vals) ZVALUE base; if (vals[0]->v_type != V_NUM) - return error_value(E_DGT1); + return error_value(E_DGT_1); if (vals[1]->v_type != V_NUM || qisfrac(vals[1]->v_num)) - return error_value(E_DGT2); + return error_value(E_DGT_2); if (count == 3) { if (vals[2]->v_type != V_NUM || qisfrac(vals[2]->v_num)) - return error_value(E_DGT3); + return error_value(E_DGT_3); base = vals[2]->v_num->num; } else { base = _ten_; @@ -1393,7 +1447,7 @@ f_digit(int count, VALUE **vals) res.v_subtype = V_NOSUBTYPE; res.v_num = qdigit(vals[0]->v_num, vals[1]->v_num->num, base); if (res.v_num == NULL) - return error_value(E_DGT3); + return error_value(E_DGT_3); return res; } @@ -1406,11 +1460,11 @@ f_digits(int count, VALUE **vals) VALUE res; if (vals[0]->v_type != V_NUM) - return error_value(E_DGTS1); + return error_value(E_DGTS_1); if (count > 1) { if (vals[1]->v_type != V_NUM || qisfrac(vals[1]->v_num) || qiszero(vals[1]->v_num) || qisunit(vals[1]->v_num)) - return error_value(E_DGTS2); + return error_value(E_DGTS_2); base = vals[1]->v_num->num; } else { base = _ten_; @@ -1429,13 +1483,13 @@ f_places(int count, VALUE **vals) VALUE res; if (vals[0]->v_type != V_NUM) - return error_value(E_PLCS1); + return error_value(E_PLCS_1); if (count > 1) { if (vals[1]->v_type != V_NUM || qisfrac(vals[1]->v_num)) - return error_value(E_PLCS2); + return error_value(E_PLCS_2); places = qplaces(vals[0]->v_num, vals[1]->v_num->num); if (places == -2) - return error_value(E_PLCS2); + return error_value(E_PLCS_2); } else places = qdecplaces(vals[0]->v_num); @@ -1484,29 +1538,29 @@ f_xor(int count, VALUE **vals) result.v_subtype = vals[0]->v_subtype; for (i = 1; i < count; i++) { if (vals[i]->v_type != type) - return error_value(E_XOR1); + return error_value(E_XOR_1); } switch (type) { - case V_NUM: - q = qlink(vals[0]->v_num); - for (i = 1; i < count; i++) { - qtmp = qxor(q, vals[i]->v_num); - qfree(q); - q = qtmp; - } - result.v_num = q; - break; - case V_STR: - s = slink(vals[0]->v_str); - for (i = 1; i < count; i++) { - stmp = stringxor(s, vals[i]->v_str); - sfree(s); - s = stmp; - } - result.v_str = s; - break; - default: - return error_value(E_XOR2); + case V_NUM: + q = qlink(vals[0]->v_num); + for (i = 1; i < count; i++) { + qtmp = qxor(q, vals[i]->v_num); + qfree(q); + q = qtmp; + } + result.v_num = q; + break; + case V_STR: + s = slink(vals[0]->v_str); + for (i = 1; i < count; i++) { + stmp = stringxor(s, vals[i]->v_str); + sfree(s); + s = stmp; + } + result.v_str = s; + break; + default: + return error_value(E_XOR_2); } return result; } @@ -1530,15 +1584,15 @@ minlistitems(LIST *lp) for (ep = lp->l_first; ep; ep = ep->e_next) { vp = &ep->e_value; switch(vp->v_type) { - case V_LIST: - term = minlistitems(vp->v_list); - break; - case V_OBJ: - term = objcall(OBJ_MIN, vp, - NULL_VALUE, NULL_VALUE); - break; - default: - copyvalue(vp, &term); + case V_LIST: + term = minlistitems(vp->v_list); + break; + case V_OBJ: + term = objcall(OBJ_MIN, vp, + NULL_VALUE, NULL_VALUE); + break; + default: + copyvalue(vp, &term); } if (min.v_type == V_NULL) { min = term; @@ -1583,15 +1637,15 @@ maxlistitems(LIST *lp) for (ep = lp->l_first; ep; ep = ep->e_next) { vp = &ep->e_value; switch(vp->v_type) { - case V_LIST: - term = maxlistitems(vp->v_list); - break; - case V_OBJ: - term = objcall(OBJ_MAX, vp, - NULL_VALUE, NULL_VALUE); - break; - default: - copyvalue(vp, &term); + case V_LIST: + term = maxlistitems(vp->v_list); + break; + case V_OBJ: + term = objcall(OBJ_MAX, vp, + NULL_VALUE, NULL_VALUE); + break; + default: + copyvalue(vp, &term); } if (max.v_type == V_NULL) { max = term; @@ -1635,15 +1689,15 @@ f_min(int count, VALUE **vals) while (count-- > 0) { vp = *vals++; switch(vp->v_type) { - case V_LIST: - term = minlistitems(vp->v_list); - break; - case V_OBJ: - term = objcall(OBJ_MIN, vp, - NULL_VALUE, NULL_VALUE); - break; - default: - copyvalue(vp, &term); + case V_LIST: + term = minlistitems(vp->v_list); + break; + case V_OBJ: + term = objcall(OBJ_MIN, vp, + NULL_VALUE, NULL_VALUE); + break; + default: + copyvalue(vp, &term); } if (min.v_type == V_NULL) { min = term; @@ -1691,15 +1745,15 @@ f_max(int count, VALUE **vals) while (count-- > 0) { vp = *vals++; switch(vp->v_type) { - case V_LIST: - term = maxlistitems(vp->v_list); - break; - case V_OBJ: - term = objcall(OBJ_MAX, vp, - NULL_VALUE, NULL_VALUE); - break; - default: - copyvalue(vp, &term); + case V_LIST: + term = maxlistitems(vp->v_list); + break; + case V_OBJ: + term = objcall(OBJ_MAX, vp, + NULL_VALUE, NULL_VALUE); + break; + default: + copyvalue(vp, &term); } if (max.v_type == V_NULL) { max = term; @@ -1800,20 +1854,20 @@ sumlistitems(LIST *lp) for (ep = lp->l_first; ep; ep = ep->e_next) { vp = &ep->e_value; switch(vp->v_type) { - case V_LIST: - term = sumlistitems(vp->v_list); - break; - case V_OBJ: - term = objcall(OBJ_SUM, vp, - NULL_VALUE, NULL_VALUE); - break; - default: - addvalue(&sum, vp, &tmp); - freevalue(&sum); - if (tmp.v_type < 0) - return tmp; - sum = tmp; - continue; + case V_LIST: + term = sumlistitems(vp->v_list); + break; + case V_OBJ: + term = objcall(OBJ_SUM, vp, + NULL_VALUE, NULL_VALUE); + break; + default: + addvalue(&sum, vp, &tmp); + freevalue(&sum); + if (tmp.v_type < 0) + return tmp; + sum = tmp; + continue; } addvalue(&sum, &term, &tmp); freevalue(&sum); @@ -1844,20 +1898,20 @@ f_sum(int count, VALUE **vals) while (count-- > 0) { vp = *vals++; switch(vp->v_type) { - case V_LIST: - term = sumlistitems(vp->v_list); - break; - case V_OBJ: - term = objcall(OBJ_SUM, vp, - NULL_VALUE, NULL_VALUE); - break; - default: - addvalue(&sum, vp, &tmp); - freevalue(&sum); - if (tmp.v_type < 0) - return tmp; - sum = tmp; - continue; + case V_LIST: + term = sumlistitems(vp->v_list); + break; + case V_OBJ: + term = objcall(OBJ_SUM, vp, + NULL_VALUE, NULL_VALUE); + break; + default: + addvalue(&sum, vp, &tmp); + freevalue(&sum); + if (tmp.v_type < 0) + return tmp; + sum = tmp; + continue; } addvalue(&sum, &term, &tmp); freevalue(&term); @@ -2116,7 +2170,7 @@ f_exp(int count, VALUE **vals) eps = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_EXP1); + return error_value(E_EXP_1); } eps = vals[1]->v_num; } @@ -2125,26 +2179,26 @@ f_exp(int count, VALUE **vals) * compute e^x to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - q = qexp(vals[0]->v_num, eps); - if (q == NULL) - return error_value(E_EXP3); - result.v_num = q; + case V_NUM: + q = qexp(vals[0]->v_num, eps); + if (q == NULL) + return error_value(E_EXP_3); + result.v_num = q; + result.v_type = V_NUM; + break; + case V_COM: + c = c_exp(vals[0]->v_com, eps); + if (c == NULL) + return error_value(E_EXP_3); + result.v_com = c; + result.v_type = V_COM; + if (cisreal(c)) { + result.v_num = c_to_q(c, true); result.v_type = V_NUM; - break; - case V_COM: - c = c_exp(vals[0]->v_com, eps); - if (c == NULL) - return error_value(E_EXP3); - result.v_com = c; - result.v_type = V_COM; - if (cisreal(c)) { - result.v_num = c_to_q(c, true); - result.v_type = V_NUM; - } - break; - default: - return error_value(E_EXP2); + } + break; + default: + return error_value(E_EXP_2); } return result; } @@ -2168,7 +2222,7 @@ f_ln(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_LN1); + return error_value(E_LN_1); } err = vals[1]->v_num; } @@ -2177,23 +2231,23 @@ f_ln(int count, VALUE **vals) * compute natural logarithm to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - if (!qisneg(vals[0]->v_num) && - !qiszero(vals[0]->v_num)) { - result.v_num = qln(vals[0]->v_num, err); - result.v_type = V_NUM; - return result; - } - ctmp.real = vals[0]->v_num; - ctmp.imag = qlink(&_qzero_); - ctmp.links = 1; - c = c_ln(&ctmp, err); - break; - case V_COM: - c = c_ln(vals[0]->v_com, err); - break; - default: - return error_value(E_LN2); + case V_NUM: + if (!qisneg(vals[0]->v_num) && + !qiszero(vals[0]->v_num)) { + result.v_num = qln(vals[0]->v_num, err); + result.v_type = V_NUM; + return result; + } + ctmp.real = vals[0]->v_num; + ctmp.imag = qlink(&_qzero_); + ctmp.links = 1; + c = c_ln(&ctmp, err); + break; + case V_COM: + c = c_ln(vals[0]->v_com, err); + break; + default: + return error_value(E_LN_2); } /* determine if we will return a numeric or complex value */ @@ -2225,7 +2279,7 @@ f_log(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_LOG1); + return error_value(E_LOG_1); } err = vals[1]->v_num; } @@ -2234,26 +2288,26 @@ f_log(int count, VALUE **vals) * compute logarithm base 10 to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - if (!qisneg(vals[0]->v_num) && - !qiszero(vals[0]->v_num)) { - result.v_num = qlog(vals[0]->v_num, err); - result.v_type = V_NUM; - return result; - } - ctmp.real = vals[0]->v_num; - ctmp.imag = qlink(&_qzero_); - ctmp.links = 1; - c = c_log(&ctmp, err); - break; - case V_COM: - c = c_log(vals[0]->v_com, err); - break; - default: - return error_value(E_LOG2); + case V_NUM: + if (!qisneg(vals[0]->v_num) && + !qiszero(vals[0]->v_num)) { + result.v_num = qlog(vals[0]->v_num, err); + result.v_type = V_NUM; + return result; + } + ctmp.real = vals[0]->v_num; + ctmp.imag = qlink(&_qzero_); + ctmp.links = 1; + c = c_log(&ctmp, err); + break; + case V_COM: + c = c_log(vals[0]->v_com, err); + break; + default: + return error_value(E_LOG_2); } if (c == NULL) { - return error_value(E_LOG3); + return error_value(E_LOG_3); } /* determine if we will return a numeric or complex value */ @@ -2294,23 +2348,23 @@ f_log2(int count, VALUE **vals) * compute base 2 logarithm to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - if (!qisneg(vals[0]->v_num) && - !qiszero(vals[0]->v_num)) { - result.v_num = qlog2(vals[0]->v_num, err); - result.v_type = V_NUM; - return result; - } - ctmp.real = vals[0]->v_num; - ctmp.imag = qlink(&_qzero_); - ctmp.links = 1; - c = c_log2(&ctmp, err); - break; - case V_COM: - c = c_log2(vals[0]->v_com, err); - break; - default: - return error_value(E_LOG2_2); + case V_NUM: + if (!qisneg(vals[0]->v_num) && + !qiszero(vals[0]->v_num)) { + result.v_num = qlog2(vals[0]->v_num, err); + result.v_type = V_NUM; + return result; + } + ctmp.real = vals[0]->v_num; + ctmp.imag = qlink(&_qzero_); + ctmp.links = 1; + c = c_log2(&ctmp, err); + break; + case V_COM: + c = c_log2(vals[0]->v_com, err); + break; + default: + return error_value(E_LOG2_2); } if (c == NULL) { return error_value(E_LOG2_3); @@ -2601,7 +2655,7 @@ f_cos(int count, VALUE **vals) eps = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_COS1); + return error_value(E_COS_1); } eps = vals[1]->v_num; } @@ -2610,23 +2664,23 @@ f_cos(int count, VALUE **vals) * compute cosinr to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - result.v_num = qcos(vals[0]->v_num, eps); + case V_NUM: + result.v_num = qcos(vals[0]->v_num, eps); + result.v_type = V_NUM; + break; + case V_COM: + c = c_cos(vals[0]->v_com, eps); + if (c == NULL) + return error_value(E_COS_3); + result.v_com = c; + result.v_type = V_COM; + if (cisreal(c)) { + result.v_num = c_to_q(c, true); result.v_type = V_NUM; - break; - case V_COM: - c = c_cos(vals[0]->v_com, eps); - if (c == NULL) - return error_value(E_COS3); - result.v_com = c; - result.v_type = V_COM; - if (cisreal(c)) { - result.v_num = c_to_q(c, true); - result.v_type = V_NUM; - } - break; - default: - return error_value(E_COS2); + } + break; + default: + return error_value(E_COS_2); } return result; } @@ -2653,7 +2707,7 @@ f_d2r(int count, VALUE **vals) eps = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_D2R1); + return error_value(E_D2R_1); } eps = vals[1]->v_num; } @@ -2662,20 +2716,20 @@ f_d2r(int count, VALUE **vals) * compute argument*(pi/180) to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - pidiv180 = qpidiv180(eps); - result.v_num = qmul(vals[0]->v_num, pidiv180); - result.v_type = V_NUM; - qfree(pidiv180); - break; - case V_COM: - pidiv180 = qpidiv180(eps); - result.v_com = c_mulq(vals[0]->v_com, pidiv180); - result.v_type = V_COM; - qfree(pidiv180); - break; - default: - return error_value(E_D2R2); + case V_NUM: + pidiv180 = qpidiv180(eps); + result.v_num = qmul(vals[0]->v_num, pidiv180); + result.v_type = V_NUM; + qfree(pidiv180); + break; + case V_COM: + pidiv180 = qpidiv180(eps); + result.v_com = c_mulq(vals[0]->v_com, pidiv180); + result.v_type = V_COM; + qfree(pidiv180); + break; + default: + return error_value(E_D2R_2); } return result; } @@ -2702,7 +2756,7 @@ f_r2d(int count, VALUE **vals) eps = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_R2D1); + return error_value(E_R2D_1); } eps = vals[1]->v_num; } @@ -2711,20 +2765,20 @@ f_r2d(int count, VALUE **vals) * compute argument/(pi/180) to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - pidiv180 = qpidiv180(eps); - result.v_num = qqdiv(vals[0]->v_num, pidiv180); - result.v_type = V_NUM; - qfree(pidiv180); - break; - case V_COM: - pidiv180 = qpidiv180(eps); - result.v_com = c_divq(vals[0]->v_com, pidiv180); - result.v_type = V_COM; - qfree(pidiv180); - break; - default: - return error_value(E_R2D2); + case V_NUM: + pidiv180 = qpidiv180(eps); + result.v_num = qqdiv(vals[0]->v_num, pidiv180); + result.v_type = V_NUM; + qfree(pidiv180); + break; + case V_COM: + pidiv180 = qpidiv180(eps); + result.v_com = c_divq(vals[0]->v_com, pidiv180); + result.v_type = V_COM; + qfree(pidiv180); + break; + default: + return error_value(E_R2D_2); } return result; } @@ -2751,7 +2805,7 @@ f_g2r(int count, VALUE **vals) eps = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_G2R1); + return error_value(E_G2R_1); } eps = vals[1]->v_num; } @@ -2760,20 +2814,20 @@ f_g2r(int count, VALUE **vals) * compute argument*(pi/200) to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - pidiv200 = qpidiv200(eps); - result.v_num = qmul(vals[0]->v_num, pidiv200); - result.v_type = V_NUM; - qfree(pidiv200); - break; - case V_COM: - pidiv200 = qpidiv200(eps); - result.v_com = c_mulq(vals[0]->v_com, pidiv200); - result.v_type = V_COM; - qfree(pidiv200); - break; - default: - return error_value(E_G2R2); + case V_NUM: + pidiv200 = qpidiv200(eps); + result.v_num = qmul(vals[0]->v_num, pidiv200); + result.v_type = V_NUM; + qfree(pidiv200); + break; + case V_COM: + pidiv200 = qpidiv200(eps); + result.v_com = c_mulq(vals[0]->v_com, pidiv200); + result.v_type = V_COM; + qfree(pidiv200); + break; + default: + return error_value(E_G2R_2); } return result; } @@ -2800,7 +2854,7 @@ f_r2g(int count, VALUE **vals) eps = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_R2G1); + return error_value(E_R2G_1); } eps = vals[1]->v_num; } @@ -2809,20 +2863,20 @@ f_r2g(int count, VALUE **vals) * compute argument/(pi/200) to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - pidiv200 = qpidiv200(eps); - result.v_num = qqdiv(vals[0]->v_num, pidiv200); - result.v_type = V_NUM; - qfree(pidiv200); - break; - case V_COM: - pidiv200 = qpidiv200(eps); - result.v_com = c_divq(vals[0]->v_com, pidiv200); - result.v_type = V_COM; - qfree(pidiv200); - break; - default: - return error_value(E_R2G2); + case V_NUM: + pidiv200 = qpidiv200(eps); + result.v_num = qqdiv(vals[0]->v_num, pidiv200); + result.v_type = V_NUM; + qfree(pidiv200); + break; + case V_COM: + pidiv200 = qpidiv200(eps); + result.v_com = c_divq(vals[0]->v_com, pidiv200); + result.v_type = V_COM; + qfree(pidiv200); + break; + default: + return error_value(E_R2G_2); } return result; } @@ -2846,16 +2900,16 @@ f_d2g(int UNUSED(count), VALUE **vals) /* calculate argument * (10/9) */ switch (vals[0]->v_type) { - case V_NUM: - result.v_num = qmul(vals[0]->v_num, &_qtendivnine_); - result.v_type = V_NUM; - break; - case V_COM: - result.v_com = c_mulq(vals[0]->v_com, &_qtendivnine_); - result.v_type = V_COM; - break; - default: - return error_value(E_D2G1); + case V_NUM: + result.v_num = qmul(vals[0]->v_num, &_qtendivnine_); + result.v_type = V_NUM; + break; + case V_COM: + result.v_com = c_mulq(vals[0]->v_com, &_qtendivnine_); + result.v_type = V_COM; + break; + default: + return error_value(E_D2G_1); } return result; } @@ -2879,16 +2933,16 @@ f_g2d(int UNUSED(count), VALUE **vals) /* calculate argument * (9/10) */ switch (vals[0]->v_type) { - case V_NUM: - result.v_num = qmul(vals[0]->v_num, &_qninedivten_); - result.v_type = V_NUM; - break; - case V_COM: - result.v_com = c_mulq(vals[0]->v_com, &_qninedivten_); - result.v_type = V_COM; - break; - default: - return error_value(E_G2D1); + case V_NUM: + result.v_num = qmul(vals[0]->v_num, &_qninedivten_); + result.v_type = V_NUM; + break; + case V_COM: + result.v_com = c_mulq(vals[0]->v_com, &_qninedivten_); + result.v_type = V_COM; + break; + default: + return error_value(E_G2D_1); } return result; } @@ -2912,7 +2966,7 @@ f_sin(int count, VALUE **vals) eps = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_SIN1); + return error_value(E_SIN_1); } eps = vals[1]->v_num; } @@ -2921,24 +2975,24 @@ f_sin(int count, VALUE **vals) * compute sine to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - result.v_num = qsin(vals[0]->v_num, eps); + case V_NUM: + result.v_num = qsin(vals[0]->v_num, eps); + result.v_type = V_NUM; + break; + case V_COM: + c = c_sin(vals[0]->v_com, eps); + if (c == NULL) { + return error_value(E_SIN_3); + } + result.v_com = c; + result.v_type = V_COM; + if (cisreal(c)) { + result.v_num = c_to_q(c, true); result.v_type = V_NUM; - break; - case V_COM: - c = c_sin(vals[0]->v_com, eps); - if (c == NULL) { - return error_value(E_SIN3); - } - result.v_com = c; - result.v_type = V_COM; - if (cisreal(c)) { - result.v_num = c_to_q(c, true); - result.v_type = V_NUM; - } - break; - default: - return error_value(E_SIN2); + } + break; + default: + return error_value(E_SIN_2); } return result; } @@ -2962,7 +3016,7 @@ f_tan(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_TAN1); + return error_value(E_TAN_1); } err = vals[1]->v_num; } @@ -2971,24 +3025,24 @@ f_tan(int count, VALUE **vals) * compute tangent to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - result.v_num = qtan(vals[0]->v_num, err); + case V_NUM: + result.v_num = qtan(vals[0]->v_num, err); + result.v_type = V_NUM; + break; + case V_COM: + c = c_tan(vals[0]->v_com, err); + if (c == NULL) { + return error_value(E_TAN_5); + } + result.v_com = c; + result.v_type = V_COM; + if (cisreal(c)) { + result.v_num = c_to_q(c, true); result.v_type = V_NUM; - break; - case V_COM: - c = c_tan(vals[0]->v_com, err); - if (c == NULL) { - return error_value(E_TAN5); - } - result.v_com = c; - result.v_type = V_COM; - if (cisreal(c)) { - result.v_num = c_to_q(c, true); - result.v_type = V_NUM; - } - break; - default: - return error_value(E_TAN2); + } + break; + default: + return error_value(E_TAN_2); } return result; } @@ -3012,7 +3066,7 @@ f_cot(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_COT1); + return error_value(E_COT_1); } err = vals[1]->v_num; } @@ -3021,30 +3075,30 @@ f_cot(int count, VALUE **vals) * compute cotangent to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - if (qiszero(vals[0]->v_num)) { - return error_value(E_COT5); - } - result.v_num = qcot(vals[0]->v_num, err); + case V_NUM: + if (qiszero(vals[0]->v_num)) { + return error_value(E_COT_5); + } + result.v_num = qcot(vals[0]->v_num, err); + result.v_type = V_NUM; + break; + case V_COM: + if (ciszero(vals[0]->v_com)) { + return error_value(E_COT_5); + } + c = c_cot(vals[0]->v_com, err); + if (c == NULL) { + return error_value(E_COT_6); + } + result.v_com = c; + result.v_type = V_COM; + if (cisreal(c)) { + result.v_num = c_to_q(c, true); result.v_type = V_NUM; - break; - case V_COM: - if (ciszero(vals[0]->v_com)) { - return error_value(E_COT5); - } - c = c_cot(vals[0]->v_com, err); - if (c == NULL) { - return error_value(E_COT6); - } - result.v_com = c; - result.v_type = V_COM; - if (cisreal(c)) { - result.v_num = c_to_q(c, true); - result.v_type = V_NUM; - } - break; - default: - return error_value(E_COT2); + } + break; + default: + return error_value(E_COT_2); } return result; } @@ -3068,7 +3122,7 @@ f_sec(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_SEC1); + return error_value(E_SEC_1); } err = vals[1]->v_num; } @@ -3077,24 +3131,24 @@ f_sec(int count, VALUE **vals) * compute secant to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - result.v_num = qsec(vals[0]->v_num, err); + case V_NUM: + result.v_num = qsec(vals[0]->v_num, err); + result.v_type = V_NUM; + break; + case V_COM: + c = c_sec(vals[0]->v_com, err); + if (c == NULL) { + return error_value(E_SEC_5); + } + result.v_com = c; + result.v_type = V_COM; + if (cisreal(c)) { + result.v_num = c_to_q(c, true); result.v_type = V_NUM; - break; - case V_COM: - c = c_sec(vals[0]->v_com, err); - if (c == NULL) { - return error_value(E_SEC5); - } - result.v_com = c; - result.v_type = V_COM; - if (cisreal(c)) { - result.v_num = c_to_q(c, true); - result.v_type = V_NUM; - } - break; - default: - return error_value(E_SEC2); + } + break; + default: + return error_value(E_SEC_2); } return result; } @@ -3118,7 +3172,7 @@ f_csc(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_CSC1); + return error_value(E_CSC_1); } err = vals[1]->v_num; } @@ -3127,30 +3181,30 @@ f_csc(int count, VALUE **vals) * compute cosecant to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - if (qiszero(vals[0]->v_num)) { - return error_value(E_CSC5); - } - result.v_num = qcsc(vals[0]->v_num, err); + case V_NUM: + if (qiszero(vals[0]->v_num)) { + return error_value(E_CSC_5); + } + result.v_num = qcsc(vals[0]->v_num, err); + result.v_type = V_NUM; + break; + case V_COM: + if (ciszero(vals[0]->v_com)) { + return error_value(E_CSC_5); + } + c = c_csc(vals[0]->v_com, err); + if (c == NULL) { + return error_value(E_CSC_6); + } + result.v_com = c; + result.v_type = V_COM; + if (cisreal(c)) { + result.v_num = c_to_q(c, true); result.v_type = V_NUM; - break; - case V_COM: - if (ciszero(vals[0]->v_com)) { - return error_value(E_CSC5); - } - c = c_csc(vals[0]->v_com, err); - if (c == NULL) { - return error_value(E_CSC6); - } - result.v_com = c; - result.v_type = V_COM; - if (cisreal(c)) { - result.v_num = c_to_q(c, true); - result.v_type = V_NUM; - } - break; - default: - return error_value(E_CSC2); + } + break; + default: + return error_value(E_CSC_2); } return result; } @@ -3174,7 +3228,7 @@ f_sinh(int count, VALUE **vals) eps = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_SINH1); + return error_value(E_SINH_1); } eps = vals[1]->v_num; } @@ -3183,26 +3237,26 @@ f_sinh(int count, VALUE **vals) * compute hyperbolic sine to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - q = qsinh(vals[0]->v_num, eps); - if (q == NULL) - return error_value(E_SINH3); - result.v_num = q; + case V_NUM: + q = qsinh(vals[0]->v_num, eps); + if (q == NULL) + return error_value(E_SINH_3); + result.v_num = q; + result.v_type = V_NUM; + break; + case V_COM: + c = c_sinh(vals[0]->v_com, eps); + if (c == NULL) + return error_value(E_SINH_3); + result.v_com = c; + result.v_type = V_COM; + if (cisreal(c)) { + result.v_num = c_to_q(c, true); result.v_type = V_NUM; - break; - case V_COM: - c = c_sinh(vals[0]->v_com, eps); - if (c == NULL) - return error_value(E_SINH3); - result.v_com = c; - result.v_type = V_COM; - if (cisreal(c)) { - result.v_num = c_to_q(c, true); - result.v_type = V_NUM; - } - break; - default: - return error_value(E_SINH2); + } + break; + default: + return error_value(E_SINH_2); } return result; } @@ -3227,7 +3281,7 @@ f_cosh(int count, VALUE **vals) eps = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_COSH1); + return error_value(E_COSH_1); } eps = vals[1]->v_num; } @@ -3236,26 +3290,26 @@ f_cosh(int count, VALUE **vals) * compute hyperbolic cosine to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - q = qcosh(vals[0]->v_num, eps); - if (q == NULL) - return error_value(E_COSH3); - result.v_num = q; + case V_NUM: + q = qcosh(vals[0]->v_num, eps); + if (q == NULL) + return error_value(E_COSH_3); + result.v_num = q; + result.v_type = V_NUM; + break; + case V_COM: + c = c_cosh(vals[0]->v_com, eps); + if (c == NULL) + return error_value(E_COSH_3); + result.v_com = c; + result.v_type = V_COM; + if (cisreal(c)) { + result.v_num = c_to_q(c, true); result.v_type = V_NUM; - break; - case V_COM: - c = c_cosh(vals[0]->v_com, eps); - if (c == NULL) - return error_value(E_COSH3); - result.v_com = c; - result.v_type = V_COM; - if (cisreal(c)) { - result.v_num = c_to_q(c, true); - result.v_type = V_NUM; - } - break; - default: - return error_value(E_COSH2); + } + break; + default: + return error_value(E_COSH_2); } return result; } @@ -3281,7 +3335,7 @@ f_tanh(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_TANH1); + return error_value(E_TANH_1); } err = vals[1]->v_num; } @@ -3290,28 +3344,28 @@ f_tanh(int count, VALUE **vals) * compute hyperbolic tangent to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - result.v_num = qtanh(vals[0]->v_num, err); - result.v_type = V_NUM; - break; - case V_COM: - tmp1.v_type = V_COM; - tmp1.v_com = c_sinh(vals[0]->v_com, err); - if (tmp1.v_com == NULL) { - return error_value(E_TANH3); - } - tmp2.v_type = V_COM; - tmp2.v_com = c_cosh(vals[0]->v_com, err); - if (tmp2.v_com == NULL) { - comfree(tmp1.v_com); - return error_value(E_TANH4); - } - divvalue(&tmp1, &tmp2, &result); + case V_NUM: + result.v_num = qtanh(vals[0]->v_num, err); + result.v_type = V_NUM; + break; + case V_COM: + tmp1.v_type = V_COM; + tmp1.v_com = c_sinh(vals[0]->v_com, err); + if (tmp1.v_com == NULL) { + return error_value(E_TANH_3); + } + tmp2.v_type = V_COM; + tmp2.v_com = c_cosh(vals[0]->v_com, err); + if (tmp2.v_com == NULL) { comfree(tmp1.v_com); - comfree(tmp2.v_com); - break; - default: - return error_value(E_TANH2); + return error_value(E_TANH_4); + } + divvalue(&tmp1, &tmp2, &result); + comfree(tmp1.v_com); + comfree(tmp2.v_com); + break; + default: + return error_value(E_TANH_2); } return result; } @@ -3337,7 +3391,7 @@ f_coth(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_COTH1); + return error_value(E_COTH_1); } err = vals[1]->v_num; } @@ -3346,30 +3400,30 @@ f_coth(int count, VALUE **vals) * compute hyperbolic cotangent to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - if (qiszero(vals[0]->v_num)) - return error_value(E_DIVBYZERO); - result.v_num = qcoth(vals[0]->v_num, err); - result.v_type = V_NUM; - break; - case V_COM: - tmp1.v_type = V_COM; - tmp1.v_com = c_cosh(vals[0]->v_com, err); - if (tmp1.v_com == NULL) { - return error_value(E_COTH3); - } - tmp2.v_type = V_COM; - tmp2.v_com = c_sinh(vals[0]->v_com, err); - if (tmp2.v_com == NULL) { - comfree(tmp1.v_com); - return error_value(E_COTH4); - } - divvalue(&tmp1, &tmp2, &result); + case V_NUM: + if (qiszero(vals[0]->v_num)) + return error_value(E_DIVBYZERO); + result.v_num = qcoth(vals[0]->v_num, err); + result.v_type = V_NUM; + break; + case V_COM: + tmp1.v_type = V_COM; + tmp1.v_com = c_cosh(vals[0]->v_com, err); + if (tmp1.v_com == NULL) { + return error_value(E_COTH_3); + } + tmp2.v_type = V_COM; + tmp2.v_com = c_sinh(vals[0]->v_com, err); + if (tmp2.v_com == NULL) { comfree(tmp1.v_com); - comfree(tmp2.v_com); - break; - default: - return error_value(E_COTH2); + return error_value(E_COTH_4); + } + divvalue(&tmp1, &tmp2, &result); + comfree(tmp1.v_com); + comfree(tmp2.v_com); + break; + default: + return error_value(E_COTH_2); } return result; } @@ -3394,7 +3448,7 @@ f_sech(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_SECH1); + return error_value(E_SECH_1); } err = vals[1]->v_num; } @@ -3403,21 +3457,21 @@ f_sech(int count, VALUE **vals) * compute hyperbolic secant to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - result.v_num = qsech(vals[0]->v_num, err); - result.v_type = V_NUM; - break; - case V_COM: - tmp.v_type = V_COM; - tmp.v_com = c_cosh(vals[0]->v_com, err); - if (tmp.v_com == NULL) { - return error_value(E_SECH3); - } - invertvalue(&tmp, &result); - comfree(tmp.v_com); - break; - default: - return error_value(E_SECH2); + case V_NUM: + result.v_num = qsech(vals[0]->v_num, err); + result.v_type = V_NUM; + break; + case V_COM: + tmp.v_type = V_COM; + tmp.v_com = c_cosh(vals[0]->v_com, err); + if (tmp.v_com == NULL) { + return error_value(E_SECH_3); + } + invertvalue(&tmp, &result); + comfree(tmp.v_com); + break; + default: + return error_value(E_SECH_2); } return result; } @@ -3442,7 +3496,7 @@ f_csch(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_CSCH1); + return error_value(E_CSCH_1); } err = vals[1]->v_num; } @@ -3451,23 +3505,23 @@ f_csch(int count, VALUE **vals) * compute hyperbolic cosecant to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - if (qiszero(vals[0]->v_num)) - return error_value(E_DIVBYZERO); - result.v_num = qcsch(vals[0]->v_num, err); - result.v_type = V_NUM; - break; - case V_COM: - tmp.v_type = V_COM; - tmp.v_com = c_sinh(vals[0]->v_com, err); - if (tmp.v_com == NULL) { - return error_value(E_CSCH3); - } - invertvalue(&tmp, &result); - comfree(tmp.v_com); - break; - default: - return error_value(E_CSCH2); + case V_NUM: + if (qiszero(vals[0]->v_num)) + return error_value(E_DIVBYZERO); + result.v_num = qcsch(vals[0]->v_num, err); + result.v_type = V_NUM; + break; + case V_COM: + tmp.v_type = V_COM; + tmp.v_com = c_sinh(vals[0]->v_com, err); + if (tmp.v_com == NULL) { + return error_value(E_CSCH_3); + } + invertvalue(&tmp, &result); + comfree(tmp.v_com); + break; + default: + return error_value(E_CSCH_2); } return result; } @@ -3491,7 +3545,7 @@ f_atan(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_ATAN1); + return error_value(E_ATAN_1); } err = vals[1]->v_num; } @@ -3500,23 +3554,23 @@ f_atan(int count, VALUE **vals) * compute inverse tangent to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - result.v_num = qatan(vals[0]->v_num, err); + case V_NUM: + result.v_num = qatan(vals[0]->v_num, err); + result.v_type = V_NUM; + break; + case V_COM: + tmp = c_atan(vals[0]->v_com, err); + if (tmp == NULL) + return error_value(E_ATAN_3); + result.v_type = V_COM; + result.v_com = tmp; + if (cisreal(tmp)) { + result.v_num = c_to_q(tmp, true); result.v_type = V_NUM; - break; - case V_COM: - tmp = c_atan(vals[0]->v_com, err); - if (tmp == NULL) - return error_value(E_ATAN3); - result.v_type = V_COM; - result.v_com = tmp; - if (cisreal(tmp)) { - result.v_num = c_to_q(tmp, true); - result.v_type = V_NUM; - } - break; - default: - return error_value(E_ATAN2); + } + break; + default: + return error_value(E_ATAN_2); } return result; } @@ -3540,7 +3594,7 @@ f_acot(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_ACOT1); + return error_value(E_ACOT_1); } err = vals[1]->v_num; } @@ -3549,23 +3603,23 @@ f_acot(int count, VALUE **vals) * compute inverse cotangent to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - result.v_num = qacot(vals[0]->v_num, err); + case V_NUM: + result.v_num = qacot(vals[0]->v_num, err); + result.v_type = V_NUM; + break; + case V_COM: + tmp = c_acot(vals[0]->v_com, err); + if (tmp == NULL) + return error_value(E_ACOT_3); + result.v_type = V_COM; + result.v_com = tmp; + if (cisreal(tmp)) { + result.v_num = c_to_q(tmp, true); result.v_type = V_NUM; - break; - case V_COM: - tmp = c_acot(vals[0]->v_com, err); - if (tmp == NULL) - return error_value(E_ACOT3); - result.v_type = V_COM; - result.v_com = tmp; - if (cisreal(tmp)) { - result.v_num = c_to_q(tmp, true); - result.v_type = V_NUM; - } - break; - default: - return error_value(E_ACOT2); + } + break; + default: + return error_value(E_ACOT_2); } return result; } @@ -3588,7 +3642,7 @@ f_asin(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_ASIN1); + return error_value(E_ASIN_1); } err = vals[1]->v_num; } @@ -3597,27 +3651,27 @@ f_asin(int count, VALUE **vals) * compute inverse sine to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - result.v_num = qasin(vals[0]->v_num, err); - result.v_type = V_NUM; - if (result.v_num == NULL) { - tmp = comalloc(); - qfree(tmp->real); - tmp->real = qlink(vals[0]->v_num); - result.v_type = V_COM; - result.v_com = c_asin(tmp, err); - comfree(tmp); - } - break; - case V_COM: - result.v_com = c_asin(vals[0]->v_com, err); + case V_NUM: + result.v_num = qasin(vals[0]->v_num, err); + result.v_type = V_NUM; + if (result.v_num == NULL) { + tmp = comalloc(); + qfree(tmp->real); + tmp->real = qlink(vals[0]->v_num); result.v_type = V_COM; - break; - default: - return error_value(E_ASIN2); + result.v_com = c_asin(tmp, err); + comfree(tmp); + } + break; + case V_COM: + result.v_com = c_asin(vals[0]->v_com, err); + result.v_type = V_COM; + break; + default: + return error_value(E_ASIN_2); } if (result.v_com == NULL) { - return error_value(E_ASIN3); + return error_value(E_ASIN_3); } if (result.v_type == V_COM && cisreal(result.v_com)) { result.v_num = c_to_q(result.v_com, true); @@ -3644,7 +3698,7 @@ f_acos(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_ACOS1); + return error_value(E_ACOS_1); } err = vals[1]->v_num; } @@ -3653,27 +3707,27 @@ f_acos(int count, VALUE **vals) * compute inverse cosine to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - result.v_num = qacos(vals[0]->v_num, err); - result.v_type = V_NUM; - if (result.v_num == NULL) { - tmp = comalloc(); - qfree(tmp->real); - tmp->real = qlink(vals[0]->v_num); - result.v_type = V_COM; - result.v_com = c_acos(tmp, err); - comfree(tmp); - } - break; - case V_COM: - result.v_com = c_acos(vals[0]->v_com, err); + case V_NUM: + result.v_num = qacos(vals[0]->v_num, err); + result.v_type = V_NUM; + if (result.v_num == NULL) { + tmp = comalloc(); + qfree(tmp->real); + tmp->real = qlink(vals[0]->v_num); result.v_type = V_COM; - break; - default: - return error_value(E_ACOS2); + result.v_com = c_acos(tmp, err); + comfree(tmp); + } + break; + case V_COM: + result.v_com = c_acos(vals[0]->v_com, err); + result.v_type = V_COM; + break; + default: + return error_value(E_ACOS_2); } if (result.v_com == NULL) { - return error_value(E_ACOS3); + return error_value(E_ACOS_3); } if (result.v_type == V_COM && cisreal(result.v_com)) { result.v_num = c_to_q(result.v_com, true); @@ -3701,7 +3755,7 @@ f_asec(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_ASEC1); + return error_value(E_ASEC_1); } err = vals[1]->v_num; } @@ -3710,29 +3764,29 @@ f_asec(int count, VALUE **vals) * compute inverse secant to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - if (qiszero(vals[0]->v_num)) - return error_value(E_ASEC3); - result.v_num = qasec(vals[0]->v_num, err); - result.v_type = V_NUM; - if (result.v_num == NULL) { - tmp = comalloc(); - qfree(tmp->real); - tmp->real = qlink(vals[0]->v_num); - result.v_com = c_asec(tmp, err); - result.v_type = V_COM; - comfree(tmp); - } - break; - case V_COM: - result.v_com = c_asec(vals[0]->v_com, err); + case V_NUM: + if (qiszero(vals[0]->v_num)) + return error_value(E_ASEC_3); + result.v_num = qasec(vals[0]->v_num, err); + result.v_type = V_NUM; + if (result.v_num == NULL) { + tmp = comalloc(); + qfree(tmp->real); + tmp->real = qlink(vals[0]->v_num); + result.v_com = c_asec(tmp, err); result.v_type = V_COM; - break; - default: - return error_value(E_ASEC2); + comfree(tmp); + } + break; + case V_COM: + result.v_com = c_asec(vals[0]->v_com, err); + result.v_type = V_COM; + break; + default: + return error_value(E_ASEC_2); } if (result.v_com == NULL) { - return error_value(E_ASEC3); + return error_value(E_ASEC_3); } if (result.v_type == V_COM) { if (cisreal(result.v_com)) { @@ -3762,7 +3816,7 @@ f_acsc(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_ACSC1); + return error_value(E_ACSC_1); } err = vals[1]->v_num; } @@ -3771,29 +3825,29 @@ f_acsc(int count, VALUE **vals) * compute inverse cosecant to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - if (qiszero(vals[0]->v_num)) - return error_value(E_ACSC3); - result.v_num = qacsc(vals[0]->v_num, err); - result.v_type = V_NUM; - if (result.v_num == NULL) { - tmp = comalloc(); - qfree(tmp->real); - tmp->real = qlink(vals[0]->v_num); - result.v_com = c_acsc(tmp, err); - result.v_type = V_COM; - comfree(tmp); - } - break; - case V_COM: - result.v_com = c_acsc(vals[0]->v_com, err); + case V_NUM: + if (qiszero(vals[0]->v_num)) + return error_value(E_ACSC_3); + result.v_num = qacsc(vals[0]->v_num, err); + result.v_type = V_NUM; + if (result.v_num == NULL) { + tmp = comalloc(); + qfree(tmp->real); + tmp->real = qlink(vals[0]->v_num); + result.v_com = c_acsc(tmp, err); result.v_type = V_COM; - break; - default: - return error_value(E_ACSC2); + comfree(tmp); + } + break; + case V_COM: + result.v_com = c_acsc(vals[0]->v_com, err); + result.v_type = V_COM; + break; + default: + return error_value(E_ACSC_2); } if (result.v_com == NULL) { - return error_value(E_ACSC3); + return error_value(E_ACSC_3); } if (result.v_type == V_COM) { if (cisreal(result.v_com)) { @@ -3823,7 +3877,7 @@ f_asinh(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_ASINH1); + return error_value(E_ASINH_1); } err = vals[1]->v_num; } @@ -3839,7 +3893,7 @@ f_asinh(int count, VALUE **vals) case V_COM: tmp = c_asinh(vals[0]->v_com, err); if (tmp == NULL) { - return error_value(E_ASINH3); + return error_value(E_ASINH_3); } result.v_type = V_COM; result.v_com = tmp; @@ -3849,7 +3903,7 @@ f_asinh(int count, VALUE **vals) } break; default: - return error_value(E_ASINH2); + return error_value(E_ASINH_2); } return result; } @@ -3873,7 +3927,7 @@ f_acosh(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_ACOSH1); + return error_value(E_ACOSH_1); } err = vals[1]->v_num; } @@ -3882,27 +3936,27 @@ f_acosh(int count, VALUE **vals) * compute inverse hyperbolic cosine to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - result.v_num = qacosh(vals[0]->v_num, err); - result.v_type = V_NUM; - if (result.v_num == NULL) { - tmp = comalloc(); - qfree(tmp->real); - tmp->real = qlink(vals[0]->v_num); - result.v_com = c_acosh(tmp, err); - result.v_type = V_COM; - comfree(tmp); - } - break; - case V_COM: - result.v_com = c_acosh(vals[0]->v_com, err); + case V_NUM: + result.v_num = qacosh(vals[0]->v_num, err); + result.v_type = V_NUM; + if (result.v_num == NULL) { + tmp = comalloc(); + qfree(tmp->real); + tmp->real = qlink(vals[0]->v_num); + result.v_com = c_acosh(tmp, err); result.v_type = V_COM; - break; - default: - return error_value(E_ACOSH2); + comfree(tmp); + } + break; + case V_COM: + result.v_com = c_acosh(vals[0]->v_com, err); + result.v_type = V_COM; + break; + default: + return error_value(E_ACOSH_2); } if (result.v_com == NULL) { - return error_value(E_ACOSH3); + return error_value(E_ACOSH_3); } if (result.v_type == V_COM && cisreal(result.v_com)) { result.v_num = c_to_q(result.v_com, true); @@ -3930,7 +3984,7 @@ f_atanh(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_ATANH1); + return error_value(E_ATANH_1); } err = vals[1]->v_num; } @@ -3939,27 +3993,27 @@ f_atanh(int count, VALUE **vals) * compute inverse hyperbolic tangent to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - result.v_num = qatanh(vals[0]->v_num, err); - result.v_type = V_NUM; - if (result.v_num == NULL) { - tmp = comalloc(); - qfree(tmp->real); - tmp->real = qlink(vals[0]->v_num); - result.v_com = c_atanh(tmp, err); - result.v_type = V_COM; - comfree(tmp); - } - break; - case V_COM: - result.v_com = c_atanh(vals[0]->v_com, err); + case V_NUM: + result.v_num = qatanh(vals[0]->v_num, err); + result.v_type = V_NUM; + if (result.v_num == NULL) { + tmp = comalloc(); + qfree(tmp->real); + tmp->real = qlink(vals[0]->v_num); + result.v_com = c_atanh(tmp, err); result.v_type = V_COM; - break; - default: - return error_value(E_ATANH2); + comfree(tmp); + } + break; + case V_COM: + result.v_com = c_atanh(vals[0]->v_com, err); + result.v_type = V_COM; + break; + default: + return error_value(E_ATANH_2); } if (result.v_com == NULL) { - return error_value(E_ATANH3); + return error_value(E_ATANH_3); } if (result.v_type == V_COM) { if (cisreal(result.v_com)) { @@ -3989,7 +4043,7 @@ f_acoth(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_ACOTH1); + return error_value(E_ACOTH_1); } err = vals[1]->v_num; } @@ -3998,27 +4052,27 @@ f_acoth(int count, VALUE **vals) * compute inverse hyperbolic cotangent to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - result.v_num = qacoth(vals[0]->v_num, err); - result.v_type = V_NUM; - if (result.v_num == NULL) { - tmp = comalloc(); - qfree(tmp->real); - tmp->real = qlink(vals[0]->v_num); - result.v_com = c_acoth(tmp, err); - result.v_type = V_COM; - comfree(tmp); - } - break; - case V_COM: - result.v_com = c_acoth(vals[0]->v_com, err); + case V_NUM: + result.v_num = qacoth(vals[0]->v_num, err); + result.v_type = V_NUM; + if (result.v_num == NULL) { + tmp = comalloc(); + qfree(tmp->real); + tmp->real = qlink(vals[0]->v_num); + result.v_com = c_acoth(tmp, err); result.v_type = V_COM; - break; - default: - return error_value(E_ACOTH2); + comfree(tmp); + } + break; + case V_COM: + result.v_com = c_acoth(vals[0]->v_com, err); + result.v_type = V_COM; + break; + default: + return error_value(E_ACOTH_2); } if (result.v_com == NULL) { - return error_value(E_ACOTH3); + return error_value(E_ACOTH_3); } if (result.v_type == V_COM) { if (cisreal(result.v_com)) { @@ -4048,7 +4102,7 @@ f_asech(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_SECH1); + return error_value(E_SECH_1); } err = vals[1]->v_num; } @@ -4057,29 +4111,29 @@ f_asech(int count, VALUE **vals) * compute inverse hyperbolic secant to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - if (qiszero(vals[0]->v_num)) - return error_value(E_ASECH3); - result.v_num = qasech(vals[0]->v_num, err); - result.v_type = V_NUM; - if (result.v_num == NULL) { - tmp = comalloc(); - qfree(tmp->real); - tmp->real = qlink(vals[0]->v_num); - result.v_com = c_asech(tmp, err); - result.v_type = V_COM; - comfree(tmp); - } - break; - case V_COM: - result.v_com = c_asech(vals[0]->v_com, err); + case V_NUM: + if (qiszero(vals[0]->v_num)) + return error_value(E_ASECH_3); + result.v_num = qasech(vals[0]->v_num, err); + result.v_type = V_NUM; + if (result.v_num == NULL) { + tmp = comalloc(); + qfree(tmp->real); + tmp->real = qlink(vals[0]->v_num); + result.v_com = c_asech(tmp, err); result.v_type = V_COM; - break; - default: - return error_value(E_ASECH2); + comfree(tmp); + } + break; + case V_COM: + result.v_com = c_asech(vals[0]->v_com, err); + result.v_type = V_COM; + break; + default: + return error_value(E_ASECH_2); } if (result.v_com == NULL) { - return error_value(E_ASECH3); + return error_value(E_ASECH_3); } if (result.v_type == V_COM) { if (cisreal(result.v_com)) { @@ -4109,7 +4163,7 @@ f_acsch(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_ACSCH1); + return error_value(E_ACSCH_1); } err = vals[1]->v_num; } @@ -4118,29 +4172,29 @@ f_acsch(int count, VALUE **vals) * compute inverse hyperbolic cosecant to a given error tolerance */ switch (vals[0]->v_type) { - case V_NUM: - if (qiszero(vals[0]->v_num)) - return error_value(E_ACSCH3); - result.v_num = qacsch(vals[0]->v_num, err); - result.v_type = V_NUM; - if (result.v_num == NULL) { - tmp = comalloc(); - qfree(tmp->real); - tmp->real = qlink(vals[0]->v_num); - result.v_com = c_acsch(tmp, err); - result.v_type = V_COM; - comfree(tmp); - } - break; - case V_COM: - result.v_com = c_acsch(vals[0]->v_com, err); + case V_NUM: + if (qiszero(vals[0]->v_num)) + return error_value(E_ACSCH_3); + result.v_num = qacsch(vals[0]->v_num, err); + result.v_type = V_NUM; + if (result.v_num == NULL) { + tmp = comalloc(); + qfree(tmp->real); + tmp->real = qlink(vals[0]->v_num); + result.v_com = c_acsch(tmp, err); result.v_type = V_COM; - break; - default: - return error_value(E_ACSCH2); + comfree(tmp); + } + break; + case V_COM: + result.v_com = c_acsch(vals[0]->v_com, err); + result.v_type = V_COM; + break; + default: + return error_value(E_ACSCH_2); } if (result.v_com == NULL) { - return error_value(E_ACSCH3); + return error_value(E_ACSCH_3); } if (result.v_type == V_COM) { if (cisreal(result.v_com)) { @@ -4170,7 +4224,7 @@ f_gd(int count, VALUE **vals) eps = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_GD1); + return error_value(E_GD_1); } eps = vals[1]->v_num; } @@ -4180,26 +4234,26 @@ f_gd(int count, VALUE **vals) */ result.v_type = V_COM; switch (vals[0]->v_type) { - case V_NUM: - if (qiszero(vals[0]->v_num)) { - result.v_type = V_NUM; - result.v_num = qlink(&_qzero_); - return result; - } - tmp = comalloc(); - qfree(tmp->real); - tmp->real = qlink(vals[0]->v_num); - result.v_com = c_gd(tmp, eps); - comfree(tmp); - break; - case V_COM: - result.v_com = c_gd(vals[0]->v_com, eps); - break; - default: - return error_value(E_GD2); + case V_NUM: + if (qiszero(vals[0]->v_num)) { + result.v_type = V_NUM; + result.v_num = qlink(&_qzero_); + return result; + } + tmp = comalloc(); + qfree(tmp->real); + tmp->real = qlink(vals[0]->v_num); + result.v_com = c_gd(tmp, eps); + comfree(tmp); + break; + case V_COM: + result.v_com = c_gd(vals[0]->v_com, eps); + break; + default: + return error_value(E_GD_2); } if (result.v_com == NULL) - return error_value(E_GD3); + return error_value(E_GD_3); if (cisreal(result.v_com)) { result.v_num = c_to_q(result.v_com, true); result.v_type = V_NUM; @@ -4226,7 +4280,7 @@ f_agd(int count, VALUE **vals) eps = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) { - return error_value(E_AGD1); + return error_value(E_AGD_1); } eps = vals[1]->v_num; } @@ -4236,26 +4290,26 @@ f_agd(int count, VALUE **vals) */ result.v_type = V_COM; switch (vals[0]->v_type) { - case V_NUM: - if (qiszero(vals[0]->v_num)) { - result.v_type = V_NUM; - result.v_num = qlink(&_qzero_); - return result; - } - tmp = comalloc(); - qfree(tmp->real); - tmp->real = qlink(vals[0]->v_num); - result.v_com = c_agd(tmp, eps); - comfree(tmp); - break; - case V_COM: - result.v_com = c_agd(vals[0]->v_com, eps); - break; - default: - return error_value(E_AGD2); + case V_NUM: + if (qiszero(vals[0]->v_num)) { + result.v_type = V_NUM; + result.v_num = qlink(&_qzero_); + return result; + } + tmp = comalloc(); + qfree(tmp->real); + tmp->real = qlink(vals[0]->v_num); + result.v_com = c_agd(tmp, eps); + comfree(tmp); + break; + case V_COM: + result.v_com = c_agd(vals[0]->v_com, eps); + break; + default: + return error_value(E_AGD_2); } if (result.v_com == NULL) - return error_value(E_AGD3); + return error_value(E_AGD_3); if (cisreal(result.v_com)) { result.v_num = c_to_q(result.v_com, true); result.v_type = V_NUM; @@ -4272,7 +4326,7 @@ f_comb(VALUE *v1, VALUE *v2) VALUE tmp1, tmp2, div; if (v2->v_type != V_NUM || qisfrac(v2->v_num)) - return error_value(E_COMB1); + return error_value(E_COMB_1); result.v_subtype = V_NOSUBTYPE; result.v_type = V_NUM; if (qisneg(v2->v_num)) { @@ -4290,11 +4344,11 @@ f_comb(VALUE *v1, VALUE *v2) if (v1->v_type == V_NUM) { result.v_num = qcomb(v1->v_num, v2->v_num); if (result.v_num == NULL) - return error_value(E_COMB2); + return error_value(E_COMB_2); return result; } if (zge24b(v2->v_num->num)) - return error_value(E_COMB2); + return error_value(E_COMB_2); n = qtoi(v2->v_num); copyvalue(v1, &result); decvalue(v1, &tmp1); @@ -4412,7 +4466,7 @@ f_arg(int count, VALUE **vals) err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) { - return error_value(E_ARG1); + return error_value(E_ARG_1); } err = vals[1]->v_num; } @@ -4422,21 +4476,21 @@ f_arg(int count, VALUE **vals) */ result.v_type = V_NUM; switch (vals[0]->v_type) { - case V_NUM: - if (qisneg(vals[0]->v_num)) - result.v_num = qpi(err); - else - result.v_num = qlink(&_qzero_); - break; - case V_COM: - c = vals[0]->v_com; - if (ciszero(c)) - result.v_num = qlink(&_qzero_); - else - result.v_num = qatan2(c->imag, c->real, err); - break; - default: - return error_value(E_ARG2); + case V_NUM: + if (qisneg(vals[0]->v_num)) + result.v_num = qpi(err); + else + result.v_num = qlink(&_qzero_); + break; + case V_COM: + c = vals[0]->v_com; + if (ciszero(c)) + result.v_num = qlink(&_qzero_); + else + result.v_num = qatan2(c->imag, c->real, err); + break; + default: + return error_value(E_ARG_2); } return result; } @@ -4595,14 +4649,14 @@ f_quomod(int count, VALUE **vals) if (v3->v_type != V_ADDR || v4->v_type != V_ADDR || v3->v_addr == v4->v_addr) - return error_value(E_QUOMOD1); + return error_value(E_QUOMOD_1); if (count == 5) { v5 = vals[4]; if (v5->v_type == V_ADDR) v5 = v5->v_addr; if (v5->v_type != V_NUM || qisfrac(v5->v_num) || qisneg(v5->v_num) || zge31b(v5->v_num->num)) - return error_value(E_QUOMOD2); + return error_value(E_QUOMOD_2); rnd = qtoi(v5->v_num); } else rnd = conf->quomod; @@ -4617,13 +4671,13 @@ f_quomod(int count, VALUE **vals) if (v1->v_type != V_NUM || v2->v_type != V_NUM || (v3->v_type != V_NUM && v3->v_type != V_NULL) || (v4->v_type != V_NUM && v4->v_type != V_NULL)) - return error_value(E_QUOMOD2); + return error_value(E_QUOMOD_2); s3 = v3->v_subtype; s4 = v4->v_subtype; if ((s3 | s4) & V_NOASSIGNTO) - return error_value(E_QUOMOD3); + return error_value(E_QUOMOD_3); freevalue(v3); freevalue(v4); @@ -4665,7 +4719,7 @@ f_d2dms(int count, VALUE **vals) } if (v5->v_type != V_NUM || qisfrac(v5->v_num) || qisneg(v5->v_num) || zge31b(v5->v_num->num)) { - return error_value(E_D2DMS4); + return error_value(E_D2DMS_4); } rnd = qtoi(v5->v_num); } else { @@ -4675,7 +4729,7 @@ f_d2dms(int count, VALUE **vals) /* type parse args */ if (v2->v_type != V_ADDR || v3->v_type != V_ADDR || v4->v_type != V_ADDR) { - return error_value(E_D2DMS1); + return error_value(E_D2DMS_1); } if (v1->v_type == V_ADDR) { v1 = v1->v_addr; @@ -4687,7 +4741,7 @@ f_d2dms(int count, VALUE **vals) (v2->v_type != V_NUM && v2->v_type != V_NULL) || (v3->v_type != V_NUM && v3->v_type != V_NULL) || (v4->v_type != V_NUM && v4->v_type != V_NULL)) { - return error_value(E_D2DMS2); + return error_value(E_D2DMS_2); } /* remember arg subtypes */ @@ -4695,7 +4749,7 @@ f_d2dms(int count, VALUE **vals) s3 = v3->v_subtype; s4 = v4->v_subtype; if ((s2 | s3 | s4) & V_NOASSIGNTO) { - return error_value(E_D2DMS3); + return error_value(E_D2DMS_3); } /* free old args that will be modified */ @@ -4784,7 +4838,7 @@ f_d2dm(int count, VALUE **vals) } if (v4->v_type != V_NUM || qisfrac(v4->v_num) || qisneg(v4->v_num) || zge31b(v4->v_num->num)) { - return error_value(E_D2DM4); + return error_value(E_D2DM_4); } rnd = qtoi(v4->v_num); } else { @@ -4793,7 +4847,7 @@ f_d2dm(int count, VALUE **vals) /* type parse args */ if (v2->v_type != V_ADDR || v3->v_type != V_ADDR) { - return error_value(E_D2DM1); + return error_value(E_D2DM_1); } if (v1->v_type == V_ADDR) { v1 = v1->v_addr; @@ -4803,14 +4857,14 @@ f_d2dm(int count, VALUE **vals) if (v1->v_type != V_NUM || (v2->v_type != V_NUM && v2->v_type != V_NULL) || (v3->v_type != V_NUM && v3->v_type != V_NULL)) { - return error_value(E_D2DM2); + return error_value(E_D2DM_2); } /* remember arg subtypes */ s2 = v2->v_subtype; s3 = v3->v_subtype; if ((s2 | s3) & V_NOASSIGNTO) { - return error_value(E_D2DM3); + return error_value(E_D2DM_3); } /* free old args that will be modified */ @@ -4882,7 +4936,7 @@ f_g2gms(int count, VALUE **vals) } if (v5->v_type != V_NUM || qisfrac(v5->v_num) || qisneg(v5->v_num) || zge31b(v5->v_num->num)) { - return error_value(E_G2GMS4); + return error_value(E_G2GMS_4); } rnd = qtoi(v5->v_num); } else { @@ -4892,7 +4946,7 @@ f_g2gms(int count, VALUE **vals) /* type parse args */ if (v2->v_type != V_ADDR || v3->v_type != V_ADDR || v4->v_type != V_ADDR) { - return error_value(E_G2GMS1); + return error_value(E_G2GMS_1); } if (v1->v_type == V_ADDR) { v1 = v1->v_addr; @@ -4904,7 +4958,7 @@ f_g2gms(int count, VALUE **vals) (v2->v_type != V_NUM && v2->v_type != V_NULL) || (v3->v_type != V_NUM && v3->v_type != V_NULL) || (v4->v_type != V_NUM && v4->v_type != V_NULL)) { - return error_value(E_G2GMS2); + return error_value(E_G2GMS_2); } /* remember arg subtypes */ @@ -4912,7 +4966,7 @@ f_g2gms(int count, VALUE **vals) s3 = v3->v_subtype; s4 = v4->v_subtype; if ((s2 | s3 | s4) & V_NOASSIGNTO) { - return error_value(E_G2GMS3); + return error_value(E_G2GMS_3); } /* free old args that will be modified */ @@ -5001,7 +5055,7 @@ f_g2gm(int count, VALUE **vals) } if (v4->v_type != V_NUM || qisfrac(v4->v_num) || qisneg(v4->v_num) || zge31b(v4->v_num->num)) { - return error_value(E_G2GM4); + return error_value(E_G2GM_4); } rnd = qtoi(v4->v_num); } else { @@ -5010,7 +5064,7 @@ f_g2gm(int count, VALUE **vals) /* type parse args */ if (v2->v_type != V_ADDR || v3->v_type != V_ADDR) { - return error_value(E_G2GM1); + return error_value(E_G2GM_1); } if (v1->v_type == V_ADDR) { v1 = v1->v_addr; @@ -5020,14 +5074,14 @@ f_g2gm(int count, VALUE **vals) if (v1->v_type != V_NUM || (v2->v_type != V_NUM && v2->v_type != V_NULL) || (v3->v_type != V_NUM && v3->v_type != V_NULL)) { - return error_value(E_G2GM2); + return error_value(E_G2GM_2); } /* remember arg subtypes */ s2 = v2->v_subtype; s3 = v3->v_subtype; if ((s2 | s3) & V_NOASSIGNTO) { - return error_value(E_G2GM3); + return error_value(E_G2GM_3); } /* free old args that will be modified */ @@ -5099,7 +5153,7 @@ f_h2hms(int count, VALUE **vals) } if (v5->v_type != V_NUM || qisfrac(v5->v_num) || qisneg(v5->v_num) || zge31b(v5->v_num->num)) { - return error_value(E_H2HMS4); + return error_value(E_H2HMS_4); } rnd = qtoi(v5->v_num); } else { @@ -5109,7 +5163,7 @@ f_h2hms(int count, VALUE **vals) /* type parse args */ if (v2->v_type != V_ADDR || v3->v_type != V_ADDR || v4->v_type != V_ADDR) { - return error_value(E_H2HMS1); + return error_value(E_H2HMS_1); } if (v1->v_type == V_ADDR) { v1 = v1->v_addr; @@ -5121,7 +5175,7 @@ f_h2hms(int count, VALUE **vals) (v2->v_type != V_NUM && v2->v_type != V_NULL) || (v3->v_type != V_NUM && v3->v_type != V_NULL) || (v4->v_type != V_NUM && v4->v_type != V_NULL)) { - return error_value(E_H2HMS2); + return error_value(E_H2HMS_2); } /* remember arg subtypes */ @@ -5129,7 +5183,7 @@ f_h2hms(int count, VALUE **vals) s3 = v3->v_subtype; s4 = v4->v_subtype; if ((s2 | s3 | s4) & V_NOASSIGNTO) { - return error_value(E_H2HMS3); + return error_value(E_H2HMS_3); } /* free old args that will be modified */ @@ -5218,7 +5272,7 @@ f_h2hm(int count, VALUE **vals) } if (v4->v_type != V_NUM || qisfrac(v4->v_num) || qisneg(v4->v_num) || zge31b(v4->v_num->num)) { - return error_value(E_H2HM4); + return error_value(E_H2HM_4); } rnd = qtoi(v4->v_num); } else { @@ -5227,7 +5281,7 @@ f_h2hm(int count, VALUE **vals) /* type parse args */ if (v2->v_type != V_ADDR || v3->v_type != V_ADDR) { - return error_value(E_H2HM1); + return error_value(E_H2HM_1); } if (v1->v_type == V_ADDR) { v1 = v1->v_addr; @@ -5237,14 +5291,14 @@ f_h2hm(int count, VALUE **vals) if (v1->v_type != V_NUM || (v2->v_type != V_NUM && v2->v_type != V_NULL) || (v3->v_type != V_NUM && v3->v_type != V_NULL)) { - return error_value(E_H2HM2); + return error_value(E_H2HM_2); } /* remember arg subtypes */ s2 = v2->v_subtype; s3 = v3->v_subtype; if ((s2 | s3) & V_NOASSIGNTO) { - return error_value(E_H2HM3); + return error_value(E_H2HM_3); } /* free old args that will be modified */ @@ -5314,7 +5368,7 @@ f_dms2d(int count, VALUE **vals) } if (v4->v_type != V_NUM || qisfrac(v4->v_num) || qisneg(v4->v_num) || zge31b(v4->v_num->num)) { - return error_value(E_DMS2D2); + return error_value(E_DMS2D_2); } rnd = qtoi(v4->v_num); } else { @@ -5324,7 +5378,7 @@ f_dms2d(int count, VALUE **vals) /* type parse args */ if (v1->v_type != V_NUM || v2->v_type != V_NUM || v3->v_type != V_NUM) { - return error_value(E_DMS2D1); + return error_value(E_DMS2D_1); } /* @@ -5385,7 +5439,7 @@ f_dm2d(int count, VALUE **vals) } if (v3->v_type != V_NUM || qisfrac(v3->v_num) || qisneg(v3->v_num) || zge31b(v3->v_num->num)) { - return error_value(E_DM2D2); + return error_value(E_DM2D_2); } rnd = qtoi(v3->v_num); } else { @@ -5394,7 +5448,7 @@ f_dm2d(int count, VALUE **vals) /* type parse args */ if (v1->v_type != V_NUM || v2->v_type != V_NUM) { - return error_value(E_DM2D1); + return error_value(E_DM2D_1); } /* @@ -5444,7 +5498,7 @@ f_gms2g(int count, VALUE **vals) } if (v4->v_type != V_NUM || qisfrac(v4->v_num) || qisneg(v4->v_num) || zge31b(v4->v_num->num)) { - return error_value(E_GMS2G2); + return error_value(E_GMS2G_2); } rnd = qtoi(v4->v_num); } else { @@ -5454,7 +5508,7 @@ f_gms2g(int count, VALUE **vals) /* type parse args */ if (v1->v_type != V_NUM || v2->v_type != V_NUM || v3->v_type != V_NUM) { - return error_value(E_GMS2G1); + return error_value(E_GMS2G_1); } /* @@ -5515,7 +5569,7 @@ f_gm2g(int count, VALUE **vals) } if (v3->v_type != V_NUM || qisfrac(v3->v_num) || qisneg(v3->v_num) || zge31b(v3->v_num->num)) { - return error_value(E_GM2G2); + return error_value(E_GM2G_2); } rnd = qtoi(v3->v_num); } else { @@ -5524,7 +5578,7 @@ f_gm2g(int count, VALUE **vals) /* type parse args */ if (v1->v_type != V_NUM || v2->v_type != V_NUM) { - return error_value(E_GM2G1); + return error_value(E_GM2G_1); } /* @@ -5574,7 +5628,7 @@ f_hms2h(int count, VALUE **vals) } if (v4->v_type != V_NUM || qisfrac(v4->v_num) || qisneg(v4->v_num) || zge31b(v4->v_num->num)) { - return error_value(E_HMS2H2); + return error_value(E_HMS2H_2); } rnd = qtoi(v4->v_num); } else { @@ -5584,7 +5638,7 @@ f_hms2h(int count, VALUE **vals) /* type parse args */ if (v1->v_type != V_NUM || v2->v_type != V_NUM || v3->v_type != V_NUM) { - return error_value(E_HMS2H1); + return error_value(E_HMS2H_1); } /* @@ -5645,7 +5699,7 @@ f_hm2h(int count, VALUE **vals) } if (v3->v_type != V_NUM || qisfrac(v3->v_num) || qisneg(v3->v_num) || zge31b(v3->v_num->num)) { - return error_value(E_H2HM2); + return error_value(E_H2HM_2); } rnd = qtoi(v3->v_num); } else { @@ -5654,7 +5708,7 @@ f_hm2h(int count, VALUE **vals) /* type parse args */ if (v1->v_type != V_NUM || v2->v_type != V_NUM) { - return error_value(E_H2HM1); + return error_value(E_H2HM_1); } /* @@ -5843,7 +5897,7 @@ f_root(int count, VALUE **vals) vp = &err; } if (vp->v_type != V_NUM || qiszero(vp->v_num)) { - return error_value(E_ROOT3); + return error_value(E_ROOT_3); } /* @@ -5876,7 +5930,7 @@ f_power(int count, VALUE **vals) vp = &err; } if ((vp->v_type != V_NUM) || qisneg(vp->v_num) || qiszero(vp->v_num)) { - return error_value(E_POWER3); + return error_value(E_POWER_3); } /* @@ -5905,7 +5959,7 @@ f_polar(int count, VALUE **vals) if (count > 2) { vp = vals[2]; if ((vp->v_type != V_NUM) || qisneg(vp->v_num) || qiszero(vp->v_num)) { - return error_value(E_POLAR2); + return error_value(E_POLAR_2); } } else { err.v_num = conf->epsilon; @@ -5913,14 +5967,14 @@ f_polar(int count, VALUE **vals) vp = &err; } if ((vp->v_type != V_NUM) || qisneg(vp->v_num) || qiszero(vp->v_num)) { - return error_value(E_POLAR2); + return error_value(E_POLAR_2); } /* * compute complex number by modulus (radius) and argument (angle) to a given error tolerance */ if ((vals[0]->v_type != V_NUM) || (vals[1]->v_type != V_NUM)) - return error_value(E_POLAR1); + return error_value(E_POLAR_1); c = c_polar(vals[0]->v_num, vals[1]->v_num, vp->v_num); result.v_com = c; result.v_type = V_COM; @@ -5974,7 +6028,7 @@ f_ilog2(VALUE *vp) res.v_num = c_ilog(vp->v_com, _two_); break; default: - return error_value(E_ILOG2); + return error_value(E_IBASE2_LOG); } if (res.v_num == NULL) @@ -5992,14 +6046,14 @@ f_ilog10(VALUE *vp) VALUE res; switch(vp->v_type) { - case V_NUM: - res.v_num = qilog(vp->v_num, _ten_); - break; - case V_COM: - res.v_num = c_ilog(vp->v_com, _ten_); - break; - default: - return error_value(E_ILOG10); + case V_NUM: + res.v_num = qilog(vp->v_num, _ten_); + break; + case V_COM: + res.v_num = c_ilog(vp->v_com, _ten_); + break; + default: + return error_value(E_IBASE10_LOG); } if (res.v_num == NULL) @@ -6032,22 +6086,22 @@ f_matfill(int count, VALUE **vals) v1 = vals[0]; v2 = vals[1]; if (v1->v_type != V_ADDR) - return error_value(E_MATFILL1); + return error_value(E_MATFILL_1); v1 = v1->v_addr; if (v1->v_subtype & V_NOCOPYTO) - return error_value(E_MATFILL3); + return error_value(E_MATFILL_3); if (v1->v_type != V_MAT) - return error_value(E_MATFILL2); + return error_value(E_MATFILL_2); if (v2->v_type == V_ADDR) v2 = v2->v_addr; if (v2->v_subtype & V_NOASSIGNFROM) - return error_value(E_MATFILL4); + return error_value(E_MATFILL_4); if (count == 3) { v3 = vals[2]; if (v3->v_type == V_ADDR) v3 = v3->v_addr; if (v3->v_subtype & V_NOASSIGNFROM) - return error_value(E_MATFILL4); + return error_value(E_MATFILL_4); } else v3 = NULL; @@ -6097,7 +6151,7 @@ S_FUNC VALUE f_mattrace(VALUE *vp) { if (vp->v_type != V_MAT) - return error_value(E_MATTRACE1); + return error_value(E_MATTRACE_1); return mattrace(vp->v_mat); } @@ -6111,9 +6165,9 @@ f_mattrans(VALUE *vp) result.v_subtype = V_NOSUBTYPE; if (vp->v_type != V_MAT) - return error_value(E_MATTRANS1); + return error_value(E_MATTRANS_1); if (vp->v_mat->m_dim > 2) - return error_value(E_MATTRANS2); + return error_value(E_MATTRANS_2); result.v_type = V_MAT; result.v_mat = mattrans(vp->v_mat); return result; @@ -6124,7 +6178,7 @@ S_FUNC VALUE f_det(VALUE *vp) { if (vp->v_type != V_MAT) - return error_value(E_DET1); + return error_value(E_DET_1); return matdet(vp->v_mat); } @@ -6140,14 +6194,14 @@ f_matdim(VALUE *vp) result.v_subtype = V_NOSUBTYPE; switch(vp->v_type) { - case V_OBJ: - result.v_num = itoq(vp->v_obj->o_actions->oa_count); - break; - case V_MAT: - result.v_num = itoq((long) vp->v_mat->m_dim); - break; - default: - return error_value(E_MATDIM); + case V_OBJ: + result.v_num = itoq(vp->v_obj->o_actions->oa_count); + break; + case V_MAT: + result.v_num = itoq((long) vp->v_mat->m_dim); + break; + default: + return error_value(E_MATDIM); } return result; } @@ -6164,15 +6218,15 @@ f_matmin(VALUE *v1, VALUE *v2) result.v_subtype = V_NOSUBTYPE; if (v1->v_type != V_MAT) - return error_value(E_MATMIN1); + return error_value(E_MATMIN_1); if (v2->v_type != V_NUM) - return error_value(E_MATMIN2); + return error_value(E_MATMIN_2); q = v2->v_num; if (qisfrac(q) || qisneg(q) || qiszero(q)) - return error_value(E_MATMIN2); + return error_value(E_MATMIN_2); i = qtoi(q); if (i > v1->v_mat->m_dim) - return error_value(E_MATMIN3); + return error_value(E_MATMIN_3); result.v_type = V_NUM; result.v_num = itoq(v1->v_mat->m_min[i - 1]); return result; @@ -6190,15 +6244,15 @@ f_matmax(VALUE *v1, VALUE *v2) result.v_subtype = V_NOSUBTYPE; if (v1->v_type != V_MAT) - return error_value(E_MATMAX1); + return error_value(E_MATMAX_1); if (v2->v_type != V_NUM) - return error_value(E_MATMAX2); + return error_value(E_MATMAX_2); q = v2->v_num; if (qisfrac(q) || qisneg(q) || qiszero(q)) - return error_value(E_MATMAX2); + return error_value(E_MATMAX_2); i = qtoi(q); if (i > v1->v_mat->m_dim) - return error_value(E_MATMAX3); + return error_value(E_MATMAX_3); result.v_type = V_NUM; result.v_num = itoq(v1->v_mat->m_max[i - 1]); return result; @@ -6215,13 +6269,13 @@ f_cp(VALUE *v1, VALUE *v2) result.v_subtype = V_NOSUBTYPE; if ((v1->v_type != V_MAT) || (v2->v_type != V_MAT)) - return error_value(E_CP1); + return error_value(E_CP_1); m1 = v1->v_mat; m2 = v2->v_mat; if ((m1->m_dim != 1) || (m2->m_dim != 1)) - return error_value(E_CP2); + return error_value(E_CP_2); if ((m1->m_size != 3) || (m2->m_size != 3)) - return error_value(E_CP3); + return error_value(E_CP_3); result.v_type = V_MAT; result.v_mat = matcross(m1, m2); return result; @@ -6234,13 +6288,13 @@ f_dp(VALUE *v1, VALUE *v2) MATRIX *m1, *m2; if ((v1->v_type != V_MAT) || (v2->v_type != V_MAT)) - return error_value(E_DP1); + return error_value(E_DP_1); m1 = v1->v_mat; m2 = v2->v_mat; if ((m1->m_dim != 1) || (m2->m_dim != 1)) - return error_value(E_DP2); + return error_value(E_DP_2); if (m1->m_size != m2->m_size) - return error_value(E_DP3); + return error_value(E_DP_3); return matdot(m1, m2); } @@ -6495,13 +6549,13 @@ f_substr(VALUE *v1, VALUE *v2, VALUE *v3) result.v_subtype = V_NOSUBTYPE; if (v1->v_type != V_STR) - return error_value(E_SUBSTR1); + return error_value(E_SUBSTR_1); if ((v2->v_type != V_NUM) || (v3->v_type != V_NUM)) - return error_value(E_SUBSTR2); + return error_value(E_SUBSTR_2); q1 = v2->v_num; q2 = v3->v_num; if (qisfrac(q1) || qisneg(q1) || qisfrac(q2) || qisneg(q2)) - return error_value(E_SUBSTR2); + return error_value(E_SUBSTR_2); start = qtoi(q1); len = qtoi(q2); if (start > 0) @@ -6538,21 +6592,21 @@ f_char(VALUE *vp) result.v_subtype = V_NOSUBTYPE; switch(vp->v_type) { - case V_NUM: - if (qisfrac(vp->v_num)) - return error_value(E_CHAR); - ch = (char) vp->v_num->num.v[0]; - if (qisneg(vp->v_num)) - ch = -ch; - break; - case V_OCTET: - ch = *vp->v_octet; - break; - case V_STR: - ch = *vp->v_str->s_str; - break; - default: + case V_NUM: + if (qisfrac(vp->v_num)) return error_value(E_CHAR); + ch = (char) vp->v_num->num.v[0]; + if (qisneg(vp->v_num)) + ch = -ch; + break; + case V_OCTET: + ch = *vp->v_octet; + break; + case V_STR: + ch = *vp->v_str->s_str; + break; + default: + return error_value(E_CHAR); } result.v_type = V_STR; result.v_str = charstring(ch); @@ -6570,14 +6624,14 @@ f_ord(VALUE *vp) result.v_subtype = V_NOSUBTYPE; switch(vp->v_type) { - case V_STR: - c = (OCTET *)vp->v_str->s_str; - break; - case V_OCTET: - c = vp->v_octet; - break; - default: - return error_value(E_ORD); + case V_STR: + c = (OCTET *)vp->v_str->s_str; + break; + case V_OCTET: + c = vp->v_octet; + break; + default: + return error_value(E_ORD); } result.v_type = V_NUM; @@ -6595,14 +6649,14 @@ f_isupper(VALUE *vp) result.v_subtype = V_NOSUBTYPE; switch(vp->v_type) { - case V_STR: - c = *vp->v_str->s_str; - break; - case V_OCTET: - c = *vp->v_octet; - break; - default: - return error_value(E_ISUPPER); + case V_STR: + c = *vp->v_str->s_str; + break; + case V_OCTET: + c = *vp->v_octet; + break; + default: + return error_value(E_ISUPPER); } result.v_type = V_NUM; @@ -6620,14 +6674,14 @@ f_islower(VALUE *vp) result.v_subtype = V_NOSUBTYPE; switch(vp->v_type) { - case V_STR: - c = *vp->v_str->s_str; - break; - case V_OCTET: - c = *vp->v_octet; - break; - default: - return error_value(E_ISLOWER); + case V_STR: + c = *vp->v_str->s_str; + break; + case V_OCTET: + c = *vp->v_octet; + break; + default: + return error_value(E_ISLOWER); } result.v_type = V_NUM; @@ -6645,14 +6699,14 @@ f_isalnum(VALUE *vp) result.v_subtype = V_NOSUBTYPE; switch(vp->v_type) { - case V_STR: - c = *vp->v_str->s_str; - break; - case V_OCTET: - c = *vp->v_octet; - break; - default: - return error_value(E_ISALNUM); + case V_STR: + c = *vp->v_str->s_str; + break; + case V_OCTET: + c = *vp->v_octet; + break; + default: + return error_value(E_ISALNUM); } result.v_type = V_NUM; @@ -6670,14 +6724,14 @@ f_isalpha(VALUE *vp) result.v_subtype = V_NOSUBTYPE; switch(vp->v_type) { - case V_STR: - c = *vp->v_str->s_str; - break; - case V_OCTET: - c = *vp->v_octet; - break; - default: - return error_value(E_ISALPHA); + case V_STR: + c = *vp->v_str->s_str; + break; + case V_OCTET: + c = *vp->v_octet; + break; + default: + return error_value(E_ISALPHA); } result.v_type = V_NUM; @@ -6685,8 +6739,7 @@ f_isalpha(VALUE *vp) return result; } -#if 0 -/* Not in C-standard, marked as obsolete in POSIX.1-2008 */ +#if 0 /* XXX - add isascii builtin funcion - XXX */ S_FUNC VALUE f_isascii(VALUE *vp) { @@ -6696,14 +6749,14 @@ f_isascii(VALUE *vp) result.v_subtype = V_NOSUBTYPE; switch(vp->v_type) { - case V_STR: - c = *vp->v_str->s_str; - break; - case V_OCTET: - c = *vp->v_octet; - break; - default: - return error_value(E_ISASCII); + case V_STR: + c = *vp->v_str->s_str; + break; + case V_OCTET: + c = *vp->v_octet; + break; + default: + return error_value(E_ISASCII); } result.v_type = V_NUM; @@ -6722,14 +6775,14 @@ f_iscntrl(VALUE *vp) result.v_subtype = V_NOSUBTYPE; switch(vp->v_type) { - case V_STR: - c = *vp->v_str->s_str; - break; - case V_OCTET: - c = *vp->v_octet; - break; - default: - return error_value(E_ISCNTRL); + case V_STR: + c = *vp->v_str->s_str; + break; + case V_OCTET: + c = *vp->v_octet; + break; + default: + return error_value(E_ISCNTRL); } result.v_type = V_NUM; @@ -6747,14 +6800,14 @@ f_isdigit(VALUE *vp) result.v_subtype = V_NOSUBTYPE; switch(vp->v_type) { - case V_STR: - c = *vp->v_str->s_str; - break; - case V_OCTET: - c = *vp->v_octet; - break; - default: - return error_value(E_ISDIGIT); + case V_STR: + c = *vp->v_str->s_str; + break; + case V_OCTET: + c = *vp->v_octet; + break; + default: + return error_value(E_ISDIGIT); } result.v_type = V_NUM; @@ -6772,14 +6825,14 @@ f_isgraph(VALUE *vp) result.v_subtype = V_NOSUBTYPE; switch(vp->v_type) { - case V_STR: - c = *vp->v_str->s_str; - break; - case V_OCTET: - c = *vp->v_octet; - break; - default: - return error_value(E_ISGRAPH); + case V_STR: + c = *vp->v_str->s_str; + break; + case V_OCTET: + c = *vp->v_octet; + break; + default: + return error_value(E_ISGRAPH); } result.v_type = V_NUM; @@ -6797,14 +6850,14 @@ f_isprint(VALUE *vp) result.v_subtype = V_NOSUBTYPE; switch(vp->v_type) { - case V_STR: - c = *vp->v_str->s_str; - break; - case V_OCTET: - c = *vp->v_octet; - break; - default: - return error_value(E_ISPRINT); + case V_STR: + c = *vp->v_str->s_str; + break; + case V_OCTET: + c = *vp->v_octet; + break; + default: + return error_value(E_ISPRINT); } result.v_type = V_NUM; @@ -6822,14 +6875,14 @@ f_ispunct(VALUE *vp) result.v_subtype = V_NOSUBTYPE; switch(vp->v_type) { - case V_STR: - c = *vp->v_str->s_str; - break; - case V_OCTET: - c = *vp->v_octet; - break; - default: - return error_value(E_ISPUNCT); + case V_STR: + c = *vp->v_str->s_str; + break; + case V_OCTET: + c = *vp->v_octet; + break; + default: + return error_value(E_ISPUNCT); } result.v_type = V_NUM; @@ -6847,14 +6900,14 @@ f_isspace(VALUE *vp) result.v_subtype = V_NOSUBTYPE; switch(vp->v_type) { - case V_STR: - c = *vp->v_str->s_str; - break; - case V_OCTET: - c = *vp->v_octet; - break; - default: - return error_value(E_ISSPACE); + case V_STR: + c = *vp->v_str->s_str; + break; + case V_OCTET: + c = *vp->v_octet; + break; + default: + return error_value(E_ISSPACE); } result.v_type = V_NUM; @@ -6872,14 +6925,14 @@ f_isxdigit(VALUE *vp) result.v_subtype = V_NOSUBTYPE; switch(vp->v_type) { - case V_STR: - c = *vp->v_str->s_str; - break; - case V_OCTET: - c = *vp->v_octet; - break; - default: - return error_value(E_ISXDIGIT); + case V_STR: + c = *vp->v_str->s_str; + break; + case V_OCTET: + c = *vp->v_octet; + break; + default: + return error_value(E_ISXDIGIT); } result.v_type = V_NUM; @@ -6904,7 +6957,7 @@ f_protect(int count, VALUE **vals) have_nblock = (v1->v_type == V_NBLOCK); if (!have_nblock) { if (v1->v_type != V_ADDR) - return error_value(E_PROTECT1); + return error_value(E_PROTECT_1); v1 = v1->v_addr; } if (count == 1) { @@ -6919,7 +6972,7 @@ f_protect(int count, VALUE **vals) if (v2->v_type == V_ADDR) v2 = v2->v_addr; if (v2->v_type != V_NUM||qisfrac(v2->v_num)||zge16b(v2->v_num->num)) - return error_value(E_PROTECT2); + return error_value(E_PROTECT_2); i = qtoi(v2->v_num); depth = 0; if (count > 2) { @@ -6928,7 +6981,7 @@ f_protect(int count, VALUE **vals) v3 = v3->v_addr; if (v3->v_type != V_NUM || qisfrac(v3->v_num) || qisneg(v3->v_num) || zge31b(v3->v_num->num)) - return error_value(E_PROTECT3); + return error_value(E_PROTECT_3); depth = qtoi(v3->v_num); } protecttodepth(v1, i, depth); @@ -7027,32 +7080,32 @@ f_search(int count, VALUE **vals) v2 = *vals++; if ((v1->v_type == V_FILE || v1->v_type == V_STR) && v2->v_type != V_STR) - return error_value(E_SEARCH2); + return error_value(E_SEARCH_2); start = end = NULL; if (count > 2) { v3 = *vals++; if (v3->v_type != V_NUM && v3->v_type != V_NULL) - return error_value(E_SEARCH3); + return error_value(E_SEARCH_3); if (v3->v_type == V_NUM) { start = v3->v_num; if (qisfrac(start)) - return error_value(E_SEARCH3); + return error_value(E_SEARCH_3); } } if (count > 3) { v4 = *vals; if (v4->v_type != V_NUM && v4->v_type != V_NULL) - return error_value(E_SEARCH4); + return error_value(E_SEARCH_4); if (v4->v_type == V_NUM) { end = v4->v_num; if (qisfrac(end)) - return error_value(E_SEARCH4); + return error_value(E_SEARCH_4); } } result.v_type = V_NULL; vsize = f_size(v1); if (vsize.v_type != V_NUM) - return error_value(E_SEARCH5); + return error_value(E_SEARCH_5); size = vsize.v_num; if (start) { if (qisneg(start)) { @@ -7085,7 +7138,7 @@ f_search(int count, VALUE **vals) qfree(start); if (end) qfree(end); - return error_value(E_SEARCH5); + return error_value(E_SEARCH_5); } if (count == 2 || (count == 4 && end != NULL)) { start = qalloc(); @@ -7119,7 +7172,7 @@ f_search(int count, VALUE **vals) if (i == EOF) return error_value(errno); if (i < 0) - return error_value(E_SEARCH6); + return error_value(E_SEARCH_6); if (i == 0) { result.v_type = V_NUM; result.v_num = qalloc(); @@ -7141,23 +7194,23 @@ f_search(int count, VALUE **vals) l_start = ztolong(start->num); l_end = ztolong(end->num); switch (v1->v_type) { - case V_MAT: - i = matsearch(v1->v_mat, v2, l_start, l_end, &indx); - break; - case V_LIST: - i = listsearch(v1->v_list, v2, l_start, l_end, &indx); - break; - case V_ASSOC: - i = assocsearch(v1->v_assoc, v2, l_start, l_end, &indx); - break; - case V_STR: - i = stringsearch(v1->v_str, v2->v_str, l_start, l_end, - &indx); - break; - default: - qfree(start); - qfree(end); - return error_value(E_SEARCH1); + case V_MAT: + i = matsearch(v1->v_mat, v2, l_start, l_end, &indx); + break; + case V_LIST: + i = listsearch(v1->v_list, v2, l_start, l_end, &indx); + break; + case V_ASSOC: + i = assocsearch(v1->v_assoc, v2, l_start, l_end, &indx); + break; + case V_STR: + i = stringsearch(v1->v_str, v2->v_str, l_start, l_end, + &indx); + break; + default: + qfree(start); + qfree(end); + return error_value(E_SEARCH_1); } qfree(start); qfree(end); @@ -7193,32 +7246,32 @@ f_rsearch(int count, VALUE **vals) v2 = *vals++; if ((v1->v_type == V_FILE || v1->v_type == V_STR) && v2->v_type != V_STR) - return error_value(E_RSEARCH2); + return error_value(E_RSEARCH_2); start = end = NULL; if (count > 2) { v3 = *vals++; if (v3->v_type != V_NUM && v3->v_type != V_NULL) - return error_value(E_RSEARCH3); + return error_value(E_RSEARCH_3); if (v3->v_type == V_NUM) { start = v3->v_num; if (qisfrac(start)) - return error_value(E_RSEARCH3); + return error_value(E_RSEARCH_3); } } if (count > 3) { v4 = *vals; if (v4->v_type != V_NUM && v4->v_type != V_NULL) - return error_value(E_RSEARCH4); + return error_value(E_RSEARCH_4); if (v4->v_type == V_NUM) { end = v4->v_num; if (qisfrac(end)) - return error_value(E_RSEARCH3); + return error_value(E_RSEARCH_3); } } result.v_type = V_NULL; vsize = f_size(v1); if (vsize.v_type != V_NUM) - return error_value(E_RSEARCH5); + return error_value(E_RSEARCH_5); size = vsize.v_num; if (start) { if (qisneg(start)) { @@ -7251,7 +7304,7 @@ f_rsearch(int count, VALUE **vals) qfree(start); if (end) qfree(end); - return error_value(E_RSEARCH5); + return error_value(E_RSEARCH_5); } if (count == 2 || (count == 4 && end != NULL)) { start = qalloc(); @@ -7295,7 +7348,7 @@ f_rsearch(int count, VALUE **vals) if (i == EOF) return error_value(errno); if (i < 0) - return error_value(E_RSEARCH6); + return error_value(E_RSEARCH_6); if (i == 0) { result.v_type = V_NUM; result.v_num = qalloc(); @@ -7327,24 +7380,24 @@ f_rsearch(int count, VALUE **vals) l_start = ztolong(start->num); l_end = ztolong(end->num); switch (v1->v_type) { - case V_MAT: - i = matrsearch(v1->v_mat, v2, l_start, l_end, &indx); - break; - case V_LIST: - i = listrsearch(v1->v_list, v2, l_start, l_end, &indx); - break; - case V_ASSOC: - i = assocrsearch(v1->v_assoc, v2, l_start, - l_end, &indx); - break; - case V_STR: - i = stringrsearch(v1->v_str, v2->v_str, l_start, - l_end, &indx); - break; - default: - qfree(start); - qfree(end); - return error_value(E_RSEARCH1); + case V_MAT: + i = matrsearch(v1->v_mat, v2, l_start, l_end, &indx); + break; + case V_LIST: + i = listrsearch(v1->v_list, v2, l_start, l_end, &indx); + break; + case V_ASSOC: + i = assocrsearch(v1->v_assoc, v2, l_start, + l_end, &indx); + break; + case V_STR: + i = stringrsearch(v1->v_str, v2->v_str, l_start, + l_end, &indx); + break; + default: + qfree(start); + qfree(end); + return error_value(E_RSEARCH_1); } qfree(start); qfree(end); @@ -7395,17 +7448,17 @@ f_indices(VALUE *v1, VALUE *v2) LIST *lp; if (v2->v_type != V_NUM || zge31b(v2->v_num->num)) - return error_value(E_INDICES2); + return error_value(E_INDICES_2); switch (v1->v_type) { - case V_ASSOC: - lp = associndices(v1->v_assoc, qtoi(v2->v_num)); - break; - case V_MAT: - lp = matindices(v1->v_mat, qtoi(v2->v_num)); - break; - default: - return error_value(E_INDICES1); + case V_ASSOC: + lp = associndices(v1->v_assoc, qtoi(v2->v_num)); + break; + case V_MAT: + lp = matindices(v1->v_mat, qtoi(v2->v_num)); + break; + default: + return error_value(E_INDICES_1); } result.v_type = V_NULL; @@ -7430,15 +7483,15 @@ f_listinsert(int count, VALUE **vals) v1 = *vals++; if ((v1->v_type != V_ADDR) || (v1->v_addr->v_type != V_LIST)) - return error_value(E_INSERT1); + return error_value(E_INSERT_1); if (v1->v_addr->v_subtype & V_NOREALLOC) - return error_value(E_LIST1); + return error_value(E_LIST_1); v2 = *vals++; if (v2->v_type == V_ADDR) v2 = v2->v_addr; if ((v2->v_type != V_NUM) || qisfrac(v2->v_num)) - return error_value(E_INSERT2); + return error_value(E_INSERT_2); pos = qtoi(v2->v_num); count--; while (--count > 0) { @@ -7465,7 +7518,7 @@ f_listpush(int count, VALUE **vals) if ((v1->v_type != V_ADDR) || (v1->v_addr->v_type != V_LIST)) return error_value(E_PUSH); if (v1->v_addr->v_subtype & V_NOREALLOC) - return error_value(E_LIST3); + return error_value(E_LIST_3); while (--count > 0) { v2 = *vals++; @@ -7491,7 +7544,7 @@ f_listappend(int count, VALUE **vals) if ((v1->v_type != V_ADDR) || (v1->v_addr->v_type != V_LIST)) return error_value(E_APPEND); if (v1->v_addr->v_subtype & V_NOREALLOC) - return error_value(E_LIST4); + return error_value(E_LIST_4); while (--count > 0) { v2 = *vals++; @@ -7513,14 +7566,14 @@ f_listdelete(VALUE *v1, VALUE *v2) result.v_subtype = V_NOSUBTYPE; if ((v1->v_type != V_ADDR) || (v1->v_addr->v_type != V_LIST)) - return error_value(E_DELETE1); + return error_value(E_DELETE_1); if (v1->v_addr->v_subtype & V_NOREALLOC) - return error_value(E_LIST2); + return error_value(E_LIST_2); if (v2->v_type == V_ADDR) v2 = v2->v_addr; if ((v2->v_type != V_NUM) || qisfrac(v2->v_num)) - return error_value(E_DELETE2); + return error_value(E_DELETE_2); removelistmiddle(v1->v_addr->v_list, qtoi(v2->v_num), &result); return result; } @@ -7535,7 +7588,7 @@ f_listpop(VALUE *vp) return error_value(E_POP); if (vp->v_addr->v_subtype & V_NOREALLOC) - return error_value(E_LIST5); + return error_value(E_LIST_5); removelistfirst(vp->v_addr->v_list, &result); return result; @@ -7551,7 +7604,7 @@ f_listremove(VALUE *vp) return error_value(E_REMOVE); if (vp->v_addr->v_subtype & V_NOREALLOC) - return error_value(E_LIST6); + return error_value(E_LIST_6); removelistlast(vp->v_addr->v_list, &result); return result; @@ -7729,19 +7782,19 @@ f_fopen(VALUE *v1, VALUE *v2) /* check for a valid mode [rwa][b+\0][b+\0] */ if (v1->v_type != V_STR || v2->v_type != V_STR) - return error_value(E_FOPEN1); + return error_value(E_FOPEN_1); mode = v2->v_str->s_str; if ((*mode != 'r') && (*mode != 'w') && (*mode != 'a')) - return error_value(E_FOPEN2); + return error_value(E_FOPEN_2); if (mode[1] != '\0') { if (mode[1] != '+' && mode[1] != 'b') - return error_value(E_FOPEN2); + return error_value(E_FOPEN_2); if (mode[2] != '\0') { if ((mode[2] != '+' && mode[2] != 'b') || mode[1] == mode[2]) - return error_value(E_FOPEN2); + return error_value(E_FOPEN_2); if (mode[3] != '\0') - return error_value(E_FOPEN2); + return error_value(E_FOPEN_2); } } @@ -7770,25 +7823,25 @@ f_fpathopen(int count, VALUE **vals) /* check for valid strong */ if (vals[0]->v_type != V_STR || vals[1]->v_type != V_STR) { - return error_value(E_FPATHOPEN1); + return error_value(E_FPATHOPEN_1); } if (count == 3 && vals[2]->v_type != V_STR) { - return error_value(E_FPATHOPEN1); + return error_value(E_FPATHOPEN_1); } /* check for a valid mode [rwa][b+\0][b+\0] */ mode = vals[1]->v_str->s_str; if ((*mode != 'r') && (*mode != 'w') && (*mode != 'a')) - return error_value(E_FPATHOPEN2); + return error_value(E_FPATHOPEN_2); if (mode[1] != '\0') { if (mode[1] != '+' && mode[1] != 'b') - return error_value(E_FPATHOPEN2); + return error_value(E_FPATHOPEN_2); if (mode[2] != '\0') { if ((mode[2] != '+' && mode[2] != 'b') || mode[1] == mode[2]) - return error_value(E_FPATHOPEN2); + return error_value(E_FPATHOPEN_2); if (mode[3] != '\0') - return error_value(E_FPATHOPEN2); + return error_value(E_FPATHOPEN_2); } } @@ -7825,21 +7878,21 @@ f_freopen(int count, VALUE **vals) /* check for a valid mode [rwa][b+\0][b+\0] */ if (vals[0]->v_type != V_FILE) - return error_value(E_FREOPEN1); + return error_value(E_FREOPEN_1); if (vals[1]->v_type != V_STR) - return error_value(E_FREOPEN2); + return error_value(E_FREOPEN_2); mode = vals[1]->v_str->s_str; if ((*mode != 'r') && (*mode != 'w') && (*mode != 'a')) - return error_value(E_FREOPEN2); + return error_value(E_FREOPEN_2); if (mode[1] != '\0') { if (mode[1] != '+' && mode[1] != 'b') - return error_value(E_FREOPEN2); + return error_value(E_FREOPEN_2); if (mode[2] != '\0') { if ((mode[2] != '+' && mode[2] != 'b') || mode[1] == mode[2]) - return error_value(E_FOPEN2); + return error_value(E_FOPEN_2); if (mode[3] != '\0') - return error_value(E_FREOPEN2); + return error_value(E_FREOPEN_2); } } @@ -7849,7 +7902,7 @@ f_freopen(int count, VALUE **vals) id = reopenid(vals[0]->v_file, mode, NULL); } else { if (vals[2]->v_type != V_STR) - return error_value(E_FREOPEN3); + return error_value(E_FREOPEN_3); id = reopenid(vals[0]->v_file, mode, vals[2]->v_str->s_str); } @@ -7861,43 +7914,361 @@ f_freopen(int count, VALUE **vals) } +S_FUNC VALUE +f_fclose(int count, VALUE **vals) +{ + VALUE result; + VALUE *vp; + int n, i=0; + + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + + errno = 0; + if (count == 0) { + i = closeall(); + } else { + for (n = 0; n < count; n++) { + vp = vals[n]; + if (vp->v_type != V_FILE) + return error_value(E_FCLOSE_1); + } + for (n = 0; n < count; n++) { + vp = vals[n]; + i = closeid(vp->v_file); + if (i < 0) + return error_value(E_REWIND_2); + } + } + if (i < 0) + return error_value(errno); + result.v_type = V_NULL; + return result; +} + + +S_FUNC VALUE +f_rm(int count, VALUE **vals) +{ + VALUE result; + int force; /* true -> -f was given as 1st arg */ + int i; + int j; + + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + + /* + * firewall + */ + if (!allow_write) + return error_value(E_WRPERM); + + /* + * check on each arg + */ + for (i=0; i < count; ++i) { + if (vals[i]->v_type != V_STR) + return error_value(E_RM_1); + if (vals[i]->v_str->s_str[0] == '\0') + return error_value(E_RM_1); + } + + /* + * look for a leading -f option + */ + force = (strcmp(vals[0]->v_str->s_str, "-f") == 0); + if (force) { + --count; + ++vals; + } + + /* + * remove file(s) + */ + for (i=0; i < count; ++i) { + j = remove(vals[i]->v_str->s_str); + if (!force && j < 0) + return error_value(errno); + } + result.v_type = V_NULL; + result.v_subtype = V_NOSUBTYPE; + return result; +} + + +S_FUNC VALUE +f_error(int count, VALUE **vals) +{ + VALUE *vp; + long r; + + /* + * case: error() no args + */ + if (count == 0) { + + /* fetch but do NOT set errno */ + r = set_errno(NULL_ERRNUM); + + /* + * case: 1 arg + */ + } else { + vp = vals[0]; /* get 1st arg */ + + /* + * case: negative or 0 v_type + */ + if (vp->v_type <= 0) { + r = (long) -vp->v_type; + if (is_valid_errnum(r) == false) { + error_value(E_ERROR_2); + math_error("Numeric argument is outside valid errnum range for error"); + not_reached(); + } + + /* + * case: error(errnum | "E_STRING") arg + */ + } else { + switch (vp->v_type) { + + /* + * case: error("E_STRING") + */ + case V_STR: + r = errsym_2_errnum(vp->v_str->s_str); + if (is_valid_errnum(r) == false) { + error_value(E_ERROR_3); + math_error("String argument is not a valid E_STRING for error"); + not_reached(); + } + break; + + /* + * case: error(errnum) + */ + case V_NUM: + r = qtoi(vp->v_num); + if (is_valid_errnum(r) == false) { + error_value(E_ERROR_2); + math_error("Numeric argument is outside valid errnum range for error"); + not_reached(); + } + break; + + /* + * case: invalid type + */ + default: + error_value(E_ERROR_1); + math_error("Invalid argument type for error"); + not_reached(); + } + } + } + + /* + * return error + */ + return error_value(r); +} + + S_FUNC VALUE f_errno(int count, VALUE **vals) { - int newerr, olderr; - VALUE *vp; - VALUE result; + int olderr; /* previous errno value */ + int newerr = NULL_ERRNUM; /* new errno to set */ + VALUE *vp; /* arg[1] */ + VALUE result; /* errno as a VALUE */ /* initialize VALUE */ result.v_type = V_NUM; result.v_subtype = V_NOSUBTYPE; - newerr = -1; - if (count > 0) { - vp = vals[0]; + /* + * case: errno() no args + */ + if (count == 0) { + /* fetch but do NOT set errno */ + olderr = set_errno(NULL_ERRNUM); + + /* + * case: 1 arg + */ + } else { + vp = vals[0]; /* get 1st arg */ + + /* + * case: negative or 0 v_type + */ if (vp->v_type <= 0) { newerr = (int) -vp->v_type; - (void) set_errno(newerr); - result.v_num = itoq((long) newerr); - return result; - } + if (is_valid_errnum(newerr) == false) { + error_value(E_ERRNO_2); + math_error("Numeric argument is outside valid errnum range for errno"); + not_reached(); + } - /* arg must be an integer */ - if (vp->v_type != V_NUM || qisfrac(vp->v_num) || - qisneg(vp->v_num) || zge16b(vp->v_num->num)) { - math_error("errno argument out of range"); - not_reached(); + /* + * case: errno(errnum | "E_STRING") arg + */ + } else { + switch (vp->v_type) { + + /* + * case: errno("E_STRING") + */ + case V_STR: + newerr = errsym_2_errnum(vp->v_str->s_str); + if (is_valid_errnum(newerr) == false) { + error_value(E_ERRNO_3); + math_error("String argument is not a valid E_STRING for errno"); + not_reached(); + } + break; + + /* + * case: errno(errnum) + */ + case V_NUM: + newerr = qtoi(vp->v_num); + if (is_valid_errnum(newerr) == false) { + error_value(E_ERRNO_2); + math_error("Numeric argument is outside valid errnum range for errno"); + not_reached(); + } + break; + + /* + * case: invalid type + */ + default: + error_value(E_ERRNO_1); + math_error("Invalid argument type for errno"); + not_reached(); + } } - newerr = (int) ztoi(vp->v_num->num); } - olderr = set_errno(newerr); + /* + * return errno + */ + olderr = set_errno(newerr); result.v_num = itoq((long) olderr); return result; } +S_FUNC VALUE +f_strerror(int count, VALUE **vals) +{ + int errnum = NULL_ERRNUM; /* errnum to convert */ + char *errmsg; /* errnum converted into errmsg string, or NULL */ + bool alloced = false; /* true ==> errmsg was allocated, false ==> errmsg is static */ + VALUE *vp; /* arg[1] */ + VALUE result; /* errmsg string as a VALUE */ + + /* initialize VALUE */ + result.v_type = V_STR; + result.v_subtype = V_NOSUBTYPE; + + /* + * case: strerror() no args + */ + if (count == 0) { + + /* fetch but do NOT set errno */ + errnum = set_errno(NULL_ERRNUM); + + /* + * case: 1 arg + */ + } else { + vp = vals[0]; /* get 1st arg */ + + /* + * case: negative or 0 v_type + */ + if (vp->v_type <= 0) { + errnum = (int) -vp->v_type; + if (is_valid_errnum(errnum) == false) { + error_value(E_STRERROR_2); + math_error("Numeric argument is outside valid errnum range for strerror"); + not_reached(); + } + + /* + * case: strerror(errnum | "E_STRING") arg + */ + } else { + switch (vp->v_type) { + + /* + * case: strerror("E_STRING") + */ + case V_STR: + errnum = errsym_2_errnum(vp->v_str->s_str); + if (is_valid_errnum(errnum) == false) { + error_value(E_STRERROR_3); + math_error("String argument is not a valid E_STRING for strerror"); + not_reached(); + } + break; + + /* + * case: strerror(errnum) + */ + case V_NUM: + errnum = qtoi(vp->v_num); + if (is_valid_errnum(errnum) == false) { + error_value(E_STRERROR_2); + math_error("Numeric argument is outside valid errnum range for strerror"); + not_reached(); + } + break; + + /* + * case: invalid type + */ + default: + error_value(E_STRERROR_1); + math_error("Invalid argument type for strerror"); + not_reached(); + } + } + } + + /* + * convert errnum into errmsg string + */ + errmsg = errnum_2_errmsg(errnum, &alloced); + if (errmsg == NULL) { + /* this should not happen: but in case it does we will throw an error */ + error_value(E_STRERROR_4); + math_error("errnum_2_errmsg returned NULL as called from strerror"); + not_reached(); + } + result.v_str = makenewstring(errmsg); + + /* + * free errmsg is it was allocated + */ + if (alloced == true) { + free(errmsg); + alloced = false; + errmsg = NULL; + } + + /* + * return errmsg result as a V_STR + */ + return result; +} + S_FUNC VALUE f_errcount(int count, VALUE **vals) @@ -7986,86 +8357,18 @@ f_stoponerror(int count, VALUE **vals) return result; } -S_FUNC VALUE -f_fclose(int count, VALUE **vals) -{ - VALUE result; - VALUE *vp; - int n, i=0; - - /* initialize VALUE */ - result.v_subtype = V_NOSUBTYPE; - - errno = 0; - if (count == 0) { - i = closeall(); - } else { - for (n = 0; n < count; n++) { - vp = vals[n]; - if (vp->v_type != V_FILE) - return error_value(E_FCLOSE1); - } - for (n = 0; n < count; n++) { - vp = vals[n]; - i = closeid(vp->v_file); - if (i < 0) - return error_value(E_REWIND2); - } - } - if (i < 0) - return error_value(errno); - result.v_type = V_NULL; - return result; -} - S_FUNC VALUE -f_rm(int count, VALUE **vals) +f_iserror(VALUE *vp) { - VALUE result; - int force; /* true -> -f was given as 1st arg */ - int i; - int j; + VALUE res; /* initialize VALUE */ - result.v_subtype = V_NOSUBTYPE; + res.v_subtype = V_NOSUBTYPE; - /* - * firewall - */ - if (!allow_write) - return error_value(E_WRPERM); - - /* - * check on each arg - */ - for (i=0; i < count; ++i) { - if (vals[i]->v_type != V_STR) - return error_value(E_RM1); - if (vals[i]->v_str->s_str[0] == '\0') - return error_value(E_RM1); - } - - /* - * look for a leading -f option - */ - force = (strcmp(vals[0]->v_str->s_str, "-f") == 0); - if (force) { - --count; - ++vals; - } - - /* - * remove file(s) - */ - for (i=0; i < count; ++i) { - j = remove(vals[i]->v_str->s_str); - if (!force && j < 0) - return error_value(errno); - } - result.v_type = V_NULL; - result.v_subtype = V_NOSUBTYPE; - return result; + res.v_type = V_NUM; + res.v_num = itoq((long)((vp->v_type < 0) ? - vp->v_type : 0)); + return res; } @@ -8096,75 +8399,6 @@ f_newerror(int count, VALUE **vals) } -S_FUNC VALUE -f_strerror(int count, VALUE **vals) -{ - VALUE *vp; - VALUE result; - long i; - char *cp; - - /* initialize VALUE */ - result.v_subtype = V_NOSUBTYPE; - - /* parse args */ - if (count > 0) { - vp = vals[0]; - if (vp->v_type < 0) { - i = (long) -vp->v_type; - } else { - if (vp->v_type != V_NUM || qisfrac(vp->v_num)) - return error_value(E_STRERROR1); - i = qtoi(vp->v_num); - if (i < 0 || i > E__USERMAX) - return error_value(E_STRERROR2); - } - } else { - i = set_errno(-1); - } - - /* setup return type */ - result.v_type = V_STR; - - /* change the meaning of error 0 */ - if (i == 0) - i = E__BASE; - - /* firewall - return generic error string if it is not assigned */ - if (i >= nexterrnum || (i > E__HIGHEST && i < E__USERDEF) - || (i < E__BASE && strerror(i) == NULL)) { - size_t snprintf_len; /* malloced snprintf buffer length */ - snprintf_len = sizeof("Unknown error 12345678901234567890")+1; - cp = (char *) malloc(snprintf_len+1); - if (cp == NULL) { - math_error("Out of memory for strerror"); - not_reached(); - } - snprintf(cp, snprintf_len, "Unknown error %ld", i); - cp[snprintf_len] = '\0'; /* paranoia */ - result.v_str = makestring(cp); - return result; - } - - /* system error */ - if (i < E__BASE) { - cp = strerror(i); - - /* user-described error */ - } else if (i >= E__USERDEF) { - cp = namestr(&newerrorstr, i - E__USERDEF); - - /* calc-described error */ - } else { - cp = (char *)error_table[i - E__BASE].errmsg; - } - - /* return result as a V_STR */ - result.v_str = makenewstring(cp); - return result; -} - - S_FUNC VALUE f_ferror(VALUE *vp) { @@ -8175,10 +8409,10 @@ f_ferror(VALUE *vp) result.v_subtype = V_NOSUBTYPE; if (vp->v_type != V_FILE) - return error_value(E_FERROR1); + return error_value(E_FERROR_1); i = errorid(vp->v_file); if (i < 0) - return error_value(E_FERROR2); + return error_value(E_FERROR_2); result.v_type = V_NUM; result.v_num = itoq((long) i); return result; @@ -8195,10 +8429,10 @@ f_feof(VALUE *vp) result.v_subtype = V_NOSUBTYPE; if (vp->v_type != V_FILE) - return error_value(E_FEOF1); + return error_value(E_FEOF_1); i = eofid(vp->v_file); if (i < 0) - return error_value(E_FEOF2); + return error_value(E_FEOF_2); result.v_type = V_NUM; result.v_num = itoq((long) i); return result; @@ -8236,48 +8470,6 @@ f_fflush(int count, VALUE **vals) } -S_FUNC VALUE -f_error(int count, VALUE **vals) -{ - VALUE *vp; - long r; - - if (count > 0) { - vp = vals[0]; - - if (vp->v_type <= 0) { - r = (long) -vp->v_type; - } else { - if (vp->v_type != V_NUM || qisfrac(vp->v_num)) { - r = E_ERROR1; - } else { - r = qtoi(vp->v_num); - if (r < 0 || r >= 32768) - r = E_ERROR2; - } - } - } else { - r = set_errno(-1); - } - - return error_value(r); -} - - -S_FUNC VALUE -f_iserror(VALUE *vp) -{ - VALUE res; - - /* initialize VALUE */ - res.v_subtype = V_NOSUBTYPE; - - res.v_type = V_NUM; - res.v_num = itoq((long)((vp->v_type < 0) ? - vp->v_type : 0)); - return res; -} - - S_FUNC VALUE f_fsize(VALUE *vp) { @@ -8289,12 +8481,12 @@ f_fsize(VALUE *vp) result.v_subtype = V_NOSUBTYPE; if (vp->v_type != V_FILE) - return error_value(E_FSIZE1); + return error_value(E_FSIZE_1); i = getsize(vp->v_file, &len); if (i == EOF) return error_value(errno); if (i) - return error_value(E_FSIZE2); + return error_value(E_FSIZE_2); result.v_type = V_NUM; result.v_num = qalloc(); result.v_num->num = len; @@ -8315,20 +8507,20 @@ f_fseek(int count, VALUE **vals) /* firewalls */ errno = 0; if (vals[0]->v_type != V_FILE) - return error_value(E_FSEEK1); + return error_value(E_FSEEK_1); if (vals[1]->v_type != V_NUM || qisfrac(vals[1]->v_num)) - return error_value(E_FSEEK2); + return error_value(E_FSEEK_2); if (count == 2) { whence = 0; } else { if (vals[2]->v_type != V_NUM || qisfrac(vals[2]->v_num) || qisneg(vals[2]->v_num)) - return error_value(E_FSEEK2); + return error_value(E_FSEEK_2); if (vals[2]->v_num->num.len > 1) - return error_value (E_FSEEK2); + return error_value (E_FSEEK_2); whence = (int)(unsigned int)(vals[2]->v_num->num.v[0]); if (whence > 2) - return error_value (E_FSEEK2); + return error_value (E_FSEEK_2); } i = fseekid(vals[0]->v_file, vals[1]->v_num->num, whence); @@ -8336,7 +8528,7 @@ f_fseek(int count, VALUE **vals) if (i == EOF) return error_value(errno); if (i < 0) - return error_value(E_FSEEK3); + return error_value(E_FSEEK_3); return result; } @@ -8353,10 +8545,10 @@ f_ftell(VALUE *vp) errno = 0; if (vp->v_type != V_FILE) - return error_value(E_FTELL1); + return error_value(E_FTELL_1); i = ftellid(vp->v_file, &pos); if (i < 0) - return error_value(E_FTELL2); + return error_value(E_FTELL_2); result.v_type = V_NUM; result.v_num = qalloc(); @@ -8380,11 +8572,11 @@ f_rewind(int count, VALUE **vals) } else { for (n = 0; n < count; n++) { if (vals[n]->v_type != V_FILE) - return error_value(E_REWIND1); + return error_value(E_REWIND_1); } for (n = 0; n < count; n++) { if (rewindid(vals[n]->v_file) != 0) { - return error_value(E_REWIND2); + return error_value(E_REWIND_2); } } } @@ -8403,13 +8595,13 @@ f_fprintf(int count, VALUE **vals) result.v_subtype = V_NOSUBTYPE; if (vals[0]->v_type != V_FILE) - return error_value(E_FPRINTF1); + return error_value(E_FPRINTF_1); if (vals[1]->v_type != V_STR) - return error_value(E_FPRINTF2); + return error_value(E_FPRINTF_2); i = idprintf(vals[0]->v_file, vals[1]->v_str->s_str, count - 2, vals + 2); if (i > 0) - return error_value(E_FPRINTF3); + return error_value(E_FPRINTF_3); result.v_type = V_NULL; return result; } @@ -8558,14 +8750,14 @@ f_fscan(int count, VALUE **vals) if (vp->v_type == V_ADDR) vp = vp->v_addr; if (vp->v_type != V_FILE) - return error_value(E_FSCAN1); + return error_value(E_FSCAN_1); i = filescan(vp->v_file, count - 1, vals + 1); if (i == EOF) return error_value(errno); if (i < 0) - return error_value(E_FSCAN2); + return error_value(E_FSCAN_2); result.v_type = V_NUM; result.v_num = itoq((long) i); @@ -8587,14 +8779,14 @@ f_scanf(int count, VALUE **vals) if (vp->v_type == V_ADDR) vp = vp->v_addr; if (vp->v_type != V_STR) - return error_value(E_SCANF1); + return error_value(E_SCANF_1); for (i = 1; i < count; i++) { if (vals[i]->v_type != V_ADDR) - return error_value(E_SCANF2); + return error_value(E_SCANF_2); } i = fscanfid(FILEID_STDIN, vp->v_str->s_str, count - 1, vals + 1); if (i < 0) - return error_value(E_SCANF3); + return error_value(E_SCANF_3); result.v_type = V_NUM; result.v_num = itoq((long) i); return result; @@ -8616,22 +8808,22 @@ f_strscanf(int count, VALUE **vals) if (vp->v_type == V_ADDR) vp = vp->v_addr; if (vp->v_type != V_STR) - return error_value(E_STRSCANF1); + return error_value(E_STRSCANF_1); vq = vals[1]; if (vq->v_type == V_ADDR) vq = vq->v_addr; if (vq->v_type != V_STR) - return error_value(E_STRSCANF2); + return error_value(E_STRSCANF_2); for (i = 2; i < count; i++) { if (vals[i]->v_type != V_ADDR) - return error_value(E_STRSCANF3); + return error_value(E_STRSCANF_3); } i = scanfstr(vp->v_str->s_str, vq->v_str->s_str, count - 2, vals + 2); if (i == EOF) return error_value(errno); if (i < 0) - return error_value(E_STRSCANF4); + return error_value(E_STRSCANF_4); result.v_type = V_NUM; result.v_num = itoq((long) i); return result; @@ -8652,15 +8844,15 @@ f_fscanf(int count, VALUE **vals) if (vp->v_type == V_ADDR) vp = vp->v_addr; if (vp->v_type != V_FILE) - return error_value(E_FSCANF1); + return error_value(E_FSCANF_1); sp = *vals++; if (sp->v_type == V_ADDR) sp = sp->v_addr; if (sp->v_type != V_STR) - return error_value(E_FSCANF2); + return error_value(E_FSCANF_2); for (i = 0; i < count - 2; i++) { if (vals[i]->v_type != V_ADDR) - return error_value(E_FSCANF3); + return error_value(E_FSCANF_3); } i = fscanfid(vp->v_file, sp->v_str->s_str, count - 2, vals); if (i == EOF) { @@ -8668,7 +8860,7 @@ f_fscanf(int count, VALUE **vals) return result; } if (i < 0) - return error_value(E_FSCANF4); + return error_value(E_FSCANF_4); result.v_type = V_NUM; result.v_num = itoq((long) i); return result; @@ -8687,7 +8879,7 @@ f_fputc(VALUE *v1, VALUE *v2) result.v_subtype = V_NOSUBTYPE; if (v1->v_type != V_FILE) - return error_value(E_FPUTC1); + return error_value(E_FPUTC_1); switch (v2->v_type) { case V_STR: ch = v2->v_str->s_str[0]; @@ -8695,7 +8887,7 @@ f_fputc(VALUE *v1, VALUE *v2) case V_NUM: q = v2->v_num; if (!qisint(q)) - return error_value(E_FPUTC2); + return error_value(E_FPUTC_2); ch = qisneg(q) ? (int)(-q->num.v[0] & 0xff) : (int)(q->num.v[0] & 0xff); @@ -8704,11 +8896,11 @@ f_fputc(VALUE *v1, VALUE *v2) ch = 0; break; default: - return error_value(E_FPUTC2); + return error_value(E_FPUTC_2); } i = idfputc(v1->v_file, ch); if (i > 0) - return error_value(E_FPUTC3); + return error_value(E_FPUTC_3); result.v_type = V_NULL; return result; } @@ -8724,15 +8916,15 @@ f_fputs(int count, VALUE **vals) result.v_subtype = V_NOSUBTYPE; if (vals[0]->v_type != V_FILE) - return error_value(E_FPUTS1); + return error_value(E_FPUTS_1); for (i = 1; i < count; i++) { if (vals[i]->v_type != V_STR) - return error_value(E_FPUTS2); + return error_value(E_FPUTS_2); } for (i = 1; i < count; i++) { err = idfputs(vals[0]->v_file, vals[i]->v_str); if (err > 0) - return error_value(E_FPUTS3); + return error_value(E_FPUTS_3); } result.v_type = V_NULL; return result; @@ -8749,16 +8941,16 @@ f_fputstr(int count, VALUE **vals) result.v_subtype = V_NOSUBTYPE; if (vals[0]->v_type != V_FILE) - return error_value(E_FPUTSTR1); + return error_value(E_FPUTSTR_1); for (i = 1; i < count; i++) { if (vals[i]->v_type != V_STR) - return error_value(E_FPUTSTR2); + return error_value(E_FPUTSTR_2); } for (i = 1; i < count; i++) { err = idfputstr(vals[0]->v_file, vals[i]->v_str->s_str); if (err > 0) - return error_value(E_FPUTSTR3); + return error_value(E_FPUTSTR_3); } result.v_type = V_NULL; return result; @@ -8775,11 +8967,11 @@ f_printf(int count, VALUE **vals) result.v_subtype = V_NOSUBTYPE; if (vals[0]->v_type != V_STR) - return error_value(E_PRINTF1); + return error_value(E_PRINTF_1); i = idprintf(FILEID_STDOUT, vals[0]->v_str->s_str, count - 1, vals + 1); if (i) - return error_value(E_PRINTF2); + return error_value(E_PRINTF_2); result.v_type = V_NULL; return result; } @@ -8796,13 +8988,13 @@ f_strprintf(int count, VALUE **vals) result.v_subtype = V_NOSUBTYPE; if (vals[0]->v_type != V_STR) - return error_value(E_STRPRINTF1); + return error_value(E_STRPRINTF_1); math_divertio(); i = idprintf(FILEID_STDOUT, vals[0]->v_str->s_str, count - 1, vals + 1); if (i) { free(math_getdivertedio()); - return error_value(E_STRPRINTF2); + return error_value(E_STRPRINTF_2); } cp = math_getdivertedio(); result.v_type = V_STR; @@ -8822,10 +9014,10 @@ f_fgetc(VALUE *vp) result.v_subtype = V_NOSUBTYPE; if (vp->v_type != V_FILE) - return error_value(E_FGETC1); + return error_value(E_FGETC_1); ch = getcharid(vp->v_file); if (ch == -2) - return error_value(E_FGETC2); + return error_value(E_FGETC_2); result.v_type = V_NULL; if (ch != EOF) { result.v_type = V_STR; @@ -8848,7 +9040,7 @@ f_ungetc(VALUE *v1, VALUE *v2) errno = 0; if (v1->v_type != V_FILE) - return error_value(E_UNGETC1); + return error_value(E_UNGETC_1); switch (v2->v_type) { case V_STR: ch = v2->v_str->s_str[0]; @@ -8856,18 +9048,18 @@ f_ungetc(VALUE *v1, VALUE *v2) case V_NUM: q = v2->v_num; if (!qisint(q)) - return error_value(E_UNGETC2); + return error_value(E_UNGETC_2); ch = qisneg(q) ? (int)(-q->num.v[0] & 0xff) : (int)(q->num.v[0] & 0xff); break; default: - return error_value(E_UNGETC2); + return error_value(E_UNGETC_2); } i = idungetc(v1->v_file, ch); if (i == EOF) return error_value(errno); if (i == -2) - return error_value(E_UNGETC3); + return error_value(E_UNGETC_3); result.v_type = V_NULL; return result; } @@ -8884,10 +9076,10 @@ f_fgetline(VALUE *vp) result.v_subtype = V_NOSUBTYPE; if (vp->v_type != V_FILE) - return error_value(E_FGETLINE1); + return error_value(E_FGETLINE_1); i = readid(vp->v_file, 9, &str); if (i > 0) - return error_value(E_FGETLINE2); + return error_value(E_FGETLINE_2); result.v_type = V_NULL; if (i == 0) { result.v_type = V_STR; @@ -8908,10 +9100,10 @@ f_fgets(VALUE *vp) result.v_subtype = V_NOSUBTYPE; if (vp->v_type != V_FILE) - return error_value(E_FGETS1); + return error_value(E_FGETS_1); i = readid(vp->v_file, 1, &str); if (i > 0) - return error_value(E_FGETS2); + return error_value(E_FGETS_2); result.v_type = V_NULL; if (i == 0) { result.v_type = V_STR; @@ -8932,10 +9124,10 @@ f_fgetstr(VALUE *vp) result.v_subtype = V_NOSUBTYPE; if (vp->v_type != V_FILE) - return error_value(E_FGETSTR1); + return error_value(E_FGETSTR_1); i = readid(vp->v_file, 10, &str); if (i > 0) - return error_value(E_FGETSTR2); + return error_value(E_FGETSTR_2); result.v_type = V_NULL; if (i == 0) { result.v_type = V_STR; @@ -8956,10 +9148,10 @@ f_fgetfield(VALUE *vp) result.v_subtype = V_NOSUBTYPE; if (vp->v_type != V_FILE) - return error_value(E_FGETFIELD1); + return error_value(E_FGETFIELD_1); i = readid(vp->v_file, 14, &str); if (i > 0) - return error_value(E_FGETFIELD2); + return error_value(E_FGETFIELD_2); result.v_type = V_NULL; if (i == 0) { result.v_type = V_STR; @@ -8979,12 +9171,12 @@ f_fgetfile(VALUE *vp) result.v_subtype = V_NOSUBTYPE; if (vp->v_type != V_FILE) - return error_value(E_FGETFILE1); + return error_value(E_FGETFILE_1); i = readid(vp->v_file, 0, &str); if (i == 1) - return error_value(E_FGETFILE2); + return error_value(E_FGETFILE_2); if (i == 3) - return error_value(E_FGETFILE3); + return error_value(E_FGETFILE_3); result.v_type = V_NULL; if (i == 0) { result.v_type = V_STR; @@ -9109,7 +9301,7 @@ f_head(VALUE *v1, VALUE *v2) if (v2->v_type != V_NUM || qisfrac(v2->v_num) || zge31b(v2->v_num->num)) - return error_value(E_HEAD2); + return error_value(E_HEAD_2); n = qtoi(v2->v_num); res.v_type = v1->v_type; @@ -9133,7 +9325,7 @@ f_head(VALUE *v1, VALUE *v2) return error_value(E_STRHEAD); return res; default: - return error_value(E_HEAD1); + return error_value(E_HEAD_1); } } @@ -9149,7 +9341,7 @@ f_tail(VALUE *v1, VALUE *v2) if (v2->v_type != V_NUM || qisfrac(v2->v_num) || zge31b(v2->v_num->num)) - return error_value(E_TAIL1); + return error_value(E_TAIL_1); n = qtoi(v2->v_num); res.v_type = v1->v_type; switch (v1->v_type) { @@ -9182,7 +9374,7 @@ f_tail(VALUE *v1, VALUE *v2) return error_value(E_STRTAIL); return res; default: - return error_value(E_TAIL1); + return error_value(E_TAIL_1); } } @@ -9200,14 +9392,14 @@ f_segment(int count, VALUE **vals) vp = vals[1]; if (vp->v_type != V_NUM || qisfrac(vp->v_num) || zge31b(vp->v_num->num)) - return error_value(E_SEG2); + return error_value(E_SEG_2); n1 = qtoi(vp->v_num); n2 = n1; if (count == 3) { vp = vals[2]; if (vp->v_type != V_NUM || qisfrac(vp->v_num) || zge31b(vp->v_num->num)) - return error_value(E_SEG3); + return error_value(E_SEG_3); n2 = qtoi(vp->v_num); } vp = vals[0]; @@ -9222,7 +9414,7 @@ f_segment(int count, VALUE **vals) return error_value(E_STRSEG); return result; default: - return error_value(E_SEG1); + return error_value(E_SEG_1); } } @@ -9238,17 +9430,17 @@ f_modify(VALUE *v1, VALUE *v2) unsigned short subtype; if (v1->v_type != V_ADDR) - return error_value(E_MODIFY1); + return error_value(E_MODIFY_1); v1 = v1->v_addr; if (v2->v_type == V_ADDR) v2 = v2->v_addr; if (v2->v_type != V_STR) - return error_value(E_MODIFY2); + return error_value(E_MODIFY_2); if (v1->v_subtype & V_NONEWVALUE) - return error_value(E_MODIFY3); + return error_value(E_MODIFY_3); fp = findfunc(adduserfunc(v2->v_str->s_str)); if (!fp) - return error_value(E_MODIFY4); + return error_value(E_MODIFY_4); switch (v1->v_type) { case V_LIST: for (ep = v1->v_list->l_first; ep; ep = ep->e_next) { @@ -9282,7 +9474,7 @@ f_modify(VALUE *v1, VALUE *v2) } break; default: - return error_value(E_MODIFY5); + return error_value(E_MODIFY_5); } res.v_type = V_NULL; res.v_subtype = V_NOSUBTYPE; @@ -9619,7 +9811,7 @@ f_access(int count, VALUE **vals) errno = 0; if (vals[0]->v_type != V_STR) - return error_value(E_ACCESS1); + return error_value(E_ACCESS_1); fname = vals[0]->v_str->s_str; m = 0; if (count == 2) { @@ -9627,7 +9819,7 @@ f_access(int count, VALUE **vals) case V_NUM: q = vals[1]->v_num; if (qisfrac(q) || qisneg(q)) - return error_value(E_ACCESS2); + return error_value(E_ACCESS_2); m = (int)(q->num.v[0] & 7); break; case V_STR: @@ -9638,14 +9830,14 @@ f_access(int count, VALUE **vals) case 'r': m |= 4; break; case 'w': m |= 2; break; case 'x': m |= 1; break; - default: return error_value(E_ACCESS2); + default: return error_value(E_ACCESS_2); } } break; case V_NULL: break; default: - return error_value(E_ACCESS2); + return error_value(E_ACCESS_2); } } i = access(fname, m); @@ -10120,17 +10312,17 @@ f_blk(int count, VALUE **vals) if (count > 0 && vals[0]->v_type != V_NULL) { /* parse len */ if (vals[0]->v_type != V_NUM || qisfrac(vals[0]->v_num)) - return error_value(E_BLK1); + return error_value(E_BLK_1); if (qisneg(vals[0]->v_num) || zge31b(vals[0]->v_num->num)) - return error_value(E_BLK2); + return error_value(E_BLK_2); len = qtoi(vals[0]->v_num); } if (count > 1 && vals[1]->v_type != V_NULL) { /* parse chunk */ if (vals[1]->v_type != V_NUM || qisfrac(vals[1]->v_num)) - return error_value(E_BLK3); + return error_value(E_BLK_3); if (qisneg(vals[1]->v_num) || zge31b(vals[1]->v_num->num)) - return error_value(E_BLK4); + return error_value(E_BLK_4); chunk = qtoi(vals[1]->v_num); } @@ -10186,17 +10378,17 @@ f_blkfree(VALUE *vp) case V_STR: id = findnblockid(vp->v_str->s_str); if (id < 0) - return error_value(E_BLKFREE1); + return error_value(E_BLKFREE_1); break; case V_NUM: if (qisfrac(vp->v_num) || qisneg(vp->v_num)) - return error_value(E_BLKFREE2); + return error_value(E_BLKFREE_2); if (zge31b(vp->v_num->num)) - return error_value(E_BLKFREE3); + return error_value(E_BLKFREE_3); id = qtoi(vp->v_num); break; default: - return error_value(E_BLKFREE4); + return error_value(E_BLKFREE_4); } id = removenblock(id); if (id) @@ -10221,13 +10413,13 @@ f_blocks(int count, VALUE **vals) return result; } if (vals[0]->v_type != V_NUM || qisfrac(vals[0]->v_num)) - return error_value(E_BLOCKS1); + return error_value(E_BLOCKS_1); id = (int) qtoi(vals[0]->v_num); nblk = findnblock(id); if (nblk == NULL) { - return error_value(E_BLOCKS2); + return error_value(E_BLOCKS_2); } else { result.v_type = V_NBLOCK; result.v_nblock = nblk; @@ -10328,10 +10520,10 @@ f_copy(int count, VALUE **vals) if (vals[4]->v_type != V_NUM || qisfrac(vals[4]->v_num) || qisneg(vals[4]->v_num)) { - return error_value(E_COPY6); + return error_value(E_COPY_06); } if (zge31b(vals[4]->v_num->num)) { - return error_value(E_COPY7); + return error_value(E_COPY_07); } dsi = qtoi(vals[4]->v_num); } @@ -10343,10 +10535,10 @@ f_copy(int count, VALUE **vals) if (vals[3]->v_type != V_NUM || qisfrac(vals[3]->v_num) || qisneg(vals[3]->v_num)) { - return error_value(E_COPY1); + return error_value(E_COPY_01); } if (zge31b(vals[3]->v_num->num)) { - return error_value(E_COPY2); + return error_value(E_COPY_02); } num = qtoi(vals[3]->v_num); } @@ -10358,10 +10550,10 @@ f_copy(int count, VALUE **vals) if (vals[2]->v_type != V_NUM || qisfrac(vals[2]->v_num) || qisneg(vals[2]->v_num)) { - return error_value(E_COPY4); + return error_value(E_COPY_04); } if (zge31b(vals[2]->v_num->num)) { - return error_value(E_COPY5); + return error_value(E_COPY_05); } ssi = qtoi(vals[2]->v_num); } @@ -10585,7 +10777,7 @@ f_versin(int count, VALUE **vals) eps = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_VERSIN1); + return error_value(E_VERSIN_1); } eps = vals[1]->v_num; } @@ -10601,7 +10793,7 @@ f_versin(int count, VALUE **vals) case V_COM: c = c_versin(vals[0]->v_com, eps); if (c == NULL) { - return error_value(E_VERSIN3); + return error_value(E_VERSIN_3); } result.v_com = c; result.v_type = V_COM; @@ -10615,7 +10807,7 @@ f_versin(int count, VALUE **vals) } break; default: - return error_value(E_VERSIN2); + return error_value(E_VERSIN_2); } return result; } @@ -10643,7 +10835,7 @@ f_aversin(int count, VALUE **vals) eps = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_AVERSIN1); + return error_value(E_AVERSIN_1); } eps = vals[1]->v_num; } @@ -10680,7 +10872,7 @@ f_aversin(int count, VALUE **vals) */ c = c_aversin(arg1.v_com, eps); if (c == NULL) { - return error_value(E_AVERSIN3); + return error_value(E_AVERSIN_3); } result.v_com = c; result.v_type = V_COM; @@ -10698,7 +10890,7 @@ f_aversin(int count, VALUE **vals) /* * case: argument type is not valid for this function */ - return error_value(E_AVERSIN2); + return error_value(E_AVERSIN_2); } return result; } @@ -10725,7 +10917,7 @@ f_coversin(int count, VALUE **vals) eps = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_COVERSIN1); + return error_value(E_COVERSIN_1); } eps = vals[1]->v_num; } @@ -10741,7 +10933,7 @@ f_coversin(int count, VALUE **vals) case V_COM: c = c_coversin(vals[0]->v_com, eps); if (c == NULL) { - return error_value(E_COVERSIN3); + return error_value(E_COVERSIN_3); } result.v_com = c; result.v_type = V_COM; @@ -10755,7 +10947,7 @@ f_coversin(int count, VALUE **vals) } break; default: - return error_value(E_COVERSIN2); + return error_value(E_COVERSIN_2); } return result; } @@ -10783,7 +10975,7 @@ f_acoversin(int count, VALUE **vals) eps = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_ACOVERSIN1); + return error_value(E_ACOVERSIN_1); } eps = vals[1]->v_num; } @@ -10820,7 +11012,7 @@ f_acoversin(int count, VALUE **vals) */ c = c_acoversin(arg1.v_com, eps); if (c == NULL) { - return error_value(E_ACOVERSIN3); + return error_value(E_ACOVERSIN_3); } result.v_com = c; result.v_type = V_COM; @@ -10838,7 +11030,7 @@ f_acoversin(int count, VALUE **vals) /* * case: argument type is not valid for this function */ - return error_value(E_ACOVERSIN2); + return error_value(E_ACOVERSIN_2); } return result; } @@ -10865,7 +11057,7 @@ f_vercos(int count, VALUE **vals) eps = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_VERCOS1); + return error_value(E_VERCOS_1); } eps = vals[1]->v_num; } @@ -10881,7 +11073,7 @@ f_vercos(int count, VALUE **vals) case V_COM: c = c_vercos(vals[0]->v_com, eps); if (c == NULL) { - return error_value(E_VERCOS3); + return error_value(E_VERCOS_3); } result.v_com = c; result.v_type = V_COM; @@ -10895,7 +11087,7 @@ f_vercos(int count, VALUE **vals) } break; default: - return error_value(E_VERCOS2); + return error_value(E_VERCOS_2); } return result; } @@ -10923,7 +11115,7 @@ f_avercos(int count, VALUE **vals) eps = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_AVERCOS1); + return error_value(E_AVERCOS_1); } eps = vals[1]->v_num; } @@ -10960,7 +11152,7 @@ f_avercos(int count, VALUE **vals) */ c = c_avercos(arg1.v_com, eps); if (c == NULL) { - return error_value(E_AVERCOS3); + return error_value(E_AVERCOS_3); } result.v_com = c; result.v_type = V_COM; @@ -10978,7 +11170,7 @@ f_avercos(int count, VALUE **vals) /* * case: argument type is not valid for this function */ - return error_value(E_AVERCOS2); + return error_value(E_AVERCOS_2); } return result; } @@ -11005,7 +11197,7 @@ f_covercos(int count, VALUE **vals) eps = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_COVERCOS1); + return error_value(E_COVERCOS_1); } eps = vals[1]->v_num; } @@ -11021,7 +11213,7 @@ f_covercos(int count, VALUE **vals) case V_COM: c = c_covercos(vals[0]->v_com, eps); if (c == NULL) { - return error_value(E_COVERCOS3); + return error_value(E_COVERCOS_3); } result.v_com = c; result.v_type = V_COM; @@ -11035,7 +11227,7 @@ f_covercos(int count, VALUE **vals) } break; default: - return error_value(E_COVERCOS2); + return error_value(E_COVERCOS_2); } return result; } @@ -11063,7 +11255,7 @@ f_acovercos(int count, VALUE **vals) eps = conf->epsilon; if (count == 2) { if (verify_eps(vals[1]) == false) { - return error_value(E_ACOVERCOS1); + return error_value(E_ACOVERCOS_1); } eps = vals[1]->v_num; } @@ -11100,7 +11292,7 @@ f_acovercos(int count, VALUE **vals) */ c = c_acovercos(arg1.v_com, eps); if (c == NULL) { - return error_value(E_ACOVERCOS3); + return error_value(E_ACOVERCOS_3); } result.v_com = c; result.v_type = V_COM; @@ -11118,7 +11310,7 @@ f_acovercos(int count, VALUE **vals) /* * case: argument type is not valid for this function */ - return error_value(E_ACOVERCOS2); + return error_value(E_ACOVERCOS_2); } return result; } diff --git a/func.h b/func.h index 7de4365..f35a58f 100644 --- a/func.h +++ b/func.h @@ -74,6 +74,7 @@ E_FUNC FUNC *curfunc; /* NOTE: This is a function pointer, we need E_FUNC */ /* * Functions to handle functions. */ +E_FUNC char *name_newerrorstr(int errnum); E_FUNC FUNC *findfunc(long index); E_FUNC char *namefunc(long index); E_FUNC bool evaluate(bool nestflag); diff --git a/hash.c b/hash.c index 343a44b..d4e5a02 100644 --- a/hash.c +++ b/hash.c @@ -40,7 +40,7 @@ #include "hash.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/help/Makefile b/help/Makefile index ac7c58c..b60c572 100644 --- a/help/Makefile +++ b/help/Makefile @@ -206,8 +206,8 @@ DETAIL_HELP= abs access acos acosh acot acoth acovercos acoversin \ calcpath catalan ceil cfappr cfsim char cmdbuf cmp comb conj cos cosh \ cot coth count covercos coversin cp csc csch ctime d2dm d2dms d2g d2r \ delete den dereference det digit digits display dms2d dp epsilon \ - errcount errmax errno error estr euler eval exp fact factor fclose \ - fcnt feof ferror fflush fgetc fgetfield fgetfile fgetline fgets \ + errcount errmax errno error errstr estr euler eval exp fact factor \ + fclose fcnt feof ferror fflush fgetc fgetfield fgetfile fgetline fgets \ fgetstr fib files floor fopen forall fpathopen fprintf fputc fputs \ fputstr frac free freebernoulli freeeuler freeglobals freeredc \ freestatics frem freopen fscan fscanf fseek fsize ftell g2d g2gm g2gms \ diff --git a/help/errcount b/help/errcount index d09493a..5e4c6a6 100644 --- a/help/errcount +++ b/help/errcount @@ -45,10 +45,9 @@ LINK LIBRARY none SEE ALSO - errmax, error, strerror, iserror, errno, newerror, errorcodes, - stoponerror + errmax, errno, errorcodes, errstr, iserror, newerror, stoponerror, strerror -## Copyright (C) 1999-2006,2021 Landon Curt Noll +## Copyright (C) 1999-2006,2021,2023 Landon Curt Noll ## ## Calc is open software; you can redistribute it and/or modify it under ## the terms of the version 2.1 of the GNU Lesser General Public License diff --git a/help/errmax b/help/errmax index e0e667a..c704c17 100644 --- a/help/errmax +++ b/help/errmax @@ -42,10 +42,9 @@ LINK LIBRARY none SEE ALSO - errcount, error, strerror, iserror, errno, newerror, errorcodes, - stoponerror + errcount, errno, errorcodes, errstr, iserror, newerror, stoponerror, strerror -## Copyright (C) 2006,2021 Landon Curt Noll +## Copyright (C) 2006,2021,2023 Landon Curt Noll ## ## Calc is open software; you can redistribute it and/or modify it under ## the terms of the version 2.1 of the GNU Lesser General Public License diff --git a/help/errno b/help/errno index 18cb5da..bcc7ffb 100644 --- a/help/errno +++ b/help/errno @@ -13,14 +13,34 @@ TYPES DESCRIPTION With errno(errnum) numeric argument: - errno(errnum) sets "global calc_errno value" to the value - errnum and returns its previous value. Unlike error(errnum) - calling errno(errnum) does NOT increment the global calc - error count (see help errcount). + For 0 < errnum <= 32767: + + errno(errnum) sets "global calc_errno value" to the value + errnum and returns its previous value. Unlike error(errnum) + calling errno(errnum) does NOT increment the global calc + error count (see help errcount). + + For all other errnum values: + + An error error condition is raised about the valid errnum. With errno("E_STRING") string argument: - XXX - fill in - XXX + If E_STRING is a valid errsym code, then the E_STRING errsym + is converted into an equivalent errnum and errno is set to errnum. + + If E_STRING is not a valid errsym code, an error error condition + is raised about the invalid E_STRING. + + For example, these two calls are equivalent: + + errno(10003); /* error 10003 has a E_STRING of "E_ADD" */ + errno("E_ADD"); /* error 10003 has a E_STRING of "E_ADD" */ + + See help errstr for information on E_STRING errsym codes. + + For a list of the E_STRING associated with calc computation error + codes, see help errorcodes. With errno() no argument: @@ -74,16 +94,16 @@ EXAMPLE LIMITS 0 <= errnum <= 32767 - E_STRING is string matching the regular expression: "^E_[A-Z0-9_]+$" + E_STRING is string that must match the regular expression: ^E_[A-Z0-9_]+$ LINK LIBRARY int calc_errno; /* global calc_errno value */ + int set_errno(int e); CONST struct errtbl error_table[ECOUNT+2]; /* calc error codes, error symbols and error messages */ SEE ALSO - errmax, errcount, error, strerror, iserror, newerror, errorcodes, - stoponerror + errcount, errmax, errorcodes, errstr, iserror, newerror, stoponerror, strerror ## Copyright (C) 1999-2006,2021,2023 Landon Curt Noll ## diff --git a/help/error b/help/error index 0c82ecb..b54b492 100644 --- a/help/error +++ b/help/error @@ -19,14 +19,20 @@ DESCRIPTION The global calc error count is not changed. - For 0 < errnum <= 32767: + With error(errnum) numeric argument: - error(errnum) returns a value that is of a special type called - "error". The "error" return value, when given to iserror() - will cause that function to return a true value that happens - to match the "global calc_errno value". + For 0 < errnum <= 32767: - The "global calc_errno value" is then set to errnum. + error(errnum) returns a value that is of a special type called + "error". The "error" return value, when given to iserror() + will cause that function to return a true value that happens + to match the "global calc_errno value". + + The "global calc_errno value" is then set to errnum. + + For all other errnum values: + + An error error condition is raised about the valid errnum. The global calc error count (see help errcount) is incremented. If the global calc error count exceeds the maximum count @@ -34,7 +40,22 @@ DESCRIPTION With error("E_STRING") string argument: - XXX - fill in - XXX + If E_STRING is a valid errsym code, then the E_STRING errsym + is converted into an equivalent errnum and respective calc + error condition is raised. + + If E_STRING is not a valid errsym code, an error error condition + is raised about the invalid E_STRING. + + For example, these two calls are equivalent: + + error(10003); /* error 10003 has a E_STRING of "E_ADD" */ + error("E_ADD"); /* error 10003 has a E_STRING of "E_ADD" */ + + See help errstr for information on E_STRING errsym codes. + + For a list of the E_STRING associated with calc computation error + codes, see help errorcodes. For no errnum arg: @@ -110,7 +131,7 @@ EXAMPLE LIMITS 0 <= errnum <= 32767 - E_STRING is string matching the regular expression: "^E_[A-Z0-9_]+$" + E_STRING is string that must match the regular expression: ^E_[A-Z0-9_]+$ LINK LIBRARY int calc_errno; /* global calc_errno value */ diff --git a/help/errstr b/help/errstr new file mode 100644 index 0000000..79c1674 --- /dev/null +++ b/help/errstr @@ -0,0 +1,176 @@ +NAME + errstr - convert between "E_STRING" errsym into a errnum number + +SYNOPSIS + errstr(errnum | "E_STRING") + +TYPES + errnum integer + E_STRING string + + return integer or string or error value + +DESCRIPTION + When called with in integer errnum argument: + + When E__BASE < errnum <= E__HIGHEST, the corresponding errsym E_STRING + from the error_table[] array is returned. + + For example: + + ; print errstr(10003) + E_ADD + + When an errnum that matches one of the following errtbl.h #define, + then the #define string is returned: + + E__NONE + E__BASE + E__USERDEF + E__USERMAX + + NOTE: For errnum == E__HIGHEST, the corresponding E_STRING that + is returned is NOT "E__HIGHEST". Instead the E_STRING corresponding + to the highest errnum number from the error_table[] array is returned. + + For example: + + ; print errstr(0) + E_NONE + + When E__NONE <= errnum < E__BASE, or when E__USERDEF <= errnum <= E__USERMAX, + an "E_STRING" errsym of the form "E_digits" is returned where "digits" + are the ASCII digits of the decimal value of errnum. + + For example: + + ; print errstr(123) + E_123 + + For all other errnum values, an error is returned. + + When called with E_STRING string argument: + + When the E_STRING starts with "E_" followed by only decimal digits: + + If E_STRING is "E_0", 0 is returned. + + If E_STRING matches the regular expression: + + ^E_[1-9][0-9]+$ + + where digits 0 < errnum <= 32767, the errnum value is returned. + + For all other cases of "E_" by only decimal digits, an error is returned. + + When the E_STRING matches one of the following special + symbols, the symbol's numeric value as #define-d in errsym.h + or errtbl.h is returned: + + E__NONE + E__BASE + E__HIGHEST + E__USERDEF + E__USERMAX + + For example: + + ; print errstr("E_NONE") + 0 + + For all other E_STRING strings that start with "E__", an error is returned. + + When the E_STRING starts with "E_" followed by an UPPER CASE LETTER that + also matches the regular expression: + + ^E_[A-Z][A-Z0-9_]+$ + + The error_table[] is searched for an errsym that exactly matches + the E_STRING. If a match is found, the corresponding errnum number + is returned. If no match is found, an error is returned. + + For example: + + ; print errstr("E_ADD") + 10003 + + For all other string arguments, an error is returned. + + When errstr returns an integer, the global calc error count (see help errcount) + is NOT changed. And of course, when errstr("E_STRING") returns an error, the + global calc error count is incremented by 1. + + Consider the E_MUL calc error condition: + + Given a E_STRING errsym, errstr("E_STRING") will return the errnum integer + error code that is associated with the E_STRING errsym. + + The 4th entry of struct errtbl error_table is: + + { 10005, "E_MUL", "Bad arguments for +" }, + + And errcode -d produces a errsym.h with the following #define: + + #define E_MUL 10005 /* Bad arguments for * */ + + Thus 10005 is the errnum, "E_MUL" is the E_STRING errsym that is + associated with the errmsg error message: "Bad arguments for +". + + In the above example, errstr("E_MUL") will return 10005. + Also errstr("E_10005") will also return 10005. + + To complete the E_STRING use in the above example: + + Both error(10005) and error("E_MUL") both raise the E_MUL calc error condition + + Both errno(10005) and errno("E_MUL") both return 10005 + + Both strerror(10005) and strerror("E_MUL") both return "Bad arguments for *" + +EXAMPLE + ; print errstr("E_ADD"), errstr("E_SUB"), errstr("E_MUL"), errstr("E_DIV") + 10003 10004 10005 10006 + + ; print errstr("E__NONE"), errstr("E__BASE"), errstr("E__USERDEF"), errstr("E__USERMAX") + 0 10000 20000 32767 + + ; print errstr(10003), errstr(10004), errstr(10005), errstr(10006) + E_ADD E_SUB E_MUL E_DIV + + ; print errstr(0), errstr(10000), errstr(20000), errstr(32767) + E__NONE E__BASE E__USERDEF E__USERMAX + +LIMITS + 0 <= errnum < 32767 + + E_STRING is string that must match the regular expression: ^E_[A-Z0-9_]+$ + +LINK LIBRARY + int calc_errno; /* global calc_errno value */ + + CONST struct errtbl error_table[ECOUNT+2]; /* calc error codes, error symbols and error messages */ + +SEE ALSO + errcount, errmax, errno, errorcodes, iserror, newerror, stoponerror, strerror + +## Copyright (C) 1999-2006,2023 Landon Curt Noll +## +## Calc is open software; you can redistribute it and/or modify it under +## the terms of the version 2.1 of the GNU Lesser General Public License +## as published by the Free Software Foundation. +## +## Calc is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General +## Public License for more details. +## +## A copy of version 2.1 of the GNU Lesser General Public License is +## distributed with calc under the filename COPYING-LGPL. You should have +## received a copy with calc; if not, write to Free Software Foundation, Inc. +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +## +## Under source code control: 1995/12/18 03:30:59 +## File existed as early as: 1995 +## +## chongo /\oo/\ http://www.isthe.com/chongo/ +## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ diff --git a/help/iserror b/help/iserror index 8bb6c10..8c81b33 100644 --- a/help/iserror +++ b/help/iserror @@ -25,13 +25,14 @@ LINK LIBRARY none SEE ALSO - error, errorcodes, stoponerror, + errcount, errmax, errno, errorcodes, errstr, newerror, stoponerror, strerror + isassoc, isatty, isblk, isconfig, isdefined, iseven, isfile, ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj, isobjtype, isodd, isprime, isrand, israndom, isreal, isrel, issimple, issq, isstr, istype -## Copyright (C) 1999-2006 Landon Curt Noll +## Copyright (C) 1999-2006,2023 Landon Curt Noll ## ## Calc is open software; you can redistribute it and/or modify it under ## the terms of the version 2.1 of the GNU Lesser General Public License diff --git a/help/newerror b/help/newerror index 69393a9..855b755 100644 --- a/help/newerror +++ b/help/newerror @@ -73,8 +73,7 @@ LINK LIBRARY none SEE ALSO - errmax, errcount, error, strerror, iserror, errno, errorcodes, - stoponerror + errcount, errmax, errno, errorcodes, errstr, iserror, stoponerror, strerror ## Copyright (C) 1999-2006,2023 Landon Curt Noll ## diff --git a/help/rand b/help/rand index 699fb41..318cf29 100644 --- a/help/rand +++ b/help/rand @@ -18,13 +18,13 @@ DESCRIPTION By default, min is 0 and beyond is 2^64. - The shuffle method is fast and serves as a fairly good standard - pseudo-random generator. If you need a fast generator and do not - need a cryptographically strong one, this generator is likely to do + The shuffle method is fast and serves as a very good pseudo-random + generator. If you need a fast generator and do not need a + cryptographically strong one, this generator is likely to do the job. Casual direct use of the shuffle generator may be - acceptable. For a much higher quality cryptographically strong - (but slower) generator use the Blum-Blum-Shub generator (see the - random help page). + acceptable. For a much higher quality cryptographically strong + (but slower) generator use the Blum-Blum-Shub generator (see + help random for more information). Other arg forms: @@ -185,7 +185,7 @@ DESCRIPTION 10239951819489363767 ==> 1363042948800878693 One might object to the complexity of the seed scramble/mapping via - the randreseed64 process. But Calling srand(0) with the randreseed64 + the randreseed64 process. Calling srand(0) with the randreseed64 process would be the same as calling srand(10239951819489363767) without it. No extra security is gained or reduced by using the randreseed64 process. The meaning of seeds are exchanged, but not @@ -195,12 +195,6 @@ DESCRIPTION generator. Every seed is converted into a different unique seed. No seed is ignored or favored. - The truly paranoid might suggest that my claims in the MAGIC NUMBERS - section are a lie intended to entrap people. Well they are not, but - if you that paranoid why would you use a non-cryptographically strong - pseudo-random number generator in the first place? You would be - better off using the random() builtin function. - The two constants that were picked from the Rand Book of Random Numbers The random numbers from the Rand Book of Random Numbers can be verified by anyone who obtains the book. As these numbers were @@ -243,7 +237,7 @@ LINK LIBRARY SEE ALSO seed, srand, randbit, isrand, random, srandom, israndom -## Copyright (C) 1999-2007,2021 Landon Curt Noll +## Copyright (C) 1999-2007,2021,2023 Landon Curt Noll ## ## Calc is open software; you can redistribute it and/or modify it under ## the terms of the version 2.1 of the GNU Lesser General Public License diff --git a/help/stoponerror b/help/stoponerror index 23f9406..8d731c8 100644 --- a/help/stoponerror +++ b/help/stoponerror @@ -36,7 +36,7 @@ LINK LIBRARY none SEE ALSO - errcount, errmax, errorcodes, iserror, errno, strerror, newerror + errcount, errmax, errno, errorcodes, errstr, iserror, newerror, strerror ## Copyright (C) 2006,2021,2023 Landon Curt Noll ## diff --git a/help/strerror b/help/strerror index 7474034..b7d4b87 100644 --- a/help/strerror +++ b/help/strerror @@ -11,7 +11,9 @@ TYPES return string DESCRIPTION - If 0 <= errnum <= 32767 then strerror(errnum) will return one of: + With errno(errnum) numeric argument: + + strerror(errnum) will return one of: * system error and libc errno value related string * calc computation error code string @@ -20,7 +22,21 @@ DESCRIPTION With strerror("E_STRING") string argument: - XXX - fill in - XXX + If E_STRING is a valid errsym code, then the E_STRING errsym + is converted into strerror(errnum). + + If E_STRING is not a valid errsym code, an error error condition + is raised about the invalid E_STRING. + + For example, these two calls are equivalent: + + cstrerror(10003); /* error 10003 has a E_STRING of "E_ADD" */ + cstrerror("E_ADD"); /* error 10003 has a E_STRING of "E_ADD" */ + + See help errstr for information on E_STRING errsym codes. + + For a list of the E_STRING associated with calc computation error + codes, see help errorcodes. Without a argument, strerror() returns as if it were called with: @@ -83,7 +99,7 @@ EXAMPLE LIMITS 0 <= errnum <= 32767 - E_STRING is string matching the regular expression: "^E_[A-Z0-9_]+$" + E_STRING is string that must match the regular expression: ^E_[A-Z0-9_]+$ LINK LIBRARY int calc_errno; /* global calc_errno value */ @@ -91,12 +107,11 @@ LINK LIBRARY CONST struct errtbl error_table[ECOUNT+2]; /* calc error codes, error symbols and error messages */ SEE ALSO + errcount, errmax, errno, errorcodes, errstr, iserror, newerror, stoponerror + strcat, strcpy, strlen, strncmp, strncpy, strpos, strprintf, strscan, strscanf, substr, - errcount, errmax, error, iserror, errno, newerror, errorcodes, - stoponerror - ## Copyright (C) 1999-2006,2023 Landon Curt Noll ## ## Calc is open software; you can redistribute it and/or modify it under diff --git a/hist.c b/hist.c index 19d32ee..e55918b 100644 --- a/hist.c +++ b/hist.c @@ -69,7 +69,7 @@ #include "have_unused.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/input.c b/input.c index 3ce2b92..aa1ca14 100644 --- a/input.c +++ b/input.c @@ -1,7 +1,7 @@ /* * input - nested input source file reader * - * Copyright (C) 1999-2007,2014,2018,2021,2022 David I. Bell + * Copyright (C) 1999-2007,2014,2018,2021-2023 David I. Bell * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -55,7 +55,7 @@ #include "strl.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/lib_calc.c b/lib_calc.c index 3b31647..487e8bc 100644 --- a/lib_calc.c +++ b/lib_calc.c @@ -94,7 +94,7 @@ typedef struct {int fd;} ttystruct; #endif /* Windows */ -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ @@ -349,6 +349,11 @@ libcalc_call_me_first(void) */ initialize(); + /* + * verify error_table[] array and setup private_error_alias[] array + */ + verify_error_table(); + /* * ready to rock & roll .. */ diff --git a/lib_util.c b/lib_util.c index dadf85f..64c65f2 100644 --- a/lib_util.c +++ b/lib_util.c @@ -1,7 +1,7 @@ /* * lib_util - calc library utility routines * - * Copyright (C) 1999-2006,2021,2022 Landon Curt Noll + * Copyright (C) 1999-2006,2021-2023 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -35,7 +35,7 @@ #include "lib_util.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/listfunc.c b/listfunc.c index b2a34f7..8fa434c 100644 --- a/listfunc.c +++ b/listfunc.c @@ -37,7 +37,7 @@ #include "zrand.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/matfunc.c b/matfunc.c index b5a9dd5..e98d865 100644 --- a/matfunc.c +++ b/matfunc.c @@ -31,12 +31,11 @@ #include "alloc.h" #include "value.h" #include "zrand.h" -#include "errsym.h" #include "have_unused.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ @@ -666,11 +665,11 @@ mattrace(MATRIX *m) return sum; } if (m->m_dim != 2) - return error_value(E_MATTRACE2); + return error_value(E_MATTRACE_2); i = (m->m_max[0] - m->m_min[0] + 1); j = (m->m_max[1] - m->m_min[1] + 1); if (i != j) - return error_value(E_MATTRACE3); + return error_value(E_MATTRACE_3); vp = m->m_table; copyvalue(vp, &sum); j++; @@ -1234,9 +1233,9 @@ matdet(MATRIX *m) } if (m->m_dim != 2) - return error_value(E_DET2); + return error_value(E_DET_2); if ((m->m_max[0] - m->m_min[0]) != (m->m_max[1] - m->m_min[1])) - return error_value(E_DET3); + return error_value(E_DET_3); /* * Loop over each row, and eliminate all lower entries in the diff --git a/obj.c b/obj.c index b774083..33f64e2 100644 --- a/obj.c +++ b/obj.c @@ -38,7 +38,7 @@ #include "strl.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/opcodes.c b/opcodes.c index c9332a1..ace2fe4 100644 --- a/opcodes.c +++ b/opcodes.c @@ -47,7 +47,7 @@ #include "have_unused.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ @@ -423,19 +423,19 @@ o_eleminit(FUNC *UNUSED(fp), long index) vp = vp->v_addr; if (vp->v_type < 0) { freevalue(stack--); - error_value(E_INIT1); + error_value(E_INIT_01); return; } if (vp->v_subtype & V_NOCOPYTO) { freevalue(stack--); - error_value(E_INIT2); + error_value(E_INIT_02); return; } switch (vp->v_type) { case V_MAT: if ((index < 0) || (index >= vp->v_mat->m_size)) { freevalue(stack--); - error_value(E_INIT3); + error_value(E_INIT_03); return; } oldvp = &vp->v_mat->m_table[index]; @@ -443,7 +443,7 @@ o_eleminit(FUNC *UNUSED(fp), long index) case V_OBJ: if (index < 0 || index >= vp->v_obj->o_actions->oa_count) { freevalue(stack--); - error_value(E_INIT3); + error_value(E_INIT_03); return; } oldvp = &vp->v_obj->o_table[index]; @@ -452,14 +452,14 @@ o_eleminit(FUNC *UNUSED(fp), long index) oldvp = listfindex(vp->v_list, index); if (oldvp == NULL) { freevalue(stack--); - error_value(E_INIT3); + error_value(E_INIT_03); return; } break; case V_STR: if (index < 0 || (size_t)index >= vp->v_str->s_len) { freevalue(stack--); - error_value(E_INIT3); + error_value(E_INIT_03); return; } ptr = (OCTET *)(&vp->v_str->s_str[index]); @@ -475,7 +475,7 @@ o_eleminit(FUNC *UNUSED(fp), long index) blk = vp->v_nblock->blk; if (blk->data == NULL) { freevalue(stack--); - error_value(E_INIT4); + error_value(E_INIT_04); return; } } @@ -483,7 +483,7 @@ o_eleminit(FUNC *UNUSED(fp), long index) blk = vp->v_block; if (index >= blk->maxsize) { freevalue(stack--); - error_value(E_INIT3); + error_value(E_INIT_03); return; } ptr = blk->data + index; @@ -497,14 +497,14 @@ o_eleminit(FUNC *UNUSED(fp), long index) return; default: freevalue(stack--); - error_value(E_INIT5); + error_value(E_INIT_05); return; } vp = stack--; subtype = oldvp->v_subtype; if (subtype & V_NOASSIGNTO) { freevalue(vp); - error_value(E_INIT6); + error_value(E_INIT_06); return; } if (vp->v_type == V_ADDR) { @@ -517,21 +517,21 @@ o_eleminit(FUNC *UNUSED(fp), long index) tmp = *vp; if ((subtype & V_NONEWVALUE) && comparevalue(oldvp, &tmp)) { freevalue(&tmp); - error_value(E_INIT7); + error_value(E_INIT_07); return; } if ((subtype & V_NONEWTYPE) && oldvp->v_type != tmp.v_type) { freevalue(&tmp); - error_value(E_INIT8); + error_value(E_INIT_08); return; } if ((subtype & V_NOERROR) && tmp.v_type < 0) { - error_value(E_INIT9); + error_value(E_INIT_09); return; } if (tmp.v_subtype & (V_NOASSIGNFROM | V_NOCOPYFROM)) { freevalue(&tmp); - error_value(E_INIT10); + error_value(E_INIT_10); return; } tmp.v_subtype |= oldvp->v_subtype; @@ -787,7 +787,7 @@ o_assign(FUNC *UNUSED(fp)) if (var->v_type == V_OCTET) { if (var->v_subtype & V_NOCOPYTO) { freevalue(stack--); - *stack = error_value(E_ASSIGN1); + *stack = error_value(E_ASSIGN_1); return; } vp = stack; @@ -795,13 +795,13 @@ o_assign(FUNC *UNUSED(fp)) vp = vp->v_addr; if (vp->v_subtype & V_NOCOPYFROM || vp->v_type < 0) { freevalue(stack--); - *stack = error_value(E_ASSIGN2); + *stack = error_value(E_ASSIGN_2); return; } copy2octet(vp, &octet); freevalue(stack--); if ((var->v_subtype & V_NONEWVALUE) && *var->v_octet != octet) { - *stack = error_value(E_ASSIGN3); + *stack = error_value(E_ASSIGN_3); return; } *var->v_octet = octet; @@ -809,7 +809,7 @@ o_assign(FUNC *UNUSED(fp)) } if (var->v_type != V_ADDR) { freevalue(stack--); - *stack = error_value(E_ASSIGN4); + *stack = error_value(E_ASSIGN_4); return; } @@ -817,7 +817,7 @@ o_assign(FUNC *UNUSED(fp)) subtype = var->v_subtype; if (subtype & V_NOASSIGNTO) { freevalue(stack--); - *stack = error_value(E_ASSIGN5); + *stack = error_value(E_ASSIGN_5); return; } @@ -843,7 +843,7 @@ o_assign(FUNC *UNUSED(fp)) if (vp == var) return; if (vp->v_subtype & V_NOASSIGNFROM) { - *stack = error_value(E_ASSIGN6); + *stack = error_value(E_ASSIGN_6); return; } copyvalue(vp, &tmp); @@ -858,16 +858,16 @@ o_assign(FUNC *UNUSED(fp)) */ if ((subtype & V_NONEWVALUE) && comparevalue(var, &tmp)) { freevalue(&tmp); - *stack = error_value(E_ASSIGN7); + *stack = error_value(E_ASSIGN_7); return; } if ((subtype & V_NONEWTYPE) && var->v_type != tmp.v_type) { freevalue(&tmp); - *stack = error_value(E_ASSIGN8); + *stack = error_value(E_ASSIGN_8); return; } if ((subtype & V_NOERROR) && tmp.v_type < 0) { - *stack = error_value(E_ASSIGN9); + *stack = error_value(E_ASSIGN_9); return; } @@ -1009,7 +1009,7 @@ o_swap(FUNC *UNUSED(fp)) if (v1->v_octet != v2->v_octet && ((v1->v_subtype | v2->v_subtype) & (V_NOCOPYTO | V_NOCOPYFROM))) { - *stack = error_value(E_SWAP1); + *stack = error_value(E_SWAP_1); return; } usb = *v1->v_octet; @@ -1020,14 +1020,14 @@ o_swap(FUNC *UNUSED(fp)) v2 = v2->v_addr; if (v1 != v2 && ((v1->v_subtype | v2->v_subtype) & (V_NOASSIGNTO | V_NOASSIGNFROM))) { - *stack = error_value(E_SWAP2); + *stack = error_value(E_SWAP_2); return; } tmp = *v1; *v1 = *v2; *v2 = tmp; } else { - *stack = error_value(E_SWAP3); + *stack = error_value(E_SWAP_3); return; } stack->v_type = V_NULL; @@ -1608,13 +1608,13 @@ o_bit(FUNC *UNUSED(fp)) if (v2->v_type != V_NUM || qisfrac(v2->v_num)) { freevalue(stack--); freevalue(stack); - *stack = error_value(E_BIT1); + *stack = error_value(E_BIT_1); return; } if (zge31b(v2->v_num->num)) { freevalue(stack--); freevalue(stack); - *stack = error_value(E_BIT2); + *stack = error_value(E_BIT_2); return; } index = qtoi(v2->v_num); @@ -1631,7 +1631,7 @@ o_bit(FUNC *UNUSED(fp)) freevalue(stack--); freevalue(stack); if (r > 1) { - *stack = error_value(E_BIT1); + *stack = error_value(E_BIT_1); } else if (r < 0) { stack->v_type = V_NULL; } else { @@ -1676,10 +1676,10 @@ o_highbit(FUNC *UNUSED(fp)) freevalue(stack); switch (index) { case -3: - *stack = error_value(E_HIGHBIT1); + *stack = error_value(E_HIGHBIT_1); return; case -2: - *stack = error_value(E_HIGHBIT2); + *stack = error_value(E_HIGHBIT_2); return; default: stack->v_type = V_NUM; @@ -1728,10 +1728,10 @@ o_lowbit(FUNC *UNUSED(fp)) freevalue(stack); switch (index) { case -3: - *stack = error_value(E_LOWBIT1); + *stack = error_value(E_LOWBIT_1); return; case -2: - *stack = error_value(E_LOWBIT2); + *stack = error_value(E_LOWBIT_2); return; default: stack->v_type = V_NUM; @@ -2923,7 +2923,7 @@ o_preinc(FUNC *UNUSED(fp)) if (stack->v_type == V_OCTET) { if (stack->v_subtype & (V_NONEWVALUE | V_NOCOPYTO)) { - *stack = error_value(E_PREINC1); + *stack = error_value(E_PREINC_1); return; } stack->v_octet[0] = stack->v_octet[0] + 1; @@ -2931,13 +2931,13 @@ o_preinc(FUNC *UNUSED(fp)) } if (stack->v_type != V_ADDR) { freevalue(stack); - *stack = error_value(E_PREINC2); + *stack = error_value(E_PREINC_2); return; } vp = stack->v_addr; if (vp->v_subtype & (V_NONEWVALUE | V_NOASSIGNTO)) { - *stack = error_value(E_PREINC3); + *stack = error_value(E_PREINC_3); return; } incvalue(vp, &tmp); @@ -2953,7 +2953,7 @@ o_predec(FUNC *UNUSED(fp)) if (stack->v_type == V_OCTET) { if (stack->v_subtype & (V_NONEWVALUE | V_NOCOPYTO)) { - *stack = error_value(E_PREDEC1); + *stack = error_value(E_PREDEC_1); return; } --(*stack->v_octet); @@ -2961,12 +2961,12 @@ o_predec(FUNC *UNUSED(fp)) } if (stack->v_type != V_ADDR) { freevalue(stack); - *stack = error_value(E_PREDEC2); + *stack = error_value(E_PREDEC_2); return; } vp = stack->v_addr; if (vp->v_subtype & (V_NONEWVALUE | V_NOASSIGNTO)) { - *stack = error_value(E_PREDEC3); + *stack = error_value(E_PREDEC_3); return; } decvalue(vp, &tmp); @@ -2983,7 +2983,7 @@ o_postinc(FUNC *UNUSED(fp)) if (stack->v_type == V_OCTET) { if (stack->v_subtype & (V_NONEWVALUE | V_NOCOPYTO)) { - *stack++ = error_value(E_POSTINC1); + *stack++ = error_value(E_POSTINC_1); stack->v_type = V_NULL; return; } @@ -2997,14 +2997,14 @@ o_postinc(FUNC *UNUSED(fp)) } if (stack->v_type != V_ADDR) { stack[1] = *stack; - *stack = error_value(E_POSTINC2); + *stack = error_value(E_POSTINC_2); stack++; return; } vp = stack->v_addr; if (vp->v_subtype & V_NONEWVALUE) { stack[1] = *stack; - *stack = error_value(E_POSTINC3); + *stack = error_value(E_POSTINC_3); stack++; return; } @@ -3026,7 +3026,7 @@ o_postdec(FUNC *UNUSED(fp)) if (stack->v_type == V_OCTET) { if (stack->v_subtype & (V_NONEWVALUE | V_NOCOPYTO)) { - *stack++ = error_value(E_POSTDEC1); + *stack++ = error_value(E_POSTDEC_1); stack->v_type = V_NULL; return; } @@ -3039,14 +3039,14 @@ o_postdec(FUNC *UNUSED(fp)) } if (stack->v_type != V_ADDR) { stack[1] = *stack; - *stack = error_value(E_POSTDEC2); + *stack = error_value(E_POSTDEC_2); stack++; return; } vp = stack->v_addr; if (vp->v_subtype & (V_NONEWVALUE | V_NOASSIGNTO)) { stack[1] = *stack; - *stack = error_value(E_POSTDEC3); + *stack = error_value(E_POSTDEC_3); stack++; return; } @@ -3403,6 +3403,10 @@ error_value(int e) if (-e > 0) e = 0; + if (is_valid_errnum(e) == false) { + math_error("Error %d is not a valid errnum in %s", e, __func__); + not_reached(); + } calc_errno = e; if (e > 0) errcount++; @@ -3416,7 +3420,7 @@ error_value(int e) } /* - * set_errno - return and set calc_errno + * set_errno - return and set calc_errno if e is a valid errnum value */ int set_errno(int e) @@ -3424,8 +3428,9 @@ set_errno(int e) int res; res = calc_errno; - if (e >= 0) + if (is_valid_errnum(e) == true) { calc_errno = e; + } return res; } diff --git a/qfunc.c b/qfunc.c index 6a8f1c2..d8df724 100644 --- a/qfunc.c +++ b/qfunc.c @@ -31,7 +31,7 @@ #include "prime.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/qio.c b/qio.c index a79e9af..0d3e4fe 100644 --- a/qio.c +++ b/qio.c @@ -31,7 +31,7 @@ #include "have_unused.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/qmath.c b/qmath.c index 0a7dde7..6ef905a 100644 --- a/qmath.c +++ b/qmath.c @@ -31,7 +31,7 @@ #include "config.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/qmod.c b/qmod.c index 045e48a..58091f7 100644 --- a/qmod.c +++ b/qmod.c @@ -31,7 +31,7 @@ #include "config.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/qtrans.c b/qtrans.c index 0d12842..46b2caa 100644 --- a/qtrans.c +++ b/qtrans.c @@ -34,7 +34,7 @@ #include "qmath.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/quickhash.c b/quickhash.c index 5b819e0..3ed9143 100644 --- a/quickhash.c +++ b/quickhash.c @@ -40,7 +40,7 @@ #include "zrandom.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/sample_many.c b/sample_many.c index 03a5836..0189ff8 100644 --- a/sample_many.c +++ b/sample_many.c @@ -1,7 +1,7 @@ /* * sample_many - generate many random values via random number generator * - * Copyright (C) 1999-2007,2021,2022 Landon Curt Noll + * Copyright (C) 1999-2007,2021-2023 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -41,7 +41,7 @@ #include "lib_util.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/sample_rand.c b/sample_rand.c index 753304f..7251226 100644 --- a/sample_rand.c +++ b/sample_rand.c @@ -1,7 +1,7 @@ /* * sample_rand - test the libcalc random number generator * - * Copyright (C) 1999-2007,2021,2022 Landon Curt Noll + * Copyright (C) 1999-2007,2021-2023 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -41,7 +41,7 @@ #include "lib_util.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/sha1.c b/sha1.c index 7095b68..45a698e 100644 --- a/sha1.c +++ b/sha1.c @@ -47,7 +47,7 @@ #include "sha1.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/size.c b/size.c index 12cbf8d..68947ee 100644 --- a/size.c +++ b/size.c @@ -1,7 +1,7 @@ /* * size - size and sizeof functions are implemented here * - * Copyright (C) 1999-2007,2021,2022 David I. Bell + * Copyright (C) 1999-2007,2021-2023 David I. Bell * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -30,7 +30,7 @@ #include "block.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/str.c b/str.c index 2e82265..94d205c 100644 --- a/str.c +++ b/str.c @@ -38,7 +38,7 @@ #include "strl.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/symbol.c b/symbol.c index de9b66e..0fce915 100644 --- a/symbol.c +++ b/symbol.c @@ -35,7 +35,7 @@ #include "func.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/token.c b/token.c index cb25f28..503c662 100644 --- a/token.c +++ b/token.c @@ -37,7 +37,7 @@ #include "lib_calc.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/value.c b/value.c index 26cf423..d5e05e6 100644 --- a/value.c +++ b/value.c @@ -37,10 +37,9 @@ #include "nametype.h" #include "file.h" #include "config.h" + + #include "errtbl.h" - - -#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -1066,12 +1065,12 @@ apprvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) case V_NULL: e = conf->epsilon; break; default: - *vres = error_value(E_APPR2); + *vres = error_value(E_APPR_2); return; } switch(v3->v_type) { case V_NUM: if (qisfrac(v3->v_num)) { - *vres = error_value(E_APPR3); + *vres = error_value(E_APPR_3); return; } R = qtoi(v3->v_num); @@ -1079,7 +1078,7 @@ apprvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) case V_NULL: R = conf->appr; break; default: - *vres = error_value(E_APPR3); + *vres = error_value(E_APPR_3); return; } @@ -1114,7 +1113,7 @@ apprvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) vres->v_com = c; return; default: - *vres = error_value(E_APPR); + *vres = error_value(E_APPR_1); return; } } @@ -1149,7 +1148,7 @@ roundvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) switch (v2->v_type) { case V_NUM: if (qisfrac(v2->v_num)) { - *vres = error_value(E_ROUND2); + *vres = error_value(E_ROUND_2); return; } places = qtoi(v2->v_num); @@ -1157,14 +1156,14 @@ roundvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) case V_NULL: break; default: - *vres = error_value(E_ROUND2); + *vres = error_value(E_ROUND_2); return; } rnd = 0; switch (v3->v_type) { case V_NUM: if (qisfrac(v3->v_num)) { - *vres = error_value(E_ROUND3); + *vres = error_value(E_ROUND_3); return; } rnd = qtoi(v3->v_num); @@ -1173,7 +1172,7 @@ roundvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) rnd = conf->round; break; default: - *vres = error_value(E_ROUND3); + *vres = error_value(E_ROUND_3); return; } switch(v1->v_type) { @@ -1199,7 +1198,7 @@ roundvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) default: if (v1->v_type <= 0) return; - *vres = error_value(E_ROUND); + *vres = error_value(E_ROUND_1); return; } } @@ -1235,7 +1234,7 @@ broundvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) switch (v2->v_type) { case V_NUM: if (qisfrac(v2->v_num)) { - *vres = error_value(E_BROUND2); + *vres = error_value(E_BROUND_2); return; } places = qtoi(v2->v_num); @@ -1243,14 +1242,14 @@ broundvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) case V_NULL: break; default: - *vres = error_value(E_BROUND2); + *vres = error_value(E_BROUND_2); return; } rnd = 0; switch (v3->v_type) { case V_NUM: if (qisfrac(v3->v_num)) { - *vres = error_value(E_BROUND3); + *vres = error_value(E_BROUND_3); return; } rnd = qtoi(v3->v_num); @@ -1259,7 +1258,7 @@ broundvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) rnd = conf->round; break; default: - *vres = error_value(E_BROUND3); + *vres = error_value(E_BROUND_3); return; } switch(v1->v_type) { @@ -1518,7 +1517,7 @@ sqrtvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) q = conf->epsilon; } else { if (v2->v_type != V_NUM || qiszero(v2->v_num)) { - *vres = error_value(E_SQRT2); + *vres = error_value(E_SQRT_2); return; } q = v2->v_num; @@ -1527,7 +1526,7 @@ sqrtvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) R = conf->sqrt; } else { if (v3->v_type != V_NUM || qisfrac(v3->v_num)) { - *vres = error_value(E_SQRT3); + *vres = error_value(E_SQRT_3); return; } R = qtoi(v3->v_num); @@ -1550,7 +1549,7 @@ sqrtvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) vres->v_com = c_sqrt(v1->v_com, q, R); break; default: - *vres = error_value(E_SQRT); + *vres = error_value(E_SQRT_1); return; } c = vres->v_com; @@ -1585,16 +1584,16 @@ rootvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) return; } if (v2->v_type != V_NUM) { - *vres = error_value(E_ROOT2); + *vres = error_value(E_ROOT_2); return; } q2 = v2->v_num; if (qisneg(q2) || qiszero(q2) || qisfrac(q2)) { - *vres = error_value(E_ROOT2); + *vres = error_value(E_ROOT_2); return; } if (v3->v_type != V_NUM || qiszero(v3->v_num)) { - *vres = error_value(E_ROOT3); + *vres = error_value(E_ROOT_3); return; } q3 = v3->v_num; @@ -1603,7 +1602,7 @@ rootvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) if (!qisneg(v1->v_num)) { vres->v_num = qroot(v1->v_num, q2, q3); if (vres->v_num == NULL) - *vres = error_value(E_ROOT4); + *vres = error_value(E_ROOT_4); vres->v_type = V_NUM; return; } @@ -1619,11 +1618,11 @@ rootvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) *vres = objcall(OBJ_ROOT, v1, v2, v3); return; default: - *vres = error_value(E_ROOT); + *vres = error_value(E_ROOT_1); return; } if (c == NULL) { - *vres = error_value(E_ROOT4); + *vres = error_value(E_ROOT_4); return; } vres->v_com = c; @@ -1663,13 +1662,13 @@ absvalue(VALUE *v1, VALUE *v2, VALUE *vres) break; case V_COM: if (v2->v_type != V_NUM || qiszero(v2->v_num)) { - *vres = error_value(E_ABS2); + *vres = error_value(E_ABS_2); return; } q = qhypot(v1->v_com->real, v1->v_com->imag, v2->v_num); break; default: - *vres = error_value(E_ABS); + *vres = error_value(E_ABS_1); return; } vres->v_num = q; @@ -1741,12 +1740,12 @@ shiftvalue(VALUE *v1, VALUE *v2, bool rightshift, VALUE *vres) return; } if ((v2->v_type != V_NUM) || (qisfrac(v2->v_num))) { - *vres = error_value(E_SHIFT2); + *vres = error_value(E_SHIFT_2); return; } if (v1->v_type != V_OBJ) { if (zge31b(v2->v_num->num)) { - *vres = error_value(E_SHIFT2); + *vres = error_value(E_SHIFT_2); return; } n = qtoi(v2->v_num); @@ -1757,7 +1756,7 @@ shiftvalue(VALUE *v1, VALUE *v2, bool rightshift, VALUE *vres) switch (v1->v_type) { case V_NUM: if (qisfrac(v1->v_num)) { - *vres = error_value(E_SHIFT); + *vres = error_value(E_SHIFT_1); return; } vres->v_num = qshift(v1->v_num, n); @@ -1765,7 +1764,7 @@ shiftvalue(VALUE *v1, VALUE *v2, bool rightshift, VALUE *vres) case V_COM: if (qisfrac(v1->v_com->real) || qisfrac(v1->v_com->imag)) { - *vres = error_value(E_SHIFT); + *vres = error_value(E_SHIFT_1); return; } c = c_shift(v1->v_com, n); @@ -1806,7 +1805,7 @@ shiftvalue(VALUE *v1, VALUE *v2, bool rightshift, VALUE *vres) qfree(tmp.v_num); return; default: - *vres = error_value(E_SHIFT); + *vres = error_value(E_SHIFT_1); return; } } @@ -1827,12 +1826,12 @@ scalevalue(VALUE *v1, VALUE *v2, VALUE *vres) return; } if ((v2->v_type != V_NUM) || qisfrac(v2->v_num)) { - *vres = error_value(E_SCALE2); + *vres = error_value(E_SCALE_2); return; } if (v1->v_type != V_OBJ) { if (zge31b(v2->v_num->num)) { - *vres = error_value(E_SCALE2); + *vres = error_value(E_SCALE_2); return; } n = qtoi(v2->v_num); @@ -1852,7 +1851,7 @@ scalevalue(VALUE *v1, VALUE *v2, VALUE *vres) *vres = objcall(OBJ_SCALE, v1, v2, NULL_VALUE); return; default: - *vres = error_value(E_SCALE); + *vres = error_value(E_SCALE_1); return; } } @@ -1942,7 +1941,7 @@ powvalue(VALUE *v1, VALUE *v2, VALUE *vres) vres->v_mat = matpowi(v1->v_mat, real_v2); break; default: - *vres = error_value(E_POWI); + *vres = error_value(E_POWI_1); break; } break; @@ -2009,14 +2008,14 @@ powvalue(VALUE *v1, VALUE *v2, VALUE *vres) } break; default: - *vres = error_value(E_POWI); + *vres = error_value(E_POWI_1); break; } break; /* unsupported exponent type */ default: - *vres = error_value(E_POWI2); + *vres = error_value(E_POWI_2); break; } return; @@ -2041,11 +2040,11 @@ powervalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) return; } if (v1->v_type != V_NUM && v1->v_type != V_COM) { - *vres = error_value(E_POWER); + *vres = error_value(E_POWER_1); return; } if (v2->v_type != V_NUM && v2->v_type != V_COM) { - *vres = error_value(E_POWER2); + *vres = error_value(E_POWER_2); return; } @@ -2054,13 +2053,13 @@ powervalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) epsilon = conf->epsilon; } else { if (v3->v_type != V_NUM || qiszero(v3->v_num)) { - *vres = error_value(E_POWER3); + *vres = error_value(E_POWER_3); return; } epsilon = v3->v_num; } if (qiszero(epsilon)) { - *vres = error_value(E_POWER3); + *vres = error_value(E_POWER_3); return; } @@ -2080,7 +2079,7 @@ powervalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) vres->v_num = qpower(v1->v_num, v2->v_num, epsilon); vres->v_type = V_NUM; if (vres->v_num == NULL) - *vres = error_value(E_POWER4); + *vres = error_value(E_POWER_4); return; case TWOVAL(V_NUM, V_COM): ctmp1.real = v1->v_num; @@ -2098,7 +2097,7 @@ powervalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) c = c_power(v1->v_com, v2->v_com, epsilon); break; default: - *vres = error_value(E_POWER); + *vres = error_value(E_POWER_1); return; } /* @@ -2233,14 +2232,14 @@ quovalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) return; } if (v2->v_type != V_NUM) { - *vres = error_value(E_QUO2); + *vres = error_value(E_QUO_2); return; } rnd = 0; switch (v3->v_type) { case V_NUM: if (qisfrac(v3->v_num)) { - *vres = error_value(E_QUO3); + *vres = error_value(E_QUO_3); return; } rnd = qtoi(v3->v_num); @@ -2249,7 +2248,7 @@ quovalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) rnd = conf->quo; break; default: - *vres = error_value(E_QUO3); + *vres = error_value(E_QUO_3); return; } switch (v1->v_type) { @@ -2273,7 +2272,7 @@ quovalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) vres->v_com = c; return; default: - *vres = error_value(E_QUO); + *vres = error_value(E_QUO_1); return; } } @@ -2312,14 +2311,14 @@ modvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) return; } if (v2->v_type != V_NUM) { - *vres = error_value(E_MOD2); + *vres = error_value(E_MOD_2); return; } rnd = 0; switch (v3->v_type) { case V_NUM: if (qisfrac(v3->v_num)) { - *vres = error_value(E_MOD3); + *vres = error_value(E_MOD_3); return; } rnd = qtoi(v3->v_num); @@ -2328,7 +2327,7 @@ modvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) rnd = conf->mod; break; default: - *vres = error_value(E_MOD3); + *vres = error_value(E_MOD_3); return; } switch (v1->v_type) { @@ -2352,7 +2351,7 @@ modvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) vres->v_com = c; return; default: - *vres = error_value(E_MOD); + *vres = error_value(E_MOD_1); return; } } diff --git a/value.h b/value.h index 7d9cc8f..c8b8021 100644 --- a/value.h +++ b/value.h @@ -1,7 +1,7 @@ /* * value - definitions of general values and related routines used by calc * - * Copyright (C) 1999-2007,2014,2021 David I. Bell + * Copyright (C) 1999-2007,2014,2021,2023 David I. Bell * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -33,21 +33,21 @@ # include "cmath.h" # include "config.h" # include "sha1.h" -# include "errsym.h" # include "hash.h" # include "block.h" # include "nametype.h" # include "str.h" +# include "errtbl.h" #else # include # include # include # include -# include # include # include # include # include +# include #endif @@ -81,9 +81,14 @@ typedef struct random RANDOM; * calc values * * See below for information on what needs to be added for a new type. + * + * NOTE: The v_type can be a negative value. This happens when + * an error is returned as a VALUE. + * + * XXX - calc v3 wish: make v_type and v_subtype an int32_t - XXX */ struct value { - short v_type; /* type of value */ + short v_type; /* type of value - IMPORTANT: v_type < 0 is an error code */ unsigned short v_subtype; /* other data related to some types */ union { /* types of values (see V_XYZ below) */ long vv_int; /* 1: small integer value */ @@ -131,7 +136,7 @@ struct value { /* - * Value types. XXX - calc v3 wish: make this and short v_type an enum - XXX + * Value types. * * NOTE: The following files should be checked/adjusted for a new type: * @@ -170,23 +175,28 @@ struct value { #define V_MAX V_NPTR /* highest legal value - must be last and match highest V_something value */ +/* + * v_subtype values + */ #define V_NOSUBTYPE 0 /* subtype has no meaning */ -#define V_NOASSIGNTO 1 /* protection status 1 */ -#define V_NONEWVALUE 2 /* protection status 2 */ -#define V_NONEWTYPE 4 /* protection status 4 */ -#define V_NOERROR 8 /* protection status 8 */ -#define V_NOCOPYTO 16 /* protection status 16 */ -#define V_NOREALLOC 32 /* protection status 32 */ -#define V_NOASSIGNFROM 64 /* protection status 64 */ -#define V_NOCOPYFROM 128 /* protection status 128 */ -#define V_PROTECTALL 256 /* protection status 256 */ +#define V_NOASSIGNTO 0x001 /* protection status 1 */ +#define V_NONEWVALUE 0x002 /* protection status 2 */ +#define V_NONEWTYPE 0x004 /* protection status 4 */ +#define V_NOERROR 0x008 /* protection status 8 */ +#define V_NOCOPYTO 0x010 /* protection status 16 */ +#define V_NOREALLOC 0x020 /* protection status 32 */ +#define V_NOASSIGNFROM 0x040 /* protection status 64 */ +#define V_NOCOPYFROM 0x080 /* protection status 128 */ +#define V_PROTECTALL 0x100 /* protection status 256 */ -#define MAXPROTECT 511 +#define MAXPROTECT 0x1ff /* OR of all of the above protection statuses */ /* * At present protect(var, sts) determines bits in var->v_subtype * corresponding to 4 * sts. MAXPROTECT is the sum of the simple * (power of two) protection status values. + * + * XXX - consider isseu #52 with respect to protect - XXX */ diff --git a/zfunc.c b/zfunc.c index 3f717e9..a007450 100644 --- a/zfunc.c +++ b/zfunc.c @@ -30,7 +30,7 @@ #include "alloc.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/zio.c b/zio.c index 460242a..b565bf8 100644 --- a/zio.c +++ b/zio.c @@ -31,7 +31,7 @@ #include "args.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/zmath.c b/zmath.c index 8746a80..d7c61c8 100644 --- a/zmath.c +++ b/zmath.c @@ -32,7 +32,7 @@ #include "zmath.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/zmath.h b/zmath.h index c4db6ab..f13c6e8 100644 --- a/zmath.h +++ b/zmath.h @@ -43,7 +43,6 @@ # include "longbits.h" # include "byteswap.h" # include "have_stdlib.h" -# include "attribute.h" # include "charbit.h" #else # include @@ -54,7 +53,6 @@ # include # include # include -# include # include #endif #ifdef HAVE_STDLIB_H @@ -657,13 +655,6 @@ E_FUNC LEN math_setdigits(LEN digits); E_FUNC void math_fmt(char *, ...) __attribute__((format(printf, 1, 2))); -/* - * The error routine. - */ -E_FUNC void math_error(char *, ...) \ - __attribute__((format(printf, 1, 2))) __attribute__((noreturn)); - - /* * external swap functions */ diff --git a/zmod.c b/zmod.c index 973b1e0..6b26992 100644 --- a/zmod.c +++ b/zmod.c @@ -41,7 +41,7 @@ #include "zmath.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/zmul.c b/zmul.c index 5474e4b..cbbee36 100644 --- a/zmul.c +++ b/zmul.c @@ -37,7 +37,7 @@ #include "zmath.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/zprime.c b/zprime.c index 5fd1a67..c0d6f12 100644 --- a/zprime.c +++ b/zprime.c @@ -33,7 +33,7 @@ #include "have_const.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/zrand.c b/zrand.c index b62098d..50394d0 100644 --- a/zrand.c +++ b/zrand.c @@ -357,7 +357,7 @@ #include "have_unused.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */ diff --git a/zrandom.c b/zrandom.c index 5d3449e..3c74a60 100644 --- a/zrandom.c +++ b/zrandom.c @@ -1099,7 +1099,7 @@ #include "have_unused.h" -#include "attribute.h" +#include "errtbl.h" #include "banned.h" /* include after system header <> includes */