CVS commit: src/lib/libutil

2024-05-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May  2 18:34:01 UTC 2024

Modified Files:
src/lib/libutil: parsedate.3

Log Message:
parsedate.3: resolve contradictory values for 'next'


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/libutil/parsedate.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2024-05-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu May  2 18:34:01 UTC 2024

Modified Files:
src/lib/libutil: parsedate.3

Log Message:
parsedate.3: resolve contradictory values for 'next'


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/libutil/parsedate.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/parsedate.3
diff -u src/lib/libutil/parsedate.3:1.26 src/lib/libutil/parsedate.3:1.27
--- src/lib/libutil/parsedate.3:1.26	Sun May 16 19:42:35 2021
+++ src/lib/libutil/parsedate.3	Thu May  2 18:34:01 2024
@@ -1,4 +1,4 @@
-.\" $NetBSD: parsedate.3,v 1.26 2021/05/16 19:42:35 kre Exp $
+.\" $NetBSD: parsedate.3,v 1.27 2024/05/02 18:34:01 rillig Exp $
 .\"
 .\" Copyright (c) 2006 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -96,7 +96,8 @@ The following words have the indicated n
 .Dv first , next ,
 or
 .Dv one =
-1,
+1
+.Pq but see the BUGS section below ,
 .Dv second
 is unused so that it is not confused with
 .Dq seconds ,



CVS commit: src/lib/libutil

2024-05-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu May  2 14:19:56 UTC 2024

Modified Files:
src/lib/libutil: parsedate.y

Log Message:
revert previous.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/lib/libutil/parsedate.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/parsedate.y
diff -u src/lib/libutil/parsedate.y:1.39 src/lib/libutil/parsedate.y:1.40
--- src/lib/libutil/parsedate.y:1.39	Wed May  1 15:59:07 2024
+++ src/lib/libutil/parsedate.y	Thu May  2 10:19:56 2024
@@ -12,7 +12,7 @@
 
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: parsedate.y,v 1.39 2024/05/01 19:59:07 christos Exp $");
+__RCSID("$NetBSD: parsedate.y,v 1.40 2024/05/02 14:19:56 christos Exp $");
 #endif
 
 #include 
