Commit 842b28a0 authored by Paul Eggert's avatar Paul Eggert

* doc/misc/texinfo.tex, lib/getopt.c, lib/intprops.h: Merge from gnulib.

parent a9f737ee
2011-05-27 Paul Eggert <eggert@cs.ucla.edu>
* doc/misc/texinfo.tex, lib/getopt.c, lib/intprops.h: Merge from gnulib.
2011-05-24 Glenn Morris <rgm@gnu.org>
* Makefile.in (check): Just give a message if no test/ directory.
......
......@@ -3,7 +3,7 @@
% Load plain if necessary, i.e., if running under initex.
\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
%
\def\texinfoversion{2011-05-11.16}
\def\texinfoversion{2011-05-23.16}
%
% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
......@@ -693,15 +693,6 @@
\newdimen\mil \mil=0.001in
% Old definition--didn't work.
%\parseargdef\need{\par %
%% This method tries to make TeX break the page naturally
%% if the depth of the box does not fit.
%{\baselineskip=0pt%
%\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak
%\prevdepth=-1000pt
%}}
\parseargdef\need{%
% Ensure vertical mode, so we don't make a big box in the middle of a
% paragraph.
......@@ -3227,7 +3218,7 @@
\finishedtitlepagetrue
}
%%% Macros to be used within @titlepage:
% Macros to be used within @titlepage:
\let\subtitlerm=\tenrm
\def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
......@@ -3260,7 +3251,7 @@
}
%%% Set up page headings and footings.
% Set up page headings and footings.
\let\thispage=\folio
......@@ -3959,9 +3950,9 @@
\setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
\global\advance\multitablelinespace by-\ht0
\fi
%% Test to see if parskip is larger than space between lines of
%% table. If not, do nothing.
%% If so, set to same dimension as multitablelinespace.
% Test to see if parskip is larger than space between lines of
% table. If not, do nothing.
% If so, set to same dimension as multitablelinespace.
\ifdim\multitableparskip>\multitablelinespace
\global\multitableparskip=\multitablelinespace
\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
......@@ -5536,14 +5527,13 @@
% (including whitespace, linebreaking, etc. around it),
% given all the information in convenient, parsed form.
%%% Args are the skip and penalty (usually negative)
% Args are the skip and penalty (usually negative)
\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
%%% Define plain chapter starts, and page on/off switching for it
% Parameter controlling skip before chapter headings (if needed)
\newskip\chapheadingskip
% Define plain chapter starts, and page on/off switching for it.
\def\chapbreak{\dobreak \chapheadingskip {-4000}}
\def\chappager{\par\vfill\supereject}
% Because \domark is called before \chapoddpage, the filler page will
......@@ -6702,7 +6692,7 @@
% commands also insert a nobreak penalty, and we don't want to allow
% a break between a section heading and a defun.
%
% As a minor refinement, we avoid "club" headers by signalling
% As a further refinement, we avoid "club" headers by signalling
% with penalty of 10003 after the very first @deffn in the
% sequence (see above), and penalty of 10002 after any following
% @def command.
......@@ -6769,13 +6759,36 @@
\def\domakedefun#1#2#3{%
\envdef#1{%
\startdefun
\doingtypefnfalse % distinguish typed functions from all else
\parseargusing\activeparens{\printdefunline#3}%
}%
\def#2{\dodefunx#1}%
\def#3%
}
%%% Untyped functions:
\newif\ifdoingtypefn % doing typed function?
\newif\ifrettypeownline % typeset return type on its own line?
% @deftypefnnewline on|off says whether the return type of typed functions
% are printed on their own line. This affects @deftypefn, @deftypefun,
% @deftypeop, and @deftypemethod.
%
\parseargdef\deftypefnnewline{%
\def\temp{#1}%
\ifx\temp\onword
\expandafter\let\csname SETtxideftypefnnl\endcsname
= \empty
\else\ifx\temp\offword
\expandafter\let\csname SETtxideftypefnnl\endcsname
= \relax
\else
\errhelp = \EMsimple
\errmessage{Unknown @txideftypefnnl value `\temp',
must be on|off}%
\fi\fi
}
% Untyped functions:
% @deffn category name args
\makedefun{deffn}{\deffngeneral{}}
......@@ -6794,7 +6807,7 @@
\defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
}
%%% Typed functions:
% Typed functions:
% @deftypefn category type name args
\makedefun{deftypefn}{\deftypefngeneral{}}
......@@ -6809,10 +6822,11 @@
%
\def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
\dosubind{fn}{\code{#4}}{#1}%
\doingtypefntrue
\defname{#2}{#3}{#4}\defunargs{#5\unskip}%
}
%%% Typed variables:
% Typed variables:
% @deftypevr category type var args
\makedefun{deftypevr}{\deftypecvgeneral{}}
......@@ -6830,7 +6844,7 @@
\defname{#2}{#3}{#4}\defunargs{#5\unskip}%
}
%%% Untyped variables:
% Untyped variables:
% @defvr category var args
\makedefun{defvr}#1 {\deftypevrheader{#1} {} }
......@@ -6841,7 +6855,8 @@
% \defcvof {category of}class var args
\def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
%%% Type:
% Types:
% @deftp category name args
\makedefun{deftp}#1 #2 #3\endheader{%
\doind{tp}{\code{#2}}%
......@@ -6869,25 +6884,49 @@
% We are followed by (but not passed) the arguments, if any.
%
\def\defname#1#2#3{%
\par
% Get the values of \leftskip and \rightskip as they were outside the @def...
\advance\leftskip by -\defbodyindent
%
% How we'll format the type name. Putting it in brackets helps
% Determine if we are typesetting the return type of a typed function
% on a line by itself.
\rettypeownlinefalse
\ifdoingtypefn % doing a typed function specifically?
% then check user option for putting return type on its own line:
\expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
\rettypeownlinetrue
\fi
\fi
%
% How we'll format the category name. Putting it in brackets helps
% distinguish it from the body text that may end up on the next line
% just below it.
\def\temp{#1}%
\setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
%
% Figure out line sizes for the paragraph shape.
% Figure out line sizes for the paragraph shape. We'll always have at
% least two.
\tempnum = 2
%
% The first line needs space for \box0; but if \rightskip is nonzero,
% we need only space for the part of \box0 which exceeds it:
\dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip
%
% If doing a return type on its own line, we'll have another line.
\ifrettypeownline
\advance\tempnum by 1
\def\maybeshapeline{0in \hsize}%
\else
\def\maybeshapeline{}%
\fi
%
% The continuations:
\dimen2=\hsize \advance\dimen2 by -\defargsindent
% (plain.tex says that \dimen1 should be used only as global.)
\parshape 2 0in \dimen0 \defargsindent \dimen2
%
% Put the type name to the right margin.
% The final paragraph shape:
\parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2
%
% Put the category name at the right margin.
\noindent
\hbox to 0pt{%
\hfil\box0 \kern-\hsize
......@@ -6909,8 +6948,16 @@
% . this still does not fix the ?` and !` ligatures, but so far no
% one has made identifiers using them :).
\df \tt
\def\temp{#2}% return value type
\ifx\temp\empty\else \tclose{\temp} \fi
\def\temp{#2}% text of the return type
\ifx\temp\empty\else
\tclose{\temp}% typeset the return type
\ifrettypeownline
% put return type on its own line; prohibit line break following:
\hfil\vadjust{\nobreak}\break
\else
\space % type on same line, so just followed by a space
\fi
\fi % no return type
#3% output function name
}%
{\rm\enskip}% hskip 0.5 em of \tenrm
......
......@@ -479,8 +479,14 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|| !strchr (optstring, argv[d->optind][1])))))
{
char *nameend;
unsigned int namelen;
const struct option *p;
const struct option *pfound = NULL;
struct option_list
{
const struct option *p;
struct option_list *next;
} *ambig_list = NULL;
int exact = 0;
int ambig = 0;
int indfound = -1;
......@@ -488,14 +494,14 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++)
/* Do nothing. */ ;
namelen = nameend - d->__nextchar;
/* Test all long options for either exact match
or abbreviated matches. */
for (p = longopts, option_index = 0; p->name; p++, option_index++)
if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar))
if (!strncmp (p->name, d->__nextchar, namelen))
{
if ((unsigned int) (nameend - d->__nextchar)
== (unsigned int) strlen (p->name))
if (namelen == (unsigned int) strlen (p->name))
{
/* Exact match found. */
pfound = p;
......@@ -513,35 +519,71 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|| pfound->has_arg != p->has_arg
|| pfound->flag != p->flag
|| pfound->val != p->val)
/* Second or later nonexact match found. */
ambig = 1;
{
/* Second or later nonexact match found. */
struct option_list *newp = malloc (sizeof (*newp));
newp->p = p;
newp->next = ambig_list;
ambig_list = newp;
}
}
if (ambig && !exact)
if (ambig_list != NULL && !exact)
{
if (print_errors)
{
struct option_list first;
first.p = pfound;
first.next = ambig_list;
ambig_list = &first;
#if defined _LIBC && defined USE_IN_LIBIO
char *buf;
char *buf = NULL;
size_t buflen = 0;
if (__asprintf (&buf, _("%s: option '%s' is ambiguous\n"),
argv[0], argv[d->optind]) >= 0)
FILE *fp = open_memstream (&buf, &buflen);
if (fp != NULL)
{
_IO_flockfile (stderr);
fprintf (fp,
_("%s: option '%s' is ambiguous; possibilities:"),
argv[0], argv[d->optind]);
int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
do
{
fprintf (fp, " '--%s'", ambig_list->p->name);
ambig_list = ambig_list->next;
}
while (ambig_list != NULL);
__fxprintf (NULL, "%s", buf);
fputc_unlocked ('\n', fp);
((_IO_FILE *) stderr)->_flags2 = old_flags2;
_IO_funlockfile (stderr);
if (__builtin_expect (fclose (fp) != EOF, 1))
{
_IO_flockfile (stderr);
free (buf);
int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
__fxprintf (NULL, "%s", buf);
((_IO_FILE *) stderr)->_flags2 = old_flags2;
_IO_funlockfile (stderr);
free (buf);
}
}
#else
fprintf (stderr, _("%s: option '%s' is ambiguous\n"),
fprintf (stderr,
_("%s: option '%s' is ambiguous; possibilities:"),
argv[0], argv[d->optind]);
do
{
fprintf (stderr, " '--%s'", ambig_list->p->name);
ambig_list = ambig_list->next;
}
while (ambig_list != NULL);
fputc ('\n', stderr);
#endif
}
d->__nextchar += strlen (d->__nextchar);
......@@ -550,6 +592,13 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
return '?';
}
while (ambig_list != NULL)
{
struct option_list *pn = ambig_list->next;
free (ambig_list);
ambig_list = pn;
}
if (pfound != NULL)
{
option_index = indfound;
......
......@@ -25,11 +25,11 @@
/* Return a integer value, converted to the same type as the integer
expression E after integer type promotion. V is the unconverted value.
E should not have side effects. */
#define _GL_INT_CONVERT(e, v) ((e) - (e) + (v))
#define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
<http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00406.html>. */
#define _GL_INT_NEGATE_CONVERT(e, v) ((e) - (e) - (v))
#define _GL_INT_NEGATE_CONVERT(e, v) (0 * (e) - (v))
/* The extra casts in the following macros work around compiler bugs,
e.g., in Cray C 5.0.3.0. */
......@@ -314,7 +314,7 @@
Arguments should be free of side effects. */
#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \
op_result_overflow (a, b, \
_GL_INT_MINIMUM ((b) - (b) + (a)), \
_GL_INT_MAXIMUM ((b) - (b) + (a)))
_GL_INT_MINIMUM (0 * (b) + (a)), \
_GL_INT_MAXIMUM (0 * (b) + (a)))
#endif /* _GL_INTPROPS_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment