summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/widechar.h17
-rw-r--r--misc-utils/cal.c16
-rw-r--r--text-utils/column.c6
-rw-r--r--text-utils/more.c8
-rw-r--r--text-utils/pg.c14
-rw-r--r--text-utils/ul.c2
6 files changed, 26 insertions, 37 deletions
diff --git a/include/widechar.h b/include/widechar.h
index d056aa394..b023b5fb2 100644
--- a/include/widechar.h
+++ b/include/widechar.h
@@ -2,23 +2,12 @@
/* This file must be included last because the redefinition of wchar_t may
cause conflicts when system include files were included after it. */
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
# include <wchar.h>
# include <wctype.h>
-#if 0 /* for testing on platforms without built-in wide character support */
-# include <libutf8.h>
-#endif
-#if 1
-/* explicit prototypes, since sometimes <wchar.h> does not give them */
-extern int wcwidth (wchar_t c); /* old: wint_t c */
-extern int wcswidth (const wchar_t *s, size_t n);
-extern size_t wcslen (const wchar_t *s);
-extern wchar_t *wcsdup (const wchar_t *s);
-#endif
-
-#else
+#else /* !HAVE_WIDECHAR */
# include <ctype.h>
/* Fallback for types */
@@ -46,4 +35,4 @@ extern wchar_t *wcsdup (const wchar_t *s);
# define wcwidth(c) 1
-#endif
+#endif /* HAVE_WIDECHAR */
diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index 339a61075..b0cca1db4 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -355,7 +355,7 @@ main(int argc, char **argv) {
exit(0);
}
-#ifndef ENABLE_WIDECHAR
+#ifndef HAVE_WIDECHAR
static char *eos(char *s) {
while (s && *s)
s++;
@@ -366,14 +366,14 @@ static char *eos(char *s) {
void headers_init(void)
{
int i, wd;
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
wchar_t day_headings_wc[22],j_day_headings_wc[29];
wchar_t wd_wc[10];
#endif
strcpy(day_headings,"");
strcpy(j_day_headings,"");
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
wcscpy(day_headings_wc,L"");
wcscpy(j_day_headings_wc,L"");
#endif
@@ -386,7 +386,7 @@ void headers_init(void)
for(i = 0 ; i < 7 ; i++ ) {
wd = (i + week1stday) % 7;
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
mbstowcs(wd_wc,weekday(wd),10);
if (wcswidth(wd_wc,10) < 3)
wcscat(j_day_headings_wc,L" ");
@@ -404,7 +404,7 @@ void headers_init(void)
#endif
}
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
wcstombs(day_headings,day_headings_wc,sizeof(day_headings));
wcstombs(j_day_headings,j_day_headings_wc,sizeof(j_day_headings));
#endif
@@ -723,7 +723,7 @@ trim_trailing_spaces(s)
void
center_str(const char* src, char* dest, size_t dest_size, int width)
{
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
wchar_t str_wc[FMT_ST_CHARS];
#endif
char str[FMT_ST_CHARS];
@@ -732,7 +732,7 @@ center_str(const char* src, char* dest, size_t dest_size, int width)
len = strlen(src);
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
if (mbstowcs(str_wc, src, FMT_ST_CHARS) > 0) {
wide_char_enabled = 1;
len = wcswidth(str_wc, SIZE(str_wc));
@@ -741,7 +741,7 @@ center_str(const char* src, char* dest, size_t dest_size, int width)
if (len > width) {
str_to_print=str;
if (wide_char_enabled) {
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
str_wc[width]=L'\0';
wcstombs(str, str_wc, SIZE(str));
#endif
diff --git a/text-utils/column.c b/text-utils/column.c
index 0320bd0a8..4e6193fb4 100644
--- a/text-utils/column.c
+++ b/text-utils/column.c
@@ -52,7 +52,7 @@
#include "widechar.h"
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
#define wcs_width(s) wcswidth(s,wcslen(s))
static wchar_t *mbs_to_wcs(const char *);
#else
@@ -312,7 +312,7 @@ input(fp)
}
}
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
static wchar_t *mbs_to_wcs(const char *s)
{
size_t n;
@@ -330,7 +330,7 @@ static wchar_t *mbs_to_wcs(const char *s)
}
#endif
-#ifndef ENABLE_WIDECHAR
+#ifndef HAVE_WIDECHAR
static char *mtsafe_strtok(char *str, const char *delim, char **ptr)
{
if (str == NULL) {
diff --git a/text-utils/more.c b/text-utils/more.c
index 72f2832a7..982edbece 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -739,7 +739,7 @@ int get_line(register FILE *f, int *length)
int column;
static int colflg;
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
int i;
wchar_t wc;
int wc_width;
@@ -762,7 +762,7 @@ int get_line(register FILE *f, int *length)
c = Getc (f);
}
while (p < &Line[LINSIZ - 1]) {
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
if (fold_opt && use_mbc_buffer_flag && MB_CUR_MAX > 1) {
use_mbc_buffer_flag = 0;
state_bak = state;
@@ -880,7 +880,7 @@ process_mbc:
*length = p - Line;
return (column);
} else {
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
if (fold_opt && MB_CUR_MAX > 1) {
memset (mbc, '\0', MB_LEN_MAX);
mbc_pos = 0;
@@ -1808,7 +1808,7 @@ void ttyin (unsigned char buf[], register int nmax, char pchar) {
}
else if (((cc_t) c == otty.c_cc[VERASE]) && !slash) {
if (sp > buf) {
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
if (MB_CUR_MAX > 1)
{
wchar_t wc;
diff --git a/text-utils/pg.c b/text-utils/pg.c
index eac12756c..10bdd1593 100644
--- a/text-utils/pg.c
+++ b/text-utils/pg.c
@@ -255,7 +255,7 @@ invopt(char *s)
usage();
}
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
/*
* A mbstowcs()-alike function that transparently handles invalid sequences.
*/
@@ -402,7 +402,7 @@ checkf(void)
return 0;
}
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
/*
* Return the last character that will fit on the line at col columns
* in case MB_CUR_MAX > 1.
@@ -489,7 +489,7 @@ endline(unsigned col, char *s)
unsigned pos = 0;
char *t = s;
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
if (MB_CUR_MAX > 1)
return endline_for_mb(col, s);
#endif
@@ -776,7 +776,7 @@ endprompt:
cmd.count = getcount(cmd.cmdline);
}
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
/*
* Remove backspace formatting, for searches
* in case MB_CUR_MAX > 1.
@@ -817,7 +817,7 @@ colb(char *s)
{
char *p = s, *q;
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
if (MB_CUR_MAX > 1)
return colb_for_mb(s);
#endif
@@ -836,7 +836,7 @@ colb(char *s)
return s;
}
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
/*
* Convert nonprintable characters to spaces
* in case MB_CUR_MAX > 1.
@@ -867,7 +867,7 @@ makeprint_for_mb(char *s, size_t l)
static void
makeprint(char *s, size_t l)
{
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
if (MB_CUR_MAX > 1)
return makeprint_for_mb(s, l);
#endif
diff --git a/text-utils/ul.c b/text-utils/ul.c
index 6396f2dfe..76c0a9703 100644
--- a/text-utils/ul.c
+++ b/text-utils/ul.c
@@ -50,7 +50,7 @@
#include "widechar.h"
-#ifdef ENABLE_WIDECHAR
+#ifdef HAVE_WIDECHAR
static int put1wc(int c) /* Output an ASCII character as a wide character */
{
if (putwchar(c) == WEOF)