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

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.



Re: CVS commit: src/lib/libutil

2015-12-08 Thread Robert Elz
Date:Mon, 7 Dec 2015 15:55:49 -0500
From:"Christos Zoulas" 
Message-ID:  <20151207205549.4f6c...@cvs.netbsd.org>

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

The change below got missed from the parsedate.3 update.

I assume you decided to leave out the bit about difference
between midnight tues and tues midnight -- that's fine, most
of what the semantics of parsedate has are unspecified.

But this one is a real bug...

kre


--- parsedate.3 2015-12-08 18:43:53.0 +0700
+++ parsedate.3.keep2015-12-07 05:23:38.0 +0700
@@ -198,11 +198,11 @@
 .Dv zp5 (+0500) ,
 .Dv ist (+0550) ,
 .Dv zp6 (+0600) ,
-.Dv wast (+0700) ,
-.Dv wadt (+0800) ,
-.Dv awst (+0700) ,
-.Dv awdt (+0800) ,
 .Dv ict (+0700) ,
+.Dv wast (+0800) ,
+.Dv wadt (+0900) ,
+.Dv awst (+0800) ,
+.Dv awdt (+0900) ,
 .Dv cct (+0800) ,
 .Dv sgt (+0800) ,
 .Dv hkt (+0800) ,


Re: CVS commit: src/lib/libutil

2013-08-12 Thread David Laight
On Wed, Aug 07, 2013 at 10:51:59PM +, Paul Goyette wrote:
 Module Name:  src
 Committed By: pgoyette
 Date: Wed Aug  7 22:51:59 UTC 2013
 
 Modified Files:
   src/lib/libutil: snprintb.3
 
 Log Message:
 Add an example using snprintb_m()
 
 Replace \*[Gt] and \*[Lt] with the simple characters  and  (OK wiz)
 
 XXX Note that the examples currently do not compile with GCC!  The hex
 XXX character sequences such as \x10CACHE are being parsed as longer
 XXX than 2-hex-digit strings!

I would change all the examples to use concatenated strings.
As well as avoiding the above problem it makes them much, much, much
easier to read.

I remember changing some of the source files to split the strings.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/lib/libutil

2013-08-07 Thread Paul Goyette

Module Name:src
Committed By:   pgoyette
Date:   Wed Aug  7 22:51:59 UTC 2013

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

Log Message:
Add an example using snprintb_m()

Replace \*[Gt] and \*[Lt] with the simple characters  and  (OK wiz)

XXX Note that the examples currently do not compile with GCC!  The hex
XXX character sequences such as \x10CACHE are being parsed as longer
XXX than 2-hex-digit strings!


Ah, this is gcc bug # 33167

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33167

I will update the example code shortly in the manner specified in the bug 
audit trail.




-
| Paul Goyette | PGP Key fingerprint: | E-mail addresses:   |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com|
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |  | pgoyette at netbsd.org  |
-


Re: CVS commit: src/lib/libutil

2013-08-07 Thread Valery Ushakov
On Wed, Aug 07, 2013 at 16:17:01 -0700, Paul Goyette wrote:

 Module Name:src
 Committed By:   pgoyette
 Date:   Wed Aug  7 22:51:59 UTC 2013
 
 Modified Files:
 src/lib/libutil: snprintb.3
 
 Log Message:
 Add an example using snprintb_m()
 
 Replace \*[Gt] and \*[Lt] with the simple characters  and  (OK wiz)
 
 XXX Note that the examples currently do not compile with GCC!  The hex
 XXX character sequences such as \x10CACHE are being parsed as longer
 XXX than 2-hex-digit strings!
 
 Ah, this is gcc bug # 33167
 
 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33167
 
 I will update the example code shortly in the manner specified in the bug 
 audit trail.

