summaryrefslogtreecommitdiff
path: root/manual.tex
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-02-05 19:32:19 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-02-05 19:32:19 -0200
commit5fa51fc4263522d8c5056d76aacbb77e52a3b1ea (patch)
treeac9796d0e9ccfb20b1d9e7e3a6400fefa28a1090 /manual.tex
parent15057aa0a42477a04d718270c9bc3303b4e9b613 (diff)
downloadlua-5fa51fc4263522d8c5056d76aacbb77e52a3b1ea.tar.gz
lua-5fa51fc4263522d8c5056d76aacbb77e52a3b1ea.tar.bz2
lua-5fa51fc4263522d8c5056d76aacbb77e52a3b1ea.zip
new option "q" in function "write", to write literal strings.
Diffstat (limited to 'manual.tex')
-rw-r--r--manual.tex27
1 files changed, 16 insertions, 11 deletions
diff --git a/manual.tex b/manual.tex
index d3aa89dc..a3b9309e 100644
--- a/manual.tex
+++ b/manual.tex
@@ -1,4 +1,4 @@
1% $Id: manual.tex,v 1.4 1996/01/30 15:24:49 roberto Exp roberto $ 1% $Id: manual.tex,v 1.5 1996/02/05 14:52:47 roberto Exp roberto $
2 2
3\documentstyle[A4,11pt,bnf]{article} 3\documentstyle[A4,11pt,bnf]{article}
4 4
@@ -11,7 +11,7 @@
11\newcommand{\Index}[1]{#1\index{#1}} 11\newcommand{\Index}[1]{#1\index{#1}}
12\newcommand{\IndexVerb}[1]{{\tt #1}\index{#1}} 12\newcommand{\IndexVerb}[1]{{\tt #1}\index{#1}}
13\newcommand{\Def}[1]{{\em #1}\index{#1}} 13\newcommand{\Def}[1]{{\em #1}\index{#1}}
14\newcommand{\Deffunc}[1]{\index{{\tt #1}}} 14\newcommand{\Deffunc}[1]{\index{#1}}
15 15
16%\makeindex 16%\makeindex
17 17
@@ -32,7 +32,7 @@ Waldemar Celes Filho
32Departamento de Inform\'atica --- PUC-Rio 32Departamento de Inform\'atica --- PUC-Rio
33} 33}
34 34
35\date{\small \verb$Date: 1996/01/30 15:24:49 $} 35\date{\small \verb$Date: 1996/02/05 14:52:47 $}
36 36
37\maketitle 37\maketitle
38 38
@@ -1268,6 +1268,7 @@ Returns the ascii code of the character \verb's[i]'.
1268If \verb'i' is absent, it is assumed to be 1. 1268If \verb'i' is absent, it is assumed to be 1.
1269 1269
1270\subsubsection*{{\tt format (formatstring, e1, e2, \ldots)}}\Deffunc{format} 1270\subsubsection*{{\tt format (formatstring, e1, e2, \ldots)}}\Deffunc{format}
1271\label{format}
1271This function returns a formated version of its variable number of arguments 1272This function returns a formated version of its variable number of arguments
1272following the description given in its first argument (which must be a string). 1273following the description given in its first argument (which must be a string).
1273The format string follows the same rules as the \verb'printf' family of 1274The format string follows the same rules as the \verb'printf' family of
@@ -1400,7 +1401,13 @@ following characters:
1400\begin{description} 1401\begin{description}
1401\item['s' or 'S'] to write strings; 1402\item['s' or 'S'] to write strings;
1402\item['f' or 'F'] to write floats; 1403\item['f' or 'F'] to write floats;
1403\item['i' or 'I'] to write integers. 1404\item['i' or 'I'] to write integers;
1405\item['q' or 'Q'] to write quoted strings.
1406This format writes the string in a form suitable to be safely read
1407back by the Lua interpreter.
1408The string is written between double quotes,
1409and all double quotes, returns and backslashes in the string
1410are correctly escaped when written.
1404\end{description} 1411\end{description}
1405These characters can be followed by 1412These characters can be followed by
1406\begin{verbatim} 1413\begin{verbatim}
@@ -1420,13 +1427,11 @@ For integers, it is the minimum number of digits.
1420This option has no meaning for strings. 1427This option has no meaning for strings.
1421\end{description} 1428\end{description}
1422 1429
1423{\em Warning:}
1424This format parameter is now obsolete;
1425formated output should use the \verb'format' function.
1426
1427When called without a format string, 1430When called without a format string,
1428this function writes numbers using the \verb'%g' format 1431this function writes numbers using the \verb'%g' format
1429and strings with \verb'%s'. 1432and strings with \verb'%s'.
1433For better format facilities,
1434the function \verb'format' should be used (\see{format}).
1430 1435
1431\subsubsection*{{\tt date ()}}\Deffunc{date} 1436\subsubsection*{{\tt date ()}}\Deffunc{date}
1432 1437
@@ -1571,7 +1576,7 @@ To store a single value with a name,
1571the following code is enough: 1576the following code is enough:
1572\begin{verbatim} 1577\begin{verbatim}
1573function store (name, value) 1578function store (name, value)
1574 write('\n' .. name .. '=') 1579 write(format('\n%s =', name))
1575 write_value(value) 1580 write_value(value)
1576end 1581end
1577\end{verbatim} 1582\end{verbatim}
@@ -1580,7 +1585,7 @@ function write_value (value)
1580 local t = type(value) 1585 local t = type(value)
1581 if t == 'nil' then write('nil') 1586 if t == 'nil' then write('nil')
1582 elseif t == 'number' then write(value) 1587 elseif t == 'number' then write(value)
1583 elseif t == 'string' then write('[[' .. value .. ']]') 1588 elseif t == 'string' then write(value, 'q')
1584 end 1589 end
1585end 1590end
1586\end{verbatim} 1591\end{verbatim}
@@ -1597,7 +1602,7 @@ function write_value (value)
1597 local t = type(value) 1602 local t = type(value)
1598 if t == 'nil' then write('nil') 1603 if t == 'nil' then write('nil')
1599 elseif t == 'number' then write(value) 1604 elseif t == 'number' then write(value)
1600 elseif t == 'string' then write('"' .. value .. '"') 1605 elseif t == 'string' then write(value, 'q')
1601 elseif t == 'table' then write_record(value) 1606 elseif t == 'table' then write_record(value)
1602 end 1607 end
1603end 1608end