1 --- bsd-finger-0.17/finger/finger.c.widechar 2005-12-15 09:14:18.000000000 +0100
2 +++ bsd-finger-0.17/finger/finger.c 2005-12-15 09:14:18.000000000 +0100
9 #include "../version.h"
12 struct sockaddr_in sin;
13 socklen_t slen = sizeof(sin);
15 + if (setlocale (LC_ALL, "") != NULL)
18 while ((ch = getopt(argc, argv, "lmps")) != EOF) {
21 --- bsd-finger-0.17/finger/finger.h.widechar 2005-12-15 09:14:17.000000000 +0100
22 +++ bsd-finger-0.17/finger/finger.h 2005-12-15 09:14:18.000000000 +0100
24 /* terminal inquiries */
26 int getscreenwidth(void);
29 +extern int has_locale;
30 +void set_haslocale(void);
32 --- bsd-finger-0.17/finger/display.c.widechar 1999-09-29 00:53:58.000000000 +0200
33 +++ bsd-finger-0.17/finger/display.c 2005-12-15 10:05:40.000000000 +0100
38 +#include <inttypes.h>
41 +#define HAVE_WCHAR_H 1
42 +#define HAVE_MBRTOWC 1
43 +#define HAVE_WCWIDTH 1
45 +#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH)
66 +#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH)
67 +static int verifymultibyte(const char *buf) {
70 + size_t bytesconsumed;
72 + (void)memset(&state, 0, sizeof(mbstate_t));
74 + eop = (char *) (buf + strlen(buf));
77 + bytesconsumed = mbrtowc(&nextchar, op, eop - op, &state);
78 + if (bytesconsumed == (size_t)(-1) ||
79 + bytesconsumed == (size_t)(-2)) {
82 + op += bytesconsumed;
88 +#define OCTALIFY(n, o) \
90 + *(n)++ = (((uint32_t)*(o) >> 6) & 3) + '0', \
91 + *(n)++ = (((uint32_t)*(o) >> 3) & 7) + '0', \
92 + *(n)++ = (((uint32_t)*(o) >> 0) & 7) + '0', \
97 static void fxputs(FILE *f, const char *buf) {
99 - for (i=0; buf[i]; i++) fxputc(f, buf[i]);
102 +#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH)
104 + widechars = verifymultibyte (buf);
111 + /* on 7-bit terminals, without wide-chars support, or string
112 + * isn't parseable, print char * by char */
113 + if (!is8bit() || !widechars) {
116 + for (i = 0; i < strlen (buf); i++) {
123 +#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH)
127 + size_t bytesconsumed;
128 + char *eop, *op, buffer[256];
129 + (void)memset(&state, 0, sizeof(mbstate_t));
131 + eop = (char *) (buf + strlen(buf));
135 + bytesconsumed = mbrtowc(&nextchar, op,
137 + /* This isn't supposed to happen as we verified the
138 + * string before hand */
139 + assert(bytesconsumed != (size_t)(-1) && bytesconsumed != (size_t)(-2));
141 + if (iswprint(nextchar)) {
142 + (void)memcpy(buffer, op, bytesconsumed);
143 + buffer[bytesconsumed] = '\0';
144 + op += bytesconsumed;
145 + } else if (bytesconsumed == 1) {
150 + buffer[bytesconsumed] = '\0';
151 + while (bytesconsumed-- > 0) {
156 + fprintf(f,"%s",op1);
161 int xprintf(const char *fmt, ...) {