All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] man: printf: all Ar arguments are processed identically
@ 2022-08-14  0:19 наб
  2022-08-14  0:20 ` [PATCH 2/2] man: printf: in 'X, X is a byte under dash наб
  2022-08-14  1:11 ` [PATCH 1/2] man: printf: all Ar arguments are processed identically Harald van Dijk
  0 siblings, 2 replies; 5+ messages in thread
From: наб @ 2022-08-14  0:19 UTC (permalink / raw)
  To: dash

[-- Attachment #1: Type: text/plain, Size: 656 bytes --]

The current wording says that given
  printf a b c d
a is the format, c and d are processed as noted,
but b is unspecified

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 src/dash.1 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/dash.1 b/src/dash.1
index ff02237..bd5c311 100644
--- a/src/dash.1
+++ b/src/dash.1
@@ -1544,7 +1544,7 @@ each of which causes printing of the next successive
 .Pp
 The
 .Ar arguments
-after the first are treated as strings if the corresponding format is
+are treated as strings if the corresponding format is
 either
 .Cm b ,
 .Cm c
-- 
2.30.2


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] man: printf: in 'X, X is a byte under dash
  2022-08-14  0:19 [PATCH 1/2] man: printf: all Ar arguments are processed identically наб
@ 2022-08-14  0:20 ` наб
  2022-08-14  1:11 ` [PATCH 1/2] man: printf: all Ar arguments are processed identically Harald van Dijk
  1 sibling, 0 replies; 5+ messages in thread
From: наб @ 2022-08-14  0:20 UTC (permalink / raw)
  To: dash

[-- Attachment #1: Type: text/plain, Size: 1312 bytes --]

Multiple issues:
  * the encoding is not always ASCII
  * what ASCII code is assigned to я
  * dash isn't internationalised
    (this is nonconformant but out of scope),
    and uses the next /byte/; in a UTF-8 locale:
      $ printf %d\\n \'ą
      196
      $ printf %d\\n \'я
      196
    this is in contrast to POSIX (and bash), which says:
      > If the leading character is a single-quote or double-quote,
      > the value shall be the numeric value in the underlying codeset
      > of the character following the single-quote or double-quote.
    (i.e. mbrtowc(&val, argv[n], ...))

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 src/dash.1 | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/dash.1 b/src/dash.1
index bd5c311..19d4d3b 100644
--- a/src/dash.1
+++ b/src/dash.1
@@ -1556,9 +1556,7 @@ otherwise it is evaluated as a C constant, with the following extensions:
 .It
 A leading plus or minus sign is allowed.
 .It
-If the leading character is a single or double quote, the value is the
-.Tn ASCII
-code of the next character.
+If the leading character is a single or double quote, the value of the next byte.
 .El
 .Pp
 The format string is reused as often as necessary to satisfy the
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] man: printf: all Ar arguments are processed identically
  2022-08-14  0:19 [PATCH 1/2] man: printf: all Ar arguments are processed identically наб
  2022-08-14  0:20 ` [PATCH 2/2] man: printf: in 'X, X is a byte under dash наб
@ 2022-08-14  1:11 ` Harald van Dijk
  2022-08-14 14:19   ` [PATCH v2 1/2] man: printf: reword to avoid confusion v/v Ar argument[s]/arguments наб
  2022-08-14 14:19   ` [PATCH v2 2/2] man: printf: in 'X, X is a byte under dash наб
  1 sibling, 2 replies; 5+ messages in thread
From: Harald van Dijk @ 2022-08-14  1:11 UTC (permalink / raw)
  To: наб, dash

On 14/08/2022 01:19, наб wrote:
> The current wording says that given
>    printf a b c d
> a is the format, c and d are processed as noted,
> but b is unspecified

I think the way "arguments after the first" is intended to be read is 
"arguments after the format string", as the format string is itself an 
argument. But this is not clear at all: "printf format [arguments ...]" 
can be read as saying that the format is not an argument.

Perhaps "arguments after the format string" or "arguments after format" 
would be a better replacement that avoids any ambiguity?

