diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-02-05 19:32:19 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-02-05 19:32:19 -0200 |
commit | 5fa51fc4263522d8c5056d76aacbb77e52a3b1ea (patch) | |
tree | ac9796d0e9ccfb20b1d9e7e3a6400fefa28a1090 /manual.tex | |
parent | 15057aa0a42477a04d718270c9bc3303b4e9b613 (diff) | |
download | lua-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.tex | 27 |
1 files changed, 16 insertions, 11 deletions
@@ -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 | |||
32 | Departamento de Inform\'atica --- PUC-Rio | 32 | Departamento 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]'. | |||
1268 | If \verb'i' is absent, it is assumed to be 1. | 1268 | If \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} | ||
1271 | This function returns a formated version of its variable number of arguments | 1272 | This function returns a formated version of its variable number of arguments |
1272 | following the description given in its first argument (which must be a string). | 1273 | following the description given in its first argument (which must be a string). |
1273 | The format string follows the same rules as the \verb'printf' family of | 1274 | The 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. | ||
1406 | This format writes the string in a form suitable to be safely read | ||
1407 | back by the Lua interpreter. | ||
1408 | The string is written between double quotes, | ||
1409 | and all double quotes, returns and backslashes in the string | ||
1410 | are correctly escaped when written. | ||
1404 | \end{description} | 1411 | \end{description} |
1405 | These characters can be followed by | 1412 | These characters can be followed by |
1406 | \begin{verbatim} | 1413 | \begin{verbatim} |
@@ -1420,13 +1427,11 @@ For integers, it is the minimum number of digits. | |||
1420 | This option has no meaning for strings. | 1427 | This option has no meaning for strings. |
1421 | \end{description} | 1428 | \end{description} |
1422 | 1429 | ||
1423 | {\em Warning:} | ||
1424 | This format parameter is now obsolete; | ||
1425 | formated output should use the \verb'format' function. | ||
1426 | |||
1427 | When called without a format string, | 1430 | When called without a format string, |
1428 | this function writes numbers using the \verb'%g' format | 1431 | this function writes numbers using the \verb'%g' format |
1429 | and strings with \verb'%s'. | 1432 | and strings with \verb'%s'. |
1433 | For better format facilities, | ||
1434 | the 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, | |||
1571 | the following code is enough: | 1576 | the following code is enough: |
1572 | \begin{verbatim} | 1577 | \begin{verbatim} |
1573 | function store (name, value) | 1578 | function store (name, value) |
1574 | write('\n' .. name .. '=') | 1579 | write(format('\n%s =', name)) |
1575 | write_value(value) | 1580 | write_value(value) |
1576 | end | 1581 | end |
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 |
1585 | end | 1590 | end |
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 |
1603 | end | 1608 | end |