[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Compiling Reverse Polish Calculator Example
From: |
Akim Demaille |
Subject: |
Re: Compiling Reverse Polish Calculator Example |
Date: |
Wed, 31 Oct 2012 18:04:33 +0100 |
Le 31 oct. 2012 à 17:24, Paul Eggert a écrit :
> On 10/31/2012 08:46 AM, Akim Demaille wrote:
>> BTW, Paul, did you see my question about quotearg in this very thread?
>
> Sorry, no, I missed that. I suppose there should be
> a quote_mem or something like that.
How about this?
(the context for gnulibers:
http://lists.gnu.org/archive/html/help-bison/2012-10/msg00017.html)
commit 4eb2dff11e4920ecbcec69a60f282900e152e400
Author: Akim Demaille <address@hidden>
Date: Wed Oct 31 18:01:34 2012 +0100
quote: provide a means to escape strings with nul characters
* lib/quote.h, lib/quote.c (quote_mem, quote_n_mem): New functions.
(quote, quote_n): Rename formal arguments for consistency with
quotearg.
diff --git a/ChangeLog b/ChangeLog
index bf77930..868e583 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-10-31 Akim Demaille <address@hidden>
+
+ quote: provide a means to escape strings with nul characters
+ * lib/quote.h, lib/quote.c (quote_mem, quote_n_mem): New functions.
+ (quote, quote_n): Rename formal arguments for consistency with
+ quotearg.
+
2012-10-30 Paul Eggert <address@hidden>
test-raise: don't assume 199 is an invalid signal
diff --git a/lib/quote.h b/lib/quote.h
index b30b166..e3b332d 100644
--- a/lib/quote.h
+++ b/lib/quote.h
@@ -18,16 +18,29 @@
#ifndef QUOTE_H_
# define QUOTE_H_ 1
+# include <stddef.h>
+
/* The quoting options used by quote_n and quote. Its type is incomplete,
so it's useful only in expressions like '"e_quoting_options'. */
extern struct quoting_options quote_quoting_options;
-/* Return an unambiguous printable representation of NAME,
- allocated in slot N, suitable for diagnostics. */
-char const *quote_n (int n, char const *name);
+/* Return an unambiguous printable representation of ARG (of size
+ ARGSIZE), allocated in slot N, suitable for diagnostics. If
+ ARGSIZE is SIZE_MAX, use the string length of the argument for
+ ARGSIZE. */
+char const *quote_n_mem (int n, char const *arg, size_t argsize);
+
+/* Return an unambiguous printable representation of ARG (of size
+ ARGSIZE), suitable for diagnostics. If ARGSIZE is SIZE_MAX, use
+ the string length of the argument for ARGSIZE. */
+char const *quote_mem (char const *arg, size_t argsize);
+
+/* Return an unambiguous printable representation of ARG, allocated in
+ slot N, suitable for diagnostics. */
+char const *quote_n (int n, char const *arg);
-/* Return an unambiguous printable representation of NAME,
- suitable for diagnostics. */
-char const *quote (char const *name);
+/* Return an unambiguous printable representation of ARG, suitable for
+ diagnostics. */
+char const *quote (char const *arg);
#endif /* !QUOTE_H_ */
diff --git a/lib/quotearg.c b/lib/quotearg.c
index 1ea583d..7fb866d 100644
--- a/lib/quotearg.c
+++ b/lib/quotearg.c
@@ -929,7 +929,7 @@ quotearg_custom_mem (char const *left_quote, char const
*right_quote,
}
-/* The quoting option used by quote_n and quote. */
+/* The quoting option used by the functions of quote.h. */
struct quoting_options quote_quoting_options =
{
locale_quoting_style,
@@ -939,13 +939,25 @@ struct quoting_options quote_quoting_options =
};
char const *
-quote_n (int n, char const *name)
+quote_n_mem (int n, char const *arg, size_t argsize)
{
- return quotearg_n_options (n, name, SIZE_MAX, "e_quoting_options);
+ return quotearg_n_options (n, arg, argsize, "e_quoting_options);
}
char const *
-quote (char const *name)
+quote_mem (char const *arg, size_t argsize)
{
- return quote_n (0, name);
+ return quote_n_mem (0, arg, argsize);
+}
+
+char const *
+quote_n (int n, char const *arg)
+{
+ return quote_n_mem (n, arg, SIZE_MAX);
+}
+
+char const *
+quote (char const *arg)
+{
+ return quote_n (0, arg);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Compiling Reverse Polish Calculator Example,
Akim Demaille <=