c-strtof, c-strtod, c-strtold: Make multithread-safe.
[gnulib.git] / doc / quote.texi
blobde16d27960892b3763fdf7f9a87ce341ad6fcbe9
1 @node Quoting
2 @section Quoting
4 @c Copyright (C) 2005, 2009--2024 Free Software Foundation, Inc.
6 @c Permission is granted to copy, distribute and/or modify this document
7 @c under the terms of the GNU Free Documentation License, Version 1.3 or
8 @c any later version published by the Free Software Foundation; with no
9 @c Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.  A
10 @c copy of the license is at <https://www.gnu.org/licenses/fdl-1.3.en.html>.
12 @cindex Quoting
13 @findex quote
14 @findex quotearg
16 Gnulib provides @samp{quote} and @samp{quotearg} modules to help with
17 quoting text, such as file names, in messages to the user.  Here's an
18 example of using @samp{quote}:
20 @example
21 #include <quote.h>
22  ...
23   error (0, errno, _("cannot change owner of %s"), quote (fname));
24 @end example
26 This differs from
28 @example
29   error (0, errno, _("cannot change owner of '%s'"), fname);
30 @end example
32 @noindent in that @code{quote} escapes unusual characters in
33 @code{fname}, e.g., @samp{'} and control characters like @samp{\n}.
35 @findex quote_n
36 However, a caveat: @code{quote} reuses the storage that it returns.
37 Hence if you need more than one thing quoted at the same time, you
38 need to use @code{quote_n}.
40 @findex quotearg_alloc
41 Also, the @code{quote} module is not suited for multithreaded applications.
42 In that case, you have to use @code{quotearg_alloc}, defined in the
43 @samp{quotearg} module, which is decidedly less convenient.