bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / code / Atom feed
* [PATCH] idx: new printf/scanf length modifier macro
@ 2021-06-14 23:47 Paul Eggert
  2021-06-15  0:55 ` Bruno Haible
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Eggert @ 2021-06-14 23:47 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Paul Eggert

* lib/idx.h (pIDX): New macro.
---
 ChangeLog | 5 +++++
 lib/idx.h | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index b98de6bf6..4e8242ade 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2021-06-14  Paul Eggert  <eggert@cs.ucla.edu>
+
+	idx: new printf/scanf length modifier macro
+	* lib/idx.h (pIDX): New macro.
+
 2021-06-13  Bruno Haible  <bruno@clisp.org>
 
 	Align 2011-11-26 patch to 2021-04-11 patch (regression from 2021-04-11).
diff --git a/lib/idx.h b/lib/idx.h
index 483587eab..28fd4ea72 100644
--- a/lib/idx.h
+++ b/lib/idx.h
@@ -107,6 +107,10 @@ typedef ptrdiff_t idx_t;
 /* IDX_MAX is the maximum value of an idx_t.  */
 #define IDX_MAX PTRDIFF_MAX
 
+/* A printf/scanf length modifier for idx_t.  For example, if i is an idx_t,
+   printf ("i = %"pIDX"d\n", i) outputs i's value.  */
+#define pIDX "t"
+
 /* So far no need has been found for an IDX_WIDTH macro.
    Perhaps there should be another macro IDX_VALUE_BITS that does not
    count the sign bit and is therefore one less than PTRDIFF_WIDTH.  */
-- 
2.30.2



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

* Re: [PATCH] idx: new printf/scanf length modifier macro
  2021-06-14 23:47 [PATCH] idx: new printf/scanf length modifier macro Paul Eggert
@ 2021-06-15  0:55 ` Bruno Haible
  2021-06-15 17:32   ` Paul Eggert
  0 siblings, 1 reply; 3+ messages in thread
From: Bruno Haible @ 2021-06-15  0:55 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Paul Eggert

> +/* A printf/scanf length modifier for idx_t.  For example, if i is an idx_t,
> +   printf ("i = %"pIDX"d\n", i) outputs i's value.  */
> +#define pIDX "t"

Note that this modifier is not supported in internationalized format strings.
gettext() supports only the modifier names from <inttypes.h>. [1]

Bruno

[1] https://www.gnu.org/software/gettext/manual/html_node/Preparing-Strings.html



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

* Re: [PATCH] idx: new printf/scanf length modifier macro
  2021-06-15  0:55 ` Bruno Haible
@ 2021-06-15 17:32   ` Paul Eggert
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Eggert @ 2021-06-15 17:32 UTC (permalink / raw)
  To: Bruno Haible, bug-gnulib

On 6/14/21 5:55 PM, Bruno Haible wrote:
> Note that this modifier is not supported in internationalized format strings.
> gettext() supports only the modifier names from <inttypes.h>. [1]

I guess I'll just use plain "%td" then. Oh well.


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

end of thread, other threads:[~2021-06-15 17:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-14 23:47 [PATCH] idx: new printf/scanf length modifier macro Paul Eggert
2021-06-15  0:55 ` Bruno Haible
2021-06-15 17:32   ` Paul Eggert

Code repositories for project(s) associated with this inbox:

	../../../mirrors/gnulib.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).