9srv Manual Collection/plan9/quote(2) | 9srv Manual Collection/plan9/quote(2) |
---|
char *quotestrdup(char *s)
Rune *quoterunestrdup(Rune *s)
char *unquotestrdup(char *s)
Rune *unquoterunestrdup(Rune *s)
int quotestrfmt(Fmt*)
int quoterunestrfmt(Fmt*)
void quotefmtinstall(void)
int (*doquote)(int c)
int needsrcquote(int c)
when quoted becomes
The empty string is represented by two quotes, ''.
The first four functions act as variants of strdup (see strcat(2)). Each returns a freshly allocated copy of the string, created using malloc(2). Quotestrdup returns a quoted copy of s, while unquotestrdup returns a copy of s with the quotes evaluated. The rune versions of these functions do the same for strings (see runestrcat(2)).
The string returned by quotestrdup or quoterunestrdup has the following properties:
The function pointer doquote is nil by default. If it is non-nil, characters are passed to that function to see if they should be quoted. This mechanism allows programs to specify that characters other than blanks, control characters, or quotes be quoted. Regardless of the return value of *doquote, blanks, control characters, and quotes are always quoted. Needsrcquote is provided as a doquote function that flags any character special to rc(1).
Quotestrfmt and quoterunestrfmt are print(2) formatting routines that produce quoted strings as output. They may be installed by hand, but quotefmtinstall installs them under the standard format characters q and Q. (They are not installed automatically.) If the format string includes the alternate format character #, for example %#q, the printed string will always be quoted; otherwise quotes will only be provided if necessary to avoid ambiguity. In <libc.h> there are #pragma statements so the compiler can type-check uses of %q and %Q in print(2) format strings.
9srv Manual Collection/plan9/quote(2) | Rev: Sun Dec 02 23:42:21 GMT 2007 |