[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo update (Wed Jul 5 09:52:01 EDT 2006)
From: |
Karl Berry |
Subject: |
texinfo update (Wed Jul 5 09:52:01 EDT 2006) |
Date: |
Wed, 05 Jul 2006 09:52:22 -0400 |
Index: doc/texinfo.txi
===================================================================
RCS file: /sources/texinfo/texinfo/doc/texinfo.txi,v
retrieving revision 1.166
retrieving revision 1.167
diff -u -r1.166 -r1.167
--- doc/texinfo.txi 24 Jun 2006 22:02:28 -0000 1.166
+++ doc/texinfo.txi 5 Jul 2006 13:39:05 -0000 1.167
@@ -1,5 +1,5 @@
\input texinfo.tex @c -*-texinfo-*-
address@hidden $Id: texinfo.txi,v 1.166 2006/06/24 22:02:28 karl Exp $
address@hidden $Id: texinfo.txi,v 1.167 2006/07/05 13:39:05 karl Exp $
@c Ordinarily, Texinfo files have the extension .texi. But texinfo.texi
@c clashes with texinfo.tex on 8.3 filesystems, so we use texinfo.txi.
@@ -13768,16 +13768,71 @@
@end display
@cindex Comma, in macro arguments
+Passing strings containing commas as macro arguments requires special
+care, since they should be properly @dfn{quoted} to prevent
address@hidden from confusing them with argument separators. To
+manually quote a comma, prepend it with a backslash character, like
+this: @code{\,}. Alternatively, use the @code{@@comma} command
+(@pxref{Inserting a Comma}). However, to facilitate use of macros,
address@hidden implements a set of rules called @dfn{automatic
+quoting}:
+
address@hidden 1
address@hidden If a macro takes only one argument, all commas in its invocation
+are quoted by default. For example:
+
address@hidden
address@hidden
+@@macro address@hidden@}
+@@address@hidden: address@hidden
+@@end macro
+
+@@address@hidden nice feature, though it can be address@hidden
address@hidden group
address@hidden example
+
address@hidden
+will produce the following output
+
address@hidden
address@hidden: A nice feature, though it can be dangerous.}
address@hidden example
+
+And indeed, it can. Namely, @command{makeinfo}
+does not control number of arguments passed to one-argument
+macros, so be careful when you invoke them.
+
address@hidden If a macro calls another macro (possibly itself), any commas in
+the nested macro invocations are quoted by default. Thus, the
+following example:
+
address@hidden
address@hidden
+@@rmacro address@hidden,address@hidden
+\a\\b\
+@@end rmacro
+
+@@address@hidden@@address@hidden, address@hidden, address@hidden
address@hidden group
address@hidden example
+
address@hidden
+will produce the string @samp{foobarbaz}.
+
address@hidden Otherwise, a comma should be explicitly quoted, as above, to be
+treated as a part of an argument.
address@hidden enumerate
+
@cindex Braces, in macro arguments
-To insert a comma, brace, or backslash in an argument, prepend a
-backslash, as in
+Other characters that need to be quoted in macro arguments are
+curly braces and backslash. For example
@example
@@@var{macname} @address@hidden@}\,@}
@end example
@noindent
-which will pass the (almost certainly error-producing) argument
+will pass the (almost certainly error-producing) argument
@address@hidden@},} to @var{macname}. However, commas in parameters, even
if escaped by a backslash, might cause trouble in @TeX{}.
@@ -18725,7 +18780,7 @@
(@url{http://www.gnu.org/software/rcs}) version control systems, which
expand it into a string such as:
@example
-$Id: texinfo.txi,v 1.166 2006/06/24 22:02:28 karl Exp $
+$Id: texinfo.txi,v 1.167 2006/07/05 13:39:05 karl Exp $
@end example
(This is useful in all sources that use version control, not just manuals.)
You may wish to include the @samp{$Id:} comment in the @code{@@copying}
@@ -18791,7 +18846,7 @@
@verbatim
\input texinfo @c -*-texinfo-*-
address@hidden $Id: texinfo.txi,v 1.166 2006/06/24 22:02:28 karl Exp $
address@hidden $Id: texinfo.txi,v 1.167 2006/07/05 13:39:05 karl Exp $
@comment %**start of header
@setfilename sample.info
@include version.texi
Index: makeinfo/macro.c
===================================================================
RCS file: /sources/texinfo/texinfo/makeinfo/macro.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- makeinfo/macro.c 15 May 2005 00:00:07 -0000 1.8
+++ makeinfo/macro.c 5 Jul 2006 13:39:05 -0000 1.9
@@ -1,5 +1,5 @@
/* macro.c -- user-defined macros for Texinfo.
- $Id: macro.c,v 1.8 2005/05/15 00:00:07 karl Exp $
+ $Id: macro.c,v 1.9 2006/07/05 13:39:05 karl Exp $
Copyright (C) 1998, 1999, 2002, 2003, 2005 Free Software Foundation, Inc.
@@ -151,13 +151,14 @@
def->source_lineno = source_lineno;
def->body = body;
def->arglist = arglist;
+ def->argcount = array_len (arglist);
def->inhibited = 0;
def->flags = flags;
}
char **
-get_brace_args (int quote_single)
+get_brace_args (enum quote_type quote)
{
char **arglist, *word;
int arglist_index, arglist_size;
@@ -187,8 +188,10 @@
depth++;
input_text_offset++;
}
- else if ((character == ',' && !quote_single) ||
- ((character == '}') && depth == 1))
+ else if ((character == ','
+ && !(quote == quote_single
+ || (quote == quote_many && depth > 1)))
+ || ((character == '}') && depth == 1))
{
int len = input_text_offset - start;
@@ -285,7 +288,7 @@
}
}
}
- return get_brace_args (def->flags & ME_QUOTE_ARG);
+ return get_brace_args (def->argcount == 1 ? quote_single : quote_many);
}
/* Substitute actual parameters for named parameters in body.
@@ -386,17 +389,13 @@
expand_macro (MACRO_DEF *def)
{
char **arglist;
- int num_args;
char *execution_string = NULL;
int start_line = line_number;
- /* Find out how many arguments this macro definition takes. */
- num_args = array_len (def->arglist);
-
/* Gather the arguments present on the line if there are any. */
arglist = get_macro_args (def);
- if (num_args < array_len (arglist))
+ if (def->argcount < array_len (arglist))
{
free_array (arglist);
line_error (_("Macro `%s' called on line %d with too many args"),
@@ -567,12 +566,6 @@
}
}
}
-
- /* If we have exactly one argument, do @quote-arg implicitly. Not
- only does this match TeX's behavior (which can't feasibly be
- changed), but it's a good idea. */
- if (arglist_index == 1)
- flags |= ME_QUOTE_ARG;
}
/* Read the text carefully until we find an "@end macro" which
@@ -595,6 +588,7 @@
(strncmp (line + 1, "allow-recursion", 15) == 0) &&
(line[16] == 0 || whitespace (line[16])))
{
+ warning (_("@allow-recursion is deprecated; please use @rmacro
instead"));
for (i = 16; whitespace (line[i]); i++);
strcpy (line, line + i);
flags |= ME_RECURSE;
@@ -609,20 +603,14 @@
(strncmp (line + 1, "quote-arg", 9) == 0) &&
(line[10] == 0 || whitespace (line[10])))
{
+ warning (_("@quote-arg is deprecated; arguments are quoted by
default"));
for (i = 10; whitespace (line[i]); i++);
strcpy (line, line + i);
-
- if (arglist && arglist[0] && !arglist[1])
- {
- flags |= ME_QUOTE_ARG;
- if (!*line)
- {
- free (line);
- continue;
- }
- }
- else
- line_error (_("@quote-arg only useful for single-argument macros"));
+ if (!*line)
+ {
+ free (line);
+ continue;
+ }
}
if (*line == COMMAND_PREFIX
Index: makeinfo/macro.h
===================================================================
RCS file: /sources/texinfo/texinfo/makeinfo/macro.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- makeinfo/macro.h 15 May 2005 00:00:07 -0000 1.3
+++ makeinfo/macro.h 5 Jul 2006 13:39:05 -0000 1.4
@@ -1,5 +1,5 @@
/* macro.h -- declarations for macro.c.
- $Id: macro.h,v 1.3 2005/05/15 00:00:07 karl Exp $
+ $Id: macro.h,v 1.4 2006/07/05 13:39:05 karl Exp $
Copyright (C) 1998, 99 Free Software Foundation, Inc.
@@ -37,16 +37,16 @@
typedef struct {
char *name; /* Name of the macro. */
char **arglist; /* Args to replace when executing. */
+ int argcount; /* Number of args in arglist */
char *body; /* Macro body. */
char *source_file; /* File where this macro is defined. */
int source_lineno; /* Line number within FILENAME. */
int inhibited; /* Nonzero means make find_macro () fail. */
- int flags; /* ME_RECURSE, ME_QUOTE_ARG, etc. */
+ int flags; /* ME_RECURSE, etc. */
} MACRO_DEF;
/* flags for MACRO_DEF */
#define ME_RECURSE 0x01
-#define ME_QUOTE_ARG 0x02
extern void execute_macro (MACRO_DEF *def);
extern MACRO_DEF *find_macro (char *name);
@@ -72,6 +72,8 @@
extern int array_len (char **array);
extern void free_array (char **array);
-extern char **get_brace_args (int quote_single);
+
+enum quote_type { quote_none, quote_single, quote_many };
+extern char **get_brace_args (enum quote_type type);
#endif /* not MACRO_H */
Index: makeinfo/makeinfo.c
===================================================================
RCS file: /sources/texinfo/texinfo/makeinfo/makeinfo.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -r1.87 -r1.88
--- makeinfo/makeinfo.c 19 Jun 2006 23:08:57 -0000 1.87
+++ makeinfo/makeinfo.c 5 Jul 2006 13:39:05 -0000 1.88
@@ -1,5 +1,5 @@
/* makeinfo -- convert Texinfo source into other formats.
- $Id: makeinfo.c,v 1.87 2006/06/19 23:08:57 karl Exp $
+ $Id: makeinfo.c,v 1.88 2006/07/05 13:39:05 karl Exp $
Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
@@ -3640,7 +3640,7 @@
{
char **arglist;
- arglist = get_brace_args (0);
+ arglist = get_brace_args (quote_none);
if (arglist)
{
Index: makeinfo/tests/Makefile.am
===================================================================
RCS file: /sources/texinfo/texinfo/makeinfo/tests/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- makeinfo/tests/Makefile.am 11 Apr 2004 17:56:47 -0000 1.5
+++ makeinfo/tests/Makefile.am 5 Jul 2006 13:39:05 -0000 1.6
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.5 2004/04/11 17:56:47 karl Exp $
+# $Id: Makefile.am,v 1.6 2006/07/05 13:39:05 karl Exp $
# Makefile.am for texinfo/tests/makeinfo.
#
# This file is free software; as a special exception the author gives
@@ -19,6 +19,7 @@
macro-at menu-whitespace \
no-headers \
node-expand node-value node-whitespace \
+ quote-args \
top \
twofiles
@@ -33,4 +34,5 @@
include-value.txi incl-incl.txi \
macro-at.txi menu-whitespace.txi \
node-expand.txi node-value.txi node-whitespace.txi \
+ quote-args.txi \
top.txi # top2.txi
P doc/texinfo.txi
P makeinfo/macro.c
P makeinfo/macro.h
P makeinfo/makeinfo.c
P makeinfo/tests/Makefile.am
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo update (Wed Jul 5 09:52:01 EDT 2006),
Karl Berry <=