Synchronize on NetBSD-CVS (2013/12/1 12:00:00 UTC)

- Fix for possible unset uid/gid in toproto
 - Fix for default mtree style
 - Update libelf
 - Importing libexecinfo
 - Resynchronize GCC, mpc, gmp, mpfr
 - build.sh: Replace params with show-params.
     This has been done as the make target has been renamed in the same
     way, while a new target named params has been added. This new
     target generates a file containing all the parameters, instead of
     printing it on the console.
 - Update test48 with new etc/services (Fix by Ben Gras <ben@minix3.org)
     get getservbyport() out of the inner loop

Change-Id: Ie6ad5226fa2621ff9f0dee8782ea48f9443d2091
This commit is contained in:
2013-12-06 12:04:52 +01:00
parent ff10274392
commit 84d9c625bf
4655 changed files with 379317 additions and 151059 deletions

View File

@@ -1,4 +1,4 @@
.\" $NetBSD: vis.1,v 1.14 2009/02/10 23:06:31 christos Exp $
.\" $NetBSD: vis.1,v 1.20 2013/10/29 12:27:23 njoly Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" @(#)vis.1 8.4 (Berkeley) 4/19/94
.\"
.Dd February 10, 2009
.Dd February 19, 2013
.Dt VIS 1
.Os
.Sh NAME
@@ -135,6 +135,26 @@ Tabs are also encoded.
White space (space-tab-newline) is also encoded.
.Pq Dv VIS_WHITE
.El
.Sh MULTIBYTE CHARACTER SUPPORT
.Nm
supports multibyte character input.
The encoding conversion is influenced by the setting of the
.Ev LC_CTYPE
environment variable which defines the set of characters that can be
copied without encoding.
.Pp
When 8-bit data is present in the input,
.Ev LC_CTYPE
must be set to the correct locale or to the C locale.
If the locales of the data and the conversion are mismatched, multibyte
character recognition may fail and encoding will be performed byte-by-byte
instead.
.Sh ENVIRONMENT
.Bl -tag -width ".Ev LC_CTYPE"
.It Ev LC_CTYPE
Specify the locale of the input data.
Set to C if the input data locale is unknown.
.El
.Sh SEE ALSO
.Xr unvis 1 ,
.Xr svis 3 ,
@@ -144,3 +164,7 @@ The
.Nm
command appears in
.Bx 4.4 .
Multibyte character support was added in
.Nx 7.0
and
.Fx 9.2 .

View File

@@ -1,4 +1,4 @@
/* $NetBSD: vis.c,v 1.15 2009/02/11 06:42:31 wiz Exp $ */
/* $NetBSD: vis.c,v 1.22 2013/02/20 17:04:45 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -39,12 +39,16 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\
#if 0
static char sccsid[] = "@(#)vis.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: vis.c,v 1.15 2009/02/11 06:42:31 wiz Exp $");
__RCSID("$NetBSD: vis.c,v 1.22 2013/02/20 17:04:45 christos Exp $");
#endif /* not lint */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <wchar.h>
#include <limits.h>
#include <unistd.h>
#include <err.h>
#include <vis.h>
@@ -55,7 +59,7 @@ static int eflags, fold, foldwidth = 80, none, markeol;
#ifdef DEBUG
int debug;
#endif
static char *extra;
static const char *extra = "";
static void process(FILE *);
@@ -157,29 +161,94 @@ process(FILE *fp)
static int col = 0;
static char nul[] = "\0";
char *cp = nul + 1; /* so *(cp-1) starts out != '\n' */
int c, rachar;
char buff[5];
wint_t c, c1, rachar;
char mbibuff[2 * MB_LEN_MAX + 1]; /* max space for 2 wchars */
char buff[4 * MB_LEN_MAX + 1]; /* max encoding length for one char */
int mbilen, cerr = 0, raerr = 0;
c = getc(fp);
while (c != EOF) {
rachar = getc(fp);
/*
* The input stream is considered to be multibyte characters.
* The input loop will read this data inputing one character,
* possibly multiple bytes, at a time and converting each to
* a wide character wchar_t.
*
* The vis(3) functions, however, require single either bytes
* or a multibyte string as their arguments. So we convert
* our input wchar_t and the following look-ahead wchar_t to
* a multibyte string for processing by vis(3).
*/
/* Read one multibyte character, store as wchar_t */
c = getwc(fp);
if (c == WEOF && errno == EILSEQ) {
/* Error in multibyte data. Read one byte. */
c = (wint_t)getc(fp);
cerr = 1;
}
while (c != WEOF) {
/* Clear multibyte input buffer. */
memset(mbibuff, 0, sizeof(mbibuff));
/* Read-ahead next multibyte character. */
if (!cerr)
rachar = getwc(fp);
if (cerr || (rachar == WEOF && errno == EILSEQ)) {
/* Error in multibyte data. Read one byte. */
rachar = (wint_t)getc(fp);
raerr = 1;
}
if (none) {
/* Handle -n flag. */
cp = buff;
*cp++ = c;
if (c == '\\')
*cp++ = '\\';
*cp = '\0';
} else if (markeol && c == '\n') {
/* Handle -l flag. */
cp = buff;
if ((eflags & VIS_NOSLASH) == 0)
*cp++ = '\\';
*cp++ = '$';
*cp++ = '\n';
*cp = '\0';
} else if (extra)
(void)svis(buff, (char)c, eflags, (char)rachar, extra);
else
(void)vis(buff, (char)c, eflags, (char)rachar);
} else {
/*
* Convert character using vis(3) library.
* At this point we will process one character.
* But we must pass the vis(3) library this
* character plus the next one because the next
* one is used as a look-ahead to decide how to
* encode this one under certain circumstances.
*
* Since our characters may be multibyte, e.g.,
* in the UTF-8 locale, we cannot use vis() and
* svis() which require byte input, so we must
* create a multibyte string and use strvisx().
*/
/* Treat EOF as a NUL char. */
c1 = rachar;
if (c1 == WEOF)
c1 = L'\0';
/*
* If we hit a multibyte conversion error above,
* insert byte directly into string buff because
* wctomb() will fail. Else convert wchar_t to
* multibyte using wctomb().
*/
if (cerr) {
*mbibuff = (char)c;
mbilen = 1;
} else
mbilen = wctomb(mbibuff, c);
/* Same for look-ahead character. */
if (raerr)
mbibuff[mbilen] = (char)c1;
else
wctomb(mbibuff + mbilen, c1);
/* Perform encoding on just first character. */
(void) strsenvisx(buff, 4 * MB_LEN_MAX, mbibuff,
1, eflags, extra, &cerr);
}
cp = buff;
if (fold) {
@@ -197,6 +266,7 @@ process(FILE *fp)
(void)putchar(*cp);
} while (*++cp);
c = rachar;
cerr = raerr;
}
/*
* terminate partial line with a hidden newline