diff --git a/bsd-finger-wide-char-support.patch b/bsd-finger-wide-char-support.patch new file mode 100644 index 0000000..7edc0d4 --- /dev/null +++ b/bsd-finger-wide-char-support.patch @@ -0,0 +1,162 @@ +diff -upr bsd-finger-0.17.bak/finger/display.c bsd-finger-0.17/finger/display.c +--- bsd-finger-0.17.bak/finger/display.c 1999-09-28 23:53:58.000000000 +0100 ++++ bsd-finger-0.17/finger/display.c 2005-12-13 15:40:36.389633972 +0000 +@@ -40,8 +40,19 @@ + #include + #include + #include ++#include + #include "finger.h" + ++#define HAVE_WCHAR_H 1 ++#define HAVE_MBRTOWC 1 ++#define HAVE_WCWIDTH 1 ++ ++#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH) ++#include ++#include ++#include ++#endif ++ + int + getscreenwidth(void) + { +@@ -147,9 +158,104 @@ xputc(int ch) + fxputc(stdout, ch); + } + ++static int has_locale = 0; ++ ++void ++set_haslocale (void) ++{ ++ has_locale = 1; ++} ++ ++#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH) ++static int verifymultibyte(const char *buf) { ++ mbstate_t state; ++ wchar_t nextchar; ++ size_t bytesconsumed; ++ char *eop, *op; ++ (void)memset(&state, 0, sizeof(mbstate_t)); ++ ++ eop = (char *) (buf + strlen(buf)); ++ op = (char *) buf; ++ while (op < eop) { ++ bytesconsumed = mbrtowc(&nextchar, op, eop - op, &state); ++ if (bytesconsumed == (size_t)(-1) || ++ bytesconsumed == (size_t)(-2)) { ++ return 0; ++ } ++ op += bytesconsumed; ++ } ++ ++ return 1; ++} ++ ++#define OCTALIFY(n, o) \ ++ *(n)++ = '\\', \ ++ *(n)++ = (((uint32_t)*(o) >> 6) & 3) + '0', \ ++ *(n)++ = (((uint32_t)*(o) >> 3) & 7) + '0', \ ++ *(n)++ = (((uint32_t)*(o) >> 0) & 7) + '0', \ ++ (o)++ ++ ++#endif ++ + static void fxputs(FILE *f, const char *buf) { +- int i; +- for (i=0; buf[i]; i++) fxputc(f, buf[i]); ++ int widechars; ++ ++#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH) ++ if (has_locale) ++ widechars = verifymultibyte (buf); ++ else ++ widechars = 0; ++#else ++ widechars = 0; ++#endif ++ ++ /* on 7-bit terminals, without wide-chars support, or string ++ * isn't parseable, print char * by char */ ++ if (!is8bit() || !widechars) { ++ unsigned int i; ++ char ch; ++ for (i = 0; i < strlen (buf); i++) { ++ ch = buf[i]; ++ fxputc(f, ch); ++ } ++ return; ++ } ++ ++#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH) ++ { ++ mbstate_t state; ++ wchar_t nextchar; ++ size_t bytesconsumed; ++ char *eop, *op, buffer[256]; ++ (void)memset(&state, 0, sizeof(mbstate_t)); ++ ++ eop = (char *) (buf + strlen(buf)); ++ op = (char *) buf; ++ while (op < eop) { ++ bytesconsumed = mbrtowc(&nextchar, op, ++ eop - op, &state); ++ /* This isn't supposed to happen as we verified the ++ * string before hand */ ++ assert(bytesconsumed != (size_t)(-1) && bytesconsumed != (size_t)(-2)); ++ ++ if (iswprint(nextchar)) { ++ (void)memcpy(buffer, op, bytesconsumed); ++ buffer[bytesconsumed] = '\0'; ++ op += bytesconsumed; ++ } else if (bytesconsumed == 1) { ++ fxputc(f, op[0]); ++ op++; ++ } else { ++ char *tmp; ++ tmp = buffer; ++ buffer[bytesconsumed] = '\0'; ++ while (bytesconsumed-- > 0) { ++ OCTALIFY(tmp, op); ++ } ++ } ++ } ++ } ++#endif + } + + int xprintf(const char *fmt, ...) { +diff -upr bsd-finger-0.17.bak/finger/finger.c bsd-finger-0.17/finger/finger.c +--- bsd-finger-0.17.bak/finger/finger.c 2005-11-28 11:53:18.000000000 +0000 ++++ bsd-finger-0.17/finger/finger.c 2005-12-13 15:36:48.892466719 +0000 +@@ -77,6 +77,7 @@ char finger_rcsid[] = \ + #include + #include + #include ++#include + #include "finger.h" + #ifdef _USAGI + #include "version.h" +@@ -286,6 +287,9 @@ userlist(int argc, char *argv[]) + struct utmp *uptr; + int dolocal, *used; + ++ if (setlocale (LC_ALL, "") != NULL) ++ set_haslocale(); ++ + used = calloc(argc, sizeof(int)); + if (!used) { + eprintf("finger: out of space.\n"); +diff -upr bsd-finger-0.17.bak/finger/finger.h bsd-finger-0.17/finger/finger.h +--- bsd-finger-0.17.bak/finger/finger.h 2005-11-28 11:53:18.000000000 +0000 ++++ bsd-finger-0.17/finger/finger.h 2005-12-13 15:36:27.233873039 +0000 +@@ -117,3 +117,7 @@ int eprintf(const char *fmt, ...); + /* terminal inquiries */ + int is8bit(void); + int getscreenwidth(void); ++ ++/* locale support */ ++void set_haslocale(void); ++ diff --git a/finger.spec b/finger.spec index c1fd4ca..6da5f1e 100644 --- a/finger.spec +++ b/finger.spec @@ -1,7 +1,7 @@ Summary: The finger client. Name: finger Version: 0.17 -Release: 30.1 +Release: 31 License: BSD Group: Applications/Internet Source: ftp://ftp.uk.linux.org/pub/linux/Networking/netkit/bsd-finger-%{version}.tar.gz @@ -15,7 +15,7 @@ Patch6: bsd-finger-0.17-usagi-ipv6.patch Patch7: bsd-finger-0.17-typo.patch Patch8: bsd-finger-0.17-strip.patch Patch9: bsd-finger-0.17-utmp.patch -Patch10: finger-munge-utf8-gecos.patch +Patch10: bsd-finger-wide-char-support.patch BuildRoot: %{_tmppath}/%{name}-root BuildRequires: gcc, glibc-devel, perl @@ -54,7 +54,7 @@ and you'd like finger information to be available. %patch7 -p1 -b .typo %patch8 -p1 -b .strip %patch9 -p1 -b .utmp -%patch10 -p1 -b .utf8 +%patch10 -p1 -b .widechar %build sh configure --enable-ipv6 @@ -96,6 +96,9 @@ rm -rf ${RPM_BUILD_ROOT} %{_mandir}/man8/fingerd.8* %changelog +* Tue Dec 13 2005 Radek Vokal 0.17-31 +- real UTF8 patch by + * Fri Dec 09 2005 Jesse Keating - rebuilt