Mercurial > hg > octave-nkf > gnulib-hg
annotate lib/quotearg.h @ 6170:a10e4460ad4c
* lib/regex_internal.h (re_sub_match_top_t): Remove unused member
next_last_offset.
(struct re_dfa_t): Remove unused member states_alloc.
* lib/regcomp.c (init_dfa): Don't initialize unused members.
* config/srclist.txt: Add glibc bug 1273.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Wed, 31 Aug 2005 18:08:34 +0000 |
parents | a48fb0e98c8c |
children | 9b212deb2601 |
rev | line source |
---|---|
1248 | 1 /* quotearg.h - quote arguments for output |
4003
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
2 |
4943
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
3 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software |
4003
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
4 Foundation, Inc. |
1248 | 5 |
6 This program is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 2, or (at your option) | |
9 any later version. | |
10 | |
11 This program is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with this program; if not, write to the Free Software Foundation, | |
5848
a48fb0e98c8c
*** empty log message ***
Paul Eggert <eggert@cs.ucla.edu>
parents:
5159
diff
changeset
|
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
1248 | 19 |
20 /* Written by Paul Eggert <eggert@twinsun.com> */ | |
21 | |
4003
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
22 #ifndef QUOTEARG_H_ |
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
23 # define QUOTEARG_H_ 1 |
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
24 |
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
25 # include <stddef.h> |
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
26 |
1248 | 27 /* Basic quoting styles. */ |
28 enum quoting_style | |
29 { | |
4943
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
30 /* Output names as-is (ls --quoting-style=literal). */ |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
31 literal_quoting_style, |
5159 | 32 |
4943
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
33 /* Quote names for the shell if they contain shell metacharacters |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
34 or would cause ambiguous output (ls --quoting-style=shell). */ |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
35 shell_quoting_style, |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
36 |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
37 /* Quote names for the shell, even if they would normally not |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
38 require quoting (ls --quoting-style=shell-always). */ |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
39 shell_always_quoting_style, |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
40 |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
41 /* Quote names as for a C language string (ls --quoting-style=c). */ |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
42 c_quoting_style, |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
43 |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
44 /* Like c_quoting_style except omit the surrounding double-quote |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
45 characters (ls --quoting-style=escape). */ |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
46 escape_quoting_style, |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
47 |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
48 /* Like clocale_quoting_style, but quote `like this' instead of |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
49 "like this" in the default C locale (ls --quoting-style=locale). */ |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
50 locale_quoting_style, |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
51 |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
52 /* Like c_quoting_style except use quotation marks appropriate for |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
53 the locale (ls --quoting-style=clocale). */ |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
54 clocale_quoting_style |
1248 | 55 }; |
56 | |
1921
d92e0bf8d650
(locale_quoting_style): New enum value.
Jim Meyering <jim@meyering.net>
parents:
1605
diff
changeset
|
57 /* For now, --quoting-style=literal is the default, but this may change. */ |
4003
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
58 # ifndef DEFAULT_QUOTING_STYLE |
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
59 # define DEFAULT_QUOTING_STYLE literal_quoting_style |
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
60 # endif |
1248 | 61 |
1605
e88d6bf51916
(quoting_style_vals): New public array.
Jim Meyering <jim@meyering.net>
parents:
1282
diff
changeset
|
62 /* Names of quoting styles and their corresponding values. */ |
1248 | 63 extern char const *const quoting_style_args[]; |
1605
e88d6bf51916
(quoting_style_vals): New public array.
Jim Meyering <jim@meyering.net>
parents:
1282
diff
changeset
|
64 extern enum quoting_style const quoting_style_vals[]; |
1248 | 65 |
66 struct quoting_options; | |
67 | |
1282 | 68 /* The functions listed below set and use a hidden variable |
69 that contains the default quoting style options. */ | |
70 | |
1248 | 71 /* Allocate a new set of quoting options, with contents initially identical |
1282 | 72 to O if O is not null, or to the default if O is null. |
1248 | 73 It is the caller's responsibility to free the result. */ |
4003
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
74 struct quoting_options *clone_quoting_options (struct quoting_options *o); |
1248 | 75 |
1282 | 76 /* Get the value of O's quoting style. If O is null, use the default. */ |
4003
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
77 enum quoting_style get_quoting_style (struct quoting_options *o); |
1248 | 78 |
1282 | 79 /* In O (or in the default if O is null), |
80 set the value of the quoting style to S. */ | |
4003
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
81 void set_quoting_style (struct quoting_options *o, enum quoting_style s); |
1248 | 82 |
1282 | 83 /* In O (or in the default if O is null), |
84 set the value of the quoting options for character C to I. | |
1248 | 85 Return the old value. Currently, the only values defined for I are |
86 0 (the default) and 1 (which means to quote the character even if | |
87 it would not otherwise be quoted). */ | |
4003
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
88 int set_char_quoting (struct quoting_options *o, char c, int i); |
1248 | 89 |
1282 | 90 /* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of |
1248 | 91 argument ARG (of size ARGSIZE), using O to control quoting. |
1282 | 92 If O is null, use the default. |
1248 | 93 Terminate the output with a null character, and return the written |
94 size of the output, not counting the terminating null. | |
1282 | 95 If BUFFERSIZE is too small to store the output string, return the |
96 value that would have been returned had BUFFERSIZE been large enough. | |
1248 | 97 If ARGSIZE is -1, use the string length of the argument for ARGSIZE. */ |
4003
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
98 size_t quotearg_buffer (char *buffer, size_t buffersize, |
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
99 char const *arg, size_t argsize, |
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
100 struct quoting_options const *o); |
1248 | 101 |
4943
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
102 /* Like quotearg_buffer, except return the result in a newly allocated |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
103 buffer. It is the caller's responsibility to free the result. */ |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
104 char *quotearg_alloc (char const *arg, size_t argsize, |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
105 struct quoting_options const *o); |
686726300104
New function quotearg_alloc. Treat { } = as special sometimes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4003
diff
changeset
|
106 |
1248 | 107 /* Use storage slot N to return a quoted version of the string ARG. |
1282 | 108 Use the default quoting options. |
1248 | 109 The returned value points to static storage that can be |
110 reused by the next call to this function with the same value of N. | |
111 N must be nonnegative. */ | |
4003
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
112 char *quotearg_n (int n, char const *arg); |
1248 | 113 |
1605
e88d6bf51916
(quoting_style_vals): New public array.
Jim Meyering <jim@meyering.net>
parents:
1282
diff
changeset
|
114 /* Equivalent to quotearg_n (0, ARG). */ |
4003
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
115 char *quotearg (char const *arg); |
1248 | 116 |
1921
d92e0bf8d650
(locale_quoting_style): New enum value.
Jim Meyering <jim@meyering.net>
parents:
1605
diff
changeset
|
117 /* Use style S and storage slot N to return a quoted version of the string ARG. |
d92e0bf8d650
(locale_quoting_style): New enum value.
Jim Meyering <jim@meyering.net>
parents:
1605
diff
changeset
|
118 This is like quotearg_n (N, ARG), except that it uses S with no other |
d92e0bf8d650
(locale_quoting_style): New enum value.
Jim Meyering <jim@meyering.net>
parents:
1605
diff
changeset
|
119 options to specify the quoting method. */ |
4003
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
120 char *quotearg_n_style (int n, enum quoting_style s, char const *arg); |
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
121 |
3710
2b37ca0328bd
(quotearg_n_style_mem): New function.
Jim Meyering <jim@meyering.net>
parents:
3658
diff
changeset
|
122 /* Use style S and storage slot N to return a quoted version of the |
2b37ca0328bd
(quotearg_n_style_mem): New function.
Jim Meyering <jim@meyering.net>
parents:
3658
diff
changeset
|
123 argument ARG of size ARGSIZE. This is like quotearg_n_style |
2b37ca0328bd
(quotearg_n_style_mem): New function.
Jim Meyering <jim@meyering.net>
parents:
3658
diff
changeset
|
124 (N, S, ARG), except it can quote null bytes. */ |
4003
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
125 char *quotearg_n_style_mem (int n, enum quoting_style s, |
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
126 char const *arg, size_t argsize); |
1921
d92e0bf8d650
(locale_quoting_style): New enum value.
Jim Meyering <jim@meyering.net>
parents:
1605
diff
changeset
|
127 |
d92e0bf8d650
(locale_quoting_style): New enum value.
Jim Meyering <jim@meyering.net>
parents:
1605
diff
changeset
|
128 /* Equivalent to quotearg_n_style (0, S, ARG). */ |
4003
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
129 char *quotearg_style (enum quoting_style s, char const *arg); |
1921
d92e0bf8d650
(locale_quoting_style): New enum value.
Jim Meyering <jim@meyering.net>
parents:
1605
diff
changeset
|
130 |
1248 | 131 /* Like quotearg (ARG), except also quote any instances of CH. */ |
4003
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
132 char *quotearg_char (char const *arg, char ch); |
1248 | 133 |
134 /* Equivalent to quotearg_char (ARG, ':'). */ | |
4003
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
135 char *quotearg_colon (char const *arg); |
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
136 |
9df30611f84c
Allow multiple inclusion by surrounding with
Paul Eggert <eggert@cs.ucla.edu>
parents:
3710
diff
changeset
|
137 #endif /* !QUOTEARG_H_ */ |