@@ -546,7 +546,7 @@ static const TABLE OtherTable[] = {
 { "now",		tMINUTE_UNIT,	0 },
 { "last",		tUNUMBER,	-1 },
 { "this",		tMINUTE_UNIT,	0 },
-{ "next",		tUNUMBER,	1 },
+{ "next",		tUNUMBER,	2 },	/* it is more useful this way */
 { "first",		tUNUMBER,	1 },
 { "one",		tUNUMBER,	1 },
 /*  { "second",		tUNUMBER,	2 }, */



CVS commit: src/lib/libutil

2024-05-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu May  2 14:19:56 UTC 2024

Modified Files:
src/lib/libutil: parsedate.y

Log Message:
revert previous.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/lib/libutil/parsedate.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/lib/libutil

2024-05-01 Thread Robert Elz
Date:Wed, 1 May 2024 22:27:02 +0200
From:Roland Illig 
Message-ID:  <754bd755-be0a-4eff-aa7b-d53fce9b4...@gmx.de>

  | > Log Message:
  | > next should increement by 1 not 2.
  |
  | Are you sure?

I agree, that change should be reverted.

"next" is even documented to be two ...

 6  Despite what is stated above, ?next? is actually 2.  The input ?next
January?, instead of producing a timestamp for January of the
following year, produces one for January 2nd, of the current year.
Use caution with ?next? it rarely does what humans expect.  For
example, on a Sunday ?next sunday? means the following Sunday (7 days
hence) whereas ?next monday? means the monday that follows that (8
days hence) rather than ?tomorrow? or just ?Mon? (without the ?next?)
which is the nearest subsequent Monday.

and is actually more useful that way.   It is peculiar, but that's how it
has worked ~forever.

There are limits to how sane a half hearted (but still useful) attempt
to understand English idiom can possibly work, we really don't want to
attempt to turn parsedate into an AI machine.

kre




Re: CVS commit: src/lib/libutil

2024-05-01 Thread Roland Illig
Am 01.05.2024 um 21:59 schrieb Christos Zoulas:
> Module Name:  src
> Committed By: christos
> Date: Wed May  1 19:59:08 UTC 2024
>
> Modified Files:
>   src/lib/libutil: parsedate.y
>
> Log Message:
> next should increement by 1 not 2.

Are you sure? I get these test results:

> t_parsedate (2/5): 7 test cases
> atsecs: [0.006548s] Passed.
> dates: [0.007241s] Passed.
> dsttimes: [0.007517s] Passed.
> gibberish: [0.007637s] Passed.
> relative: [0.287375s] Failed: 2258 checks failed; see output for more 
> details
> times: [0.008402s] Passed.
> zones: [0.007586s] Passed.

After your change, "next sunday" goes backward in time, for example:

> From 28110552 (Sun Nov 22 08:29:12 1970) using "next sunday",
> obtained 2808 (Sun Nov 22 00:00:00 1970);
> expected 28684800 (Sun Nov 29 00:00:00 1970)



CVS commit: src/lib/libutil

2024-05-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May  1 19:59:08 UTC 2024

Modified Files:
src/lib/libutil: parsedate.y

Log Message:
next should increement by 1 not 2.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/lib/libutil/parsedate.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/parsedate.y
diff -u src/lib/libutil/parsedate.y:1.38 src/lib/libutil/parsedate.y:1.39
--- src/lib/libutil/parsedate.y:1.38	Thu Feb 29 15:55:35 2024
+++ src/lib/libutil/parsedate.y	Wed May  1 15:59:07 2024
@@ -12,7 +12,7 @@
 
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: parsedate.y,v 1.38 2024/02/29 20:55:35 rillig Exp $");
+__RCSID("$NetBSD: parsedate.y,v 1.39 2024/05/01 19:59:07 christos Exp $");
 #endif
 
 #include 
@@ -546,7 +546,7 @@ static const TABLE OtherTable[] = {
 { "now",		tMINUTE_UNIT,	0 },
 { "last",		tUNUMBER,	-1 },
 { "this",		tMINUTE_UNIT,	0 },
-{ "next",		tUNUMBER,	2 },
+{ "next",		tUNUMBER,	1 },
 { "first",		tUNUMBER,	1 },
 { "one",		tUNUMBER,	1 },
 /*  { "second",		tUNUMBER,	2 }, */



CVS commit: src/lib/libutil

2024-05-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May  1 19:59:08 UTC 2024

Modified Files:
src/lib/libutil: parsedate.y

Log Message:
next should increement by 1 not 2.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/lib/libutil/parsedate.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/lib/libutil

2024-04-09 Thread Valery Ushakov
On Mon, Apr 08, 2024 at 23:31:16 +0200, Roland Illig wrote:

> Am 08.04.2024 um 21:18 schrieb Valery Ushakov:
> >   "=\017FIFTEEN\0"
> >
> > with its result a few lines below that has:
> >
> >   BURST=0xf=FIFTEEN
> 
> Thank you for explaining this example. I had a gut feeling that there
> would be some hidden correlation between some octal/hexadecimal
> combinations, but I couldn't name it. Indeed, if the number base for
> output is hexadecimal, the field comparisons should be done in
> hexadecimal as well.
> 
> I adjusted the description and examples in the manual page accordingly.

Thanks!  My unscientific impression is that snprintb(3) was not very
popular and its uses sometimes are a bit of a cargo-cult, so existing
use cases have to be taken with a grain of salt and don't necessarily
represent good style.  This is why improving the docs with good
examples is important, imho.


-uwe


Re: CVS commit: src/lib/libutil

2024-04-08 Thread Roland Illig
Am 08.04.2024 um 21:18 schrieb Valery Ushakov:
>   "=\017FIFTEEN\0"
>
> with its result a few lines below that has:
>
>   BURST=0xf=FIFTEEN

Thank you for explaining this example. I had a gut feeling that there
would be some hidden correlation between some octal/hexadecimal
combinations, but I couldn't name it. Indeed, if the number base for
output is hexadecimal, the field comparisons should be done in
hexadecimal as well.

I adjusted the description and examples in the manual page accordingly.

Roland



Re: CVS commit: src/lib/libutil

2024-04-08 Thread Valery Ushakov
On Mon, Apr 08, 2024 at 20:21:07 +0200, Roland Illig wrote:

> I didn't eradicate _all_ hexadecimal examples, I just made each example
> use only one number base, not mix them both. There are both octal and
> hexadecimal examples in the manual page.

That's not what "prefer octal in examples" conveys.

I would also say that source code that says

  "=\x0f" "FIFTEEN\0"

aligns much better than

  "=\017FIFTEEN\0"

with its result a few lines below that has:

  BURST=0xf=FIFTEEN


-uwe


Re: CVS commit: src/lib/libutil

2024-04-08 Thread Roland Illig
Am 08.04.2024 um 03:24 schrieb Valery Ushakov:
> On Sun, Apr 07, 2024 at 14:28:27 +, Roland Illig wrote:
>
>> Log Message:
>> snprintb.3: clean up formatting and wording, prefer octal in examples
>>
>> Using hexadecimal character escapes requires separate string literals if
>> the description starts with one of the letters A-F; octal character
>> escapes have at most 3 digits, reducing ambiguity.
>
> 70s are over, very few people speak octal fluently.  If anything, the
> man page should highlight the potential snag.  Besides, separate
> literal for the name is good for readability anyway.

When I looked through the NetBSD tree exploring the current usage, I
found that a significant majority uses octal instead of hexadecimal. I
don't know the exact reasons for this, it might be due to existing
practice in the 1990s, to avoid splitting the bit position and the
description to separate string literals, to be able to easily split the
bit position into the byte and the bit portion mentally, or maybe
something entirely different.

While your claim that "very few people speak octal fluently" may be true
for programmers in general, I expect those using the snprintb function
to be more fluent than others. Of course, I saw cases where "\040" was
followed by "\039", just as I saw cases of "\x0fFIELD". Lint now warns
in both these cases.

Regarding the separate literals, I didn't see them in wide use up to
now. Existing code seems to focus more on compressing the source code
into as few lines as possible rather than making it easily readable. I
agree that separate string literals are more readable, and I converted
the example that uses hexadecimal escapes to this style.

I didn't eradicate _all_ hexadecimal examples, I just made each example
use only one number base, not mix them both. There are both octal and
hexadecimal examples in the manual page.

Roland



Re: CVS commit: src/lib/libutil

2024-04-07 Thread Valery Ushakov
On Sun, Apr 07, 2024 at 14:28:27 +, Roland Illig wrote:

> Log Message:
> snprintb.3: clean up formatting and wording, prefer octal in examples
> 
> Using hexadecimal character escapes requires separate string literals if
> the description starts with one of the letters A-F; octal character
> escapes have at most 3 digits, reducing ambiguity.

70s are over, very few people speak octal fluently.  If anything, the
man page should highlight the potential snag.  Besides, separate
literal for the name is good for readability anyway.

Please, revert.

-uwe


CVS commit: src/lib/libutil

2024-04-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Apr  7 14:28:27 UTC 2024

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
snprintb.3: clean up formatting and wording, prefer octal in examples

Using hexadecimal character escapes requires separate string literals if
the description starts with one of the letters A-F; octal character
escapes have at most 3 digits, reducing ambiguity.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/snprintb.3
diff -u src/lib/libutil/snprintb.3:1.37 src/lib/libutil/snprintb.3:1.38
--- src/lib/libutil/snprintb.3:1.37	Sun Apr  7 12:05:23 2024
+++ src/lib/libutil/snprintb.3	Sun Apr  7 14:28:26 2024
@@ -1,4 +1,4 @@
-.\" $NetBSD: snprintb.3,v 1.37 2024/04/07 12:05:23 rillig Exp $
+.\" $NetBSD: snprintb.3,v 1.38 2024/04/07 14:28:26 rillig Exp $
 .\"
 .\" Copyright (c) 1998, 2024 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd February 22, 2024
+.Dd April 7, 2024
 .Dt SNPRINTB 3
 .Os
 .Sh NAME
@@ -180,10 +180,10 @@ followed by type-specific parameters, ea
 followed by a
 .Tn NUL Ns -terminated description.
 The bit positions are 0-based,
-they range from
-.Sq \e000
-for the least significant bit to
-.Sq \e077
+ranging from
+.Ql \e000
+(0) for the least significant bit to
+.Ql \e077
 (63) for the most significant bit.
 .
 .Bl -tag -width Cm
@@ -252,15 +252,15 @@ If none of the previous
 .Sq Cm \&=
 or
 .Sq Cm \&:
-conversions matched, prints the field value, using the
-.Xr printf 3
-format
-.Ar fmt .
+conversions matched, prints the format string
+.Ar fmt
+via
+.Xr printf 3 .
 The format string
 .Ar fmt
 may contain a single
 .Vt uintmax_t
-conversion specification that prints the value that did not match.
+conversion specification to print the field value that did not match.
 .El
 .Pp
 The new format is terminated by an additional
@@ -285,15 +285,15 @@ total number of bytes.
 .Sh EXAMPLES
 Two examples of the old formatting style:
 .Bd -literal -offset indent
-snprintb(buf, bufsize, "\e10\e2BITTWO\e1BITONE", 3)
+snprintb(buf, bufsize, "\e010\e002BITTWO\e001BITONE", 3)
 \(rA "03"
 
 snprintb(buf, bufsize,
-"\e20"
-"\ex10NOTBOOT" "\ex0f""FPP" "\ex0eSDVMA"
-"\ex0cVIDEO" "\ex0bLORES" "\ex0a""FPA" "\ex09""DIAG"
-"\ex07""CACHE" "\ex06IOCACHE" "\ex05LOOPBACK"
-"\ex04""DBGCACHE",
+"\e020"
+"\ex10""NOTBOOT"   "\ex0f""FPP"   "\ex0e""SDVMA"
+"\ex0c""VIDEO" "\ex0b""LORES" "\ex0a""FPA"
+"\ex09""DIAG"  "\ex07""CACHE" "\ex06""IOCACHE"
+"\ex05""LOOPBACK"  "\ex04""DBGCACHE",
 0xe860)
 \(rA "0xe860"
 .Ed
@@ -302,9 +302,9 @@ An example of the new formatting style:
 .Bd -literal -offset indent
 snprintb(buf, bufsize,
 "\e177\e020"
-"b\e0LSB\e0" "b\e1BITONE\e0" "f\e4\e4NIBBLE2\e0"
-"f\ex10\e4BURST\e0" "=\e4FOUR\e0" "=\exf""FIFTEEN\e0"
-"b\ex1fMSB\e0",
+"b\e000LSB\e0" "b\e001BITONE\e0" "f\e004\e004NIBBLE2\e0"
+"f\e020\e004BURST\e0" "=\e004FOUR\e0" "=\e017FIFTEEN\e0"
+"b\e037MSB\e0",
 0x800f0701)
 \(rA "0x800f0701"
 .Ed
@@ -313,9 +313,9 @@ The same example using snprintb_m:
 .Bd -literal -offset indent
 snprintb_m(buf, bufsize,
 "\e177\e020"
-"b\e0LSB\e0" "b\e1BITONE\e0" "f\e4\e4NIBBLE2\e0"
-"f\ex10\e4BURST\e0" "=\e4FOUR\e0" "=\exf""FIFTEEN\e0"
-"b\ex1fMSB\e0",
+"b\e000LSB\e0" "b\e001BITONE\e0" "f\e004\e004NIBBLE2\e0"
+"f\e020\e004BURST\e0" "=\e004FOUR\e0" "=\e017FIFTEEN\e0"
+"b\e037MSB\e0",
 0x800f0701, 34)
 \(rA "0x800f0701\e0"
"0x800f0701\e0"



CVS commit: src/lib/libutil

2024-04-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Apr  7 14:28:27 UTC 2024

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
snprintb.3: clean up formatting and wording, prefer octal in examples

Using hexadecimal character escapes requires separate string literals if
the description starts with one of the letters A-F; octal character
escapes have at most 3 digits, reducing ambiguity.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2024-02-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Feb 29 21:08:55 UTC 2024

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
snprintb.3: fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/snprintb.3
diff -u src/lib/libutil/snprintb.3:1.35 src/lib/libutil/snprintb.3:1.36
--- src/lib/libutil/snprintb.3:1.35	Thu Feb 22 21:04:24 2024
+++ src/lib/libutil/snprintb.3	Thu Feb 29 21:08:54 2024
@@ -1,4 +1,4 @@
-.\" $NetBSD: snprintb.3,v 1.35 2024/02/22 21:04:24 rillig Exp $
+.\" $NetBSD: snprintb.3,v 1.36 2024/02/29 21:08:54 rillig Exp $
 .\"
 .\" Copyright (c) 1998, 2024 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -69,7 +69,7 @@ terminating
 If
 .Fa bufsize
 is zero, nothing is written and
-.Fa arg
+.Fa buf
 may be a null pointer.
 .Pp
 The



CVS commit: src/lib/libutil

2024-02-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Feb 29 21:08:55 UTC 2024

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
snprintb.3: fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2024-02-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Feb 29 20:55:35 UTC 2024

Modified Files:
src/lib/libutil: parsedate.y

Log Message:
parsedate.y: remove outdated comment

The number of shift/reduce conflicts has grown to 16.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/lib/libutil/parsedate.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/parsedate.y
diff -u src/lib/libutil/parsedate.y:1.37 src/lib/libutil/parsedate.y:1.38
--- src/lib/libutil/parsedate.y:1.37	Sat Apr 23 13:02:04 2022
+++ src/lib/libutil/parsedate.y	Thu Feb 29 20:55:35 2024
@@ -5,8 +5,6 @@
 **  a couple of people on Usenet.  Completely overhauled by Rich $alz
 **   and Jim Berets  in August, 1990;
 **
-**  This grammar has 10 shift/reduce conflicts.
-**
 **  This code is in the public domain and has no copyright.
 */
 /* SUPPRESS 287 on yaccpar_sccsid *//* Unused static variable */
@@ -14,7 +12,7 @@
 
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: parsedate.y,v 1.37 2022/04/23 13:02:04 christos Exp $");
+__RCSID("$NetBSD: parsedate.y,v 1.38 2024/02/29 20:55:35 rillig Exp $");
 #endif
 
 #include 



CVS commit: src/lib/libutil

2024-02-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Feb 29 20:55:35 UTC 2024

Modified Files:
src/lib/libutil: parsedate.y

Log Message:
parsedate.y: remove outdated comment

The number of shift/reduce conflicts has grown to 16.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/lib/libutil/parsedate.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2024-02-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Feb 20 20:38:54 UTC 2024

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
snprintb.3: sync examples with reality


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/snprintb.3
diff -u src/lib/libutil/snprintb.3:1.32 src/lib/libutil/snprintb.3:1.33
--- src/lib/libutil/snprintb.3:1.32	Sun Feb 18 16:55:02 2024
+++ src/lib/libutil/snprintb.3	Tue Feb 20 20:38:54 2024
@@ -1,4 +1,4 @@
-.\" $NetBSD: snprintb.3,v 1.32 2024/02/18 16:55:02 rillig Exp $
+.\" $NetBSD: snprintb.3,v 1.33 2024/02/20 20:38:54 rillig Exp $
 .\"
 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd February 18, 2024
+.Dd February 20, 2024
 .Dt SNPRINTB 3
 .Os
 .Sh NAME
@@ -305,7 +305,7 @@ snprintb(buf, bufsize,
 "f\ex10\e4BURST\e0" "=\e4FOUR\e0" "=\exf""FIFTEEN\e0"
 "b\ex1fMSB\e0",
 0x800f0701)
-\(rA "0x800f0701"
+\(rA "0x800f0701"
 .Ed
 .Pp
 The same example using snprintb_m:
@@ -316,7 +316,7 @@ snprintb_m(buf, bufsize,
 "f\ex10\e4BURST\e0" "=\e4FOUR\e0" "=\exf""FIFTEEN\e0"
 "b\ex1fMSB\e0",
 0x800f0701, 34)
-\(rA "0x800f0701\e0"
+\(rA "0x800f0701\e0"
"0x800f0701\e0"
""
 .Ed
@@ -377,7 +377,7 @@ snprintb(buf, bufsize, MAP_FMT, 0x0d0012
 \(rA "0xd001234"
 
 snprintb(buf, bufsize, MAP_FMT, 0x2e00)
-\(rA "0xd001234<0x2e00"
+\(rA "0x2e00"
 .Ed
 .Sh ERRORS
 .Fn snprintb



CVS commit: src/lib/libutil

2024-02-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Feb 20 20:38:54 UTC 2024

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
snprintb.3: sync examples with reality


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2024-02-04 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Feb  4 18:44:54 UTC 2024

Modified Files:
src/lib/libutil: getrawpartition.3

Log Message:
getrawpartition(3): reword to clarify return value, use .Pq

"'a' == 0" is, stricly speaking false, and since 'a' is an int, it's
not immediately clear if it's 'a' or 0 that is returned.  Try to
clarify this.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libutil/getrawpartition.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/getrawpartition.3
diff -u src/lib/libutil/getrawpartition.3:1.11 src/lib/libutil/getrawpartition.3:1.12
--- src/lib/libutil/getrawpartition.3:1.11	Tue May  4 06:41:27 2010
+++ src/lib/libutil/getrawpartition.3	Sun Feb  4 18:44:54 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: getrawpartition.3,v 1.11 2010/05/04 06:41:27 jruoho Exp $
+.\"	$NetBSD: getrawpartition.3,v 1.12 2024/02/04 18:44:54 uwe Exp $
 .\"
 .\" Copyright (c) 1996 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -43,11 +43,15 @@ partition
 .Fn getrawpartition void
 .Sh DESCRIPTION
 .Fn getrawpartition
-returns the partition number (
-.Sq a
-== 0,
-.Sq b
-== 1, ...) of the
+returns the partition number
+.Po
+0 for
+.Ql a ,
+1 for
+.Ql b ,
+etc
+.Pc
+of the
 .Dq raw
 partition of the system's disks,
 or \-1 in case of an error, setting the global



CVS commit: src/lib/libutil

2024-02-04 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Feb  4 18:44:54 UTC 2024

Modified Files:
src/lib/libutil: getrawpartition.3

Log Message:
getrawpartition(3): reword to clarify return value, use .Pq

"'a' == 0" is, stricly speaking false, and since 'a' is an int, it's
not immediately clear if it's 'a' or 0 that is returned.  Try to
clarify this.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libutil/getrawpartition.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2024-02-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Feb  1 22:18:34 UTC 2024

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
snprintb.3: fix examples, clean up wording

In the examples using hex escape sequences, there must be a delimiter
between the escape sequence and the following description if the
description starts with [A-Fa-f], as hex escape sequences are not
limited in length.

Distinguish between a 'directive' (bit + length + description) and a
'description' (only the text).

The fmt parameter is not a string, as strings only reach to the first
'\0' byte, but the new-style format may include additional '\0' as bit
numbers.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/snprintb.3
diff -u src/lib/libutil/snprintb.3:1.29 src/lib/libutil/snprintb.3:1.30
--- src/lib/libutil/snprintb.3:1.29	Mon Jan 22 00:11:21 2024
+++ src/lib/libutil/snprintb.3	Thu Feb  1 22:18:34 2024
@@ -1,4 +1,4 @@
-.\" $NetBSD: snprintb.3,v 1.29 2024/01/22 00:11:21 uwe Exp $
+.\" $NetBSD: snprintb.3,v 1.30 2024/02/01 22:18:34 rillig Exp $
 .\"
 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd January 21, 2024
+.Dd February 1, 2024
 .Dt SNPRINTB 3
 .Os
 .Sh NAME
@@ -56,7 +56,7 @@ into the buffer
 of size
 .Fa buflen ,
 using a specified radix and an interpretation of
-the bits within that integer as though they were flags.
+the bits within that integer as though they were flags or groups of bits.
 The buffer is always
 .Tn NUL Ns -terminated.
 If the buffer
@@ -98,7 +98,7 @@ additional
 character
 .Pq or, if you prefer, a zero-length string .
 .Pp
-The decoding directive string
+The decoding directive in
 .Fa fmt
 describes how the bitfield is to be interpreted and displayed.
 It follows two possible syntaxes, referred to as
@@ -113,7 +113,9 @@ The first character of
 .Fa fmt
 may be
 .Ql \e177 ,
-indicating that the remainder of the format string follows the
+indicating that the remainder of the
+.Fa fmt
+argument follows the
 .Dq new
 syntax.
 The second character
@@ -131,18 +133,17 @@ and
 .Ql \e20
 .Pq hexadecimal .
 .Pp
-The remaining characters in
+The remaining characters in the
 .Fa fmt
-are interpreted as a list of bit-position\(endescription pairs.
-From here the syntaxes diverge.
+argument are interpreted as a list of formatting directives.
 .
 .Ss Old Syntax
 .Pp
 The
 .Dq old
-format syntax is series of bit-position\(endescription pairs.
+format syntax is a series of bit-position\(endescription pairs.
 .Pp
-Each description begins with a binary character value that represents
+Each directive begins with a binary character value that represents
 the position of the bit being described.
 .Pp
 .Sy NB :
@@ -164,17 +165,19 @@ The old syntax is limited to 32-bit valu
 The remaining characters are the description to print should the bit
 being described be set.
 .Pp
-Description strings are delimited by the next bit position value character
+Descriptions are delimited by the next bit position value character
 encountered
 .Pq distinguishable by its value being \*[Le] 32 ,
-or the end of the decoding directive string itself.
+or by the end of the format string itself.
 .
 .Ss New Syntax
 .Pp
 For the
 .Dq new
-format syntax, a field description begins with a field type followed
-by a binary field position and possibly a field length.
+format syntax,
+a formatting directive begins with a field type
+followed by a binary field position and possibly a field length,
+followed by a description.
 The bit positions are 0-based,
 the least significant bit is bit-position zero.
 Each description is terminated by a
@@ -188,7 +191,7 @@ Describes a single bit at bit-position
 .Ar B .
 The remaining characters are the description to print should the bit
 being described be set.
-This field description is similar in function to the old format.
+This field directive is similar in function to the old format.
 When converting old formats to the new syntax don't forget that the
 new syntax uses zero-based bit positions.
 .
@@ -202,8 +205,9 @@ followed by
 .Ql \&=
 and the value of the field.
 The value of the field is printed in the base specified as the second
-character of the decoding directive string
-.Ar fmt .
+character of the
+.Ar fmt
+argument.
 .
 .It Cm F\e Ns Ar B Ns Cm \e Ns Ar L
 Describes a multi-bit field like
@@ -224,7 +228,7 @@ directive is compared to the byte value
 .Pq for values 0 through 255 .
 If they are equal,
 .Ql \&=
-followed by the string following
+followed by the description string following
 .Ar V
 is printed.
 This and the
@@ -240,7 +244,7 @@ directive, but omits the leading
 .It Cm * Ns Ar FMT
 This provides a
 

CVS commit: src/lib/libutil

2024-02-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Feb  1 22:18:34 UTC 2024

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
snprintb.3: fix examples, clean up wording

In the examples using hex escape sequences, there must be a delimiter
between the escape sequence and the following description if the
description starts with [A-Fa-f], as hex escape sequences are not
limited in length.

Distinguish between a 'directive' (bit + length + description) and a
'description' (only the text).

The fmt parameter is not a string, as strings only reach to the first
'\0' byte, but the new-style format may include additional '\0' as bit
numbers.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2024-01-21 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Jan 22 00:11:21 UTC 2024

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
snprintb(3): restore empty string in snprintb_m example

Restore the empty string at the end of snprintb_m output that was
accidentally removed along with empty string placeholders in the
format strings.  While here, move that example to be next to its
snprintb counterpart.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/snprintb.3
diff -u src/lib/libutil/snprintb.3:1.28 src/lib/libutil/snprintb.3:1.29
--- src/lib/libutil/snprintb.3:1.28	Sun Jan 21 23:57:49 2024
+++ src/lib/libutil/snprintb.3	Mon Jan 22 00:11:21 2024
@@ -1,4 +1,4 @@
-.\" $NetBSD: snprintb.3,v 1.28 2024/01/21 23:57:49 uwe Exp $
+.\" $NetBSD: snprintb.3,v 1.29 2024/01/22 00:11:21 uwe Exp $
 .\"
 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -304,6 +304,19 @@ snprintb(buf, buflen,
 \(rA "0x800f0701"
 .Ed
 .Pp
+The same example using snprintb_m:
+.Bd -literal -offset indent
+snprintb_m(buf, buflen,
+"\e177\e020"
+"b\e0LSB\e0" "b\e1BITONE\e0" "f\e4\e4NIBBLE2\e0"
+"f\ex10\e4BURST\e0" "=\e4FOUR\e0" "=\exfFIFTEEN\e0"
+"b\ex1fMSB\e0",
+0x800f0701, 34)
+\(rA "0x800f0701\e0"
+   "0x800f0701\e0"
+   ""
+.Ed
+.Pp
 A more complex example from
 .In sys/mman.h
 that uses the both bit position
@@ -360,19 +373,7 @@ snprintb(buf, buflen, MAP_FMT, 0x0d00123
 \(rA "0xd001234"
 
 snprintb(buf, buflen, MAP_FMT, 0x2e00)
-\(rA "0xd001234<0x2e00
-.Ed
-.Pp
-An example using snprintb_m:
-.Bd -literal -offset indent
-snprintb_m(buf, buflen,
-"\e177\e020"
-"b\e0LSB\e0" "b\e1BITONE\e0" "f\e4\e4NIBBLE2\e0"
-"f\ex10\e4BURST\e0" "=\e4FOUR\e0" "=\exfFIFTEEN\e0"
-"b\ex1fMSB\e0" "\e0",
-0x800f0701, 34)
-\(rA "0x800f0701\e0"
-   "0x800f0701\e0"
+\(rA "0xd001234<0x2e00"
 .Ed
 .Sh ERRORS
 .Fn snprintb



CVS commit: src/lib/libutil

2024-01-21 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon Jan 22 00:11:21 UTC 2024

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
snprintb(3): restore empty string in snprintb_m example

Restore the empty string at the end of snprintb_m output that was
accidentally removed along with empty string placeholders in the
format strings.  While here, move that example to be next to its
snprintb counterpart.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2024-01-21 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Jan 21 23:57:49 UTC 2024

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
snprintb(3): update mmap example

Bring over the prettier version of the mmap format string that we have
in the header file for some time now.  Clarify that the final NUL of
the new format string is supplied by the compiler, g/c explicit final
\0 from the example that had it.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2024-01-21 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Jan 21 23:57:49 UTC 2024

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
snprintb(3): update mmap example

Bring over the prettier version of the mmap format string that we have
in the header file for some time now.  Clarify that the final NUL of
the new format string is supplied by the compiler, g/c explicit final
\0 from the example that had it.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/snprintb.3
diff -u src/lib/libutil/snprintb.3:1.27 src/lib/libutil/snprintb.3:1.28
--- src/lib/libutil/snprintb.3:1.27	Sun Jan 21 23:44:30 2024
+++ src/lib/libutil/snprintb.3	Sun Jan 21 23:57:49 2024
@@ -1,4 +1,4 @@
-.\" $NetBSD: snprintb.3,v 1.27 2024/01/21 23:44:30 uwe Exp $
+.\" $NetBSD: snprintb.3,v 1.28 2024/01/21 23:57:49 uwe Exp $
 .\"
 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -260,6 +260,10 @@ The new format string is terminated by a
 .Tn NUL
 character at the end, following that delimiting the last
 bit-position\(endescription pair.
+This
+.Tn NUL
+is supplied by the compiler to terminate the string literal and
+doesn't need to be written explicitly.
 .Sh RETURN VALUES
 The
 .Fn snprintb
@@ -295,7 +299,7 @@ snprintb(buf, buflen,
 "b\e0LSB\e0" "b\e1BITONE\e0"
 "f\e4\e4NIBBLE2\e0"
 "f\ex10\e4BURST\e0" "=\e4FOUR\e0" "=\exfFIFTEEN\e0"
-"b\ex1fMSB\e0" "\e0",
+"b\ex1fMSB\e0",
 0x800f0701)
 \(rA "0x800f0701"
 .Ed
@@ -303,53 +307,58 @@ snprintb(buf, buflen,
 A more complex example from
 .In sys/mman.h
 that uses the both bit position
-.Sq b
+.Sq Cm b
 formatting as well as the
-.Sq F
-multi-field formatting with a default case:
+.Sq Cm F
+multibit field formatting with a default case
+.Pq Sq Cm \&* :
 .Bd -literal -offset indent
-#define MAP_FMT	"\e177\e020\e
-b\e0SHARED\e0\e
-b\e1PRIVATE\e0\e
-b\e2COPY\e0\e
-b\e4FIXED\e0\e
-b\e5RENAME\e0\e
-b\e6NORESERVE\e0\e
-b\e7INHERIT\e0\e
-b\e11HASSEMAPHORE\e0\e
-b\e12TRYFIXED\e0\e
-b\e13WIRED\e0\e
-F\e14\e1\e0\e
-:\e0FILE\e0\e
-:\e1ANONYMOUS\e0\e
-b\e15STACK\e0\e
-F\e30\e010\e0\e
-:\e000ALIGN=NONE\e0\e
-:\e012ALIGN=1KB\e0\e
-:\e013ALIGN=2KB\e0\e
-:\e014ALIGN=4KB\e0\e
-:\e015ALIGN=8KB\e0\e
-:\e016ALIGN=16KB\e0\e
-:\e017ALIGN=32KB\e0\e
-:\e020ALIGN=64KB\e0\e
-:\e021ALIGN=128KB\e0\e
-:\e022ALIGN=256KB\e0\e
-:\e023ALIGN=512KB\e0\e
-:\e024ALIGN=1MB\e0\e
-:\e030ALIGN=16MB\e0\e
-:\e034ALIGN=256MB\e0\e
-:\e040ALIGN=4GB\e0\e
-:\e044ALIGN=64GB\e0\e
-:\e050ALIGN=1TB\e0\e
-:\e054ALIGN=16TB\e0\e
-:\e060ALIGN=256TB\e0\e
-:\e064ALIGN=4PB\e0\e
-:\e070ALIGN=64PB\e0\e
-:\e074ALIGN=256PB\e0\e
-*ALIGN=2^%jd\e0\e
-"
+#define MAP_FMT "\e177\e020"  \e
+"b\e0"  "SHARED\e0"   \e
+"b\e1"  "PRIVATE\e0"  \e
+"b\e2"  "COPY\e0" \e
+"b\e4"  "FIXED\e0"\e
+"b\e5"  "RENAME\e0"   \e
+"b\e6"  "NORESERVE\e0"\e
+"b\e7"  "INHERIT\e0"  \e
+"b\e11" "HASSEMAPHORE\e0" \e
+"b\e12" "TRYFIXED\e0" \e
+"b\e13" "WIRED\e0"\e
+"F\e14\e1\e0"  \e
+":\e0" "FILE\e0"  \e
+":\e1" "ANONYMOUS\e0" \e
+"b\e15" "STACK\e0"\e
+"F\e30\e010\e0"\e
+":\e000" "ALIGN=NONE\e0"  \e
+":\e012" "ALIGN=1KB\e0"   \e
+":\e013" "ALIGN=2KB\e0"   \e
+":\e014" "ALIGN=4KB\e0"   \e
+":\e015" "ALIGN=8KB\e0"   \e
+":\e016" "ALIGN=16KB\e0"  \e
+":\e017" "ALIGN=32KB\e0"  \e
+":\e020" "ALIGN=64KB\e0"  \e
+":\e021" "ALIGN=128KB\e0" \e
+":\e022" "ALIGN=256KB\e0" \e
+":\e023" "ALIGN=512KB\e0" \e
+":\e024" "ALIGN=1MB\e0"   \e
+":\e025" "ALIGN=2MB\e0"   \e
+":\e026" "ALIGN=4MB\e0"   \e
+":\e027" "ALIGN=8MB\e0"   \e
+":\e030" "ALIGN=16MB\e0"  \e
+":\e034" "ALIGN=256MB\e0" \e
+":\e040" "ALIGN=4GB\e0"   \e
+":\e044" "ALIGN=64GB\e0"  \e
+":\e050" "ALIGN=1TB\e0"   \e
+":\e054" "ALIGN=16TB\e0"  \e
+":\e060" "ALIGN=256TB\e0" \e
+":\e064" "ALIGN=4PB\e0"   \e
+":\e070" "ALIGN=64PB\e0"  \e
+

CVS commit: src/lib/libutil

2024-01-21 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Jan 21 23:44:30 UTC 2024

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
snprintb(3): try to improve narration

Try to make the narration more coherent.  Make the old and new
syntaxes easy to distinguish and go out of our way to highlight that
the old syntax uses 1-based bit positions.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/snprintb.3
diff -u src/lib/libutil/snprintb.3:1.26 src/lib/libutil/snprintb.3:1.27
--- src/lib/libutil/snprintb.3:1.26	Sun Jan 21 22:06:46 2024
+++ src/lib/libutil/snprintb.3	Sun Jan 21 23:44:30 2024
@@ -1,4 +1,4 @@
-.\" $NetBSD: snprintb.3,v 1.26 2024/01/21 22:06:46 rillig Exp $
+.\" $NetBSD: snprintb.3,v 1.27 2024/01/21 23:44:30 uwe Exp $
 .\"
 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -57,14 +57,46 @@ of size
 .Fa buflen ,
 using a specified radix and an interpretation of
 the bits within that integer as though they were flags.
-The buffer is always NUL-terminated.
+The buffer is always
+.Tn NUL Ns -terminated.
 If the buffer
 .Fa buf
 is too small to hold the formatted output,
 .Fn snprintb
 will fill as much as it can, and return the number of bytes
 that it would have written if the buffer were long enough excluding the
-terminating NUL.
+terminating
+.Tn NUL .
+.Pp
+The
+.Fn snprintb_m
+function accepts an additional
+.Fa max
+argument.
+If this argument is zero, the
+.Fn snprintb_m
+function returns exactly the same results in the
+.Fa buf
+as the
+.Fn snprintb
+function.
+If the
+.Fa max
+argument has a non-zero value, it represents the maximum length of a
+formatted string.
+If the formatted string would require more than
+.Fa max
+characters, the
+.Fn snprintb_m
+function returns multiple formatted strings in the output buffer
+.Fa buf .
+Each string is
+.Tn NUL Ns -terminated ,
+and the last string is followed by an
+additional
+.Tn NUL
+character
+.Pq or, if you prefer, a zero-length string .
 .Pp
 The decoding directive string
 .Fa fmt
@@ -80,7 +112,7 @@ formatting is that it is capable of hand
 The first character of
 .Fa fmt
 may be
-.Li \e177 ,
+.Ql \e177 ,
 indicating that the remainder of the format string follows the
 .Dq new
 syntax.
@@ -91,142 +123,143 @@ output numeral base in which the bitfiel
 Recognized radix values
 .Pq in C escape-character format
 are
-.Li \e10
+.Ql \e10
 .Pq octal ,
-.Li \e12
+.Ql \e12
 .Pq decimal ,
 and
-.Li \e20
+.Ql \e20
 .Pq hexadecimal .
 .Pp
 The remaining characters in
 .Fa fmt
 are interpreted as a list of bit-position\(endescription pairs.
 From here the syntaxes diverge.
+.
+.Ss Old Syntax
 .Pp
 The
 .Dq old
 format syntax is series of bit-position\(endescription pairs.
-Each begins with a binary character value that represents the position
-of the bit being described.
-A bit position value of one describes the least significant bit.
+.Pp
+Each description begins with a binary character value that represents
+the position of the bit being described.
+.Pp
+.Sy NB :
+the bit positions in the old syntax are
+.Em 1-based\^ !
+A bit position value of 1
+.Pq Ql \e1
+describes the least significant bit.
 Whereas a position value of 32
-.Pq octal 40, hexadecimal 20, the ASCII space character
+.Po octal
+.Ql \e040 ,
+hexadecimal
+.Ql \ex20 ,
+the ASCII space character
+.Pc
 describes the most significant bit.
+The old syntax is limited to 32-bit values.
+.Pp
+The remaining characters are the description to print should the bit
+being described be set.
 .Pp
-The remaining characters in a bit-position\(endescription pair are the
-characters to print should the bit being described be set.
 Description strings are delimited by the next bit position value character
 encountered
 .Pq distinguishable by its value being \*[Le] 32 ,
 or the end of the decoding directive string itself.
+.
+.Ss New Syntax
 .Pp
 For the
 .Dq new
-format syntax, a bit-position\(endescription begins with a field type
-followed by a binary bit-position and possibly a field length.
-The least significant bit is bit-position zero, unlike the
-.Dq old
-syntax where it is one.
-.Bl -tag -width "x"
-.It Cm b\eB
-Describes a bit position.
-The bit-position
-.Fa B
-indicates the corresponding bit, as in the
-.Dq old
-format.
-.It Cm f\eB\eL
+format syntax, a field description begins with a field type followed
+by a binary field position and possibly a field length.
+The bit positions are 0-based,
+the least significant bit is bit-position zero.
+Each description is terminated by a
+.Tn NUL
+byte.
+.
+.Bl -tag -width Cm
+.
+.It Cm b\e Ns Ar B
+Describes a single bit at bit-position
+.Ar B .
+The remaining characters are the description to print should the bit
+being described be set.
+This field description is similar in function to the old format.

CVS commit: src/lib/libutil

2024-01-21 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Jan 21 23:44:30 UTC 2024

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
snprintb(3): try to improve narration

Try to make the narration more coherent.  Make the old and new
syntaxes easy to distinguish and go out of our way to highlight that
the old syntax uses 1-based bit positions.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2024-01-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 21 22:06:46 UTC 2024

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
snprintb.3: remove empty string literals from examples

Suggested by uwe@, as gaps in bitmasks are quite common and thus
shouldn't clutter the code.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/snprintb.3
diff -u src/lib/libutil/snprintb.3:1.25 src/lib/libutil/snprintb.3:1.26
--- src/lib/libutil/snprintb.3:1.25	Sun Jan 21 21:31:23 2024
+++ src/lib/libutil/snprintb.3	Sun Jan 21 22:06:46 2024
@@ -1,4 +1,4 @@
-.\" $NetBSD: snprintb.3,v 1.25 2024/01/21 21:31:23 rillig Exp $
+.\" $NetBSD: snprintb.3,v 1.26 2024/01/21 22:06:46 rillig Exp $
 .\"
 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -247,9 +247,9 @@ snprintb(buf, buflen, "\e10\e2BITTWO\e1B
 
 snprintb(buf, buflen,
 "\e20"
-"\ex10NOTBOOT" "\ex0fFPP" "\ex0eSDVMA" ""
+"\ex10NOTBOOT" "\ex0fFPP" "\ex0eSDVMA"
 "\ex0cVIDEO" "\ex0bLORES" "\ex0aFPA" "\ex09DIAG"
-"" "\ex07CACHE" "\ex06IOCACHE" "\ex05LOOPBACK"
+"\ex07CACHE" "\ex06IOCACHE" "\ex05LOOPBACK"
 "\ex04DBGCACHE",
 0xe860)
 \(rA "0xe860"
@@ -331,7 +331,6 @@ snprintb_m(buf, buflen,
 0x800f0701, 34)
 \(rA "0x800f0701\e0"
"0x800f0701\e0"
-   ""
 .Ed
 .Sh ERRORS
 .Fn snprintb



CVS commit: src/lib/libutil

2024-01-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 21 22:06:46 UTC 2024

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
snprintb.3: remove empty string literals from examples

Suggested by uwe@, as gaps in bitmasks are quite common and thus
shouldn't clutter the code.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/lib/libutil

2024-01-21 Thread Valery Ushakov
On Sun, Jan 21, 2024 at 21:31:23 +, Roland Illig wrote:

> and also didn't make it clear that a few bits were omitted from
> having descriptions.

I dislike this part.  It's internally inconsistent as it doesn't add
the placeholders for the low bits; and in many real-life scenarios
there will be *lots* of gaps in the defined bits, so implying in the
man page that the placeholders are good style just places the people
in a situation where they have to make the sensible thing, but go
against the style suggested in the man page.  I don't think that's
helpful.

Please, can we remove the placeholders from this example?

-uwe


CVS commit: src/lib/libutil

2024-01-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 21 21:31:23 UTC 2024

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
snprintb.3: fix examples

The first example broke the format string at boundaries that didn't
highlight the structure of the format string and also didn't make it
clear that a few bits were omitted from having descriptions.

The second example contained an off-by-one error for SIXTEEN, which was
actually FIFTEEN.

The snprintb_m example repeated the above off-by-one error, and its
output was shown wrong, due to concatenated escape sequences.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/snprintb.3
diff -u src/lib/libutil/snprintb.3:1.24 src/lib/libutil/snprintb.3:1.25
--- src/lib/libutil/snprintb.3:1.24	Thu Jul 30 21:23:36 2020
+++ src/lib/libutil/snprintb.3	Sun Jan 21 21:31:23 2024
@@ -1,4 +1,4 @@
-.\" $NetBSD: snprintb.3,v 1.24 2020/07/30 21:23:36 uwe Exp $
+.\" $NetBSD: snprintb.3,v 1.25 2024/01/21 21:31:23 rillig Exp $
 .\"
 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd December 6, 2019
+.Dd January 21, 2024
 .Dt SNPRINTB 3
 .Os
 .Sh NAME
@@ -246,21 +246,25 @@ snprintb(buf, buflen, "\e10\e2BITTWO\e1B
 \(rA "03"
 
 snprintb(buf, buflen,
-   "\e20\ex10NOTBOOT\ex0f" "FPP\ex0eSDVMA\ex0cVIDEO"
-   "\ex0bLORES\ex0a" "FPA\ex09" "DIAG\ex07" "CACHE"
-   "\ex06IOCACHE\ex05LOOPBACK\ex04" "DBGCACHE",
-   0xe860)
+"\e20"
+"\ex10NOTBOOT" "\ex0fFPP" "\ex0eSDVMA" ""
+"\ex0cVIDEO" "\ex0bLORES" "\ex0aFPA" "\ex09DIAG"
+"" "\ex07CACHE" "\ex06IOCACHE" "\ex05LOOPBACK"
+"\ex04DBGCACHE",
+0xe860)
 \(rA "0xe860"
 .Ed
 .Pp
 An example of the new formatting style:
 .Bd -literal -offset indent
 snprintb(buf, buflen,
-   "\e177\e020b\e0LSB\e0b\e1_BITONE\e0f\e4\e4NIBBLE2\e0"
-   "f\ex10\e4BURST\e0=\e4FOUR\e0=\exfSIXTEEN\e0"
-   "b\ex1fMSB\e0\e0",
-   0x800f0701)
-\(rA "0x800f0701"
+"\e177\e020"
+"b\e0LSB\e0" "b\e1BITONE\e0"
+"f\e4\e4NIBBLE2\e0"
+"f\ex10\e4BURST\e0" "=\e4FOUR\e0" "=\exfFIFTEEN\e0"
+"b\ex1fMSB\e0" "\e0",
+0x800f0701)
+\(rA "0x800f0701"
 .Ed
 .Pp
 A more complex example from
@@ -320,11 +324,14 @@ snprintb(buf, buflen, MAP_FMT, 0x2e0
 An example using snprintb_m:
 .Bd -literal -offset indent
 snprintb_m(buf, buflen,
-   "\e177\e020b\e0LSB\e0b\e1_BITONE\e0f\e4\e4NIBBLE2\e0"
-   "f\ex10\e4BURST\e0=\e4FOUR\e0=\exfSIXTEEN\e0"
-   "b\ex1fMSB\e0\e0",
-   0x800f0701, 34)
-\(rA "0x800f0701\e00x800f0701\e0"
+"\e177\e020"
+"b\e0LSB\e0" "b\e1BITONE\e0" "f\e4\e4NIBBLE2\e0"
+"f\ex10\e4BURST\e0" "=\e4FOUR\e0" "=\exfFIFTEEN\e0"
+"b\ex1fMSB\e0" "\e0",
+0x800f0701, 34)
+\(rA "0x800f0701\e0"
+   "0x800f0701\e0"
+   ""
 .Ed
 .Sh ERRORS
 .Fn snprintb



CVS commit: src/lib/libutil

2024-01-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 21 21:31:23 UTC 2024

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
snprintb.3: fix examples

The first example broke the format string at boundaries that didn't
highlight the structure of the format string and also didn't make it
clear that a few bits were omitted from having descriptions.

The second example contained an off-by-one error for SIXTEEN, which was
actually FIFTEEN.

The snprintb_m example repeated the above off-by-one error, and its
output was shown wrong, due to concatenated escape sequences.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2023-05-31 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed May 31 21:49:39 UTC 2023

Modified Files:
src/lib/libutil: stat_flags.3

Log Message:
stat_flags(3): try to improve the descriptions

List all alternative forms recognized by string_to_flags(3).
Both "dump" and "nonodump" are the negative of "nodump".
string_to_flags does not recognize "snap".
Provide xrefs for flag descriptions where applicable.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libutil/stat_flags.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/stat_flags.3
diff -u src/lib/libutil/stat_flags.3:1.8 src/lib/libutil/stat_flags.3:1.9
--- src/lib/libutil/stat_flags.3:1.8	Wed Sep 19 23:22:56 2012
+++ src/lib/libutil/stat_flags.3	Wed May 31 21:49:39 2023
@@ -1,4 +1,4 @@
-.\" $NetBSD: stat_flags.3,v 1.8 2012/09/19 23:22:56 wiz Exp $
+.\" $NetBSD: stat_flags.3,v 1.9 2023/05/31 21:49:39 uwe Exp $
 .\"
 .\" Copyright (c) 1996 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd September 20, 2012
+.Dd May 31, 2023
 .Dt STAT_FLAGS 3
 .Os
 .Sh NAME
@@ -49,36 +49,59 @@ and
 .Fn string_to_flags
 functions are used by
 programs such as
+.Xr chflags 1 ,
 .Xr ls 1 ,
-.Xr mtree 8 ,
 .Xr makefs 8 ,
+.Xr mtree 8 ,
 etc., to parse and/or print the
-.Dv st_flags field in the
+.Fa st_flags
+field in the
 .Xr stat 2
 structure.
+.
 .Pp
 They recognize the following flags:
-.Bl -column -offset indent "uappnd " "SF_IMMUTABLE" "xxx"
-.It Sy String Ta Sy Flag Ta Sy Description
-.It Va arch Ta Dv SF_ARCHIVED Ta file is archived
-.It Va nodump Ta Dv UF_NODUMP Ta do not dump file
-.It Va opaque Ta Dv UF_OPAQUE Ta directory is opaque in union filesystems
-.It Va sappnd Ta Dv SF_APPEND Ta writes to the file may only append
-.It Va schg Ta Dv SF_IMMUTABLE Ta file cannot be changed; it is immutable
-.It Va snap Ta Dv SF_SNAPSHOT Ta file is a snapshot inode
-.It Va uappnd Ta Dv UF_APPEND Ta writes to the file may only append
-.It Va uchg Ta Dv UF_IMMUTABLE Ta file cannot be changed; it is immutable
+.
+.Bl -tag -width Cm -offset indent
+.
+.It Cm arch , Cm archived Pq Dv SF_ARCHIVED
+file is archived
+.Po legacy/compat flag for
+.Xr mount_msdos 8
+filesystems
+.Pc
+.
+.It Cm nodump Pq Dv UF_NODUMP
+do not
+.Xr dump 8
+file
+.
+.It Cm opaque Pq Dv UF_OPAQUE
+directory is opaque in
+.Xr mount_union 8
+filesystems
+.
+.It Cm sappnd , Cm sappend Pq Dv SF_APPEND
+writes to the file may only append
+.Pq flag can be changed by the superuser only
+.
+.It Cm schg , Cm schange , Cm simmutable Pq Dv SF_IMMUTABLE
+file cannot be changed; it is immutable
+.Pq flag can be changed by the superuser only
+.
+.It Cm snap Pq Dv SF_SNAPSHOT
+file is an
+.Xr fss 4
+snapshot inode
+.
+.It Cm uappnd , Cm uappend Pq Dv UF_APPEND
+writes to the file may only append
+.
+.It Cm uchg , Cm uchange , Cm uimmutable Pq Dv UF_IMMUTABLE
+file cannot be changed; it is immutable
+.
 .El
-.Pp
-The
-.Dv SF_APPEND
-and
-.Dv SF_IMMUTABLE
-flags are for the superuser only, whereas
-.Dv UF_APPEND
-and
-.Dv UF_IMMUTABLE
-are for the user only.
+.
 .Pp
 The
 .Fn flags_to_string
@@ -94,6 +117,10 @@ and it is the responsibility of the call
 .Xr free 3
 it.
 .Pp
+Where the above list has several flag names for a flag,
+the first of the listed names is returned.
+.
+.Pp
 The
 .Fn string_to_flags
 function takes a
@@ -102,16 +129,35 @@ of space, comma, or tab separated flag n
 and places their bit value on the
 .Fa setp
 argument.
-If the flag name is prefixed by:
-.Dq no ,
+.Pp
+If the flag name is prefixed by
+.Ql no ,
 then the bit value is placed on the
 .Fa clrp
 argument.
+Both
+.Cm nonodump
+and
+.Cm dump
+are recognized as negative forms of the
+.Cm nodump
+flag name.
+.Pp
+Where the above list has several flag names for a flag,
+all of them are recognized.
+The
+.Cm snap
+flag name is
+.Em not
+recognized
+.Pq as its flag cannot be changed anyway .
+.
 .Sh RETURN VALUES
 .Fn flags_to_string
 returns the symbolic representation of flags, the default string, or
 .Dv NULL
 if allocation failed.
+.
 .Pp
 .Fn string_to_flags
 returns
@@ -120,7 +166,7 @@ on success and
 .Dv 1
 if it fails to parse the string, setting
 .Fa stringp
-to point to the first string that it failed to parse.
+to point to the first name that it failed to parse.
 .Sh SEE ALSO
 .Xr chflags 2 ,
 .Xr stat 2



CVS commit: src/lib/libutil

2023-05-31 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed May 31 21:49:39 UTC 2023

Modified Files:
src/lib/libutil: stat_flags.3

Log Message:
stat_flags(3): try to improve the descriptions

List all alternative forms recognized by string_to_flags(3).
Both "dump" and "nonodump" are the negative of "nodump".
string_to_flags does not recognize "snap".
Provide xrefs for flag descriptions where applicable.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libutil/stat_flags.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2022-12-04 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Dec  4 22:51:43 UTC 2022

Modified Files:
src/lib/libutil: login_cap.3

Log Message:
login_cap(3): Markup fixes


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libutil/login_cap.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/login_cap.3
diff -u src/lib/libutil/login_cap.3:1.23 src/lib/libutil/login_cap.3:1.24
--- src/lib/libutil/login_cap.3:1.23	Sat Jan 23 07:21:18 2016
+++ src/lib/libutil/login_cap.3	Sun Dec  4 22:51:43 2022
@@ -1,4 +1,4 @@
-.\" $NetBSD: login_cap.3,v 1.23 2016/01/23 07:21:18 wiz Exp $
+.\" $NetBSD: login_cap.3,v 1.24 2022/12/04 22:51:43 uwe Exp $
 .\"
 .\" Copyright (c) 1996,1997 Berkeley Software Design, Inc. All rights reserved.
 .\"
@@ -76,25 +76,27 @@
 The
 .Fn login_getclass
 function extracts the entry specified by
-.Ar class
+.Fa class
 (or
-.Li default
+.Ql default
 if
-.Ar class
+.Fa class
 is
 .Dv NULL
 or the empty string)
 from
 .Pa /etc/login.conf
-(see
-.Xr login.conf 5 ) .
+.Po
+see
+.Xr login.conf 5
+.Pc .
 If the entry is found, a
-.Li login_cap_t
+.Vt login_cap_t
 pointer is returned.
 .Dv NULL
 is returned if the user class is not found.
 When the
-.Li login_cap_t
+.Vt login_cap_t
 structure is no longer needed, it should be freed by the
 .Fn login_close
 function.
@@ -102,10 +104,11 @@ function.
 The
 .Fn login_getpwclass
 function is equivalent to:
+.Pp
 .Dl login_getclass(pwd\ ? pwd->pw_class\ : NULL)
 .Pp
 Once
-.Ar lc
+.Fa lc
 has been returned by
 .Fn login_getclass ,
 any of the other
@@ -119,13 +122,13 @@ The
 and
 .Fn login_getcaptime
 functions all query the database entry for a field named
-.Ar cap .
+.Fa cap .
 If the field is found, its value is returned.
 If the field is not found, the value specified by
-.Ar def
+.Fa def
 is returned.
 If an error is encountered while trying to find the field,
-.Ar err
+.Fa err
 is returned.
 See
 .Xr login.conf 5
@@ -134,23 +137,26 @@ The
 .Fn login_getcapbool
 function is slightly different.
 It returns
-.Ar def
-if no capabilities were found for this class (typically meaning that
+.Fa def
+if no capabilities were found for this class
+.Po
+typically meaning that
 the default class was used and the
-.Li /etc/login.conf
-file is missing).
+.Pa /etc/login.conf
+file is missing
+.Pc .
 It returns a non-zero value if
-.Ar cap ,
+.Fa cap ,
 with no value, was found,
 zero otherwise.
 .Pp
 The
 .Fn setclasscontext
 function takes
-.Ar class ,
+.Fa class ,
 the name of a user class,
 and sets the resources defined by that class according to
-.Ar flags .
+.Fa flags .
 Only the
 .Dv LOGIN_SETPATH ,
 .Dv LOGIN_SETPRIORITY ,
@@ -158,88 +164,89 @@ Only the
 and
 .Dv LOGIN_SETUMASK
 bits are used.
-(See
+.Po
+See
 .Fn setusercontext
-below).
-It returns 0 on success and -1 on failure.
+below
+.Pc .
+It returns 0 on success and \-1 on failure.
 .Pp
 The
 .Fn setusercontext
 function
 sets the resources according to
-.Ar flags .
+.Fa flags .
 The
-.Ar lc
+.Fa lc
 argument, if not
 .Dv NULL ,
 contains the class information that should
 be used.
 The
-.Ar pwd
+.Fa pwd
 argument, if not
 .Dv NULL ,
 provides information about the user.
-Both
-.Ar lc
+.Fa lc
 and
-.Ar pwd
-cannot be
+.Fa pwd
+cannot both be
 .Dv NULL .
 The
-.Ar uid
+.Fa uid
 argument is used in place of the user id contained in the
-.Ar pwd
+.Fa pwd
 structure when calling
 .Xr setuid 2 .
 The various bits available to be or-ed together to make up
-.Ar flags
+.Fa flags
 are:
-.Bl -tag -width LOGIN_SETRESOURCESXX
-.It LOGIN_SETGID
+.Bl -tag -width Dv
+.It Dv LOGIN_SETGID
 Set the group id.
 Requires the
-.Ar pwd
+.Fa pwd
 field be specified.
-.It LOGIN_SETGROUPS
+.It Dv LOGIN_SETGROUPS
 Set the group membership list by calling
 .Xr initgroups 3 .
 Requires the
-.Ar pwd
+.Fa pwd
 field be specified.
-.It LOGIN_SETGROUP
+.It Dv LOGIN_SETGROUP
 Set the group id and call
 .Xr initgroups 3 .
 Requires the
-.Ar pwd
+.Fa pwd
 field be specified.
-.It LOGIN_SETLOGIN
+.It Dv LOGIN_SETLOGIN
 Sets the login name by
 .Xr setlogin 2 .
 Requires the
-.Ar pwd
+.Fa pwd
 field be specified.
-.It LOGIN_SETPATH
+.It Dv LOGIN_SETPATH
 Sets the
 .Ev PATH
 environment variable.
-.It LOGIN_SETPRIORITY
+.It Dv LOGIN_SETPRIORITY
 Sets the priority by
 .Xr setpriority 2 .
-.It LOGIN_SETRESOURCES
+.It Dv LOGIN_SETRESOURCES
 Sets the various system resources by
 .Xr setrlimit 2 .
-.It LOGIN_SETUMASK
+.It Dv LOGIN_SETUMASK
 Sets the umask by
 .Xr umask 2 .
-.It LOGIN_SETUSER
+.It Ev LOGIN_SETUSER
 Sets the user id to
-.Ar uid
+.Fa uid
 by
 .Xr setuid 2 .
-.It LOGIN_SETENV
+.It Dv LOGIN_SETENV
 Sets the environment variables as defined by the setenv keyword, by
 .Xr setenv 3 .
-.It LOGIN_SETALL
+.It Dv LOGIN_SETALL
 Sets all of the above.
 .El
 .Sh SEE ALSO



CVS commit: src/lib/libutil

2022-12-04 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Dec  4 22:51:43 UTC 2022

Modified Files:
src/lib/libutil: login_cap.3

Log Message:
login_cap(3): Markup fixes


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libutil/login_cap.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2022-12-04 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Dec  4 11:16:39 UTC 2022

Modified Files:
src/lib/libutil: pw_init.3

Log Message:
pw_init(3): Use .Ev for EDITOR


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/lib/libutil/pw_init.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/pw_init.3
diff -u src/lib/libutil/pw_init.3:1.16 src/lib/libutil/pw_init.3:1.17
--- src/lib/libutil/pw_init.3:1.16	Mon Jul  3 21:32:51 2017
+++ src/lib/libutil/pw_init.3	Sun Dec  4 11:16:39 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: pw_init.3,v 1.16 2017/07/03 21:32:51 wiz Exp $
+.\"	$NetBSD: pw_init.3,v 1.17 2022/12/04 11:16:39 uwe Exp $
 .\"
 .\" Copyright (c) 1995
 .\"	The Regents of the University of California.  All rights reserved.
@@ -78,9 +78,13 @@ disabling most signals.
 .Pp
 The
 .Fn pw_edit
-function runs an editor (named by the environment variable EDITOR, or
+function runs an editor (named by the environment variable
+.Ev EDITOR ,
+or
 .Pa /usr/bin/vi
-if EDITOR is not set) on the file
+if
+.Ev EDITOR
+is not set) on the file
 .Fa filename
 (or
 .Pa /etc/ptmp



CVS commit: src/lib/libutil

2022-12-04 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Dec  4 11:16:39 UTC 2022

Modified Files:
src/lib/libutil: pw_init.3

Log Message:
pw_init(3): Use .Ev for EDITOR


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/lib/libutil/pw_init.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2022-04-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Apr 23 13:02:04 UTC 2022

Modified Files:
src/lib/libutil: parsedate.y

Log Message:
fix date -d 12/01/2022, found by Anon Ymous


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/lib/libutil/parsedate.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/parsedate.y
diff -u src/lib/libutil/parsedate.y:1.36 src/lib/libutil/parsedate.y:1.37
--- src/lib/libutil/parsedate.y:1.36	Fri Oct 30 18:03:11 2020
+++ src/lib/libutil/parsedate.y	Sat Apr 23 09:02:04 2022
@@ -14,7 +14,7 @@
 
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: parsedate.y,v 1.36 2020/10/30 22:03:11 kre Exp $");
+__RCSID("$NetBSD: parsedate.y,v 1.37 2022/04/23 13:02:04 christos Exp $");
 #endif
 
 #include 
@@ -359,7 +359,7 @@ date:
 			param->yyMonth = $3;
 			param->yyDay = $5;
 		} else {
-			if ($1 >= 12 || $3 > 31 || $1 == 0 || $3 == 0)
+			if ($1 > 12 || $3 > 31 || $1 == 0 || $3 == 0)
 YYREJECT;
 			param->yyMonth = $1;
 			param->yyDay = $3;



CVS commit: src/lib/libutil

2022-04-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Apr 23 13:02:04 UTC 2022

Modified Files:
src/lib/libutil: parsedate.y

Log Message:
fix date -d 12/01/2022, found by Anon Ymous


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/lib/libutil/parsedate.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2021-05-16 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun May 16 19:42:35 UTC 2021

Modified Files:
src/lib/libutil: parsedate.3

Log Message:
PR bin/56042

Fix typos (2nd acst should have been acdt), 0550 for ist should be 0530
(5.5 hours is not 5 hours and 50 minutes...).

Comment out the zp4 zp5 and zp6 zone names.   They are supposedly supported
by the source (they're in the table) but cannot work, as the parsedate
lexer doesn't allow a "word" to start with an alpha and also contain
digits.   Maybe (just maybe) that could be fixed sometime, but since these
have never worked, and no-one has ever seemed to miss them, and they're the
only words which are of that form, for now, just stop pretending they work.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/lib/libutil/parsedate.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2021-05-16 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun May 16 19:42:35 UTC 2021

Modified Files:
src/lib/libutil: parsedate.3

Log Message:
PR bin/56042

Fix typos (2nd acst should have been acdt), 0550 for ist should be 0530
(5.5 hours is not 5 hours and 50 minutes...).

Comment out the zp4 zp5 and zp6 zone names.   They are supposedly supported
by the source (they're in the table) but cannot work, as the parsedate
lexer doesn't allow a "word" to start with an alpha and also contain
digits.   Maybe (just maybe) that could be fixed sometime, but since these
have never worked, and no-one has ever seemed to miss them, and they're the
only words which are of that form, for now, just stop pretending they work.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/lib/libutil/parsedate.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/parsedate.3
diff -u src/lib/libutil/parsedate.3:1.25 src/lib/libutil/parsedate.3:1.26
--- src/lib/libutil/parsedate.3:1.25	Mon Oct 19 15:08:39 2020
+++ src/lib/libutil/parsedate.3	Sun May 16 19:42:35 2021
@@ -1,4 +1,4 @@
-.\" $NetBSD: parsedate.3,v 1.25 2020/10/19 15:08:39 kre Exp $
+.\" $NetBSD: parsedate.3,v 1.26 2021/05/16 19:42:35 kre Exp $
 .\"
 .\" Copyright (c) 2006 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd October 19, 2020
+.Dd May 16, 2021
 .Dt PARSEDATE 3
 .Os
 .Sh NAME
@@ -239,10 +239,10 @@ Timezone names:
 .Dv eet (+0200) ,
 .Dv bt (+0300) ,
 .Dv it (+0330) ,
-.Dv zp4 (+0400) ,
-.Dv zp5 (+0500) ,
-.Dv ist (+0550) ,
-.Dv zp6 (+0600) ,
+.\".Dv zp4 (+0400) ,
+.\".Dv zp5 (+0500) ,
+.Dv ist (+0530) ,
+.\".Dv zp6 (+0600) ,
 .Dv ict (+0700) ,
 .Dv wast (+0800) ,
 .Dv wadt (+0900) ,
@@ -255,7 +255,7 @@ Timezone names:
 .Dv cast (+0930) ,
 .Dv cadt (+1030) ,
 .Dv acst (+0930) ,
-.Dv acst (+1030) ,
+.Dv acdt (+1030) ,
 .Dv east (+1000) ,
 .Dv eadt (+1100) ,
 .Dv aest (+1000) ,



CVS commit: src/lib/libutil

2020-10-30 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Fri Oct 30 22:03:11 UTC 2020

Modified Files:
src/lib/libutil: parsedate.y

Log Message:
PR lib/46542

Add checks to detect overflow, and also detect other invalid
(out of range) inputs for parsedate().

There could be more, and some of what is being added is not
perfect, but many calculation overflows will be detected now
(and cause an error return) and some of the most bizarre
inputs that were previously accepted no longer will be.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/lib/libutil/parsedate.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2020-10-30 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Fri Oct 30 22:03:11 UTC 2020

Modified Files:
src/lib/libutil: parsedate.y

Log Message:
PR lib/46542

Add checks to detect overflow, and also detect other invalid
(out of range) inputs for parsedate().

There could be more, and some of what is being added is not
perfect, but many calculation overflows will be detected now
(and cause an error return) and some of the most bizarre
inputs that were previously accepted no longer will be.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/lib/libutil/parsedate.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/parsedate.y
diff -u src/lib/libutil/parsedate.y:1.35 src/lib/libutil/parsedate.y:1.36
--- src/lib/libutil/parsedate.y:1.35	Mon Oct 19 17:47:45 2020
+++ src/lib/libutil/parsedate.y	Fri Oct 30 22:03:11 2020
@@ -14,12 +14,13 @@
 
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: parsedate.y,v 1.35 2020/10/19 17:47:45 kre Exp $");
+__RCSID("$NetBSD: parsedate.y,v 1.36 2020/10/30 22:03:11 kre Exp $");
 #endif
 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -95,6 +96,15 @@ struct dateinfo {
 		int	yyRelMonth;
 	} yyRel[MAXREL];
 };
+
+static int RelVal(struct dateinfo *, time_t, time_t, int, int);
+
+#define CheckRelVal(a, b, c, d, e) do {\
+		if (!RelVal((a), (b), (c), (d), (e))) {		\
+			YYREJECT;\
+		}		\
+	} while (0)
+
 %}
 
 %union {
@@ -191,6 +201,8 @@ at_number:
 
 time:
 	  tUNUMBER tMERIDIAN {
+		if ($1 > 24)
+			YYREJECT;
 		param->yyMinutes = 0;
 		param->yySeconds = 0;
 		if ($2 == MER_NOON || $2 == MER_MN) {
@@ -209,6 +221,8 @@ time:
 		}
 	  }
 	| tUNUMBER ':' tUNUMBER o_merid {
+		if ($1 > 24 || $3 >= 60)
+			YYREJECT;
 		param->yyMinutes = $3;
 		param->yySeconds = 0;
 		if ($4 == MER_NOON || $4 == MER_MN) {
@@ -227,6 +241,8 @@ time:
 		}
 	  }
 	| tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid {
+		if ($1 > 24 || $3 >= 60 || $5 > 60)
+			YYREJECT;
 		param->yyMinutes = $3;
 		param->yySeconds = $5;
 		if ($6 == MER_NOON || $6 == MER_MN) {
@@ -245,6 +261,8 @@ time:
 		}
 	  }
 	| tUNUMBER ':' tUNUMBER ':' tUNUMBER '.' tUNUMBER {
+		if ($1 > 24 || $3 >= 60 || $5 > 60)
+			YYREJECT;
 		param->yyHour = $1;
 		param->yyMinutes = $3;
 		param->yySeconds = $5;
@@ -252,6 +270,8 @@ time:
 		/* XXX: Do nothing with fractional secs ($7) */
 	  }
 	| tUNUMBER ':' tUNUMBER ':' tUNUMBER ',' tUNUMBER {
+		if ($1 > 24 || $3 >= 60 || $5 > 60)
+			YYREJECT;
 		param->yyHour = $1;
 		param->yyMinutes = $3;
 		param->yySeconds = $5;
@@ -280,6 +300,10 @@ time:
 
 time_numericzone:
 	  tUNUMBER ':' tUNUMBER tSNUMBER {
+		if ($4 < -(47 * 100 + 59) || $4 > (47 * 100 + 59))
+			YYREJECT;
+		if ($1 > 24 || $3 > 59)
+			YYREJECT;
 		param->yyHour = $1;
 		param->yyMinutes = $3;
 		param->yyMeridian = MER24;
@@ -287,6 +311,10 @@ time_numericzone:
 		param->yyTimezone = - ($4 % 100 + ($4 / 100) * 60);
 	  }
 	| tUNUMBER ':' tUNUMBER ':' tUNUMBER tSNUMBER {
+		if ($6 < -(47 * 100 + 59) || $6 > (47 * 100 + 59))
+			YYREJECT;
+		if ($1 > 24 || $3 > 59 || $5 > 60)
+			YYREJECT;
 		param->yyHour = $1;
 		param->yyMinutes = $3;
 		param->yySeconds = $5;
@@ -303,6 +331,8 @@ zone:
 	| tSNUMBER	{
 			  if (param->yyHaveDate == 0 && param->yyHaveTime == 0)
 YYREJECT;
+			  if ($1 < -(47 * 100 + 59) || $1 > (47 * 100 + 59))
+YYREJECT;
 			  param->yyTimezone = - ($1 % 100 + ($1 / 100) * 60);
 			  param->yyDSTmode = DSTmaybe;
 			}
@@ -316,15 +346,21 @@ day:
 
 date:
 	  tUNUMBER '/' tUNUMBER {
+		if ($1 > 12 || $3 > 31 || $1 == 0 || $3 == 0)
+			YYREJECT;
 		param->yyMonth = $1;
 		param->yyDay = $3;
 	  }
 	| tUNUMBER '/' tUNUMBER '/' tUNUMBER {
 		if ($1 >= 100) {
+			if ($3 > 12 || $5 > 31 || $3 == 0 || $5 == 0)
+YYREJECT;
 			param->yyYear = $1;
 			param->yyMonth = $3;
 			param->yyDay = $5;
 		} else {
+			if ($1 >= 12 || $3 > 31 || $1 == 0 || $3 == 0)
+YYREJECT;
 			param->yyMonth = $1;
 			param->yyDay = $3;
 			param->yyYear = $5;
@@ -332,39 +368,55 @@ date:
 	  }
 	| tUNUMBER tSNUMBER tSNUMBER {
 		/* ISO 8601 format.  -mm-dd.  */
+		if ($2 >= 0 || $2 < -12 || $3 >= 0 || $3 < -31)
+			YYREJECT;
 		param->yyYear = $1;
 		param->yyHaveFullYear = 1;
 		param->yyMonth = -$2;
 		param->yyDay = -$3;
 	  }
 	| tUNUMBER tMONTH tSNUMBER {
+		if ($3 > 0 || $1 == 0 || $1 > 31)
+			YYREJECT;
 		/* e.g. 17-JUN-1992.  */
 		param->yyDay = $1;
 		param->yyMonth = $2;
 		param->yyYear = -$3;
 	  }
 	| tMONTH tUNUMBER {
+		if ($2 == 0 || $2 > 31)
+			YYREJECT;
 		param->yyMonth = $1;
 		param->yyDay = $2;
 	  }
 	| tMONTH tUNUMBER ',' tUNUMBER {
+		if ($2 == 0 || $2 > 31)
+			YYREJECT;
 		param->yyMonth = $1;
 		param->yyDay = $2;
 		param->yyYear = $4;
 	  }
 	| tUNUMBER tMONTH {
+		if ($1 == 0 || $1 > 31)
+			YYREJECT;
 		param->yyMonth = $2;
 		param->yyDay = $1;
 	  }
 	| tUNUMBER tMONTH tUNUMBER {
-		param->yyMonth = $2;
+		if ($1 > 31 && $3 > 

CVS commit: src/lib/libutil

2020-10-19 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Oct 19 17:47:45 UTC 2020

Modified Files:
src/lib/libutil: parsedate.y

Log Message:
Check the year field of a tentative ISO-8601 date format for overflow
before committing to it being an 8601 format date, rather than after
(or the fall back grammar parser doesn't start with a clean slate).

This isn't likely to ever bother anyone, the chances of encountering
something that looks just like an 8601 format date, but with a year
field so large it overflows a long are kind of slim.   If it did happen
the chances that the string could be correctly parsed (into something
different) by the grammar are even slimmer. But better to do it properly.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/lib/libutil/parsedate.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2020-10-19 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Oct 19 17:47:45 UTC 2020

Modified Files:
src/lib/libutil: parsedate.y

Log Message:
Check the year field of a tentative ISO-8601 date format for overflow
before committing to it being an 8601 format date, rather than after
(or the fall back grammar parser doesn't start with a clean slate).

This isn't likely to ever bother anyone, the chances of encountering
something that looks just like an 8601 format date, but with a year
field so large it overflows a long are kind of slim.   If it did happen
the chances that the string could be correctly parsed (into something
different) by the grammar are even slimmer. But better to do it properly.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/lib/libutil/parsedate.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/parsedate.y
diff -u src/lib/libutil/parsedate.y:1.34 src/lib/libutil/parsedate.y:1.35
--- src/lib/libutil/parsedate.y:1.34	Mon Oct 19 15:08:17 2020
+++ src/lib/libutil/parsedate.y	Mon Oct 19 17:47:45 2020
@@ -14,7 +14,7 @@
 
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: parsedate.y,v 1.34 2020/10/19 15:08:17 kre Exp $");
+__RCSID("$NetBSD: parsedate.y,v 1.35 2020/10/19 17:47:45 kre Exp $");
 #endif
 
 #include 
@@ -1081,6 +1081,7 @@ parsedate(const char *p, const time_t *n
 	const unsigned char *pp = (const unsigned char *)p;
 	char *ep;	/* starts as "expected, becomes "end ptr" */
 	static char format[] = "-dd-ddTdd:dd:dd";
+	time_t yr;
 
 	while (isdigit(*pp))
 		pp++;
@@ -1121,6 +1122,11 @@ parsedate(const char *p, const time_t *n
 	if (*pp != '\0' && !isspace(*pp))
 		break;
 
+	errno = 0;
+	yr = (time_t)strtol(p, , 10);
+	if (errno != 0)			/* out of range (can be big number) */
+		break;			/* the ones below are all 2 digits */
+
 	/*
 	 * This is good enough to commit to there being an ISO format
 	 * timestamp leading the input string.   We permit standard
@@ -1135,10 +1141,7 @@ parsedate(const char *p, const time_t *n
 		param.yyHaveZone = 1;
 	}
 
-	errno = 0;
-	param.yyYear = (time_t)strtol(p, , 10);
-	if (errno != 0)			/* out of range (can be big number) */
-		break;			/* the ones below are all 2 digits */
+	param.yyYear = yr;
 	param.yyMonth = (time_t)strtol(ep + 1, , 10);
 	param.yyDay = (time_t)strtol(ep + 1, , 10);
 	param.yyHour = (time_t)strtol(ep + 1, , 10);



CVS commit: src/lib/libutil

2020-10-19 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Oct 19 15:08:17 UTC 2020

Modified Files:
src/lib/libutil: parsedate.y

Log Message:
For touch -d (which uses parsedate()) POSIX specifies that the
ISO-8601 format -mm-ddTHH:MM:SS[radix_and+frac][Z]
be accepted.

We didn't handle that, as in parsedate(), 'T' represents the
military timezone designator, not a padding separator between
date & time as POSIX specified it.

The way parsedate() is written, fixing this in the grammar/lexer
would be hard without deleting support for T as a zone indicator
(it is *my* timezone!).

So, instead of doing that, parse an ISO-8901 string which occurs
right at the start of the input (not even any preceding white space)
by hand, before invoking the grammar, and so not involving the lexer.
This is sufficient to make touch -d conform.

After doing that, we still need to allow earlier valid inputs,
where an ISO-8601 format (using space as the separator, but without
the 'Z' (Zulu, or UTC) suffix) followed by an arbitrary timezone
designation, and other modifiers (eg: "+5 minutes" work.  So we
call the grammar on whatever is left of the input after the 8601
string has been consumed.   This all "just works" with one exception,
a format like "-mm-dd hh:mm:ss +0700" would have the grammar parse
just "+0700" which by itself would be meaningless, and so wasn't
handled.Add a grammar rule & processing to Handle it.

Also note that while POSIX specifies "at least 4" digits in the 
field, we implement "at least one" so years from 0-999 continue to be
parsed as they always have (nb: these were, and continue to be, treated
as absolute year numbers, year 10 is year 10, not 2010).  Years > 2 billion
(give or take) cannot be represented in the tm_year field of a struct tm,
so there's a limit on the max number of digits as well.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/lib/libutil/parsedate.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/parsedate.y
diff -u src/lib/libutil/parsedate.y:1.33 src/lib/libutil/parsedate.y:1.34
--- src/lib/libutil/parsedate.y:1.33	Mon Oct 19 15:05:53 2020
+++ src/lib/libutil/parsedate.y	Mon Oct 19 15:08:17 2020
@@ -14,7 +14,7 @@
 
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: parsedate.y,v 1.33 2020/10/19 15:05:53 kre Exp $");
+__RCSID("$NetBSD: parsedate.y,v 1.34 2020/10/19 15:08:17 kre Exp $");
 #endif
 
 #include 
@@ -300,6 +300,12 @@ zone:
 	  tZONE		{ param->yyTimezone = $1; param->yyDSTmode = DSToff; }
 	| tDAYZONE	{ param->yyTimezone = $1; param->yyDSTmode = DSTon; }
 	| tZONE tDST	{ param->yyTimezone = $1; param->yyDSTmode = DSTon; }
+	| tSNUMBER	{
+			  if (param->yyHaveDate == 0 && param->yyHaveTime == 0)
+YYREJECT;
+			  param->yyTimezone = - ($1 % 100 + ($1 / 100) * 60);
+			  param->yyDSTmode = DSTmaybe;
+			}
 ;
 
 day:
@@ -1066,6 +1072,85 @@ parsedate(const char *p, const time_t *n
 param.yyHaveTime = 0;
 param.yyHaveZone = 0;
 
+/*
+ * This one is too hard to parse using a grammar (the lexer would
+ * confuse the 'T' with the Mil format timezone designator)
+ * so handle it as a special case.
+ */
+do {
+	const unsigned char *pp = (const unsigned char *)p;
+	char *ep;	/* starts as "expected, becomes "end ptr" */
+	static char format[] = "-dd-ddTdd:dd:dd";
+
+	while (isdigit(*pp))
+		pp++;
+
+	if (pp == (const unsigned char *)p)
+		break;
+
+	for (ep = format; *ep; ep++, pp++) {
+		switch (*ep) {
+		case 'd':
+			if (isdigit(*pp))
+continue;
+			break;
+		case 'T':
+			if (*pp == 'T' || *pp == 't' || *pp == ' ')
+continue;
+			break;
+		default:
+			if (*pp == *ep)
+continue;
+			break;
+		}
+		break;
+	}
+	if (*ep != '\0')
+		break;
+	if (*pp == '.' || *pp == ',') {
+		if (!isdigit(pp[1]))
+			break;
+		while (isdigit(*++pp))
+			continue;
+	}
+	if (*pp == 'Z' || *pp == 'z')
+		pp++;
+	else if (isdigit(*pp))
+		break;
+
+	if (*pp != '\0' && !isspace(*pp))
+		break;
+
+	/*
+	 * This is good enough to commit to there being an ISO format
+	 * timestamp leading the input string.   We permit standard
+	 * parsedate() modifiers to follow but not precede this string.
+	 */
+	param.yyHaveTime = 1;
+	param.yyHaveDate = 1;
+	param.yyHaveFullYear = 1;
+
+	if (pp[-1] == 'Z' || pp[-1] == 'z') {
+		param.yyTimezone = 0;
+		param.yyHaveZone = 1;
+	}
+
+	errno = 0;
+	param.yyYear = (time_t)strtol(p, , 10);
+	if (errno != 0)			/* out of range (can be big number) */
+		break;			/* the ones below are all 2 digits */
+	param.yyMonth = (time_t)strtol(ep + 1, , 10);
+	param.yyDay = (time_t)strtol(ep + 1, , 10);
+	param.yyHour = (time_t)strtol(ep + 1, , 10);
+	param.yyMinutes = (time_t)strtol(ep + 1, , 10);
+	param.yySeconds = (time_t)strtol(ep + 1, , 10);
+	/* ignore any fractional seconds, no way to return them in a time_t */
+
+	param.yyMeridian = MER24;
+
+	p = (const char *)pp;
+} while (0);
+
 if 

CVS commit: src/lib/libutil

2020-10-19 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Oct 19 15:08:39 UTC 2020

Modified Files:
src/lib/libutil: parsedate.3

Log Message:
Catch the parsedate man page up with recent updates, ans also include
some general improvements I've had kicking around for a long time, but
never got around to committing.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/libutil/parsedate.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2020-10-19 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Oct 19 15:08:39 UTC 2020

Modified Files:
src/lib/libutil: parsedate.3

Log Message:
Catch the parsedate man page up with recent updates, ans also include
some general improvements I've had kicking around for a long time, but
never got around to committing.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/libutil/parsedate.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/parsedate.3
diff -u src/lib/libutil/parsedate.3:1.24 src/lib/libutil/parsedate.3:1.25
--- src/lib/libutil/parsedate.3:1.24	Wed Mar 22 18:17:42 2017
+++ src/lib/libutil/parsedate.3	Mon Oct 19 15:08:39 2020
@@ -1,4 +1,4 @@
-.\" $NetBSD: parsedate.3,v 1.24 2017/03/22 18:17:42 kre Exp $
+.\" $NetBSD: parsedate.3,v 1.25 2020/10/19 15:08:39 kre Exp $
 .\"
 .\" Copyright (c) 2006 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd March 22, 2017
+.Dd October 19, 2020
 .Dt PARSEDATE 3
 .Os
 .Sh NAME
@@ -42,7 +42,7 @@
 .Sh DESCRIPTION
 The
 .Fn parsedate
-function parses a datetime from
+function parses a date and time from
 .Ar datestr
 described in English relative to an optional
 .Ar time
@@ -65,9 +65,28 @@ The
 .Ar datestr
 is a sequence of white-space separated items.
 The white-space is optional if the concatenated items are not ambiguous.
+The string contains data which can specify a base time (used in
+conjunction with the
+.Ar time
+parameter, totally replacing that parameter's value if sufficient data
+appears in
+.Ar datestr
+to do so), and data specifying an offset from the base time.
+Both of those are optional.
+If no data specifies the base time, then
+.Nm
+simply uses the value given by
+.Ar \&*time
+.Pq "or now" .
+If there is no offset data then no offset is applied.
 An empty
+.Ar datestr ,
+or a
 .Ar datestr
-is equivalent to midnight today (the beginning of this day).
+containing nothing but whitespace,
+is equivalent to midnight at the start of the day specified by
+.Ar \&*time
+.Pq "or today" .
 .Pp
 The following words have the indicated numeric meanings:
 .Dv last =
@@ -147,6 +166,11 @@ The months:
 .Dv november ,
 .Dv december ,
 and common abbreviations for them.
+When a month name (or its ordinal number) is given,
+the number of some particular day of that month is required to accompany it.
+This is generally true of any data that specifies a period
+with a duration longer than a day, so simply specifying a year,
+or a month, is invalid, as also is specifying a year and a month.
 .Pp
 The days of the week:
 .Dv sunday ,
@@ -157,6 +181,9 @@ The days of the week:
 .Dv friday ,
 .Dv saturday ,
 and common abbreviations for them.
+Weekday names are typically ignored if any other data
+is given to specify the date, even if the name given
+is not the day on which the specified date occurred.
 .Pp
 Time units:
 .Dv year ,
@@ -239,20 +266,27 @@ Timezone names:
 .Dv nzdt (+1300) ,
 .Dv idle (+1200) .
 .Pp
-The timezone names specify an offset from Coordinated Universal Time (UTC)
+The timezone names simply specify an offset from
+Coordinated Universal Time (UTC)
 and do not imply validating the time/date to be reasonable in any zone
 that happens to use the abbreviation specified.
 .Pp
 A variety of unambiguous dates are recognized:
 .Bl -tag -compact -width "20 Jun 1994"
 .It 9/10/69
-For years between 70-99 we assume 1900+ and for years between 0-69
+For years between 69-99 we assume 1900+ and for years between 0-68
 we assume 2000+.
 .It 2006-11-17
 An ISO-8601 date.
-.It 69-09-10
+Note that when using the ISO-8601 format date and time with the
+.Sq T
+designator to separate date and time-of-day,
+this must appear at the start of the input string,
+with no preceding whitespace.
+Other modifiers may optionally follow.
+.It 67-09-10
 The year in an ISO-8601 date is always taken literally,
-so this is the year 69, not 2069.
+so this is the year 67, not 2067.
 .It 10/1/2000
 October 1, 2000; the common, but bizarre, US format.
 .It 20 Jun 1994
@@ -261,7 +295,14 @@ October 1, 2000; the common, but bizarre
 Other common abbreviations.
 .It 1/11
 The year can be omitted.
-This is the US month/day format.
+A missing year is taken from the
+.Ar \&*time
+value, or
+.Dq now
+if
+.Ar time
+is NULL.
+Again, this is the US month/day format (the 11th of January).
 .El
 .Pp
 Standard e-mail (RFC822, RFC2822, etc)
@@ -269,18 +310,28 @@ formats and the output from
 .Xr date 1 ,
 and
 .Xr asctime 3
-are all supported as input.
+are all supported as input,
+as is cvs date format (where years < 100 are treated as
+20th century).
 .Pp
-As well as times:
+Times can also be specified in common forms:
 .Bl -tag -compact -width 12:11:01.12
 .It 10:01
 .It 10:12pm
 .It 12:11:01.12
 .It 12:21-0500
 .El

CVS commit: src/lib/libutil

2020-10-19 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Oct 19 15:08:17 UTC 2020

Modified Files:
src/lib/libutil: parsedate.y

Log Message:
For touch -d (which uses parsedate()) POSIX specifies that the
ISO-8601 format -mm-ddTHH:MM:SS[radix_and+frac][Z]
be accepted.

We didn't handle that, as in parsedate(), 'T' represents the
military timezone designator, not a padding separator between
date & time as POSIX specified it.

The way parsedate() is written, fixing this in the grammar/lexer
would be hard without deleting support for T as a zone indicator
(it is *my* timezone!).

So, instead of doing that, parse an ISO-8901 string which occurs
right at the start of the input (not even any preceding white space)
by hand, before invoking the grammar, and so not involving the lexer.
This is sufficient to make touch -d conform.

After doing that, we still need to allow earlier valid inputs,
where an ISO-8601 format (using space as the separator, but without
the 'Z' (Zulu, or UTC) suffix) followed by an arbitrary timezone
designation, and other modifiers (eg: "+5 minutes" work.  So we
call the grammar on whatever is left of the input after the 8601
string has been consumed.   This all "just works" with one exception,
a format like "-mm-dd hh:mm:ss +0700" would have the grammar parse
just "+0700" which by itself would be meaningless, and so wasn't
handled.Add a grammar rule & processing to Handle it.

Also note that while POSIX specifies "at least 4" digits in the 
field, we implement "at least one" so years from 0-999 continue to be
parsed as they always have (nb: these were, and continue to be, treated
as absolute year numbers, year 10 is year 10, not 2010).  Years > 2 billion
(give or take) cannot be represented in the tm_year field of a struct tm,
so there's a limit on the max number of digits as well.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/lib/libutil/parsedate.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2020-10-19 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Oct 19 15:05:53 UTC 2020

Modified Files:
src/lib/libutil: parsedate.y

Log Message:
POSIX requires that when converting 2 digit year representations to
actual specific years, values from 69-99 be treated as 20th century,
and values from 0-68 be treated as 21st century.  This allows for those
unfortunate enough to reside in a timezone west of Greenwich to convert
the epoch (or a time very close to it) to text, write that with just two
digits, and correctly convert it back to a time near the epoch, rather
than to something in 2069.

We used to split things so 0-69 were 21st century, and 70-99 were 20th.
Change that (this requires a change in the parsedate ATF tests which
test this specific boundary).

While here, add support for another POSIX requirement, that the radix
char before fractional seconds can be either a ',' or a '.'.  We used
to allow only '.', add support for ','.   This is something of a meaningless
change, as parsedate() returns a time_t in which there is no way to
represent fractional seconds, so there's little point in ever specifying
them regardless of what char is used for the "decimal point" - they will
be ignored anyway.But at least fractional seconds using a ',' as the
radix char will no longer cause the conversion to fail (or do something else
bizarre).


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/lib/libutil/parsedate.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/parsedate.y
diff -u src/lib/libutil/parsedate.y:1.32 src/lib/libutil/parsedate.y:1.33
--- src/lib/libutil/parsedate.y:1.32	Wed Mar 22 18:17:42 2017
+++ src/lib/libutil/parsedate.y	Mon Oct 19 15:05:53 2020
@@ -14,7 +14,7 @@
 
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: parsedate.y,v 1.32 2017/03/22 18:17:42 kre Exp $");
+__RCSID("$NetBSD: parsedate.y,v 1.33 2020/10/19 15:05:53 kre Exp $");
 #endif
 
 #include 
@@ -249,7 +249,14 @@ time:
 		param->yyMinutes = $3;
 		param->yySeconds = $5;
 		param->yyMeridian = MER24;
-		/* XXX: Do nothing with millis */
+		/* XXX: Do nothing with fractional secs ($7) */
+	  }
+	| tUNUMBER ':' tUNUMBER ':' tUNUMBER ',' tUNUMBER {
+		param->yyHour = $1;
+		param->yyMinutes = $3;
+		param->yySeconds = $5;
+		param->yyMeridian = MER24;
+		/* XXX: Do nothing with fractional seconds ($7) */
 	  }
 	| tTIME {
 		param->yyHour = $1;
@@ -664,7 +671,8 @@ RelVal(struct dateinfo *param, time_t v,
  * e.g. convert 70 to 1970.
  * Input Year is either:
  *  - A negative number, which means to use its absolute value (why?)
- *  - A number from 0 to 99, which means a year from 1900 to 1999, or
+ *  - A number from 0 to 68, which means a year from 2000 to 2068, 
+ *  - A number from 69 to 99, which means a year from 1969 to 1999, or
  *  - The actual year (>=100).
  * Returns the full year.
  */
@@ -674,7 +682,7 @@ AdjustYear(time_t Year)
 /* XXX Y2K */
 if (Year < 0)
 	Year = -Year;
-if (Year < 70)
+if (Year < 69)	/* POSIX compliant, 0..68 is 2000's, 69-99 1900's */
 	Year += 2000;
 else if (Year < 100)
 	Year += 1900;



CVS commit: src/lib/libutil

2020-10-19 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Oct 19 15:05:53 UTC 2020

Modified Files:
src/lib/libutil: parsedate.y

Log Message:
POSIX requires that when converting 2 digit year representations to
actual specific years, values from 69-99 be treated as 20th century,
and values from 0-68 be treated as 21st century.  This allows for those
unfortunate enough to reside in a timezone west of Greenwich to convert
the epoch (or a time very close to it) to text, write that with just two
digits, and correctly convert it back to a time near the epoch, rather
than to something in 2069.

We used to split things so 0-69 were 21st century, and 70-99 were 20th.
Change that (this requires a change in the parsedate ATF tests which
test this specific boundary).

While here, add support for another POSIX requirement, that the radix
char before fractional seconds can be either a ',' or a '.'.  We used
to allow only '.', add support for ','.   This is something of a meaningless
change, as parsedate() returns a time_t in which there is no way to
represent fractional seconds, so there's little point in ever specifying
them regardless of what char is used for the "decimal point" - they will
be ignored anyway.But at least fractional seconds using a ',' as the
radix char will no longer cause the conversion to fail (or do something else
bizarre).


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/lib/libutil/parsedate.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2020-07-30 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Thu Jul 30 21:23:36 UTC 2020

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
Fix grammar.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/snprintb.3
diff -u src/lib/libutil/snprintb.3:1.23 src/lib/libutil/snprintb.3:1.24
--- src/lib/libutil/snprintb.3:1.23	Sat Dec  7 12:47:07 2019
+++ src/lib/libutil/snprintb.3	Thu Jul 30 21:23:36 2020
@@ -1,4 +1,4 @@
-.\" $NetBSD: snprintb.3,v 1.23 2019/12/07 12:47:07 wiz Exp $
+.\" $NetBSD: snprintb.3,v 1.24 2020/07/30 21:23:36 uwe Exp $
 .\"
 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -63,7 +63,7 @@ If the buffer
 is too small to hold the formatted output,
 .Fn snprintb
 will fill as much as it can, and return the number of bytes
-that would have written if the buffer was long enough excluding the
+that it would have written if the buffer were long enough excluding the
 terminating NUL.
 .Pp
 The decoding directive string



CVS commit: src/lib/libutil

2020-07-30 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Thu Jul 30 21:23:36 UTC 2020

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
Fix grammar.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2020-03-30 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Mar 30 08:24:36 UTC 2020

Modified Files:
src/lib/libutil: pidlock.c

Log Message:
fail to create a pidfile if hostname contains '/'


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/lib/libutil/pidlock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/pidlock.c
diff -u src/lib/libutil/pidlock.c:1.16 src/lib/libutil/pidlock.c:1.17
--- src/lib/libutil/pidlock.c:1.16	Sat Apr  7 16:17:17 2012
+++ src/lib/libutil/pidlock.c	Mon Mar 30 08:24:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pidlock.c,v 1.16 2012/04/07 16:17:17 christos Exp $ */
+/*	$NetBSD: pidlock.c,v 1.17 2020/03/30 08:24:36 ryo Exp $ */
 
 /*
  * Copyright 1996, 1997 by Curt Sampson .
@@ -24,7 +24,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: pidlock.c,v 1.16 2012/04/07 16:17:17 christos Exp $");
+__RCSID("$NetBSD: pidlock.c,v 1.17 2020/03/30 08:24:36 ryo Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include 
@@ -67,6 +67,12 @@ pidlock(const char *lockfile, int flags,
 		return -1;
 	hostname[sizeof(hostname) - 1] = '\0';
 
+	/* avoid '/' in hostname, as it may contain arbitrary characters */
+	for (p = hostname; *p != '\0'; p++) {
+		if (*p == '/')
+			*p = '_';
+	}
+
 	/*
 	 * Build a path to the temporary file.
 	 * We use the path with the PID and hostname appended.



CVS commit: src/lib/libutil

2020-03-30 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Mar 30 08:24:36 UTC 2020

Modified Files:
src/lib/libutil: pidlock.c

Log Message:
fail to create a pidfile if hostname contains '/'


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/lib/libutil/pidlock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2019-12-07 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Dec  7 12:47:07 UTC 2019

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
Remove trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/snprintb.3
diff -u src/lib/libutil/snprintb.3:1.22 src/lib/libutil/snprintb.3:1.23
--- src/lib/libutil/snprintb.3:1.22	Fri Dec  6 19:31:52 2019
+++ src/lib/libutil/snprintb.3	Sat Dec  7 12:47:07 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: snprintb.3,v 1.22 2019/12/06 19:31:52 christos Exp $
+.\" $NetBSD: snprintb.3,v 1.23 2019/12/07 12:47:07 wiz Exp $
 .\"
 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -191,7 +191,7 @@ or
 have not matched.
 .Ar FMT
 may contain a
-.Ft uintmax_t 
+.Ft uintmax_t
 format specification that prints the value that
 did not match, since the field can be more than 32 bits wide.
 .El



CVS commit: src/lib/libutil

2019-12-07 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Dec  7 12:47:07 UTC 2019

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
Remove trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2019-12-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec  6 19:31:52 UTC 2019

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
Correct the man page, and say that the printf(3) format characters need
to be uintmax_t.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2019-12-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec  6 19:31:52 UTC 2019

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
Correct the man page, and say that the printf(3) format characters need
to be uintmax_t.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/snprintb.3
diff -u src/lib/libutil/snprintb.3:1.21 src/lib/libutil/snprintb.3:1.22
--- src/lib/libutil/snprintb.3:1.21	Mon Apr 29 03:55:38 2019
+++ src/lib/libutil/snprintb.3	Fri Dec  6 14:31:52 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: snprintb.3,v 1.21 2019/04/29 07:55:38 kre Exp $
+.\" $NetBSD: snprintb.3,v 1.22 2019/12/06 19:31:52 christos Exp $
 .\"
 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd April 27, 2019
+.Dd December 6, 2019
 .Dt SNPRINTB 3
 .Os
 .Sh NAME
@@ -190,8 +190,10 @@ or
 .Sq \&=
 have not matched.
 .Ar FMT
-may contain an integer format specification that prints the value that
-did not match.
+may contain a
+.Ft uintmax_t 
+format specification that prints the value that
+did not match, since the field can be more than 32 bits wide.
 .El
 .Pp
 Finally, each field is delimited by a NUL
@@ -307,7 +309,7 @@ F\e30\e010\e0\e
 :\e064ALIGN=4PB\e0\e
 :\e070ALIGN=64PB\e0\e
 :\e074ALIGN=256PB\e0\e
-*ALIGN=2^%d\e0\e
+*ALIGN=2^%jd\e0\e
 "
 snprintb(buf, buflen, MAP_FMT, 0x0d001234)
 \(rA "0xd001234"



CVS commit: src/lib/libutil

2019-10-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Oct  8 18:50:34 UTC 2019

Modified Files:
src/lib/libutil: Makefile

Log Message:
-Wstringop-truncation is only gcc.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/lib/libutil/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2019-10-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Oct  8 18:50:34 UTC 2019

Modified Files:
src/lib/libutil: Makefile

Log Message:
-Wstringop-truncation is only gcc.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/lib/libutil/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/Makefile
diff -u src/lib/libutil/Makefile:1.83 src/lib/libutil/Makefile:1.84
--- src/lib/libutil/Makefile:1.83	Thu Oct  3 20:03:56 2019
+++ src/lib/libutil/Makefile	Tue Oct  8 14:50:34 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.83 2019/10/04 00:03:56 christos Exp $
+#	$NetBSD: Makefile,v 1.84 2019/10/08 18:50:34 christos Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/4/93
 
 USE_SHLIBDIR=	yes
@@ -39,10 +39,10 @@ CPPFLAGS.sockaddr_snprintf.c+=-DHAVE_UTI
 CPPFLAGS.sockaddr_snprintf.c+=-DHAVE_NETATALK_AT_H
 CPPFLAGS.sockaddr_snprintf.c+=-DHAVE_NET_IF_DL_H
 
-#.if ${HAVE_GCC:U0} > 7
+.if ${ACTIVE_CC} == "gcc"
 COPTS.logwtmp.c += -Wno-stringop-truncation
 COPTS.logwtmpx.c += -Wno-stringop-truncation
-#.endif
+.endif
 
 YPREFIX=__pd
 .PATH:	${NETBSDSRCDIR}/lib/libc/gen



CVS commit: src/lib/libutil

2019-10-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  4 00:03:56 UTC 2019

Modified Files:
src/lib/libutil: Makefile

Log Message:
Ignore strncpy(foo, bar, sizeof(foo)) for the wtmp fields where we don't
want NUL termination. We can't use pragma's because the old gcc complains
about the new warnings it does not understand.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/lib/libutil/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/Makefile
diff -u src/lib/libutil/Makefile:1.82 src/lib/libutil/Makefile:1.83
--- src/lib/libutil/Makefile:1.82	Wed Apr  4 00:43:46 2018
+++ src/lib/libutil/Makefile	Thu Oct  3 20:03:56 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.82 2018/04/04 04:43:46 kre Exp $
+#	$NetBSD: Makefile,v 1.83 2019/10/04 00:03:56 christos Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/4/93
 
 USE_SHLIBDIR=	yes
@@ -39,6 +39,11 @@ CPPFLAGS.sockaddr_snprintf.c+=-DHAVE_UTI
 CPPFLAGS.sockaddr_snprintf.c+=-DHAVE_NETATALK_AT_H
 CPPFLAGS.sockaddr_snprintf.c+=-DHAVE_NET_IF_DL_H
 
+#.if ${HAVE_GCC:U0} > 7
+COPTS.logwtmp.c += -Wno-stringop-truncation
+COPTS.logwtmpx.c += -Wno-stringop-truncation
+#.endif
+
 YPREFIX=__pd
 .PATH:	${NETBSDSRCDIR}/lib/libc/gen
 



CVS commit: src/lib/libutil

2019-10-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  4 00:03:56 UTC 2019

Modified Files:
src/lib/libutil: Makefile

Log Message:
Ignore strncpy(foo, bar, sizeof(foo)) for the wtmp fields where we don't
want NUL termination. We can't use pragma's because the old gcc complains
about the new warnings it does not understand.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/lib/libutil/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2019-10-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Thu Oct  3 20:29:19 UTC 2019

Modified Files:
src/lib/libutil: efun.c

Log Message:
annotate __dead


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libutil/efun.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2019-10-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Thu Oct  3 20:29:19 UTC 2019

Modified Files:
src/lib/libutil: efun.c

Log Message:
annotate __dead


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libutil/efun.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/efun.c
diff -u src/lib/libutil/efun.c:1.11 src/lib/libutil/efun.c:1.12
--- src/lib/libutil/efun.c:1.11	Thu Oct  3 18:12:44 2019
+++ src/lib/libutil/efun.c	Thu Oct  3 20:29:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: efun.c,v 1.11 2019/10/03 18:12:44 christos Exp $	*/
+/*	$NetBSD: efun.c,v 1.12 2019/10/03 20:29:19 tnn Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: efun.c,v 1.11 2019/10/03 18:12:44 christos Exp $");
+__RCSID("$NetBSD: efun.c,v 1.12 2019/10/03 20:29:19 tnn Exp $");
 #endif
 
 #include 
@@ -49,7 +49,7 @@ __RCSID("$NetBSD: efun.c,v 1.11 2019/10/
 
 static void (*efunc)(int, const char *, ...) = err;
 
-static void 
+static void __dead
 eexit(int e, const char *fmt __unused, ...)
 {
 	exit(e);



CVS commit: src/lib/libutil

2019-10-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Oct  3 18:12:44 UTC 2019

Modified Files:
src/lib/libutil: efun.c

Log Message:
provide a default error function instead of trying to cast exit(3).


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libutil/efun.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/efun.c
diff -u src/lib/libutil/efun.c:1.10 src/lib/libutil/efun.c:1.11
--- src/lib/libutil/efun.c:1.10	Sat Jul 25 22:20:30 2015
+++ src/lib/libutil/efun.c	Thu Oct  3 14:12:44 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: efun.c,v 1.10 2015/07/26 02:20:30 kamil Exp $	*/
+/*	$NetBSD: efun.c,v 1.11 2019/10/03 18:12:44 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: efun.c,v 1.10 2015/07/26 02:20:30 kamil Exp $");
+__RCSID("$NetBSD: efun.c,v 1.11 2019/10/03 18:12:44 christos Exp $");
 #endif
 
 #include 
@@ -49,11 +49,17 @@ __RCSID("$NetBSD: efun.c,v 1.10 2015/07/
 
 static void (*efunc)(int, const char *, ...) = err;
 
+static void 
+eexit(int e, const char *fmt __unused, ...)
+{
+	exit(e);
+}
+
 void (*
 esetfunc(void (*ef)(int, const char *, ...)))(int, const char *, ...)
 {
 	void (*of)(int, const char *, ...) = efunc;
-	efunc = ef == NULL ? (void (*)(int, const char *, ...))exit : ef;
+	efunc = ef == NULL ? eexit : ef;
 	return of;
 }
 



CVS commit: src/lib/libutil

2019-10-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Oct  3 18:12:44 UTC 2019

Modified Files:
src/lib/libutil: efun.c

Log Message:
provide a default error function instead of trying to cast exit(3).


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libutil/efun.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2019-08-22 Thread Brad Spencer
Module Name:src
Committed By:   brad
Date:   Thu Aug 22 20:23:43 UTC 2019

Modified Files:
src/lib/libutil: getdiskrawname.c

Log Message:
Teach getdiskrawname and getdiskcookedname about zvols.

Reviewed by Christos


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libutil/getdiskrawname.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/getdiskrawname.c
diff -u src/lib/libutil/getdiskrawname.c:1.5 src/lib/libutil/getdiskrawname.c:1.6
--- src/lib/libutil/getdiskrawname.c:1.5	Wed Sep 17 23:54:42 2014
+++ src/lib/libutil/getdiskrawname.c	Thu Aug 22 20:23:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: getdiskrawname.c,v 1.5 2014/09/17 23:54:42 christos Exp $	*/
+/*	$NetBSD: getdiskrawname.c,v 1.6 2019/08/22 20:23:43 brad Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: getdiskrawname.c,v 1.5 2014/09/17 23:54:42 christos Exp $");
+__RCSID("$NetBSD: getdiskrawname.c,v 1.6 2019/08/22 20:23:43 brad Exp $");
 
 #include 
 
@@ -70,10 +70,74 @@ resolve_link(char *buf, size_t bufsiz, c
 	return buf;
 }
 
+/*
+ * zvol device names look like:
+ * /dev/zvol/dsk/pool_name/.../volume_name
+ * /dev/zvol/rdsk/pool_name/.../volume_name
+ *
+ * ZFS pools can be divided nearly to infinity
+ *
+ * This allows for 16 pool names, which one would hope would be enough
+ */
+#define DISKMAXPARTS 20
+static int
+calc_zvol_name(char *buf, size_t bufsiz, const char *name, const char *raw)
+{
+	char copyname[PATH_MAX];
+	char *names[DISKMAXPARTS];
+	char *last, *p;
+	size_t i = 0;
+
+	strlcpy(copyname, name, sizeof(copyname));
+	for (p = strtok_r(copyname, "/", ); p;
+	 p = strtok_r(NULL, "/", )) {
+		if (i >= DISKMAXPARTS) {
+			errno =  ENOSPC;
+			return -1;
+		}
+		names[i++] = p;
+	}
+
+	if (i < 4) {
+		errno = EINVAL;
+		return -1;
+	}
+
+	snprintf(buf, bufsiz, "/dev/zvol/%sdsk", raw);
+	for (size_t j = 3; j < i; j++) {
+		strlcat(buf, "/", bufsiz);
+		strlcat(buf, names[j], bufsiz);
+	}
+	return 0;
+}
+
+static int
+calc_name(char *buf, size_t bufsiz, const char *name, const char *raw)
+{
+	int skip = 1;
+
+	if (strncmp("/dev/zvol/", name, 10) == 0)
+		return calc_zvol_name(buf, bufsiz, name, raw);
+
+	const char *dp = strrchr(name, '/');
+	if (!*raw && ((dp != NULL && dp[1] != 'r')
+		|| (dp == NULL && name[0] != 'r'))) {
+		errno = EINVAL;
+		return -1;
+	}
+	if (raw[0] != 'r')
+		skip = 2;
+	if (dp != NULL)
+		snprintf(buf, bufsiz, "%.*s/%s%s", (int)(dp - name),
+		name, raw, dp + skip);
+	else
+		snprintf(buf, bufsiz, "%s%s", raw, name);
+	return 0;
+}
+
 const char *
 getdiskrawname(char *buf, size_t bufsiz, const char *name)
 {
-	const char *dp;
 	struct stat st;
 	char dest[PATH_MAX];
 
@@ -82,8 +146,6 @@ getdiskrawname(char *buf, size_t bufsiz,
 		return NULL;
 	}
 
-	dp = strrchr(name, '/');
-
 	if (stat(name, ) == -1)
 		return NULL;
 
@@ -92,10 +154,8 @@ getdiskrawname(char *buf, size_t bufsiz,
 		return NULL;
 	}
 
-	if (dp != NULL)
-		(void)snprintf(buf, bufsiz, "%.*s/r%s", (int)(dp - name), name, dp + 1);
-	else
-		(void)snprintf(buf, bufsiz, "r%s", name);
+	if (calc_name(buf, bufsiz, name, "r") == -1)
+		return NULL;
 
 	return buf;
 }
@@ -103,7 +163,6 @@ getdiskrawname(char *buf, size_t bufsiz,
 const char *
 getdiskcookedname(char *buf, size_t bufsiz, const char *name)
 {
-	const char *dp;
 	struct stat st;
 	char dest[PATH_MAX];
 
@@ -112,13 +171,6 @@ getdiskcookedname(char *buf, size_t bufs
 		return NULL;
 	}
 
-	dp = strrchr(name, '/');
-
-	if ((dp != NULL && dp[1] != 'r') || (dp == NULL && name[0] != 'r')) {
-		errno = EINVAL;
-		return NULL;
-	}
-
 	if (stat(name, ) == -1)
 		return NULL;
 
@@ -127,10 +179,8 @@ getdiskcookedname(char *buf, size_t bufs
 		return NULL;
 	}
 
-	if (dp != NULL)
-		(void)snprintf(buf, bufsiz, "%.*s/%s", (int)(dp - name), name, dp + 2);
-	else
-		(void)snprintf(buf, bufsiz, "%s", name + 1);
+	if (calc_name(buf, bufsiz, name, "") == -1)
+		return NULL;
 
 	return buf;
 }



CVS commit: src/lib/libutil

2019-08-22 Thread Brad Spencer
Module Name:src
Committed By:   brad
Date:   Thu Aug 22 20:23:43 UTC 2019

Modified Files:
src/lib/libutil: getdiskrawname.c

Log Message:
Teach getdiskrawname and getdiskcookedname about zvols.

Reviewed by Christos


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libutil/getdiskrawname.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2019-04-27 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Apr 27 17:58:51 UTC 2019

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
Remove trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2019-04-27 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Apr 27 17:58:51 UTC 2019

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
Remove trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/snprintb.3
diff -u src/lib/libutil/snprintb.3:1.19 src/lib/libutil/snprintb.3:1.20
--- src/lib/libutil/snprintb.3:1.19	Sat Apr 27 17:48:13 2019
+++ src/lib/libutil/snprintb.3	Sat Apr 27 17:58:51 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: snprintb.3,v 1.19 2019/04/27 17:48:13 christos Exp $
+.\" $NetBSD: snprintb.3,v 1.20 2019/04/27 17:58:51 wiz Exp $
 .\"
 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -183,7 +183,7 @@ This provides a
 case that prints
 .Ar FMT
 using
-.Xr printf 3 
+.Xr printf 3
 when other
 .Sq \&:
 or



CVS commit: src/lib/libutil

2019-04-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Apr 27 17:48:13 UTC 2019

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
remove dup line


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2019-04-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Apr 27 17:48:13 UTC 2019

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
remove dup line


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/snprintb.3
diff -u src/lib/libutil/snprintb.3:1.18 src/lib/libutil/snprintb.3:1.19
--- src/lib/libutil/snprintb.3:1.18	Sat Apr 27 13:46:08 2019
+++ src/lib/libutil/snprintb.3	Sat Apr 27 13:48:13 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: snprintb.3,v 1.18 2019/04/27 17:46:08 christos Exp $
+.\" $NetBSD: snprintb.3,v 1.19 2019/04/27 17:48:13 christos Exp $
 .\"
 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -271,7 +271,6 @@ multi-field formatting with a default ca
 .Bd -literal -offset indent
 #define MAP_FMT	"\e177\e020\e
 b\e0SHARED\e0\e
-b\e0SHARED\e0\e
 b\e1PRIVATE\e0\e
 b\e2COPY\e0\e
 b\e4FIXED\e0\e



CVS commit: src/lib/libutil

2019-04-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Apr 27 17:46:08 UTC 2019

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
Document the '*' field and give a more complex example with F and *.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/snprintb.3
diff -u src/lib/libutil/snprintb.3:1.17 src/lib/libutil/snprintb.3:1.18
--- src/lib/libutil/snprintb.3:1.17	Sun Oct 22 12:59:18 2017
+++ src/lib/libutil/snprintb.3	Sat Apr 27 13:46:08 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: snprintb.3,v 1.17 2017/10/22 16:59:18 abhinav Exp $
+.\" $NetBSD: snprintb.3,v 1.18 2019/04/27 17:46:08 christos Exp $
 .\"
 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd May 7, 2009
+.Dd April 27, 2019
 .Dt SNPRINTB 3
 .Os
 .Sh NAME
@@ -177,6 +177,21 @@ Operates like the
 .Sq \&=
 operator, but omits the leading
 .Sq \&= .
+.It Cm *FMT
+This provides a
+.Dq default
+case that prints
+.Ar FMT
+using
+.Xr printf 3 
+when other
+.Sq \&:
+or
+.Sq \&=
+have not matched.
+.Ar FMT
+may contain an integer format specification that prints the value that
+did not match.
 .El
 .Pp
 Finally, each field is delimited by a NUL
@@ -246,6 +261,61 @@ snprintb(buf, buflen,
 \(rA "0x800f0701"
 .Ed
 .Pp
+A more complex example from
+.In sys/mman.h
+that uses the both bit position
+.Sq b
+formatting as well as the
+.Sq F
+multi-field formatting with a default case:
+.Bd -literal -offset indent
+#define MAP_FMT	"\e177\e020\e
+b\e0SHARED\e0\e
+b\e0SHARED\e0\e
+b\e1PRIVATE\e0\e
+b\e2COPY\e0\e
+b\e4FIXED\e0\e
+b\e5RENAME\e0\e
+b\e6NORESERVE\e0\e
+b\e7INHERIT\e0\e
+b\e11HASSEMAPHORE\e0\e
+b\e12TRYFIXED\e0\e
+b\e13WIRED\e0\e
+F\e14\e1\e
+:\e0FILE\e0\e
+:\e1ANONYMOUS\e0\e
+b\e15STACK\e0\e
+F\e30\e010\e
+:\e000ALIGN=NONE\e0\e
+:\e012ALIGN=1KB\e0\e
+:\e013ALIGN=2KB\e0\e
+:\e014ALIGN=4KB\e0\e
+:\e015ALIGN=8KB\e0\e
+:\e016ALIGN=16KB\e0\e
+:\e017ALIGN=32KB\e0\e
+:\e020ALIGN=64KB\e0\e
+:\e021ALIGN=128KB\e0\e
+:\e022ALIGN=256KB\e0\e
+:\e023ALIGN=512KB\e0\e
+:\e024ALIGN=1MB\e0\e
+:\e030ALIGN=16MB\e0\e
+:\e034ALIGN=256MB\e0\e
+:\e040ALIGN=4GB\e0\e
+:\e044ALIGN=64GB\e0\e
+:\e050ALIGN=1TB\e0\e
+:\e054ALIGN=16TB\e0\e
+:\e060ALIGN=256TB\e0\e
+:\e064ALIGN=4PB\e0\e
+:\e070ALIGN=64PB\e0\e
+:\e074ALIGN=256PB\e0\e
+*ALIGN=2^%d\e0\e
+"
+snprintb(buf, buflen, MAP_FMT, 0x0d001234)
+\(rA "0xd001234"
+snprintb(buf, buflen, MAP_FMT, 0x2e00)
+\(rA "0xd001234<0x2e00
+.Ed
+.Pp
 An example using snprintb_m:
 .Bd -literal -offset indent
 snprintb_m(buf, buflen,



CVS commit: src/lib/libutil

2019-04-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Apr 27 17:46:08 UTC 2019

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
Document the '*' field and give a more complex example with F and *.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2018-12-28 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Fri Dec 28 18:44:11 UTC 2018

Modified Files:
src/lib/libutil: getfsspecname.3

Log Message:
Document "ROOT." syntax before documenting a generic .


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libutil/getfsspecname.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/getfsspecname.3
diff -u src/lib/libutil/getfsspecname.3:1.6 src/lib/libutil/getfsspecname.3:1.7
--- src/lib/libutil/getfsspecname.3:1.6	Sat Oct  6 13:09:53 2018
+++ src/lib/libutil/getfsspecname.3	Fri Dec 28 18:44:11 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: getfsspecname.3,v 1.6 2018/10/06 13:09:53 jmcneill Exp $
+.\"	$NetBSD: getfsspecname.3,v 1.7 2018/12/28 18:44:11 alnsn Exp $
 .\"
 .\" Copyright (c) 2012 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -28,7 +28,7 @@
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
 .\"
-.Dd October 6, 2018
+.Dd December 28, 2018
 .Dt GETFSSPECNAME 3
 .Os
 .Sh NAME
@@ -58,16 +58,6 @@ up to len
 .Pp
 If the
 .Fa spec
-argument is not of the form
-.Dq NAME=wedgename ,
-.Fa spec
-is copied
-to
-.Fa buf
-and returned.
-.Pp
-If the
-.Fa spec
 argument starts with
 .Dq ROOT. ,
 a path in the form
@@ -85,6 +75,18 @@ is the characters following
 in the
 .Fa spec
 argument.
+.Pp
+If the
+.Fa spec
+argument is not of the form
+.Dq NAME=wedgename
+and it doesn't start with
+.Dq ROOT. ,
+.Fa spec
+is copied
+to
+.Fa buf
+and returned.
 .Sh RETURN VALUES
 On success the absolute pathname of the underlying wedge device is returned,
 or the original



CVS commit: src/lib/libutil

2018-12-28 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Fri Dec 28 18:44:11 UTC 2018

Modified Files:
src/lib/libutil: getfsspecname.3

Log Message:
Document "ROOT." syntax before documenting a generic .


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libutil/getfsspecname.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2018-12-27 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Thu Dec 27 21:35:48 UTC 2018

Modified Files:
src/lib/libutil: getfsspecname.c

Log Message:
No need to quadruple a buffer because strunvis(3) doesn't expand.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libutil/getfsspecname.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/getfsspecname.c
diff -u src/lib/libutil/getfsspecname.c:1.7 src/lib/libutil/getfsspecname.c:1.8
--- src/lib/libutil/getfsspecname.c:1.7	Sat Oct  6 23:48:00 2018
+++ src/lib/libutil/getfsspecname.c	Thu Dec 27 21:35:48 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: getfsspecname.c,v 1.7 2018/10/06 23:48:00 christos Exp $	*/
+/*	$NetBSD: getfsspecname.c,v 1.8 2018/12/27 21:35:48 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: getfsspecname.c,v 1.7 2018/10/06 23:48:00 christos Exp $");
+__RCSID("$NetBSD: getfsspecname.c,v 1.8 2018/12/27 21:35:48 alnsn Exp $");
 
 #include 
 #include 
@@ -108,7 +108,7 @@ getfsspecname(char *buf, size_t bufsiz, 
 #ifdef COMPAT_DKWEDGE
 search:
 #endif
-	vname = malloc(strlen(name) * 4 + 1);
+	vname = malloc(strlen(name) + 1);
 	if (vname == NULL) {
 		savee = errno;
 		strlcpy(buf, "malloc failed", bufsiz);



CVS commit: src/lib/libutil

2018-12-27 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Thu Dec 27 21:35:48 UTC 2018

Modified Files:
src/lib/libutil: getfsspecname.c

Log Message:
No need to quadruple a buffer because strunvis(3) doesn't expand.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libutil/getfsspecname.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2018-10-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Oct  6 23:48:00 UTC 2018

Modified Files:
src/lib/libutil: getfsspecname.c

Log Message:
use the right type.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libutil/getfsspecname.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/getfsspecname.c
diff -u src/lib/libutil/getfsspecname.c:1.6 src/lib/libutil/getfsspecname.c:1.7
--- src/lib/libutil/getfsspecname.c:1.6	Sat Oct  6 09:09:53 2018
+++ src/lib/libutil/getfsspecname.c	Sat Oct  6 19:48:00 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: getfsspecname.c,v 1.6 2018/10/06 13:09:53 jmcneill Exp $	*/
+/*	$NetBSD: getfsspecname.c,v 1.7 2018/10/06 23:48:00 christos Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: getfsspecname.c,v 1.6 2018/10/06 13:09:53 jmcneill Exp $");
+__RCSID("$NetBSD: getfsspecname.c,v 1.7 2018/10/06 23:48:00 christos Exp $");
 
 #include 
 #include 
@@ -68,7 +68,7 @@ getfsspecname(char *buf, size_t bufsiz, 
 	 */
 	if (strncasecmp(name, "ROOT.", 5) == 0 && strchr(name, ':') == NULL) {
 		static const int mib_root[] = { CTL_KERN, KERN_ROOT_DEVICE };
-		static const int mib_rootlen = __arraycount(mib_root);
+		static const unsigned int mib_rootlen = __arraycount(mib_root);
 
 		strlcpy(buf, "/dev/", bufsiz);
 		len = bufsiz - 5;



CVS commit: src/lib/libutil

2018-10-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Oct  6 23:48:00 UTC 2018

Modified Files:
src/lib/libutil: getfsspecname.c

Log Message:
use the right type.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libutil/getfsspecname.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2018-06-24 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Jun 24 09:30:26 UTC 2018

Modified Files:
src/lib/libutil: pty.c

Log Message:
Fix stack use after scope in libutil/pty

The pt variable's elements are used after the end of the pt scope.
A move of pt to outer scope fixes this.

Detected with MKSANITIZER/ASan with tmux(1), a forkpty(3) user.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/lib/libutil/pty.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2018-06-24 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Jun 24 09:30:26 UTC 2018

Modified Files:
src/lib/libutil: pty.c

Log Message:
Fix stack use after scope in libutil/pty

The pt variable's elements are used after the end of the pt scope.
A move of pt to outer scope fixes this.

Detected with MKSANITIZER/ASan with tmux(1), a forkpty(3) user.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/lib/libutil/pty.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/pty.c
diff -u src/lib/libutil/pty.c:1.31 src/lib/libutil/pty.c:1.32
--- src/lib/libutil/pty.c:1.31	Fri Feb 20 16:44:06 2009
+++ src/lib/libutil/pty.c	Sun Jun 24 09:30:26 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pty.c,v 1.31 2009/02/20 16:44:06 christos Exp $	*/
+/*	$NetBSD: pty.c,v 1.32 2018/06/24 09:30:26 kamil Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)pty.c	8.3 (Berkeley) 5/16/94";
 #else
-__RCSID("$NetBSD: pty.c,v 1.31 2009/02/20 16:44:06 christos Exp $");
+__RCSID("$NetBSD: pty.c,v 1.32 2018/06/24 09:30:26 kamil Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -70,6 +70,7 @@ openpty(int *amaster, int *aslave, char 
 	mode_t mode;
 	struct group grs, *grp;
 	char grbuf[1024];
+	struct ptmget pt;
 
 	_DIAGASSERT(amaster != NULL);
 	_DIAGASSERT(aslave != NULL);
@@ -78,7 +79,6 @@ openpty(int *amaster, int *aslave, char 
 	/* winp may be NULL */
 
 	if ((master = open("/dev/ptm", O_RDWR)) != -1) {
-		struct ptmget pt;
 		if (ioctl(master, TIOCPTMGET, ) != -1) {
 			(void)close(master);
 			master = pt.cfd;



CVS commit: src/lib/libutil

2018-06-23 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Jun 24 01:53:14 UTC 2018

Modified Files:
src/lib/libutil: passwd.c

Log Message:
Prevent underflow buffer read in trim_whitespace() in libutil/passwd.c

If a string is empty or contains only white characters, the algorithm of
removal of white characters at the end of the passed string will read
buffer at index -1 and keep iterating backward.

Detected with MKSANITIZER/ASan when executing passwd(1).


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/lib/libutil/passwd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/passwd.c
diff -u src/lib/libutil/passwd.c:1.52 src/lib/libutil/passwd.c:1.53
--- src/lib/libutil/passwd.c:1.52	Mon Jun 25 22:32:47 2012
+++ src/lib/libutil/passwd.c	Sun Jun 24 01:53:14 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: passwd.c,v 1.52 2012/06/25 22:32:47 abs Exp $	*/
+/*	$NetBSD: passwd.c,v 1.53 2018/06/24 01:53:14 kamil Exp $	*/
 
 /*
  * Copyright (c) 1987, 1993, 1994, 1995
@@ -31,7 +31,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: passwd.c,v 1.52 2012/06/25 22:32:47 abs Exp $");
+__RCSID("$NetBSD: passwd.c,v 1.53 2018/06/24 01:53:14 kamil Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include 
@@ -503,13 +503,21 @@ trim_whitespace(char *line)
 
 	_DIAGASSERT(line != NULL);
 
+	/* Handle empty string */
+	if (*line == '\0')
+		return;
+
 	/* Remove leading spaces */
 	p = line;
 	while (isspace((unsigned char) *p))
 		p++;
 	memmove(line, p, strlen(p) + 1);
 
-	/* Remove trailing spaces */
+	/* Handle empty string after removal of whitespace characters */
+	if (*line == '\0')
+		return;
+
+	/* Remove trailing spaces, line must not be empty string here */
 	p = line + strlen(line) - 1;
 	while (isspace((unsigned char) *p))
 		p--;



CVS commit: src/lib/libutil

2018-06-23 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Jun 24 01:53:14 UTC 2018

Modified Files:
src/lib/libutil: passwd.c

Log Message:
Prevent underflow buffer read in trim_whitespace() in libutil/passwd.c

If a string is empty or contains only white characters, the algorithm of
removal of white characters at the end of the passed string will read
buffer at index -1 and keep iterating backward.

Detected with MKSANITIZER/ASan when executing passwd(1).


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/lib/libutil/passwd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2018-04-05 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Apr  5 11:07:00 UTC 2018

Modified Files:
src/lib/libutil: opendisk.3

Log Message:
Use mdoc macros.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/libutil/opendisk.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/opendisk.3
diff -u src/lib/libutil/opendisk.3:1.15 src/lib/libutil/opendisk.3:1.16
--- src/lib/libutil/opendisk.3:1.15	Wed Apr  4 04:43:46 2018
+++ src/lib/libutil/opendisk.3	Thu Apr  5 11:07:00 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: opendisk.3,v 1.15 2018/04/04 04:43:46 kre Exp $
+.\"	$NetBSD: opendisk.3,v 1.16 2018/04/05 11:07:00 wiz Exp $
 .\"
 .\" Copyright (c) 1997, 2001 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -200,7 +200,7 @@ may also set
 to any value specified by the
 .Xr open 2
 function.
-.PP
+.Pp
 The
 .Fn opendisk1
 function may also set
@@ -216,7 +216,7 @@ The
 .Fn opendisk
 function first appeared in
 .Nx 1.3 .
-.br
+.Pp
 The
 .Fn opendisk1
 function first appeared in



CVS commit: src/lib/libutil

2018-04-05 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Apr  5 11:07:00 UTC 2018

Modified Files:
src/lib/libutil: opendisk.3

Log Message:
Use mdoc macros.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/libutil/opendisk.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2017-10-22 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Oct 23 01:05:10 UTC 2017

Modified Files:
src/lib/libutil: pidlock.3

Log Message:
Sort errors.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libutil/pidlock.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/pidlock.3
diff -u src/lib/libutil/pidlock.3:1.12 src/lib/libutil/pidlock.3:1.13
--- src/lib/libutil/pidlock.3:1.12	Mon Mar  9 19:24:27 2009
+++ src/lib/libutil/pidlock.3	Mon Oct 23 01:05:10 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: pidlock.3,v 1.12 2009/03/09 19:24:27 joerg Exp $
+.\"	$NetBSD: pidlock.3,v 1.13 2017/10/23 01:05:10 wiz Exp $
 .\"
 .\" Copyright 1996, 1997 by Curt Sampson 
 .\"
@@ -152,16 +152,16 @@ can set
 .Va errno
 to the following values on failure:
 .Bl -tag -width Er
-.It Bq Er EWOULDBLOCK
-Another running process has a lock and the
-.Dv PIDLOCK_NONBLOCK
-flag was specified.
 .It Bq Er EFTYPE
 The
 .Fa tty
 specified in
 .Fn ttylock
 is not a character special device.
+.It Bq Er EWOULDBLOCK
+Another running process has a lock and the
+.Dv PIDLOCK_NONBLOCK
+flag was specified.
 .El
 .\" .Sh SEE ALSO
 .Sh HISTORY



CVS commit: src/lib/libutil

2017-10-22 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Oct 23 01:05:10 UTC 2017

Modified Files:
src/lib/libutil: pidlock.3

Log Message:
Sort errors.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libutil/pidlock.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2017-10-22 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Oct 22 16:59:18 UTC 2017

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
Add snprintb_m to the NAME section.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/snprintb.3
diff -u src/lib/libutil/snprintb.3:1.16 src/lib/libutil/snprintb.3:1.17
--- src/lib/libutil/snprintb.3:1.16	Wed Aug  7 23:22:28 2013
+++ src/lib/libutil/snprintb.3	Sun Oct 22 16:59:18 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: snprintb.3,v 1.16 2013/08/07 23:22:28 pgoyette Exp $
+.\" $NetBSD: snprintb.3,v 1.17 2017/10/22 16:59:18 abhinav Exp $
 .\"
 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -31,7 +31,8 @@
 .Dt SNPRINTB 3
 .Os
 .Sh NAME
-.Nm snprintb
+.Nm snprintb ,
+.Nm snprintb_m
 .Nd bitmask output conversion
 .Sh LIBRARY
 .Lb libutil



CVS commit: src/lib/libutil

2017-10-22 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Oct 22 16:59:18 UTC 2017

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
Add snprintb_m to the NAME section.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2017-10-22 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Oct 22 16:55:32 UTC 2017

Modified Files:
src/lib/libutil: pidfile.3

Log Message:
Add missing functions to the NAME section


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/libutil/pidfile.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/pidfile.3
diff -u src/lib/libutil/pidfile.3:1.15 src/lib/libutil/pidfile.3:1.16
--- src/lib/libutil/pidfile.3:1.15	Mon Apr 11 08:49:57 2016
+++ src/lib/libutil/pidfile.3	Sun Oct 22 16:55:32 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: pidfile.3,v 1.15 2016/04/11 08:49:57 wiz Exp $
+.\"	$NetBSD: pidfile.3,v 1.16 2017/10/22 16:55:32 abhinav Exp $
 .\"
 .\" Copyright (c) 1999, 2016 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -31,7 +31,10 @@
 .Dt PIDFILE 3
 .Os
 .Sh NAME
-.Nm pidfile
+.Nm pidfile ,
+.Nm pidfile_lock ,
+.Nm pidfile_read ,
+.Nm pidfile_clean
 .Nd write a daemon pid file
 .Sh LIBRARY
 .Lb libutil



CVS commit: src/lib/libutil

2017-10-22 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Oct 22 16:55:32 UTC 2017

Modified Files:
src/lib/libutil: pidfile.3

Log Message:
Add missing functions to the NAME section


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/libutil/pidfile.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libutil

2017-03-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Thu Mar 30 20:00:21 UTC 2017

Modified Files:
src/lib/libutil: util.3

Log Message:
Use Sy to highlight the table header.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/lib/libutil/util.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/util.3
diff -u src/lib/libutil/util.3:1.25 src/lib/libutil/util.3:1.26
--- src/lib/libutil/util.3:1.25	Thu Mar 30 19:56:36 2017
+++ src/lib/libutil/util.3	Thu Mar 30 20:00:21 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: util.3,v 1.25 2017/03/30 19:56:36 abhinav Exp $
+.\" $NetBSD: util.3,v 1.26 2017/03/30 20:00:21 abhinav Exp $
 .\"
 .\" Copyright (c) 2001 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -57,7 +57,7 @@ library and the associated functions are
 directory.
 .Sh LIST OF FUNCTIONS
 .Bl -column ".Xr sockaddr_snprintf 3" -compact
-.It Sy Name	Description
+.It Sy Name Ta Sy Description
 .It Xr disklabel_dkcksum 3 Ta compute the checksum for a disklabel
 .It Xr disklabel_scan 3 Ta scan a buffer for a valid disklabel
 .It Xr efun 3 Ta error checked utility functions



CVS commit: src/lib/libutil

2017-03-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Thu Mar 30 19:56:36 UTC 2017

Modified Files:
src/lib/libutil: util.3

Log Message:
Add missing functions


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/libutil/util.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/util.3
diff -u src/lib/libutil/util.3:1.24 src/lib/libutil/util.3:1.25
--- src/lib/libutil/util.3:1.24	Mon Aug 29 12:39:50 2011
+++ src/lib/libutil/util.3	Thu Mar 30 19:56:36 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: util.3,v 1.24 2011/08/29 12:39:50 jruoho Exp $
+.\" $NetBSD: util.3,v 1.25 2017/03/30 19:56:36 abhinav Exp $
 .\"
 .\" Copyright (c) 2001 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd August 29, 2011
+.Dd March 31, 2017
 .Dt UTIL 3
 .Os
 .Sh NAME
@@ -60,12 +60,20 @@ directory.
 .It Sy Name	Description
 .It Xr disklabel_dkcksum 3 Ta compute the checksum for a disklabel
 .It Xr disklabel_scan 3 Ta scan a buffer for a valid disklabel
+.It Xr efun 3 Ta error checked utility functions
 .It Xr forkpty 3 Ta tty utility function
 .It Xr getbootfile 3 Ta get the name of the booted kernel file
+.It Xr getbyteorder 3 Ta get the current byte order
+.It Xr getdiskrawname 3 Ta get the the block/character device name for a disk
+.It Xr getfsspecname 3 Ta get the underlying wedge name from a label
+.It Xr getfstypename 3 Ta convert a partition file system type integer to a wedge
+partition type name
 .It Xr getlabeloffset 3 Ta get the sector number and offset of the disklabel
 .It Xr getlabelsector 3 Ta get the sector number and offset of the disklabel
 .It Xr getmaxpartitions 3 Ta get the maximum number of partitions allowed per disk
+.It Xr getmntopts 3 Ta scan mount options
 .It Xr getrawpartition 3 Ta get the system ``raw'' partition
+.It Xr kinfo_getvmmap 3 Ta get per-process memory map information
 .It Xr login 3 Ta login utility function
 .It Xr login_cap 3 Ta query login.conf database about a user class
 .It Xr login_close 3 Ta query login.conf database about a user class
@@ -85,6 +93,7 @@ directory.
 .It Xr openpty 3 Ta tty utility function
 .It Xr pidfile 3 Ta write a daemon pid file
 .It Xr pidlock 3 Ta locks based on files containing PIDs
+.It Xr proc_compare 3 Ta compare two processes' interactivity
 .It Xr pw_abort 3 Ta passwd file update function
 .It Xr pw_copy 3 Ta utility function for interactive passwd file updates
 .It Xr pw_edit 3 Ta utility function for interactive passwd file updates
@@ -97,6 +106,7 @@ directory.
 .It Xr pw_prompt 3 Ta utility function for interactive passwd file updates
 .It Xr pw_scan 3 Ta utility function for interactive passwd file updates
 .It Xr pw_setprefix 3 Ta passwd file update function
+.It Xr raise_default_signal 3 Ta raise the default signal handler
 .It Xr secure_path 3 Ta determine if a file appears to be ``secure''
 .It Xr setclasscontext 3 Ta query login.conf database about a user class
 .It Xr setusercontext 3 Ta query login.conf database about a user class



  1   2   3   4   >