sync with OpenBSD -current

This commit is contained in:
purplerain 2023-11-13 23:00:18 +00:00
parent 62d64fa864
commit 4574748555
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
13806 changed files with 1142078 additions and 937084 deletions

View file

@ -1,7 +1,9 @@
.\" $OpenBSD: mbtowc.3,v 1.6 2016/02/27 14:07:04 schwarze Exp $
.\" $OpenBSD: mbtowc.3,v 1.8 2023/11/11 01:38:23 schwarze Exp $
.\" $NetBSD: mbtowc.3,v 1.5 2003/09/08 17:54:31 wiz Exp $
.\"
.\" Copyright (c)2002 Citrus Project,
.\" Copyright (c) 2016, 2023 Ingo Schwarze <schwarze@openbsd.org>
.\" Copyright (c) 2010, 2015 Stefan Sperling <stsp@openbsd.org>
.\" Copyright (c) 2002 Citrus Project,
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@ -25,14 +27,12 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd $Mdocdate: February 27 2016 $
.Dd $Mdocdate: November 11 2023 $
.Dt MBTOWC 3
.Os
.\" ----------------------------------------------------------------------
.Sh NAME
.Nm mbtowc
.Nd converts a multibyte character to a wide character
.\" ----------------------------------------------------------------------
.Sh SYNOPSIS
.In stdlib.h
.Ft int
@ -61,13 +61,16 @@ be undefined.
.Pp
If a call to
.Fn mbtowc
resulted in an undefined internal state,
results in an undefined internal state, parsing of the string starting at
.Fa s
cannot continue, not even at a later byte, and
.Fn mbtowc
must be called with
.Ar s
set to
.Dv NULL
to reset the internal state before it can safely be used again.
to reset the internal state before it can safely be used again
on a different string.
.Pp
The behaviour of
.Fn mbtowc
@ -127,7 +130,6 @@ never form a complete character and
.Fn mbtowc
always fails.
.El
.\" ----------------------------------------------------------------------
.Sh RETURN VALUES
Normally,
.Fn mbtowc
@ -163,7 +165,55 @@ The current encoding is state-independent.
.It non-zero
The current encoding is state-dependent.
.El
.\" ----------------------------------------------------------------------
.Sh EXAMPLES
The following program parses a UTF-8 string and reports encoding errors:
.Bd -literal
#include <limits.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
int
main(void)
{
char s[LINE_MAX];
wchar_t wc;
int i, len;
setlocale(LC_CTYPE, "C.UTF-8");
if (fgets(s, sizeof(s), stdin) == NULL)
*s = '\e0';
for (i = 0, len = 1; len != 0; i += len) {
switch (len = mbtowc(&wc, s + i, MB_CUR_MAX)) {
case 0:
printf("byte %d end of string 0x00\en", i);
break;
case -1:
printf("byte %d invalid 0x%0.2hhx\en", i, s[i]);
len = 1;
break;
default:
printf("byte %d U+%0.4X %lc\en", i, wc, wc);
break;
}
}
return 0;
}
.Ed
.Pp
Recovering from encoding errors and continuing to parse the rest of the
string as shown above is only possible for state-independent character
encodings.
For full generality, the error handling can be modified
to reset the internal state.
In that case, the rest of the string has to be skipped
if the encoding is state-dependent:
.Bd -literal
case -1:
printf("byte %d invalid 0x%0.2hhx\en", i, s[i]);
len = !mbtowc(NULL, NULL, MB_CUR_MAX);
break;
.Ed
.Sh ERRORS
.Fn mbtowc
will set
@ -174,12 +224,10 @@ in the following cases:
.Fa s
points to an invalid or incomplete multibyte character.
.El
.\" ----------------------------------------------------------------------
.Sh SEE ALSO
.Xr mblen 3 ,
.Xr mbrtowc 3 ,
.Xr setlocale 3
.\" ----------------------------------------------------------------------
.Sh STANDARDS
The
.Fn mbtowc

View file

@ -1,4 +1,4 @@
.\" $OpenBSD: mount.2,v 1.51 2022/12/29 14:56:48 schwarze Exp $
.\" $OpenBSD: mount.2,v 1.52 2023/11/10 00:25:59 schwarze Exp $
.\" $NetBSD: mount.2,v 1.12 1996/02/29 23:47:48 jtc Exp $
.\"
.\" Copyright (c) 1980, 1989, 1993
@ -30,7 +30,7 @@
.\"
.\" @(#)mount.2 8.2 (Berkeley) 12/11/93
.\"
.Dd $Mdocdate: December 29 2022 $
.Dd $Mdocdate: November 10 2023 $
.Dt MOUNT 2
.Os
.Sh NAME
@ -92,9 +92,9 @@ All I/O to the filesystem should be done synchronously.
.It Dv MNT_ASYNC
All I/O to the filesystem should be done asynchronously.
.It Dv MNT_SOFTDEP
Use soft dependencies.
Applies to FFS filesystems only (see 'softdep' in
.Xr mount 8 ) .
Use soft dependencies on an FFS filesystem.
This flag is provided for compatibility only and has no effect on
.Ox .
.It Dv MNT_WXALLOWED
Processes that ask for memory to be made writeable plus executable
using the