mirror of
git://slackware.nl/current.git
synced 2024-12-30 10:24:23 +01:00
646a5c1cbf
a/pkgtools-15.0-noarch-13.txz: Rebuilt. installpkg: default line length for --terselength is the number of columns. removepkg: added --terse mode. upgradepkg: default line length for --terselength is the number of columns. upgradepkg: accept -option in addition to --option. ap/vim-8.1.0026-x86_64-1.txz: Upgraded. d/bison-3.0.5-x86_64-1.txz: Upgraded. e/emacs-26.1-x86_64-1.txz: Upgraded. kde/kopete-4.14.3-x86_64-8.txz: Rebuilt. Recompiled against libidn-1.35. n/conntrack-tools-1.4.5-x86_64-1.txz: Upgraded. n/libnetfilter_conntrack-1.0.7-x86_64-1.txz: Upgraded. n/libnftnl-1.1.0-x86_64-1.txz: Upgraded. n/links-2.16-x86_64-2.txz: Rebuilt. Rebuilt to enable X driver for -g mode. n/lynx-2.8.9dev.19-x86_64-1.txz: Upgraded. n/nftables-0.8.5-x86_64-1.txz: Upgraded. n/p11-kit-0.23.11-x86_64-1.txz: Upgraded. n/ulogd-2.0.7-x86_64-1.txz: Upgraded. n/whois-5.3.1-x86_64-1.txz: Upgraded. xap/network-manager-applet-1.8.12-x86_64-1.txz: Upgraded. xap/vim-gvim-8.1.0026-x86_64-1.txz: Upgraded.
170 lines
3.9 KiB
Diff
170 lines
3.9 KiB
Diff
--- bsd-finger-0.17/finger/finger.c.widechar 2005-12-15 09:14:18.000000000 +0100
|
|
+++ bsd-finger-0.17/finger/finger.c 2005-12-15 09:14:18.000000000 +0100
|
|
@@ -77,6 +77,7 @@
|
|
#include <getopt.h>
|
|
#include <signal.h>
|
|
#include <errno.h>
|
|
+#include <locale.h>
|
|
#include "finger.h"
|
|
#ifdef _USAGI
|
|
#include "version.h"
|
|
@@ -211,6 +212,9 @@
|
|
struct utmp *uptr;
|
|
char name[UT_NAMESIZE + 1];
|
|
|
|
+ if (setlocale (LC_ALL, "") != NULL)
|
|
+ set_haslocale();
|
|
+
|
|
name[UT_NAMESIZE] = '\0';
|
|
|
|
/*
|
|
@@ -286,6 +287,9 @@
|
|
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");
|
|
--- bsd-finger-0.17/finger/finger.h.widechar 2005-12-15 09:14:17.000000000 +0100
|
|
+++ bsd-finger-0.17/finger/finger.h 2005-12-15 09:14:18.000000000 +0100
|
|
@@ -117,3 +117,7 @@
|
|
/* terminal inquiries */
|
|
int is8bit(void);
|
|
int getscreenwidth(void);
|
|
+
|
|
+/* locale support */
|
|
+void set_haslocale(void);
|
|
+
|
|
--- bsd-finger-0.17/finger/display.c.widechar 1999-09-29 00:53:58.000000000 +0200
|
|
+++ bsd-finger-0.17/finger/display.c 2005-12-15 10:05:40.000000000 +0100
|
|
@@ -40,8 +40,19 @@
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdarg.h>
|
|
+#include <inttypes.h>
|
|
#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 <wchar.h>
|
|
+#include <wctype.h>
|
|
+#include <assert.h>
|
|
+#endif
|
|
+
|
|
int
|
|
getscreenwidth(void)
|
|
{
|
|
@@ -147,9 +158,105 @@
|
|
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));
|
|
+ char* op1;
|
|
+ eop = (char *) (buf + strlen(buf));
|
|
+ op = (char *) buf;
|
|
+ op1 = op;
|
|
+ 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) {
|
|
+ op++;
|
|
+ } else {
|
|
+ char *tmp;
|
|
+ tmp = buffer;
|
|
+ buffer[bytesconsumed] = '\0';
|
|
+ while (bytesconsumed-- > 0) {
|
|
+ OCTALIFY(tmp, op);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ fprintf(f,"%s",op1);
|
|
+ }
|
|
+#endif
|
|
}
|
|
|
|
int xprintf(const char *fmt, ...) {
|