From 62e1a467f549f5c8b88005b2f5e336e3d8c530e8 Mon Sep 17 00:00:00 2001 From: Dianne Skoll Date: Thu, 18 Dec 2025 15:21:18 -0500 Subject: [PATCH] Make and mbstowcs mandatory. Get rid of some conditional compilation. --- configure | 11 +++++++++ configure.ac | 11 +++++++++ src/calendar.c | 63 +------------------------------------------------ src/config.h.in | 6 ----- src/custom.h | 6 ----- src/custom.h.in | 6 ----- src/err.h | 10 ++++---- src/expr.c | 6 ----- src/funcs.c | 29 +---------------------- src/main.c | 7 +----- src/protos.h | 2 -- tests/test.cmp | 1 - 12 files changed, 29 insertions(+), 129 deletions(-) diff --git a/configure b/configure index be8466f5..c2094f93 100755 --- a/configure +++ b/configure @@ -4316,6 +4316,12 @@ if test "$?" != 0 ; then echo "*** COULD NOT DETERMINE RELEASE DATE: docs/WHATSNEW is incorrect!" exit 1 fi + +if test "$ac_cv_header_wctype_h" != "yes" ; then + echo "*** Remind requires the header" + exit 1 +fi + ac_fn_c_check_func "$LINENO" "strdup" "ac_cv_func_strdup" if test "x$ac_cv_func_strdup" = xyes then : @@ -4384,6 +4390,11 @@ then : fi +if test "$ac_cv_func_mbstowcs" != "yes"; then + echo "*** Remind requires the mbstowcs function" + exit 1 +fi + VERSION=$PACKAGE_VERSION CONFIG_CMD="$0$ac_configure_args_raw" CONFIG_CMD=`echo "$CONFIG_CMD" | sed -e 's/"/\\\\"/g'` diff --git a/configure.ac b/configure.ac index fc382ad5..418413a3 100644 --- a/configure.ac +++ b/configure.ac @@ -103,8 +103,19 @@ if test "$?" != 0 ; then echo "*** COULD NOT DETERMINE RELEASE DATE: docs/WHATSNEW is incorrect!" exit 1 fi + +if test "$ac_cv_header_wctype_h" != "yes" ; then + echo "*** Remind requires the header" + exit 1 +fi + AC_CHECK_FUNCS(strdup strcasecmp strncasecmp setenv unsetenv glob mbstowcs setlocale initgroups inotify_init1 readline) +if test "$ac_cv_func_mbstowcs" != "yes"; then + echo "*** Remind requires the mbstowcs function" + exit 1 +fi + VERSION=$PACKAGE_VERSION CONFIG_CMD="$0$ac_configure_args_raw" CONFIG_CMD=`echo "$CONFIG_CMD" | sed -e 's/"/\\\\"/g'` diff --git a/src/calendar.c b/src/calendar.c index 78d06b39..edd060d3 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -23,10 +23,8 @@ #include #include -#ifdef REM_USE_WCHAR #include #include -#endif #ifdef HAVE_LANGINFO_H #include @@ -44,10 +42,8 @@ typedef struct cal_entry { char *text; char *raw_text; char const *pos; -#ifdef REM_USE_WCHAR wchar_t *wc_text; wchar_t const *wc_pos; -#endif int is_color; int r, g, b; int time; @@ -360,7 +356,6 @@ UnBackgroundize(int d) printf("%s", Decolorize()); } -#ifdef REM_USE_WCHAR static void send_lrm(void) { @@ -375,7 +370,6 @@ send_lrm(void) printf("\xE2\x80\x8E"); } } -#endif static char const * despace(char const *s) @@ -532,7 +526,6 @@ static void PrintJSONKeyPairTime(char const *name, int t) } -#ifdef REM_USE_WCHAR void PutWideChar(wchar_t const wc, DynamicBuffer *output) { char buf[MB_CUR_MAX+1]; @@ -548,16 +541,11 @@ void PutWideChar(wchar_t const wc, DynamicBuffer *output) } } } -#endif static char const * get_month_abbrev(char const *mon) { static char buf[80]; -#ifndef REM_USE_WCHAR - snprintf(buf, sizeof(buf), "%.3s", mon); - return buf; -#else char *s; wchar_t tmp_buf[128] = {0}; wchar_t *ws; @@ -582,10 +570,8 @@ get_month_abbrev(char const *mon) } *s = 0; return buf; -#endif } -#ifdef REM_USE_WCHAR static int make_wchar_versions(CalEntry *e) { size_t len; @@ -602,7 +588,6 @@ static int make_wchar_versions(CalEntry *e) e->wc_pos = buf; return 1; } -#endif static void gon(void) { @@ -1355,14 +1340,6 @@ static int WriteCalendarRow(void) /***************************************************************/ static void PrintLeft(char const *s, int width, char pad) { -#ifndef REM_USE_WCHAR - int len = strlen(s); - int i; - for (i=0; iwc_text) { wspace = NULL; ws = e->wc_pos; @@ -1694,7 +1646,6 @@ static int WriteOneColLine(int col) } if (CalColumn[col]) return 1; else return 0; } else { -#endif space = NULL; s = e->pos; @@ -1704,9 +1655,7 @@ static int WriteOneColLine(int col) PrintLeft("", ColSpaces, ' '); CalColumn[col] = e->next; free(e->text); -#ifdef REM_USE_WCHAR if (e->wc_text) free(e->wc_text); -#endif free(e->raw_text); FreeTrigInfoChain(e->infos); free(e); @@ -1766,9 +1715,7 @@ static int WriteOneColLine(int col) if (!*s && !e->next) { CalColumn[col] = e->next; free(e->text); -#ifdef REM_USE_WCHAR if (e->wc_text) free(e->wc_text); -#endif free(e->raw_text); FreeTrigInfoChain(e->infos); free(e); @@ -1776,9 +1723,7 @@ static int WriteOneColLine(int col) e->pos = s; } if (CalColumn[col]) return 1; else return 0; -#ifdef REM_USE_WCHAR } -#endif } /***************************************************************/ @@ -2393,10 +2338,8 @@ static int DoCalRem(ParsePtr p, int col) e->trig.tz = StrDup(e->trig.tz); } e->tt = tim; -#ifdef REM_USE_WCHAR e->wc_pos = NULL; e->wc_text = NULL; -#endif e->is_color = is_color; e->r = col_r; e->g = col_g; @@ -2414,9 +2357,7 @@ static int DoCalRem(ParsePtr p, int col) FreeTrig(&trig); return E_NO_MEM; } -#ifdef REM_USE_WCHAR make_wchar_versions(e); -#endif DBufInit(&(e->tags)); DBufPuts(&(e->tags), DBufValue(&(trig.tags))); if (SynthesizeTags) { @@ -2826,9 +2767,7 @@ static void WriteSimpleEntries(int col, int dse) free(e->text); free(e->raw_text); FreeTrigInfoChain(e->infos); -#ifdef REM_USE_WCHAR if (e->wc_text) free(e->wc_text); -#endif n = e->next; free(e); e = n; diff --git a/src/config.h.in b/src/config.h.in index 15dd2c10..7aea6589 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -27,9 +27,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LOCALE_H -/* Define to 1 if you have the `mbstowcs' function. */ -#undef HAVE_MBSTOWCS - /* Define to 1 if you have the `setenv' function. */ #undef HAVE_SETENV @@ -84,9 +81,6 @@ /* Define to 1 if you have the `unsetenv' function. */ #undef HAVE_UNSETENV -/* Define to 1 if you have the header file. */ -#undef HAVE_WCTYPE_H - /* Define to 1 if you have the header file. */ #undef HAVE_READLINE_HISTORY_H diff --git a/src/custom.h b/src/custom.h index 06b779c9..d7e5d04f 100644 --- a/src/custom.h +++ b/src/custom.h @@ -154,12 +154,6 @@ #define PSBEGIN2 "# rem2ps2 begin" #define PSEND2 "# rem2ps2 end" -#if defined(HAVE_MBSTOWCS) && defined(HAVE_WCTYPE_H) -#define REM_USE_WCHAR 1 -#else -#undef REM_USE_WCHAR -#endif - #if defined(HAVE_READLINE) && defined(HAVE_READLINE_READLINE_H) #define USE_READLINE 1 #else diff --git a/src/custom.h.in b/src/custom.h.in index 06b779c9..d7e5d04f 100644 --- a/src/custom.h.in +++ b/src/custom.h.in @@ -154,12 +154,6 @@ #define PSBEGIN2 "# rem2ps2 begin" #define PSEND2 "# rem2ps2 end" -#if defined(HAVE_MBSTOWCS) && defined(HAVE_WCTYPE_H) -#define REM_USE_WCHAR 1 -#else -#undef REM_USE_WCHAR -#endif - #if defined(HAVE_READLINE) && defined(HAVE_READLINE_READLINE_H) #define USE_READLINE 1 #else diff --git a/src/err.h b/src/err.h index 953cba6a..fc4a51a6 100644 --- a/src/err.h +++ b/src/err.h @@ -134,11 +134,10 @@ #define E_MAX_OVERDUE_WITHOUT_TODO 110 #define E_TZ_SPECIFIED_TWICE 111 #define E_TZ_NO_AT 112 -#define E_NO_MB 113 -#define E_BAD_MB_SEQ 114 -#define E_EXPR_NODES_EXCEEDED 115 -#define E_EXPECTING_EOXPR 116 -#define E_EXPECTING_ATOM 117 +#define E_BAD_MB_SEQ 113 +#define E_EXPR_NODES_EXCEEDED 114 +#define E_EXPECTING_EOXPR 115 +#define E_EXPECTING_ATOM 116 #ifdef MK_GLOBALS #undef EXTERN @@ -270,7 +269,6 @@ EXTERN char *ErrMsg[] /* E_MAX_OVERDUE_WITHOUT_TODO */ "MAX-OVERDUE specified without TODO", /* E_TZ_SPECIFIED_TWICE */ "TZ specified twice", /* E_TZ_NO_AT */ "TZ specified for non-timed reminder", -/* E_NO_MB */ "C library does not support multibyte characters", /* E_BAD_MB_SEQ */ "Invalid multibyte sequence", /* E_EXPR_NODES_EXCEEDED */ "Maximum expression complexity exceeded", /* E_EXPECTING_EOXPR */ "Expecting operator or end-of-expression", diff --git a/src/expr.c b/src/expr.c index f28668d3..ae2775f2 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2994,7 +2994,6 @@ int EvalExpr(char const **e, Value *v, ParsePtr p) return r; } -#ifdef REM_USE_WCHAR /* Truncate a wide-char string to MAX_PRT_LEN characters */ static char const *truncate_string(char const *src) { @@ -3014,7 +3013,6 @@ static char const *truncate_string(char const *src) cbuf[MAX_PRT_LEN*8] = 0; return cbuf; } -#endif /***************************************************************/ /* */ @@ -3040,7 +3038,6 @@ char const *PrintValue (Value const *v, FILE *fp) } if (v->type == STR_TYPE) { -#ifdef REM_USE_WCHAR s = (unsigned char const *) truncate_string(v->v.str); if (s != (unsigned char const *) v->v.str) { max_str_put = INT_MAX; @@ -3048,9 +3045,6 @@ char const *PrintValue (Value const *v, FILE *fp) truncated = 1; } } -#else - s = (unsigned char const *) v->v.str; -#endif PV_PUTC(fp, '"'); for (y=0; y #include -#endif #include @@ -506,7 +504,6 @@ static int FStrlen(func_info *info) /***************************************************************/ static int FMbstrlen(func_info *info) { -#ifdef REM_USE_WCHAR ASSERT_TYPE(0, STR_TYPE); size_t l = mbstowcs(NULL, ARGSTR(0), 0); if (l == (size_t) -1) { @@ -516,9 +513,6 @@ static int FMbstrlen(func_info *info) RetVal.type = INT_TYPE; RETVAL = (int) l; return OK; -#else - return E_NO_MB; -#endif } /***************************************************************/ @@ -768,7 +762,6 @@ static int FHex(func_info *info) /***************************************************************/ static int FCodepoint(func_info *info) { -#ifdef REM_USE_WCHAR wchar_t arr[2]; size_t len; @@ -782,9 +775,6 @@ static int FCodepoint(func_info *info) RetVal.type = INT_TYPE; RETVAL = (int) arr[0]; return OK; -#else - return E_NO_MB; -#endif } /***************************************************************/ @@ -843,7 +833,6 @@ static int FChar(func_info *info) /***************************************************************/ static int FMbchar(func_info *info) { -#ifdef REM_USE_WCHAR int i; size_t len; wchar_t *arr; @@ -889,9 +878,6 @@ static int FMbchar(func_info *info) RetVal.type = STR_TYPE; RetVal.v.str = s; return OK; -#else - return E_NO_MB; -#endif } /***************************************************************/ @@ -2564,7 +2550,6 @@ static int FSubstr(func_info *info) /***************************************************************/ static int FMbsubstr(func_info *info) { -#ifdef REM_USE_WCHAR wchar_t *str; wchar_t *s; wchar_t const *t; @@ -2619,9 +2604,6 @@ static int FMbsubstr(func_info *info) RetVal.v.str = converted; free( (void *) str); return OK; -#else - return E_NO_MB; -#endif } /***************************************************************/ @@ -2671,7 +2653,6 @@ static int FIndex(func_info *info) /***************************************************************/ static int FMbindex(func_info *info) { -#ifdef REM_USE_WCHAR wchar_t *haystack; wchar_t *needle; wchar_t const *s; @@ -2724,9 +2705,6 @@ static int FMbindex(func_info *info) free( (void *) haystack); free( (void *) needle); return OK; -#else - return E_NO_MB; -#endif } /***************************************************************/ @@ -4798,16 +4776,14 @@ static int FRows(func_info *info) } static int FColumns(func_info *info) { -#ifdef REM_USE_WCHAR size_t len; wchar_t *buf, *s; int width; -#endif + if (Nargs == 0) { return rows_or_cols(info, 0); } ASSERT_TYPE(0, STR_TYPE); -#ifdef REM_USE_WCHAR len = mbstowcs(NULL, ARGSTR(0), 0); if (len == (size_t) -1) return E_NO_MEM; buf = calloc(len+1, sizeof(wchar_t)); @@ -4835,9 +4811,6 @@ static int FColumns(func_info *info) RetVal.type = INT_TYPE; RETVAL = width; return OK; -#else - return E_BAD_TYPE; -#endif } /* The following sets of functions are for computing solstices and equinoxes. diff --git a/src/main.c b/src/main.c index a8033ab4..ec75e140 100644 --- a/src/main.c +++ b/src/main.c @@ -39,10 +39,8 @@ #include #include -#ifdef REM_USE_WCHAR #include #include -#endif #include "types.h" #include "protos.h" @@ -1730,7 +1728,6 @@ static char const *OutputEscapeSequences(char const *s, int print, DynamicBuffer return s; } -#ifdef REM_USE_WCHAR #define ISWBLANK(c) (iswspace(c) && (c) != '\n') static wchar_t const *OutputEscapeSequencesWS(wchar_t const *s, int print, DynamicBuffer *output) { @@ -1848,7 +1845,7 @@ FillParagraphWC(char const *s, DynamicBuffer *output) free(buf); return OK; } -#endif + /***************************************************************/ /* */ /* FillParagraph */ @@ -1881,11 +1878,9 @@ void FillParagraph(char const *s, DynamicBuffer *output) while(ISBLANK(*s)) s++; if (!*s) return; -#ifdef REM_USE_WCHAR if (FillParagraphWC(s, output) == OK) { return; } -#endif /* Start formatting */ while(1) { diff --git a/src/protos.h b/src/protos.h index 76f9522a..f6a7893a 100644 --- a/src/protos.h +++ b/src/protos.h @@ -224,12 +224,10 @@ void FixSpecialType(Trigger *trig); void WriteJSONTrigger(Trigger const *t, int include_tags); void WriteJSONTimeTrigger(TimeTrig const *tt); int GetOnceDate(void); -#ifdef REM_USE_WCHAR #define _XOPEN_SOURCE 600 #include #include void PutWideChar(wchar_t const wc, DynamicBuffer *output); -#endif /* These functions are in utils.c and are used to detect overflow in various arithmetic operators. They have to be in separate diff --git a/tests/test.cmp b/tests/test.cmp index 92c70b6b..254ea773 100644 --- a/tests/test.cmp +++ b/tests/test.cmp @@ -25071,7 +25071,6 @@ TRANSLATE "MAX-OVERDUE specified twice" "" TRANSLATE "MAX-OVERDUE specified without TODO" "" TRANSLATE "TZ specified twice" "" TRANSLATE "TZ specified for non-timed reminder" "" -TRANSLATE "C library does not support multibyte characters" "" TRANSLATE "Invalid multibyte sequence" "" TRANSLATE "Maximum expression complexity exceeded" "" TRANSLATE "Expecting operator or end-of-expression" ""