Make <wchar.t> and mbstowcs mandatory. Get rid of some conditional compilation.

This commit is contained in:
Dianne Skoll
2025-12-18 15:21:18 -05:00
parent 0933cd83b1
commit 62e1a467f5
12 changed files with 29 additions and 129 deletions

11
configure vendored
View File

@@ -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 <wctype.h> 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'`

View File

@@ -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 <wctype.h> 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'`

View File

@@ -23,10 +23,8 @@
#include <sys/ioctl.h>
#include <unistd.h>
#ifdef REM_USE_WCHAR
#include <wctype.h>
#include <wchar.h>
#endif
#ifdef HAVE_LANGINFO_H
#include <langinfo.h>
@@ -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; i<len && i<width; i++) {
fputc(*(s+i), stdout);
}
while (i++ < width) putchar(pad);
#else
size_t len = mbstowcs(NULL, s, 0);
int i;
wchar_t static_buf[128];
@@ -1413,8 +1390,6 @@ static void PrintLeft(char const *s, int width, char pad)
i++;
}
if (buf != static_buf) free(buf);
#endif
}
/***************************************************************/
@@ -1426,26 +1401,6 @@ static void PrintLeft(char const *s, int width, char pad)
/***************************************************************/
static void PrintCentered(char const *s, int width, char const *pad)
{
#ifndef REM_USE_WCHAR
int len = strlen(s);
int d = (width - len) / 2;
int i;
for (i=0; i<d; i++) fputs(pad, stdout);
for (i=0; i<width-d; i++) {
if (*s) {
if (isspace(*s)) {
putchar(' ');
s++;
} else {
putchar(*s++);
}
} else {
break;
}
}
for (i=d+len; i<width; i++) fputs(pad, stdout);
#else
size_t len = mbstowcs(NULL, s, 0);
int display_len;
int i;
@@ -1500,7 +1455,6 @@ static void PrintCentered(char const *s, int width, char const *pad)
i++;
}
if (buf != static_buf) free(buf);
#endif
}
/***************************************************************/
@@ -1567,11 +1521,10 @@ static int WriteOneColLine(int col)
char const *s;
char const *space;
#ifdef REM_USE_WCHAR
wchar_t const *ws;
wchar_t const *wspace;
int width;
#endif
int clamp = 1;
int numwritten = 0;
int d = ColToDay[col];
@@ -1581,7 +1534,6 @@ static int WriteOneColLine(int col)
clamp = 0;
}
/* Print as many characters as possible within the column */
#ifdef REM_USE_WCHAR
if (e->wc_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;

View File

@@ -27,9 +27,6 @@
/* Define to 1 if you have the <locale.h> 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 <wctype.h> header file. */
#undef HAVE_WCTYPE_H
/* Define to 1 if you have the <readline/history.h> header file. */
#undef HAVE_READLINE_HISTORY_H

View File

@@ -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

View File

@@ -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

View File

@@ -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",

View File

@@ -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<max_str_put && *s; y++) {
switch(*s) {

View File

@@ -18,11 +18,9 @@
#define __EXTENSIONS__
#endif
#ifdef REM_USE_WCHAR
#define _XOPEN_SOURCE 600
#include <wctype.h>
#include <wchar.h>
#endif
#include <stdio.h>
@@ -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.

View File

@@ -39,10 +39,8 @@
#include <time.h>
#include <sys/types.h>
#ifdef REM_USE_WCHAR
#include <wctype.h>
#include <wchar.h>
#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) {

View File

@@ -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 <wctype.h>
#include <wchar.h>
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

View File

@@ -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" ""