This is not a bug, as the audit trail mentions.  Relevant passages
from the standard follow:

   6.4.4.4  Character constants

   [#14] EXAMPLE 3 Even if eight bits are used for objects that
   have  type  char,  the  construction  '\x123'  specifies  an
   integer  character  constant  containing only one character,
   since a hexadecimal escape sequence is terminated only by  a
   non-hexadecimal  character. ...

   6.4.5  String literals

   [#3]  The  same  considerations apply to each element of the
   sequence in a character string  literal  or  a  wide  string
   literal  as if it were in an integer character constant or a
   wide character constant, ...

   [#7]   EXAMPLE  This   pair  of  adjacent  character  string
   literals

   \x12 3

   produces a single character string  literal  containing  the
   two  characters  whose  values  are  '\x12' and '3', because
   escape sequences are converted into single  members  of  the
   execution  character  set  just  prior  to  adjacent  string
   literal concatenation.

Adding a caveat to the man page about being careful with \x might be a
good idea.

-uwe


Re: CVS commit: src/lib/libutil

2013-06-21 Thread Christos Zoulas
In article 20130621081825.11fd...@cvs.netbsd.org,
Thomas Klausner source-changes-d@NetBSD.org wrote:
-=-=-=-=-=-

Module Name:   src
Committed By:  wiz
Date:  Fri Jun 21 08:18:25 UTC 2013

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

Log Message:
Punctuation nit.
(Shouldn't the whole line be .Dl or .Bl -literal instead?)

Yes, that would be better.

christos



Re: CVS commit: src/lib/libutil

2012-12-31 Thread David Laight
On Mon, Dec 31, 2012 at 02:59:13AM +0100, Joerg Sonnenberger wrote:
 On Sun, Dec 30, 2012 at 05:36:00PM +, David A. Holland wrote:
  Module Name:src
  Committed By:   dholland
  Date:   Sun Dec 30 17:36:00 UTC 2012
  
  Modified Files:
  src/lib/libutil: efun.c
  
  Log Message:
  If malloc, calloc, or realloc returns NULL when a size of 0 was
  requested, which is allowed by pertinent standards, honor it instead
  of bombing.
  
  Do not do this for calloc(x, y) where x != 0  y != 0 but x*y == 0;
  in that case bomb.
 
 The commit message is misleading. We expect calloc(x,y) to return NULL
 if x!=0  y!=0  x*y==0.

I've never quite understood why calloc() was ever defined with 2
parameters.
The only time it can be different (and valid) from a naiive multiply
is when the multiply is done as 'int' on a system where size_t  int.

I'd have thought calloc() should be required to check that the
multiply doesn't overflow - but that ought (probably) require a different
errno than ENOMEM.

Certainly checking for multiply overflow would seem better than
checking for the product being zero.
Unfortunately that check tends to need a divide - although some
simple range checks will avoid that in most cases.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/lib/libutil

2012-12-31 Thread David Holland
On Mon, Dec 31, 2012 at 10:21:09AM +, David Laight wrote:
Modified Files:
 src/lib/libutil: efun.c

Log Message:
If malloc, calloc, or realloc returns NULL when a size of 0 was
requested, which is allowed by pertinent standards, honor it instead
of bombing.

Do not do this for calloc(x, y) where x != 0  y != 0 but x*y == 0;
in that case bomb.
   
   The commit message is misleading. We expect calloc(x,y) to return NULL
   if x!=0  y!=0  x*y==0.
  
  I've never quite understood why calloc() was ever defined with 2
  parameters.

Me either.

  The only time it can be different (and valid) from a naiive multiply
  is when the multiply is done as 'int' on a system where size_t  int.

It does mean that the overflow test is centralized instead of being
replicated at every allocation site, which has its virtues.

  I'd have thought calloc() should be required to check that the
  multiply doesn't overflow - but that ought (probably) require a different
  errno than ENOMEM.

This is not explicitly stated in C99, but from the wording it is
certainly *allowed* to check, and one could construct a reasonable
argument that it's required to.

  Certainly checking for multiply overflow would seem better than
  checking for the product being zero.

Yes. But, you know, I didn't change calloc, I changed ecalloc. The
question is when a NULL return is an error. It is not an error if a
size of zero is requested, but it is on overflow. A size of zero is
requested only if one or both of the arguments is zero, *not* if the
product is zero. Hence the logic I described.

TBH, I don't understand why this is apparently confusing.

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/lib/libutil

2012-12-30 Thread Joerg Sonnenberger
On Sun, Dec 30, 2012 at 05:36:00PM +, David A. Holland wrote:
 Module Name:  src
 Committed By: dholland
 Date: Sun Dec 30 17:36:00 UTC 2012
 
 Modified Files:
   src/lib/libutil: efun.c
 
 Log Message:
 If malloc, calloc, or realloc returns NULL when a size of 0 was
 requested, which is allowed by pertinent standards, honor it instead
 of bombing.
 
 Do not do this for calloc(x, y) where x != 0  y != 0 but x*y == 0;
 in that case bomb.

The commit message is misleading. We expect calloc(x,y) to return NULL
if x!=0  y!=0  x*y==0.

Joerg


Re: CVS commit: src/lib/libutil

2012-12-30 Thread David Holland
On Mon, Dec 31, 2012 at 02:59:13AM +0100, Joerg Sonnenberger wrote:
   Modified Files:
  src/lib/libutil: efun.c
   
   Log Message:
   If malloc, calloc, or realloc returns NULL when a size of 0 was
   requested, which is allowed by pertinent standards, honor it instead
   of bombing.
   
   Do not do this for calloc(x, y) where x != 0  y != 0 but x*y == 0;
   in that case bomb.
  
  The commit message is misleading. We expect calloc(x,y) to return NULL
  if x!=0  y!=0  x*y==0.

I don't understand. The logic I added is exactly what I described.

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/lib/libutil

2012-12-30 Thread Alan Barrett

On Mon, 31 Dec 2012, Joerg Sonnenberger wrote:

Log Message:
If malloc, calloc, or realloc returns NULL when a size of 0 was
requested, which is allowed by pertinent standards, honor it instead
of bombing.

Do not do this for calloc(x, y) where x != 0  y != 0 but x*y == 0;
in that case bomb.


The commit message is misleading. We expect calloc(x,y) to return NULL
if x!=0  y!=0  x*y==0.


(x!=0  y!=0  x*y==0) can be true only if calculating x*y results
in what would loosely be called integer overflow; since the types are
unsigned, it's a well-defined kind of wraparound, not the undefined kind
of overflow.  I'd expect an error like EINVAL rather than an error like
ENOMEM for this case.

--apb (Alan Barrett)


Re: CVS commit: src/lib/libutil

2012-07-23 Thread Joerg Sonnenberger
On Sun, Jul 22, 2012 at 10:21:14PM -0400, Christos Zoulas wrote:
 Module Name:  src
 Committed By: christos
 Date: Mon Jul 23 02:21:14 UTC 2012
 
 Modified Files:
   src/lib/libutil: openpty.3
 
 Log Message:
 Mention how big the name can be.

I don't think we should leak internals like that. It's a path name, the
only limit guaranteed by the system should PATH_MAX as such.

Joerg


Re: CVS commit: src/lib/libutil

2011-11-17 Thread Jean-Yves Migeon

On 13.11.2011 23:03, Christos Zoulas wrote:

Module Name:src
Committed By:   christos
Date:   Sun Nov 13 22:03:34 UTC 2011

Modified Files:
src/lib/libutil: Makefile
Added Files:
src/lib/libutil: getfstypename.3

Log Message:
add manual page


Just wondering: is there a different rule applicable to man pages for 
4-clause vs 2-clause BSD? I occasionally see new man pages written with 
a 4-clause BSD, however, most newly written code is 2-clause.


--
Jean-Yves Migeon
jeanyves.mig...@free.fr


Re: CVS commit: src/lib/libutil

2011-11-17 Thread Christos Zoulas
In article 4ec5a97e.2070...@free.fr,
Jean-Yves Migeon  jeanyves.mig...@free.fr wrote:
On 13.11.2011 23:03, Christos Zoulas wrote:
 Module Name: src
 Committed By:christos
 Date:Sun Nov 13 22:03:34 UTC 2011

 Modified Files:
  src/lib/libutil: Makefile
 Added Files:
  src/lib/libutil: getfstypename.3

 Log Message:
 add manual page

Just wondering: is there a different rule applicable to man pages for 
4-clause vs 2-clause BSD? I occasionally see new man pages written with 
a 4-clause BSD, however, most newly written code is 2-clause.

fixed.

christos



Re: CVS commit: src/lib/libutil

2011-11-02 Thread Bernd Ernesti
Hi,

On Thu, Oct 20, 2011 at 09:37:59PM -0400, Christos Zoulas wrote:
 Module Name:  src
 Committed By: christos
 Date: Fri Oct 21 01:37:59 UTC 2011
 
 Modified Files:
   src/lib/libutil: Makefile
 
 Log Message:
 Don't use = to assing SRCS, but += so that we can remove snprintb.c,
 which was added elsewhere.

I find that a little dangerous.

Now SRCS could be defined in the environment which may cause
different behaviour like including different not wanted source
file, build errors ...

I do not know if it would work to move the include of the common
Makefile.inc at the end, propably not. And yes the common Makefile.inc
already used SRCS+= before. That alone should require to move
that include after a normal SRCS=

Bernd



Re: CVS commit: src/lib/libutil

2011-10-21 Thread YAMAMOTO Takashi
hi,

 Module Name:  src
 Committed By: christos
 Date: Fri Oct 21 02:05:36 UTC 2011
 
 Modified Files:
   src/lib/libutil: Makefile
 
 Log Message:
 Add proc_compare

you forgot to commit proc_compare.3?

YAMAMOTO Takashi

 
 
 To generate a diff of this commit:
 cvs rdiff -u -r1.67 -r1.68 src/lib/libutil/Makefile
 
 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

2011-10-21 Thread Christos Zoulas
On Oct 21,  9:33am, y...@mwd.biglobe.ne.jp (YAMAMOTO Takashi) wrote:
-- Subject: Re: CVS commit: src/lib/libutil

| hi,
| 
|  Module Name:src
|  Committed By:   christos
|  Date:   Fri Oct 21 02:05:36 UTC 2011
|  
|  Modified Files:
|  src/lib/libutil: Makefile
|  
|  Log Message:
|  Add proc_compare
| 
| you forgot to commit proc_compare.3?
| 
| YAMAMOTO Takashi

Yup, thanks!

christos


re: CVS commit: src/lib/libutil

2010-05-05 Thread matthew green
   
   Modified Files:
src/lib/libutil: util.3
   
   Log Message:
   Upon lukem@'s request, put the list of functions back.

thank you.


Re: CVS commit: src/lib/libutil

2010-05-04 Thread Luke Mewburn
On Tue, May 04, 2010 at 07:07:12AM +, Jukka Ruohonen wrote:
  | Module Name:src
  | Committed By:   jruoho
  | Date:   Tue May  4 07:07:12 UTC 2010
  | 
  | Modified Files:
  | src/lib/libutil: util.3
  | 
  | Log Message:
  | Remove the list of functions in the libutil library.
  | 
  | While such lists are nice, they are doomed to be repeatedly out of date due
  | maintenance costs related to manual updates. Ideally there should be a
  | common routine to auto-generate these, but in the meantime, just point to
  | the directory where libutil is implemented.

Please revert this; manual pages and application development
tools are often installed on systems where the full source is not.
As I mentioned in my reply to the similar change in stdio(3),
these lists are useful.

cheers,
Luke.


pgpCGMz7b2c4i.pgp
Description: PGP signature


Re: CVS commit: src/lib/libutil

2010-05-04 Thread Jukka Ruohonen
On Wed, May 05, 2010 at 01:05:02PM +1000, Luke Mewburn wrote:
 Please revert this; manual pages and application development
 tools are often installed on systems where the full source is not.

But you always have the header file. Shouldn't that be enough?

 As I mentioned in my reply to the similar change in stdio(3),
 these lists are useful.

And as I noted, incomplete and inaccurate documentation is often worse than
no documentation at all.

- Jukka.


Re: CVS commit: src/lib/libutil

2010-05-04 Thread Luke Mewburn
On Wed, May 05, 2010 at 07:35:41AM +0300, Jukka Ruohonen wrote:
  | On Wed, May 05, 2010 at 01:05:02PM +1000, Luke Mewburn wrote:
  |  Please revert this; manual pages and application development
  |  tools are often installed on systems where the full source is not.
  | 
  | But you always have the header file. Shouldn't that be enough?

In general, I don't find it sufficient to just rely upon reading
header files, especially when the APIs are spread across multiple
recursive #includes and/or may be a macro on some implementations
and a function on others.

This is also true on other UNIX-like platforms such as Darwin  Linux,
and in C++ (STL headers, anyone?)


pgpsZAH8uBSXl.pgp
Description: PGP signature