From owner-svn-src-head@freebsd.org Mon Jan 18 20:47:05 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AD640A87025; Mon, 18 Jan 2016 20:47:05 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 65F1517A2; Mon, 18 Jan 2016 20:47:05 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u0IKl4UZ098516; Mon, 18 Jan 2016 20:47:04 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u0IKl4Qi098515; Mon, 18 Jan 2016 20:47:04 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201601182047.u0IKl4Qi098515@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Mon, 18 Jan 2016 20:47:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r294293 - head/usr.bin/finger X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jan 2016 20:47:05 -0000 Author: bapt Date: Mon Jan 18 20:47:04 2016 New Revision: 294293 URL: https://svnweb.freebsd.org/changeset/base/294293 Log: Fix printing multibyte printing when performing a networked finger(1) request MFC after: 1 week Modified: head/usr.bin/finger/net.c Modified: head/usr.bin/finger/net.c ============================================================================== --- head/usr.bin/finger/net.c Mon Jan 18 20:44:29 2016 (r294292) +++ head/usr.bin/finger/net.c Mon Jan 18 20:47:04 2016 (r294293) @@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #include @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "finger.h" static void cleanup(int sig); @@ -108,7 +109,7 @@ do_protocol(const char *name, const stru { int cnt, line_len, s; FILE *fp; - int c, lastc; + wint_t c, lastc; struct iovec iov[3]; struct msghdr msg; static char slash_w[] = "/W "; @@ -168,7 +169,7 @@ do_protocol(const char *name, const stru if ((fp = fdopen(s, "r")) != NULL) { cnt = 0; line_len = 0; - while ((c = getc(fp)) != EOF) { + while ((c = getwc(fp)) != EOF) { if (++cnt > OUTPUT_MAX) { printf("\n\n Output truncated at %d bytes...\n", cnt - 1); @@ -180,7 +181,7 @@ do_protocol(const char *name, const stru c = '\n'; lastc = '\r'; } else { - if (!isprint(c) && !isspace(c)) { + if (!iswprint(c) && !iswspace(c)) { c &= 0x7f; c |= 0x40; } @@ -191,7 +192,7 @@ do_protocol(const char *name, const stru continue; } } - putchar(c); + putwchar(c); if (c != '\n' && ++line_len > _POSIX2_LINE_MAX) { putchar('\\'); putchar('\n'); @@ -206,7 +207,7 @@ do_protocol(const char *name, const stru */ warn("reading from network"); } - if (lastc != '\n') + if (lastc != L'\n') putchar('\n'); fclose(fp);