165 lines
7.6 KiB
HTML
165 lines
7.6 KiB
HTML
|
|
<head>
|
||
|
|
<title>quote(3) - Plan 9 from User Space</title>
|
||
|
|
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
|
||
|
|
</head>
|
||
|
|
<body bgcolor=#ffffff>
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0 width=100%>
|
||
|
|
<tr height=10><td>
|
||
|
|
<tr><td width=20><td>
|
||
|
|
<tr><td width=20><td><b>QUOTE(3)</b><td align=right><b>QUOTE(3)</b>
|
||
|
|
<tr><td width=20><td colspan=2>
|
||
|
|
<br>
|
||
|
|
<p><font size=+1><b>NAME </b></font><br>
|
||
|
|
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
|
||
|
|
|
||
|
|
quotestrdup, quoterunestrdup, unquotestrdup, unquoterunestrdup,
|
||
|
|
quotestrfmt, quoterunestrfmt, quotefmtinstall, doquote, needsrcquote
|
||
|
|
– quoted character strings<br>
|
||
|
|
|
||
|
|
</table>
|
||
|
|
<p><font size=+1><b>SYNOPSIS </b></font><br>
|
||
|
|
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
|
||
|
|
|
||
|
|
<tt><font size=+1>#include <u.h><br>
|
||
|
|
#include <libc.h>
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||
|
|
</font></tt>
|
||
|
|
<tt><font size=+1>char *quotestrdup(char *s)
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||
|
|
</font></tt>
|
||
|
|
<tt><font size=+1>Rune *quoterunestrdup(Rune *s)
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||
|
|
</font></tt>
|
||
|
|
<tt><font size=+1>char *unquotestrdup(char *s)
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||
|
|
</font></tt>
|
||
|
|
<tt><font size=+1>Rune *unquoterunestrdup(Rune *s)
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||
|
|
</font></tt>
|
||
|
|
<tt><font size=+1>int quotestrfmt(Fmt*)
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||
|
|
</font></tt>
|
||
|
|
<tt><font size=+1>int quoterunestrfmt(Fmt*)
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||
|
|
</font></tt>
|
||
|
|
<tt><font size=+1>void quotefmtinstall(void)
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||
|
|
</font></tt>
|
||
|
|
<tt><font size=+1>int (*doquote)(int c)
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||
|
|
</font></tt>
|
||
|
|
<tt><font size=+1>int needsrcquote(int c)
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||
|
|
</font></tt>
|
||
|
|
|
||
|
|
</table>
|
||
|
|
<p><font size=+1><b>DESCRIPTION </b></font><br>
|
||
|
|
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
|
||
|
|
|
||
|
|
These routines manipulate character strings, either adding or
|
||
|
|
removing quotes as necessary. In the quoted form, the strings
|
||
|
|
are in the style of <a href="../man1/rc.html"><i>rc</i>(1)</a><i>,</i> with single quotes surrounding the
|
||
|
|
string. Embedded single quotes are indicated by a doubled single
|
||
|
|
quote. For instance,<br>
|
||
|
|
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
|
||
|
|
|
||
|
|
<tt><font size=+1>Don't worry!<br>
|
||
|
|
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||
|
|
</font></tt>
|
||
|
|
|
||
|
|
</table>
|
||
|
|
when quoted becomes<br>
|
||
|
|
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
|
||
|
|
|
||
|
|
<tt><font size=+1>'Don''t worry!'<br>
|
||
|
|
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||
|
|
</font></tt>
|
||
|
|
|
||
|
|
</table>
|
||
|
|
The empty string is represented by two quotes, <tt><font size=+1>''</font></tt>.
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||
|
|
|
||
|
|
The first four functions act as variants of <tt><font size=+1>strdup</font></tt> (see <a href="../man3/strcat.html"><i>strcat</i>(3)</a>).
|
||
|
|
Each returns a freshly allocated copy of the string, created using
|
||
|
|
<a href="../man3/malloc.html"><i>malloc</i>(3)</a>. <i>Quotestrdup</i> returns a quoted copy of <i>s</i>, while <i>unquotestrdup</i>
|
||
|
|
returns a copy of <i>s</i> with the quotes evaluated. The <i>rune</i> versions
|
||
|
|
of these functions do the same for strings (see
|
||
|
|
<a href="../man3/runestrcat.html"><i>runestrcat</i>(3)</a>).
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||
|
|
|
||
|
|
The string returned by <i>quotestrdup</i> or <i>quoterunestrdup</i> has the
|
||
|
|
following properties:<br>
|
||
|
|
1. If the original string <i>s</i> is empty, the returned string is <tt><font size=+1>''</font></tt>.<br>
|
||
|
|
2. If <i>s</i> contains no quotes, blanks, or control characters, the
|
||
|
|
returned string is identical to <i>s</i>.<br>
|
||
|
|
3. If <i>s</i> needs quotes to be added, the first character of the returned
|
||
|
|
string will be a quote. For example, <tt><font size=+1>hello world</font></tt> becomes <tt><font size=+1>'hello
|
||
|
|
world'</font></tt> not <tt><font size=+1>hello' 'world</font></tt>.
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||
|
|
|
||
|
|
The function pointer <i>doquote</i> is <tt><font size=+1>nil</font></tt> 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 <i>*doquote</i>, blanks, control
|
||
|
|
characters, and quotes are always quoted. <i>Needsrcquote</i> is provided
|
||
|
|
as a <i>doquote</i> function that flags any character special to <a href="../man1/rc.html"><i>rc</i>(1)</a>.
|
||
|
|
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
|
||
|
|
|
||
|
|
<i>Quotestrfmt</i> and <i>quoterunestrfmt</i> are <a href="../man3/print.html"><i>print</i>(3)</a> formatting routines
|
||
|
|
that produce quoted strings as output. They may be installed by
|
||
|
|
hand, but <i>quotefmtinstall</i> installs them under the standard format
|
||
|
|
characters <tt><font size=+1>q</font></tt> and <tt><font size=+1>Q</font></tt>. (They are not installed automatically.) If
|
||
|
|
the format string includes the alternate format character <tt><font size=+1>#</font></tt>,
|
||
|
|
for example <tt><font size=+1>%#q</font></tt>, the printed string will always be quoted; otherwise
|
||
|
|
quotes will only be provided if necessary to avoid ambiguity.
|
||
|
|
In <tt><font size=+1><libc.h></font></tt> there are <tt><font size=+1>#pragma</font></tt> statements so the compiler can type-check
|
||
|
|
uses of <tt><font size=+1>%q</font></tt> and <tt><font size=+1>%Q</font></tt> in <a href="../man3/print.html"><i>print</i>(3)</a> format strings.<br>
|
||
|
|
|
||
|
|
</table>
|
||
|
|
<p><font size=+1><b>SOURCE </b></font><br>
|
||
|
|
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
|
||
|
|
|
||
|
|
<tt><font size=+1>/usr/local/plan9/src/lib9/quote.c<br>
|
||
|
|
/usr/local/plan9/src/lib9/fmt/fmtquote.c<br>
|
||
|
|
</font></tt>
|
||
|
|
</table>
|
||
|
|
<p><font size=+1><b>SEE ALSO </b></font><br>
|
||
|
|
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
|
||
|
|
|
||
|
|
<a href="../man1/rc.html"><i>rc</i>(1)</a>, <a href="../man3/malloc.html"><i>malloc</i>(3)</a>, <a href="../man3/print.html"><i>print</i>(3)</a>, <a href="../man3/strcat.html"><i>strcat</i>(3)</a><br>
|
||
|
|
|
||
|
|
</table>
|
||
|
|
<p><font size=+1><b>BUGS </b></font><br>
|
||
|
|
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
|
||
|
|
|
||
|
|
Because it is provided by the format library, <i>doquote</i> is a preprocessor
|
||
|
|
macro defined as <i>fmtdoquote</i>; see <a href="../man3/intro.html"><i>intro</i>(3)</a>.<br>
|
||
|
|
|
||
|
|
</table>
|
||
|
|
|
||
|
|
<td width=20>
|
||
|
|
<tr height=20><td>
|
||
|
|
</table>
|
||
|
|
<!-- TRAILER -->
|
||
|
|
<table border=0 cellpadding=0 cellspacing=0 width=100%>
|
||
|
|
<tr height=15><td width=10><td><td width=10>
|
||
|
|
<tr><td><td>
|
||
|
|
<center>
|
||
|
|
<a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a>
|
||
|
|
</center>
|
||
|
|
</table>
|
||
|
|
<!-- TRAILER -->
|
||
|
|
</body></html>
|