Cheers,
Harald van Dijk

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] man: printf: reword to avoid confusion v/v Ar argument[s]/arguments
  2022-08-14  1:11 ` [PATCH 1/2] man: printf: all Ar arguments are processed identically Harald van Dijk
@ 2022-08-14 14:19   ` наб
  2022-08-14 14:19   ` [PATCH v2 2/2] man: printf: in 'X, X is a byte under dash наб
  1 sibling, 0 replies; 5+ messages in thread
From: наб @ 2022-08-14 14:19 UTC (permalink / raw)
  To: dash, Harald van Dijk

[-- Attachment #1: Type: text/plain, Size: 2326 bytes --]

The current wording says that given
  printf a b c d
a is the format, c and d are processed as noted,
but b is unspecified

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
That's a fair cop, considering the manual already abuses Ar arguments as
Ar argument and arguments.

Please consider the following updated patch, which calls the arguments
consumed by conversions "value"s.

 src/dash.1 | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/src/dash.1 b/src/dash.1
index ff02237..310f34e 100644
--- a/src/dash.1
+++ b/src/dash.1
@@ -1528,30 +1528,26 @@ With the
 option specified the output will be formatted suitably for non-interactive use.
 .\".Pp
 .It Xo printf Ar format
-.Op Ar arguments  ...
+.Oo Ar value Oc Ns ...
 .Xc
 .Ic printf
-formats and prints its arguments, after the first, under control
-of the
-.Ar format  .
-The
-.Ar format
-is a character string which contains three types of objects: plain characters,
+formats and prints its arguments according to
+.Ar format ,
+a character string which contains three types of objects: plain characters,
 which are simply copied to standard output, character escape sequences which
 are converted and copied to the standard output, and format specifications,
 each of which causes printing of the next successive
-.Ar argument  .
+.Ar value .
 .Pp
-The
-.Ar arguments
-after the first are treated as strings if the corresponding format is
+Each
+.Ar value
+is treated as a string if the corresponding format specification is
 either
 .Cm b ,
-.Cm c
+.Cm c ,
 or
 .Cm s ;
-otherwise it is evaluated as a C constant, with the following extensions:
-.Pp
+otherwise it is evaluated as a C constant, with the following additions:
 .Bl -bullet -offset indent -compact
 .It
 A leading plus or minus sign is allowed.
@@ -1561,8 +1557,9 @@ If the leading character is a single or double quote, the value is the
 code of the next character.
 .El
 .Pp
-The format string is reused as often as necessary to satisfy the
-.Ar arguments  .
+The format string is reused as often as necessary until all
+.Ar value Ns s
+are consumed.
 Any extra format specifications are evaluated with zero or the null
 string.
 .Pp
-- 
2.30.2


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] man: printf: in 'X, X is a byte under dash
  2022-08-14  1:11 ` [PATCH 1/2] man: printf: all Ar arguments are processed identically Harald van Dijk
  2022-08-14 14:19   ` [PATCH v2 1/2] man: printf: reword to avoid confusion v/v Ar argument[s]/arguments наб
@ 2022-08-14 14:19   ` наб
  1 sibling, 0 replies; 5+ messages in thread
From: наб @ 2022-08-14 14:19 UTC (permalink / raw)
  To: dash, Harald van Dijk

[-- Attachment #1: Type: text/plain, Size: 1306 bytes --]

Multiple issues:
  * the encoding is not always ASCII
  * what ASCII code is assigned to я
  * dash isn't internationalised
    (this is nonconformant but out of scope),
    and uses the next /byte/; in a UTF-8 locale:
      $ printf %d\\n \'ą
      196
      $ printf %d\\n \'я
      196
    this is in contrast to POSIX (and bash), which says:
      > If the leading character is a single-quote or double-quote,
      > the value shall be the numeric value in the underlying codeset
      > of the character following the single-quote or double-quote.
    (i.e. mbrtowc(&val, argv[n], ...))

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 src/dash.1 | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/dash.1 b/src/dash.1
index 310f34e..38cf020 100644
--- a/src/dash.1
+++ b/src/dash.1
@@ -1552,9 +1552,7 @@ otherwise it is evaluated as a C constant, with the following additions:
 .It
 A leading plus or minus sign is allowed.
 .It
-If the leading character is a single or double quote, the value is the
-.Tn ASCII
-code of the next character.
+If the leading character is a single or double quote, the value of the next byte.
 .El
 .Pp
 The format string is reused as often as necessary until all
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-14 14:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-14  0:19 [PATCH 1/2] man: printf: all Ar arguments are processed identically наб
2022-08-14  0:20 ` [PATCH 2/2] man: printf: in 'X, X is a byte under dash наб
2022-08-14  1:11 ` [PATCH 1/2] man: printf: all Ar arguments are processed identically Harald van Dijk
2022-08-14 14:19   ` [PATCH v2 1/2] man: printf: reword to avoid confusion v/v Ar argument[s]/arguments наб
2022-08-14 14:19   ` [PATCH v2 2/2] man: printf: in 'X, X is a byte under dash наб

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.