aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2011-05-27 09:58:43 -0700
committerPaul Eggert2011-05-27 09:58:43 -0700
commit842b28a0658be1d3afdf0dbda876c4c354d3672c (patch)
tree724d281966fb3f0aa6b6644a48ce42253a0765a4
parenta9f737eef69ffe03dd045df555300ae6b41d0edf (diff)
downloademacs-842b28a0658be1d3afdf0dbda876c4c354d3672c.tar.gz
emacs-842b28a0658be1d3afdf0dbda876c4c354d3672c.zip
* doc/misc/texinfo.tex, lib/getopt.c, lib/intprops.h: Merge from gnulib.
-rw-r--r--ChangeLog4
-rw-r--r--doc/misc/texinfo.tex109
-rw-r--r--lib/getopt.c83
-rw-r--r--lib/intprops.h8
4 files changed, 152 insertions, 52 deletions
diff --git a/ChangeLog b/ChangeLog
index 9486bbdca3f..4e6512e3070 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
12011-05-27 Paul Eggert <eggert@cs.ucla.edu>
2
3 * doc/misc/texinfo.tex, lib/getopt.c, lib/intprops.h: Merge from gnulib.
4
12011-05-24 Glenn Morris <rgm@gnu.org> 52011-05-24 Glenn Morris <rgm@gnu.org>
2 6
3 * Makefile.in (check): Just give a message if no test/ directory. 7 * Makefile.in (check): Just give a message if no test/ directory.
diff --git a/doc/misc/texinfo.tex b/doc/misc/texinfo.tex
index 47837c938c8..fd22fd68567 100644
--- a/doc/misc/texinfo.tex
+++ b/doc/misc/texinfo.tex
@@ -3,7 +3,7 @@
3% Load plain if necessary, i.e., if running under initex. 3% Load plain if necessary, i.e., if running under initex.
4\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi 4\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
5% 5%
6\def\texinfoversion{2011-05-11.16} 6\def\texinfoversion{2011-05-23.16}
7% 7%
8% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, 8% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
9% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 9% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
@@ -693,15 +693,6 @@ where each line of input produces a line of output.}
693 693
694\newdimen\mil \mil=0.001in 694\newdimen\mil \mil=0.001in
695 695
696% Old definition--didn't work.
697%\parseargdef\need{\par %
698%% This method tries to make TeX break the page naturally
699%% if the depth of the box does not fit.
700%{\baselineskip=0pt%
701%\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak
702%\prevdepth=-1000pt
703%}}
704
705\parseargdef\need{% 696\parseargdef\need{%
706 % Ensure vertical mode, so we don't make a big box in the middle of a 697 % Ensure vertical mode, so we don't make a big box in the middle of a
707 % paragraph. 698 % paragraph.
@@ -3227,7 +3218,7 @@ end
3227 \finishedtitlepagetrue 3218 \finishedtitlepagetrue
3228} 3219}
3229 3220
3230%%% Macros to be used within @titlepage: 3221% Macros to be used within @titlepage:
3231 3222
3232\let\subtitlerm=\tenrm 3223\let\subtitlerm=\tenrm
3233\def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines} 3224\def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
@@ -3260,7 +3251,7 @@ end
3260} 3251}
3261 3252
3262 3253
3263%%% Set up page headings and footings. 3254% Set up page headings and footings.
3264 3255
3265\let\thispage=\folio 3256\let\thispage=\folio
3266 3257
@@ -3959,9 +3950,9 @@ end
3959\setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip 3950\setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
3960\global\advance\multitablelinespace by-\ht0 3951\global\advance\multitablelinespace by-\ht0
3961\fi 3952\fi
3962%% Test to see if parskip is larger than space between lines of 3953% Test to see if parskip is larger than space between lines of
3963%% table. If not, do nothing. 3954% table. If not, do nothing.
3964%% If so, set to same dimension as multitablelinespace. 3955% If so, set to same dimension as multitablelinespace.
3965\ifdim\multitableparskip>\multitablelinespace 3956\ifdim\multitableparskip>\multitablelinespace
3966\global\multitableparskip=\multitablelinespace 3957\global\multitableparskip=\multitablelinespace
3967\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller 3958\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
@@ -5536,14 +5527,13 @@ end
5536% (including whitespace, linebreaking, etc. around it), 5527% (including whitespace, linebreaking, etc. around it),
5537% given all the information in convenient, parsed form. 5528% given all the information in convenient, parsed form.
5538 5529
5539%%% Args are the skip and penalty (usually negative) 5530% Args are the skip and penalty (usually negative)
5540\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} 5531\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
5541 5532
5542%%% Define plain chapter starts, and page on/off switching for it
5543% Parameter controlling skip before chapter headings (if needed) 5533% Parameter controlling skip before chapter headings (if needed)
5544
5545\newskip\chapheadingskip 5534\newskip\chapheadingskip
5546 5535
5536% Define plain chapter starts, and page on/off switching for it.
5547\def\chapbreak{\dobreak \chapheadingskip {-4000}} 5537\def\chapbreak{\dobreak \chapheadingskip {-4000}}
5548\def\chappager{\par\vfill\supereject} 5538\def\chappager{\par\vfill\supereject}
5549% Because \domark is called before \chapoddpage, the filler page will 5539% Because \domark is called before \chapoddpage, the filler page will
@@ -6702,7 +6692,7 @@ end
6702 % commands also insert a nobreak penalty, and we don't want to allow 6692 % commands also insert a nobreak penalty, and we don't want to allow
6703 % a break between a section heading and a defun. 6693 % a break between a section heading and a defun.
6704 % 6694 %
6705 % As a minor refinement, we avoid "club" headers by signalling 6695 % As a further refinement, we avoid "club" headers by signalling
6706 % with penalty of 10003 after the very first @deffn in the 6696 % with penalty of 10003 after the very first @deffn in the
6707 % sequence (see above), and penalty of 10002 after any following 6697 % sequence (see above), and penalty of 10002 after any following
6708 % @def command. 6698 % @def command.
@@ -6769,13 +6759,36 @@ end
6769\def\domakedefun#1#2#3{% 6759\def\domakedefun#1#2#3{%
6770 \envdef#1{% 6760 \envdef#1{%
6771 \startdefun 6761 \startdefun
6762 \doingtypefnfalse % distinguish typed functions from all else
6772 \parseargusing\activeparens{\printdefunline#3}% 6763 \parseargusing\activeparens{\printdefunline#3}%
6773 }% 6764 }%
6774 \def#2{\dodefunx#1}% 6765 \def#2{\dodefunx#1}%
6775 \def#3% 6766 \def#3%
6776} 6767}
6777 6768
6778%%% Untyped functions: 6769\newif\ifdoingtypefn % doing typed function?
6770\newif\ifrettypeownline % typeset return type on its own line?
6771
6772% @deftypefnnewline on|off says whether the return type of typed functions
6773% are printed on their own line. This affects @deftypefn, @deftypefun,
6774% @deftypeop, and @deftypemethod.
6775%
6776\parseargdef\deftypefnnewline{%
6777 \def\temp{#1}%
6778 \ifx\temp\onword
6779 \expandafter\let\csname SETtxideftypefnnl\endcsname
6780 = \empty
6781 \else\ifx\temp\offword
6782 \expandafter\let\csname SETtxideftypefnnl\endcsname
6783 = \relax
6784 \else
6785 \errhelp = \EMsimple
6786 \errmessage{Unknown @txideftypefnnl value `\temp',
6787 must be on|off}%
6788 \fi\fi
6789}
6790
6791% Untyped functions:
6779 6792
6780% @deffn category name args 6793% @deffn category name args
6781\makedefun{deffn}{\deffngeneral{}} 6794\makedefun{deffn}{\deffngeneral{}}
@@ -6794,7 +6807,7 @@ end
6794 \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}% 6807 \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
6795} 6808}
6796 6809
6797%%% Typed functions: 6810% Typed functions:
6798 6811
6799% @deftypefn category type name args 6812% @deftypefn category type name args
6800\makedefun{deftypefn}{\deftypefngeneral{}} 6813\makedefun{deftypefn}{\deftypefngeneral{}}
@@ -6809,10 +6822,11 @@ end
6809% 6822%
6810\def\deftypefngeneral#1#2 #3 #4 #5\endheader{% 6823\def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
6811 \dosubind{fn}{\code{#4}}{#1}% 6824 \dosubind{fn}{\code{#4}}{#1}%
6825 \doingtypefntrue
6812 \defname{#2}{#3}{#4}\defunargs{#5\unskip}% 6826 \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
6813} 6827}
6814 6828
6815%%% Typed variables: 6829% Typed variables:
6816 6830
6817% @deftypevr category type var args 6831% @deftypevr category type var args
6818\makedefun{deftypevr}{\deftypecvgeneral{}} 6832\makedefun{deftypevr}{\deftypecvgeneral{}}
@@ -6830,7 +6844,7 @@ end
6830 \defname{#2}{#3}{#4}\defunargs{#5\unskip}% 6844 \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
6831} 6845}
6832 6846
6833%%% Untyped variables: 6847% Untyped variables:
6834 6848
6835% @defvr category var args 6849% @defvr category var args
6836\makedefun{defvr}#1 {\deftypevrheader{#1} {} } 6850\makedefun{defvr}#1 {\deftypevrheader{#1} {} }
@@ -6841,7 +6855,8 @@ end
6841% \defcvof {category of}class var args 6855% \defcvof {category of}class var args
6842\def\defcvof#1#2 {\deftypecvof{#1}#2 {} } 6856\def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
6843 6857
6844%%% Type: 6858% Types:
6859
6845% @deftp category name args 6860% @deftp category name args
6846\makedefun{deftp}#1 #2 #3\endheader{% 6861\makedefun{deftp}#1 #2 #3\endheader{%
6847 \doind{tp}{\code{#2}}% 6862 \doind{tp}{\code{#2}}%
@@ -6869,25 +6884,49 @@ end
6869% We are followed by (but not passed) the arguments, if any. 6884% We are followed by (but not passed) the arguments, if any.
6870% 6885%
6871\def\defname#1#2#3{% 6886\def\defname#1#2#3{%
6887 \par
6872 % Get the values of \leftskip and \rightskip as they were outside the @def... 6888 % Get the values of \leftskip and \rightskip as they were outside the @def...
6873 \advance\leftskip by -\defbodyindent 6889 \advance\leftskip by -\defbodyindent
6874 % 6890 %
6875 % How we'll format the type name. Putting it in brackets helps 6891 % Determine if we are typesetting the return type of a typed function
6892 % on a line by itself.
6893 \rettypeownlinefalse
6894 \ifdoingtypefn % doing a typed function specifically?
6895 % then check user option for putting return type on its own line:
6896 \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
6897 \rettypeownlinetrue
6898 \fi
6899 \fi
6900 %
6901 % How we'll format the category name. Putting it in brackets helps
6876 % distinguish it from the body text that may end up on the next line 6902 % distinguish it from the body text that may end up on the next line
6877 % just below it. 6903 % just below it.
6878 \def\temp{#1}% 6904 \def\temp{#1}%
6879 \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi} 6905 \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
6880 % 6906 %
6881 % Figure out line sizes for the paragraph shape. 6907 % Figure out line sizes for the paragraph shape. We'll always have at
6908 % least two.
6909 \tempnum = 2
6910 %
6882 % The first line needs space for \box0; but if \rightskip is nonzero, 6911 % The first line needs space for \box0; but if \rightskip is nonzero,
6883 % we need only space for the part of \box0 which exceeds it: 6912 % we need only space for the part of \box0 which exceeds it:
6884 \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip 6913 \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip
6914 %
6915 % If doing a return type on its own line, we'll have another line.
6916 \ifrettypeownline
6917 \advance\tempnum by 1
6918 \def\maybeshapeline{0in \hsize}%
6919 \else
6920 \def\maybeshapeline{}%
6921 \fi
6922 %
6885 % The continuations: 6923 % The continuations:
6886 \dimen2=\hsize \advance\dimen2 by -\defargsindent 6924 \dimen2=\hsize \advance\dimen2 by -\defargsindent
6887 % (plain.tex says that \dimen1 should be used only as global.)
6888 \parshape 2 0in \dimen0 \defargsindent \dimen2
6889 % 6925 %
6890 % Put the type name to the right margin. 6926 % The final paragraph shape:
6927 \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2
6928 %
6929 % Put the category name at the right margin.
6891 \noindent 6930 \noindent
6892 \hbox to 0pt{% 6931 \hbox to 0pt{%
6893 \hfil\box0 \kern-\hsize 6932 \hfil\box0 \kern-\hsize
@@ -6909,8 +6948,16 @@ end
6909 % . this still does not fix the ?` and !` ligatures, but so far no 6948 % . this still does not fix the ?` and !` ligatures, but so far no
6910 % one has made identifiers using them :). 6949 % one has made identifiers using them :).
6911 \df \tt 6950 \df \tt
6912 \def\temp{#2}% return value type 6951 \def\temp{#2}% text of the return type
6913 \ifx\temp\empty\else \tclose{\temp} \fi 6952 \ifx\temp\empty\else
6953 \tclose{\temp}% typeset the return type
6954 \ifrettypeownline
6955 % put return type on its own line; prohibit line break following:
6956 \hfil\vadjust{\nobreak}\break
6957 \else
6958 \space % type on same line, so just followed by a space
6959 \fi
6960 \fi % no return type
6914 #3% output function name 6961 #3% output function name
6915 }% 6962 }%
6916 {\rm\enskip}% hskip 0.5 em of \tenrm 6963 {\rm\enskip}% hskip 0.5 em of \tenrm
diff --git a/lib/getopt.c b/lib/getopt.c
index c8b301363f1..ee96d972d95 100644
--- a/lib/getopt.c
+++ b/lib/getopt.c
@@ -479,8 +479,14 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
479 || !strchr (optstring, argv[d->optind][1]))))) 479 || !strchr (optstring, argv[d->optind][1])))))
480 { 480 {
481 char *nameend; 481 char *nameend;
482 unsigned int namelen;
482 const struct option *p; 483 const struct option *p;
483 const struct option *pfound = NULL; 484 const struct option *pfound = NULL;
485 struct option_list
486 {
487 const struct option *p;
488 struct option_list *next;
489 } *ambig_list = NULL;
484 int exact = 0; 490 int exact = 0;
485 int ambig = 0; 491 int ambig = 0;
486 int indfound = -1; 492 int indfound = -1;
@@ -488,14 +494,14 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
488 494
489 for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++) 495 for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++)
490 /* Do nothing. */ ; 496 /* Do nothing. */ ;
497 namelen = nameend - d->__nextchar;
491 498
492 /* Test all long options for either exact match 499 /* Test all long options for either exact match
493 or abbreviated matches. */ 500 or abbreviated matches. */
494 for (p = longopts, option_index = 0; p->name; p++, option_index++) 501 for (p = longopts, option_index = 0; p->name; p++, option_index++)
495 if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar)) 502 if (!strncmp (p->name, d->__nextchar, namelen))
496 { 503 {
497 if ((unsigned int) (nameend - d->__nextchar) 504 if (namelen == (unsigned int) strlen (p->name))
498 == (unsigned int) strlen (p->name))
499 { 505 {
500 /* Exact match found. */ 506 /* Exact match found. */
501 pfound = p; 507 pfound = p;
@@ -513,35 +519,71 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
513 || pfound->has_arg != p->has_arg 519 || pfound->has_arg != p->has_arg
514 || pfound->flag != p->flag 520 || pfound->flag != p->flag
515 || pfound->val != p->val) 521 || pfound->val != p->val)
516 /* Second or later nonexact match found. */ 522 {
517 ambig = 1; 523 /* Second or later nonexact match found. */
524 struct option_list *newp = malloc (sizeof (*newp));
525 newp->p = p;
526 newp->next = ambig_list;
527 ambig_list = newp;
528 }
518 } 529 }
519 530
520 if (ambig && !exact) 531 if (ambig_list != NULL && !exact)
521 { 532 {
522 if (print_errors) 533 if (print_errors)
523 { 534 {
535 struct option_list first;
536 first.p = pfound;
537 first.next = ambig_list;
538 ambig_list = &first;
539
524#if defined _LIBC && defined USE_IN_LIBIO 540#if defined _LIBC && defined USE_IN_LIBIO
525 char *buf; 541 char *buf = NULL;
542 size_t buflen = 0;
526 543
527 if (__asprintf (&buf, _("%s: option '%s' is ambiguous\n"), 544 FILE *fp = open_memstream (&buf, &buflen);
528 argv[0], argv[d->optind]) >= 0) 545 if (fp != NULL)
529 { 546 {
530 _IO_flockfile (stderr); 547 fprintf (fp,
548 _("%s: option '%s' is ambiguous; possibilities:"),
549 argv[0], argv[d->optind]);
531 550
532 int old_flags2 = ((_IO_FILE *) stderr)->_flags2; 551 do
533 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; 552 {
553 fprintf (fp, " '--%s'", ambig_list->p->name);
554 ambig_list = ambig_list->next;
555 }
556 while (ambig_list != NULL);
534 557
535 __fxprintf (NULL, "%s", buf); 558 fputc_unlocked ('\n', fp);
536 559
537 ((_IO_FILE *) stderr)->_flags2 = old_flags2; 560 if (__builtin_expect (fclose (fp) != EOF, 1))
538 _IO_funlockfile (stderr); 561 {
562 _IO_flockfile (stderr);
539 563
540 free (buf); 564 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
565 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
566
567 __fxprintf (NULL, "%s", buf);
568
569 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
570 _IO_funlockfile (stderr);
571
572 free (buf);
573 }
541 } 574 }
542#else 575#else
543 fprintf (stderr, _("%s: option '%s' is ambiguous\n"), 576 fprintf (stderr,
577 _("%s: option '%s' is ambiguous; possibilities:"),
544 argv[0], argv[d->optind]); 578 argv[0], argv[d->optind]);
579 do
580 {
581 fprintf (stderr, " '--%s'", ambig_list->p->name);
582 ambig_list = ambig_list->next;
583 }
584 while (ambig_list != NULL);
585
586 fputc ('\n', stderr);
545#endif 587#endif
546 } 588 }
547 d->__nextchar += strlen (d->__nextchar); 589 d->__nextchar += strlen (d->__nextchar);
@@ -550,6 +592,13 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
550 return '?'; 592 return '?';
551 } 593 }
552 594
595 while (ambig_list != NULL)
596 {
597 struct option_list *pn = ambig_list->next;
598 free (ambig_list);
599 ambig_list = pn;
600 }
601
553 if (pfound != NULL) 602 if (pfound != NULL)
554 { 603 {
555 option_index = indfound; 604 option_index = indfound;
diff --git a/lib/intprops.h b/lib/intprops.h
index 293204ab43a..d722648555b 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -25,11 +25,11 @@
25/* Return a integer value, converted to the same type as the integer 25/* Return a integer value, converted to the same type as the integer
26 expression E after integer type promotion. V is the unconverted value. 26 expression E after integer type promotion. V is the unconverted value.
27 E should not have side effects. */ 27 E should not have side effects. */
28#define _GL_INT_CONVERT(e, v) ((e) - (e) + (v)) 28#define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
29 29
30/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see 30/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
31 <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00406.html>. */ 31 <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00406.html>. */
32#define _GL_INT_NEGATE_CONVERT(e, v) ((e) - (e) - (v)) 32#define _GL_INT_NEGATE_CONVERT(e, v) (0 * (e) - (v))
33 33
34/* The extra casts in the following macros work around compiler bugs, 34/* The extra casts in the following macros work around compiler bugs,
35 e.g., in Cray C 5.0.3.0. */ 35 e.g., in Cray C 5.0.3.0. */
@@ -314,7 +314,7 @@
314 Arguments should be free of side effects. */ 314 Arguments should be free of side effects. */
315#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \ 315#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \
316 op_result_overflow (a, b, \ 316 op_result_overflow (a, b, \
317 _GL_INT_MINIMUM ((b) - (b) + (a)), \ 317 _GL_INT_MINIMUM (0 * (b) + (a)), \
318 _GL_INT_MAXIMUM ((b) - (b) + (a))) 318 _GL_INT_MAXIMUM (0 * (b) + (a)))
319 319
320#endif /* _GL_INTPROPS_H */ 320#endif /* _GL_INTPROPS_H */