diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-10-11 14:49:26 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-10-11 15:19:40 -0700 |
commit | 011c1d1c0766c65517ebd495465c99e86edb63ec (patch) | |
tree | 30d8f6a13235af90897c3223554871ef52225462 /lib | |
parent | 40cfaccf7b178b6239b5cd0013ef80b7ff8e503e (diff) | |
download | vyatta-bash-011c1d1c0766c65517ebd495465c99e86edb63ec.tar.gz vyatta-bash-011c1d1c0766c65517ebd495465c99e86edb63ec.zip |
Update to bash-4.1
Diffstat (limited to 'lib')
231 files changed, 8205 insertions, 17855 deletions
diff --git a/lib/glob/Makefile.in b/lib/glob/Makefile.in index a25b7bb..1ccae68 100644 --- a/lib/glob/Makefile.in +++ b/lib/glob/Makefile.in @@ -4,21 +4,20 @@ # # #################################################################### # -# Copyright (C) 1996-2005 Free Software Foundation, Inc. +# Copyright (C) 1996-2009 Free Software Foundation, Inc. -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. srcdir = @srcdir@ VPATH = .:@srcdir@ @@ -74,6 +73,12 @@ HSOURCES = $(srcdir)/strmatch.h OBJECTS = glob.o strmatch.o smatch.o xmbsrtowcs.o +# The texinfo files which document this library. +DOCSOURCE = doc/glob.texi +DOCOBJECT = doc/glob.dvi +DOCSUPPORT = doc/Makefile +DOCUMENTATION = $(DOCSOURCE) $(DOCOBJECT) $(DOCSUPPORT) + SUPPORT = Makefile ChangeLog $(DOCSUPPORT) SOURCES = $(CSOURCES) $(HSOURCES) $(DOCSOURCE) @@ -95,7 +100,7 @@ what-tar: done documentation: force - + -(cd doc; $(MAKE) $(MFLAGS)) force: # The rule for 'includes' is written funny so that the if statement @@ -105,11 +110,14 @@ install: clean: rm -f $(OBJECTS) $(LIBRARY_NAME) + -(cd doc && $(MAKE) $(MFLAGS) $@ ) realclean distclean maintainer-clean: clean + -( cd doc && $(MAKE) $(MFLAGS) $@ ) $(RM) -f Makefile mostlyclean: clean + -( cd doc && $(MAKE) $(MFLAGS) $@ ) ###################################################################### # # diff --git a/lib/glob/collsyms.h b/lib/glob/collsyms.h index ccd9f43..d56df61 100644 --- a/lib/glob/collsyms.h +++ b/lib/glob/collsyms.h @@ -5,19 +5,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* The upper-case letters, lower-case letters, and digits are omitted from this table. The digits are not included in the table in the POSIX.2 diff --git a/lib/glob/glob.c b/lib/glob/glob.c index 08a7da8..c77618f 100644 --- a/lib/glob/glob.c +++ b/lib/glob/glob.c @@ -1,20 +1,22 @@ /* glob.c -- file-name wildcard pattern matching for Bash. - Copyright (C) 1985-2005 Free Software Foundation, Inc. + Copyright (C) 1985-2009 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify + This file is part of GNU Bash, the Bourne-Again SHell. + + Bash is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* To whomever it may concern: I have never seen the code which most Unix programs use to perform this function. I wrote this from scratch @@ -45,7 +47,8 @@ #include "stdc.h" #include "memalloc.h" -#include "quit.h" + +#include "shell.h" #include "glob.h" #include "strmatch.h" @@ -72,8 +75,15 @@ # define ALLOCA_MAX 100000 #endif +struct globval + { + struct globval *next; + char *name; + }; + extern void throw_to_top_level __P((void)); extern int sh_eaccess __P((char *, int)); +extern char *sh_makepath __P((const char *, const char *, int)); extern int extended_glob; @@ -88,10 +98,12 @@ int glob_ignore_case = 0; /* Global variable to return to signify an error in globbing. */ char *glob_error_return; +static struct globval finddirs_error_return; + /* Some forward declarations. */ -static int skipname __P((char *, char *)); +static int skipname __P((char *, char *, int)); #if HANDLE_MULTIBYTE -static int mbskipname __P((char *, char *)); +static int mbskipname __P((char *, char *, int)); #endif #if HANDLE_MULTIBYTE static void udequote_pathname __P((char *)); @@ -154,9 +166,10 @@ glob_pattern_p (pattern) with matching leading `.'. */ static int -skipname (pat, dname) +skipname (pat, dname, flags) char *pat; char *dname; + int flags; { /* If a leading dot need not be explicitly matched, and the pattern doesn't start with a `.', don't match `.' or `..' */ @@ -179,8 +192,9 @@ skipname (pat, dname) characters in PAT and DNAME. Mostly concerned with matching leading `.'. */ static int -mbskipname (pat, dname) +mbskipname (pat, dname, flags) char *pat, *dname; + int flags; { int ret; wchar_t *pat_wc, *dn_wc; @@ -232,7 +246,8 @@ udequote_pathname (pathname) if (pathname[i - 1] == 0) break; } - pathname[j] = '\0'; + if (pathname) + pathname[j] = '\0'; } #if HANDLE_MULTIBYTE @@ -265,7 +280,8 @@ wdequote_pathname (pathname) if (wpathname[i - 1] == L'\0') break; } - wpathname[j] = L'\0'; + if (wpathname) + wpathname[j] = L'\0'; /* Convert the wide character string into unibyte character set. */ memset (&ps, '\0', sizeof(mbstate_t)); @@ -293,9 +309,9 @@ dequote_pathname (pathname) # define GLOB_TESTNAME(name) (lstat (name, &finfo)) #else /* !HAVE_LSTAT */ # if !defined (AFS) -# define GLOB_TESTNAME(name) (sh_eaccess (nextname, F_OK)) +# define GLOB_TESTNAME(name) (sh_eaccess (name, F_OK)) # else /* AFS */ -# define GLOB_TESTNAME(name) (access (nextname, F_OK)) +# define GLOB_TESTNAME(name) (access (name, F_OK)) # endif /* AFS */ #endif /* !HAVE_LSTAT */ @@ -306,6 +322,7 @@ glob_testdir (dir) { struct stat finfo; +/*itrace("glob_testdir: testing %s", dir);*/ if (stat (dir, &finfo) < 0) return (-1); @@ -315,6 +332,75 @@ glob_testdir (dir) return (0); } +/* Recursively scan SDIR for directories matching PAT (PAT is always `**'). + FLAGS is simply passed down to the recursive call to glob_vector. Returns + a list of matching directory names. EP, if non-null, is set to the last + element of the returned list. NP, if non-null, is set to the number of + directories in the returned list. These two variables exist for the + convenience of the caller (always glob_vector). */ +static struct globval * +finddirs (pat, sdir, flags, ep, np) + char *pat; + char *sdir; + int flags; + struct globval **ep; + int *np; +{ + char **r, *n; + int ndirs; + struct globval *ret, *e, *g; + +/*itrace("finddirs: pat = `%s' sdir = `%s' flags = 0x%x", pat, sdir, flags);*/ + e = ret = 0; + r = glob_vector (pat, sdir, flags); + if (r == 0 || r[0] == 0) + { + if (np) + *np = 0; + if (ep) + *ep = 0; + if (r && r != &glob_error_return) + free (r); + return (struct globval *)0; + } + for (ndirs = 0; r[ndirs] != 0; ndirs++) + { + g = (struct globval *) malloc (sizeof (struct globval)); + if (g == 0) + { + while (ret) /* free list built so far */ + { + g = ret->next; + free (ret); + ret = g; + } + + free (r); + if (np) + *np = 0; + if (ep) + *ep = 0; + return (&finddirs_error_return); + } + if (e == 0) + e = g; + + g->next = ret; + ret = g; + + g->name = r[ndirs]; + } + + free (r); + if (ep) + *ep = e; + if (np) + *np = ndirs; + + return ret; +} + + /* Return a vector of names of files in directory DIR whose names match glob pattern PAT. The names are not in any particular order. @@ -337,31 +423,28 @@ glob_vector (pat, dir, flags) char *dir; int flags; { - struct globval - { - struct globval *next; - char *name; - }; - DIR *d; register struct dirent *dp; - struct globval *lastlink; + struct globval *lastlink, *e, *dirlist; register struct globval *nextlink; - register char *nextname, *npat; + register char *nextname, *npat, *subdir; unsigned int count; - int lose, skip; + int lose, skip, ndirs, isdir, sdlen, add_current, patlen; register char **name_vector; register unsigned int i; int mflags; /* Flags passed to strmatch (). */ + int pflags; /* flags passed to sh_makepath () */ int nalloca; struct globval *firstmalloc, *tmplink; + char *convfn; lastlink = 0; - count = lose = skip = 0; + count = lose = skip = add_current = 0; firstmalloc = 0; nalloca = 0; +/*itrace("glob_vector: pat = `%s' dir = `%s' flags = 0x%x", pat, dir, flags);*/ /* If PAT is empty, skip the loop, but return one (empty) filename. */ if (pat == 0 || *pat == '\0') { @@ -387,6 +470,8 @@ glob_vector (pat, dir, flags) skip = 1; } + patlen = strlen (pat); + /* If the filename pattern (PAT) does not contain any globbing characters, we can dispense with reading the directory, and just see if there is a filename `DIR/PAT'. If there is, and we can access it, just make the @@ -400,8 +485,8 @@ glob_vector (pat, dir, flags) return ((char **) &glob_error_return); dirlen = strlen (dir); - nextname = (char *)malloc (dirlen + strlen (pat) + 2); - npat = (char *)malloc (strlen (pat) + 1); + nextname = (char *)malloc (dirlen + patlen + 2); + npat = (char *)malloc (patlen + 1); if (nextname == 0 || npat == 0) lose = 1; else @@ -463,6 +548,8 @@ glob_vector (pat, dir, flags) if (extended_glob) mflags |= FNM_EXTMATCH; + add_current = ((flags & (GX_ALLDIRS|GX_ADDCURDIR)) == (GX_ALLDIRS|GX_ADDCURDIR)); + /* Scan the directory, finding all names that match. For each name that matches, allocate a struct globval on the stack and store the name in it. @@ -490,14 +577,71 @@ glob_vector (pat, dir, flags) #endif #if HANDLE_MULTIBYTE - if (MB_CUR_MAX > 1 && mbskipname (pat, dp->d_name)) + if (MB_CUR_MAX > 1 && mbskipname (pat, dp->d_name, flags)) continue; else #endif - if (skipname (pat, dp->d_name)) + if (skipname (pat, dp->d_name, flags)) continue; - if (strmatch (pat, dp->d_name, mflags) != FNM_NOMATCH) + /* If we're only interested in directories, don't bother with files */ + if (flags & (GX_MATCHDIRS|GX_ALLDIRS)) + { + pflags = (flags & GX_ALLDIRS) ? MP_RMDOT : 0; + if (flags & GX_NULLDIR) + pflags |= MP_IGNDOT; + subdir = sh_makepath (dir, dp->d_name, pflags); + isdir = glob_testdir (subdir); + if (isdir < 0 && (flags & GX_MATCHDIRS)) + { + free (subdir); + continue; + } + } + + if (flags & GX_ALLDIRS) + { + if (isdir == 0) + { + dirlist = finddirs (pat, subdir, (flags & ~GX_ADDCURDIR), &e, &ndirs); + if (dirlist == &finddirs_error_return) + { + free (subdir); + lose = 1; + break; + } + if (ndirs) /* add recursive directories to list */ + { + if (firstmalloc == 0) + firstmalloc = e; + e->next = lastlink; + lastlink = dirlist; + count += ndirs; + } + } + + nextlink = (struct globval *) malloc (sizeof (struct globval)); + if (firstmalloc == 0) + firstmalloc = nextlink; + sdlen = strlen (subdir); + nextname = (char *) malloc (sdlen + 1); + if (nextlink == 0 || nextname == 0) + { + free (subdir); + lose = 1; + break; + } + nextlink->next = lastlink; + lastlink = nextlink; + nextlink->name = nextname; + bcopy (subdir, nextname, sdlen + 1); + free (subdir); + ++count; + continue; + } + + convfn = fnx_fromfs (dp->d_name, D_NAMLEN (dp)); + if (strmatch (pat, convfn, mflags) != FNM_NOMATCH) { if (nalloca < ALLOCA_MAX) { @@ -510,6 +654,7 @@ glob_vector (pat, dir, flags) if (firstmalloc == 0) firstmalloc = nextlink; } + nextname = (char *) malloc (D_NAMLEN (dp) + 1); if (nextlink == 0 || nextname == 0) { @@ -527,6 +672,29 @@ glob_vector (pat, dir, flags) (void) closedir (d); } + /* compat: if GX_ADDCURDIR, add the passed directory also. Add an empty + directory name as a placeholder if GX_NULLDIR (in which case the passed + directory name is "."). */ + if (add_current) + { + sdlen = strlen (dir); + nextname = (char *)malloc (sdlen + 1); + nextlink = (struct globval *) malloc (sizeof (struct globval)); + if (nextlink == 0 || nextname == 0) + lose = 1; + else + { + nextlink->name = nextname; + nextlink->next = lastlink; + lastlink = nextlink; + if (flags & GX_NULLDIR) + nextname[0] = '\0'; + else + bcopy (dir, nextname, sdlen + 1); + ++count; + } + } + if (lose == 0) { name_vector = (char **) malloc ((count + 1) * sizeof (char *)); @@ -585,7 +753,7 @@ glob_vector (pat, dir, flags) free (tmplink); } } - + return (name_vector); } @@ -678,9 +846,10 @@ glob_filename (pathname, flags) { char **result; unsigned int result_size; - char *directory_name, *filename; + char *directory_name, *filename, *dname; unsigned int directory_len; int free_dirname; /* flag */ + int dflags; result = (char **) malloc (sizeof (char *)); result_size = 1; @@ -721,10 +890,14 @@ glob_filename (pathname, flags) char **directories; register unsigned int i; + dflags = flags & ~GX_MARKDIRS; + if ((flags & GX_GLOBSTAR) && directory_name[0] == '*' && directory_name[1] == '*' && (directory_name[2] == '/' || directory_name[2] == '\0')) + dflags |= GX_ALLDIRS|GX_ADDCURDIR; + if (directory_name[directory_len - 1] == '/') directory_name[directory_len - 1] = '\0'; - directories = glob_filename (directory_name, flags & ~GX_MARKDIRS); + directories = glob_filename (directory_name, dflags); if (free_dirname) { @@ -753,10 +926,22 @@ glob_filename (pathname, flags) { char **temp_results; - /* Scan directory even on a NULL pathname. That way, `*h/' + /* XXX -- we've recursively scanned any directories resulting from + a `**', so turn off the flag. We turn it on again below if + filename is `**' */ + /* Scan directory even on a NULL filename. That way, `*h/' returns only directories ending in `h', instead of all files ending in `h' with a `/' appended. */ - temp_results = glob_vector (filename, directories[i], flags & ~GX_MARKDIRS); + dname = directories[i]; + dflags = flags & ~(GX_MARKDIRS|GX_ALLDIRS|GX_ADDCURDIR); + if ((flags & GX_GLOBSTAR) && filename[0] == '*' && filename[1] == '*' && filename[2] == '\0') + dflags |= GX_ALLDIRS|GX_ADDCURDIR; + if (dname[0] == '\0' && filename[0]) + { + dflags |= GX_NULLDIR; + dname = "."; /* treat null directory name and non-null filename as current directory */ + } + temp_results = glob_vector (filename, dname, dflags); /* Handle error cases. */ if (temp_results == NULL) @@ -769,7 +954,12 @@ glob_filename (pathname, flags) char **array; register unsigned int l; - array = glob_dir_to_array (directories[i], temp_results, flags); + /* If we're expanding **, we don't need to glue the directory + name to the results; we've already done it in glob_vector */ + if ((dflags & GX_ALLDIRS) && filename[0] == '*' && filename[1] == '*' && filename[2] == '\0') + array = temp_results; + else + array = glob_dir_to_array (directories[i], temp_results, flags); l = 0; while (array[l] != NULL) ++l; @@ -786,7 +976,8 @@ glob_filename (pathname, flags) result[result_size - 1] = NULL; /* Note that the elements of ARRAY are not freed. */ - free ((char *) array); + if (array != temp_results) + free ((char *) array); } } /* Free the directories. */ @@ -830,9 +1021,27 @@ glob_filename (pathname, flags) /* Just return what glob_vector () returns appended to the directory name. */ + /* If flags & GX_ALLDIRS, we're called recursively */ + dflags = flags & ~GX_MARKDIRS; + if (directory_len == 0) + dflags |= GX_NULLDIR; + if ((flags & GX_GLOBSTAR) && filename[0] == '*' && filename[1] == '*' && filename[2] == '\0') + { + dflags |= GX_ALLDIRS|GX_ADDCURDIR; +#if 0 + /* If we want all directories (dflags & GX_ALLDIRS) and we're not + being called recursively as something like `echo [star][star]/[star].o' + ((flags & GX_ALLDIRS) == 0), we want to prevent glob_vector from + adding a null directory name to the front of the temp_results + array. We turn off ADDCURDIR if not called recursively and + dlen == 0 */ +#endif + if (directory_len == 0 && (flags & GX_ALLDIRS) == 0) + dflags &= ~GX_ADDCURDIR; + } temp_results = glob_vector (filename, (directory_len == 0 ? "." : directory_name), - flags & ~GX_MARKDIRS); + dflags); if (temp_results == NULL || temp_results == (char **)&glob_error_return) { @@ -841,7 +1050,7 @@ glob_filename (pathname, flags) return (temp_results); } - result = glob_dir_to_array (directory_name, temp_results, flags); + result = glob_dir_to_array ((dflags & GX_ALLDIRS) ? "" : directory_name, temp_results, flags); if (free_dirname) free (directory_name); return (result); diff --git a/lib/glob/glob.h b/lib/glob/glob.h index 95108a4..993ed70 100644 --- a/lib/glob/glob.h +++ b/lib/glob/glob.h @@ -1,28 +1,35 @@ /* File-name wildcard pattern matching for GNU. - Copyright (C) 1985, 1988, 1989 Free Software Foundation, Inc. + Copyright (C) 1985, 1988, 1989, 2008,2009 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify + This file is part of GNU Bash, the Bourne-Again SHell. + + Bash is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef _GLOB_H_ #define _GLOB_H_ #include "stdc.h" -#define GX_MARKDIRS 0x01 /* mark directory names with trailing `/' */ -#define GX_NOCASE 0x02 /* ignore case */ -#define GX_MATCHDOT 0x04 /* match `.' literally */ +#define GX_MARKDIRS 0x001 /* mark directory names with trailing `/' */ +#define GX_NOCASE 0x002 /* ignore case */ +#define GX_MATCHDOT 0x004 /* match `.' literally */ +#define GX_MATCHDIRS 0x008 /* match only directory names */ +#define GX_ALLDIRS 0x010 /* match all directory names, no others */ +#define GX_NULLDIR 0x100 /* internal -- no directory preceding pattern */ +#define GX_ADDCURDIR 0x200 /* internal -- add passed directory name */ +#define GX_GLOBSTAR 0x400 /* turn on special handling of ** */ extern int glob_pattern_p __P((const char *)); extern char **glob_vector __P((char *, char *, int)); diff --git a/lib/glob/glob_loop.c b/lib/glob/glob_loop.c index 253cac9..89e86af 100644 --- a/lib/glob/glob_loop.c +++ b/lib/glob/glob_loop.c @@ -2,19 +2,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ static int INTERNAL_GLOB_PATTERN_P __P((const CHAR *)); diff --git a/lib/glob/sm_loop.c b/lib/glob/sm_loop.c index 41b0759..dfff06c 100644 --- a/lib/glob/sm_loop.c +++ b/lib/glob/sm_loop.c @@ -2,19 +2,20 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ + int FCT __P((CHAR *, CHAR *, int)); static int GMATCH __P((CHAR *, CHAR *, CHAR *, CHAR *, int)); diff --git a/lib/glob/smatch.c b/lib/glob/smatch.c index be4f927..11d86b0 100644 --- a/lib/glob/smatch.c +++ b/lib/glob/smatch.c @@ -5,19 +5,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/glob/strmatch.c b/lib/glob/strmatch.c index 4d9c68d..cea9bd8 100644 --- a/lib/glob/strmatch.c +++ b/lib/glob/strmatch.c @@ -5,19 +5,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> @@ -25,7 +25,7 @@ #include "strmatch.h" extern int xstrmatch __P((char *, char *, int)); -#if defined (HAVE_MULTIBYTE) +#if defined (HANDLE_MULTIBYTE) extern int internal_wstrmatch __P((wchar_t *, wchar_t *, int)); #endif diff --git a/lib/glob/strmatch.h b/lib/glob/strmatch.h index 7471444..5c99e0c 100644 --- a/lib/glob/strmatch.h +++ b/lib/glob/strmatch.h @@ -1,20 +1,20 @@ /* Copyright (C) 1991-2004 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., -59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + + This file is part of GNU Bash, the Bourne-Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef _STRMATCH_H #define _STRMATCH_H 1 diff --git a/lib/glob/xmbsrtowcs.c b/lib/glob/xmbsrtowcs.c index 83b67b4..23fcd8e 100644 --- a/lib/glob/xmbsrtowcs.c +++ b/lib/glob/xmbsrtowcs.c @@ -4,19 +4,20 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ + #include <config.h> #include <bashansi.h> @@ -27,6 +28,10 @@ #include <shmbutil.h> #if HANDLE_MULTIBYTE + +#ifndef FREE +# define FREE(x) do { if (x) free (x); } while (0) +#endif /* On some locales (ex. ja_JP.sjis), mbsrtowc doesn't convert 0x5c to U<0x5c>. So, this function is made for converting 0x5c to U<0x5c>. */ @@ -160,12 +165,16 @@ xdupmbstowcs (destp, indicesp, src) return (size_t)-1; } - indices = (char **) malloc (wsbuf_size * sizeof(char *)); - if (indices == NULL) + indices = NULL; + if (indicesp) { - free (wsbuf); - *destp = NULL; - return (size_t)-1; + indices = (char **) malloc (wsbuf_size * sizeof(char *)); + if (indices == NULL) + { + free (wsbuf); + *destp = NULL; + return (size_t)-1; + } } p = src; @@ -196,7 +205,7 @@ xdupmbstowcs (destp, indicesp, src) if (MB_INVALIDCH (mblength)) { free (wsbuf); - free (indices); + FREE (indices); *destp = NULL; return (size_t)-1; } @@ -215,25 +224,29 @@ xdupmbstowcs (destp, indicesp, src) if (wstmp == NULL) { free (wsbuf); - free (indices); + FREE (indices); *destp = NULL; return (size_t)-1; } wsbuf = wstmp; - idxtmp = (char **) realloc (indices, wsbuf_size * sizeof (char **)); - if (idxtmp == NULL) + if (indicesp) { - free (wsbuf); - free (indices); - *destp = NULL; - return (size_t)-1; + idxtmp = (char **) realloc (indices, wsbuf_size * sizeof (char **)); + if (idxtmp == NULL) + { + free (wsbuf); + free (indices); + *destp = NULL; + return (size_t)-1; + } + indices = idxtmp; } - indices = idxtmp; } wsbuf[wcnum - 1] = wc; - indices[wcnum - 1] = (char *)p; + if (indices) + indices[wcnum - 1] = (char *)p; p += mblength; } while (MB_NULLWCH (wc) == 0); @@ -242,8 +255,6 @@ xdupmbstowcs (destp, indicesp, src) *destp = wsbuf; if (indicesp != NULL) *indicesp = indices; - else - free (indices); return (wcnum - 1); } diff --git a/lib/intl/Makefile.in b/lib/intl/Makefile.in index 8520ed2..c5245d4 100644 --- a/lib/intl/Makefile.in +++ b/lib/intl/Makefile.in @@ -1,20 +1,19 @@ # Makefile for directory with message catalog handling library of GNU gettext -# Copyright (C) 1995-1998, 2000-2003 Free Software Foundation, Inc. +# Copyright (C) 1995-1998, 2000-2003, 2008,2009 Free Software Foundation, Inc. # -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, -# USA. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. PACKAGE = @PACKAGE_NAME@ VERSION = @PACKAGE_VERSION@ @@ -29,14 +28,20 @@ VPATH = $(srcdir) prefix = @prefix@ exec_prefix = @exec_prefix@ transform = @program_transform_name@ + +datarootdir = @datarootdir@ + libdir = @libdir@ includedir = @includedir@ datadir = @datadir@ -localedir = $(datadir)/locale +localedir = @localedir@ + gettextsrcdir = $(datadir)/gettext/intl aliaspath = $(localedir) subdir = intl +@SET_MAKE@ + INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ MKINSTALLDIRS = @MKINSTALLDIRS@ @@ -58,7 +63,7 @@ DEFS = -DLOCALEDIR=\"$(localedir)\" -DLOCALE_ALIAS_PATH=\"$(aliaspath)\" \ -DENABLE_RELOCATABLE=1 -DIN_LIBRARY -DINSTALLDIR=\"$(libdir)\" -DNO_XMALLOC \ -Dset_relocation_prefix=libintl_set_relocation_prefix \ -Drelocate=libintl_relocate \ --DDEPENDS_ON_LIBICONV=1 @DEFS@ @LOCAL_DEFS@ +-DDEPENDS_ON_LIBICONV=1 @DEFS@ ${LOCAL_DEFS} CPPFLAGS = @CPPFLAGS@ CFLAGS = @CFLAGS@ LDFLAGS = @LDFLAGS@ @@ -229,7 +234,7 @@ libgnuintl.h: $(srcdir)/libgnuintl.h.in cp $(srcdir)/libgnuintl.h.in libgnuintl.h libintl.h: libgnuintl.h - cp libgnuintl.h libintl.h + cmp libgnuintl.h libintl.h || cp libgnuintl.h libintl.h charset.alias: $(srcdir)/config.charset $(SHELL) $(srcdir)/config.charset '@host@' > t-$@ diff --git a/lib/intl/bindtextdom.c b/lib/intl/bindtextdom.c index 250f5e8..ef5479e 100644 --- a/lib/intl/bindtextdom.c +++ b/lib/intl/bindtextdom.c @@ -1,20 +1,22 @@ -/* Implementation of the bindtextdomain(3) function - Copyright (C) 1995-1998, 2000, 2001, 2002 Free Software Foundation, Inc. +/* bindtextdom.c - Implementation of the bindtextdomain(3) function */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 1995-1998, 2000, 2001, 2002, 2005-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/lib/intl/config.charset b/lib/intl/config.charset index 32becec..10c4439 100755..100644 --- a/lib/intl/config.charset +++ b/lib/intl/config.charset @@ -1,22 +1,20 @@ #! /bin/sh # Output a system dependent table of character encoding aliases. # -# Copyright (C) 2000-2003 Free Software Foundation, Inc. +# Copyright (C) 2000-2009 Free Software Foundation, Inc. # -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2, or (at your option) -# any later version. +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Library General Public License for more details. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU Library General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, -# USA. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. # # The table consists of lines of the form # ALIAS CANONICAL diff --git a/lib/intl/dcgettext.c b/lib/intl/dcgettext.c index ca6a1c8..c156ca2 100644 --- a/lib/intl/dcgettext.c +++ b/lib/intl/dcgettext.c @@ -1,20 +1,22 @@ -/* Implementation of the dcgettext(3) function. - Copyright (C) 1995-1999, 2000, 2001, 2002 Free Software Foundation, Inc. +/* dcgettext.c - Implementation of the dcgettext(3) function. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 1995-1999, 2000, 2001, 2002, 2006-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/lib/intl/dcigettext.c b/lib/intl/dcigettext.c index c7e696a..c0f347e 100644 --- a/lib/intl/dcigettext.c +++ b/lib/intl/dcigettext.c @@ -1,20 +1,22 @@ -/* Implementation of the internal dcigettext function. - Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc. +/* dcigettext.c - Implementation of the internal dcigettext function. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 1995-1999, 2000-2003, 2006-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* Tell glibc's <string.h> to provide a prototype for mempcpy(). This must come before <config.h> because <config.h> may include diff --git a/lib/intl/dcngettext.c b/lib/intl/dcngettext.c index 3a3404e..3d70b18 100644 --- a/lib/intl/dcngettext.c +++ b/lib/intl/dcngettext.c @@ -1,20 +1,22 @@ -/* Implementation of the dcngettext(3) function. - Copyright (C) 1995-1999, 2000, 2001, 2002 Free Software Foundation, Inc. +/* dcngettext.c - Implementation of the dcngettext(3) function. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 1995-1999, 2000, 2001, 2002, 2006-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/lib/intl/dgettext.c b/lib/intl/dgettext.c index cf5b403..5351631 100644 --- a/lib/intl/dgettext.c +++ b/lib/intl/dgettext.c @@ -1,20 +1,22 @@ -/* Implementation of the dgettext(3) function. - Copyright (C) 1995-1997, 2000, 2001, 2002 Free Software Foundation, Inc. +/* dgettext.c - Implementation of the dgettext(3) function. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 1995-1997, 2000, 2001, 2002, 2006-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/lib/intl/dngettext.c b/lib/intl/dngettext.c index 67fd030..4276f3b 100644 --- a/lib/intl/dngettext.c +++ b/lib/intl/dngettext.c @@ -1,20 +1,22 @@ -/* Implementation of the dngettext(3) function. - Copyright (C) 1995-1997, 2000, 2001, 2002 Free Software Foundation, Inc. +/* dngettext.c - Implementation of the dngettext(3) function. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 1995-1997, 2000, 2001, 2002, 2005, 2006, 2008,2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/lib/intl/eval-plural.h b/lib/intl/eval-plural.h index 19c7ca6..3441c74 100644 --- a/lib/intl/eval-plural.h +++ b/lib/intl/eval-plural.h @@ -1,20 +1,22 @@ -/* Plural expression evaluation. - Copyright (C) 2000-2002 Free Software Foundation, Inc. +/* eval-plural.c - Plural expression evaluation. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 2000-2002, 2006-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef STATIC #define STATIC static diff --git a/lib/intl/explodename.c b/lib/intl/explodename.c index 2985064..adc3640 100644 --- a/lib/intl/explodename.c +++ b/lib/intl/explodename.c @@ -1,20 +1,23 @@ -/* Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc. +/* explodename.c */ + +/* Copyright (C) 1995-1998, 2000, 2001, 2005-2009 Free Software Foundation, Inc. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/lib/intl/finddomain.c b/lib/intl/finddomain.c index d242764..69a3586 100644 --- a/lib/intl/finddomain.c +++ b/lib/intl/finddomain.c @@ -1,21 +1,23 @@ -/* Handle list of needed message catalogs - Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. +/* finddomain.c - Handle list of needed message catalogs */ + +/* Copyright (C) 1995-1999, 2000, 2001, 2005-2009 Free Software Foundation, Inc. Written by Ulrich Drepper <drepper@gnu.org>, 1995. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/lib/intl/gettext.c b/lib/intl/gettext.c index 43d689f..fd3fa0f 100644 --- a/lib/intl/gettext.c +++ b/lib/intl/gettext.c @@ -1,20 +1,22 @@ -/* Implementation of gettext(3) function. - Copyright (C) 1995, 1997, 2000, 2001, 2002 Free Software Foundation, Inc. +/* gettext.c - Implementation of gettext(3) function. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 1995, 1997, 2000, 2001, 2002, 2005-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/lib/intl/gettextP.h b/lib/intl/gettextP.h index f1748a3..5c137e5 100644 --- a/lib/intl/gettextP.h +++ b/lib/intl/gettextP.h @@ -1,21 +1,23 @@ -/* Header describing internals of libintl library. - Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc. +/* gettextP.h - Header describing internals of libintl library. */ + +/* Copyright (C) 1995-1999, 2000-2003, 2005-2009 Free Software Foundation, Inc. Written by Ulrich Drepper <drepper@cygnus.com>, 1995. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef _GETTEXTP_H #define _GETTEXTP_H diff --git a/lib/intl/gmo.h b/lib/intl/gmo.h index d1fe4d6..2c57851 100644 --- a/lib/intl/gmo.h +++ b/lib/intl/gmo.h @@ -1,20 +1,22 @@ -/* Description of GNU message catalog format: general file layout. - Copyright (C) 1995, 1997, 2000-2002 Free Software Foundation, Inc. +/* gmo.h - Description of GNU message catalog format: general file layout. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 1995, 1997, 2000-2002, 2005-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef _GETTEXT_H #define _GETTEXT_H 1 diff --git a/lib/intl/hash-string.h b/lib/intl/hash-string.h index b267a87..b5a7d41 100644 --- a/lib/intl/hash-string.h +++ b/lib/intl/hash-string.h @@ -1,20 +1,22 @@ -/* Description of GNU message catalog format: string hashing function. - Copyright (C) 1995, 1997, 1998, 2000, 2001 Free Software Foundation, Inc. +/* hash-string.h - Description of GNU message catalog format: string hashing function. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 1995, 1997, 1998, 2000, 2001, 2005-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* @@ end of prolog @@ */ diff --git a/lib/intl/intl-compat.c b/lib/intl/intl-compat.c index 36b7af0..7f32349 100644 --- a/lib/intl/intl-compat.c +++ b/lib/intl/intl-compat.c @@ -1,21 +1,22 @@ -/* intl-compat.c - Stub functions to call gettext functions from GNU gettext - Library. - Copyright (C) 1995, 2000-2003 Software Foundation, Inc. +/* intl-compat.c - Stub functions to call gettext functions from GNU gettext library. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 1995, 2000-2003, 2005-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/lib/intl/l10nflist.c b/lib/intl/l10nflist.c index ec8713f..9f02487 100644 --- a/lib/intl/l10nflist.c +++ b/lib/intl/l10nflist.c @@ -1,20 +1,23 @@ -/* Copyright (C) 1995-1999, 2000, 2001, 2002 Free Software Foundation, Inc. +/* l10nflist.c - make localization file list. */ + +/* Copyright (C) 1995-1999, 2000, 2001, 2002, 2005-2009 Free Software Foundation, Inc. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* Tell glibc's <string.h> to provide a prototype for stpcpy(). This must come before <config.h> because <config.h> may include diff --git a/lib/intl/libgnuintl.h.in b/lib/intl/libgnuintl.h.in index f596cfc..14f9cf9 100644 --- a/lib/intl/libgnuintl.h.in +++ b/lib/intl/libgnuintl.h.in @@ -1,20 +1,22 @@ -/* Message catalogs for internationalization. - Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc. +/* libgnuintl.h - Message catalogs for internationalization. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 1995-1997, 2000-2003, 2004-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef _LIBINTL_H #define _LIBINTL_H 1 diff --git a/lib/intl/loadinfo.h b/lib/intl/loadinfo.h index 1d3ba61..d06a277 100644 --- a/lib/intl/loadinfo.h +++ b/lib/intl/loadinfo.h @@ -1,21 +1,24 @@ -/* Copyright (C) 1996-1999, 2000-2002 Free Software Foundation, Inc. +/* loadinfo.c */ + +/* Copyright (C) 1996-1999, 2000-2002, 2005-2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef _LOADINFO_H #define _LOADINFO_H 1 diff --git a/lib/intl/loadmsgcat.c b/lib/intl/loadmsgcat.c index 8509bd3..83ca63f 100644 --- a/lib/intl/loadmsgcat.c +++ b/lib/intl/loadmsgcat.c @@ -1,20 +1,22 @@ -/* Load needed message catalogs. - Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc. +/* loadmsgcat.c - Load needed message catalogs. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 1995-1999, 2000-2003, 2005-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* Tell glibc's <string.h> to provide a prototype for mempcpy(). This must come before <config.h> because <config.h> may include diff --git a/lib/intl/localcharset.c b/lib/intl/localcharset.c index d04d053..6983d0b 100644 --- a/lib/intl/localcharset.c +++ b/lib/intl/localcharset.c @@ -1,21 +1,22 @@ -/* Determine a canonical name for the current locale's character encoding. +/* localcharset.c - Determine a canonical name for the current locale's character encoding. */ - Copyright (C) 2000-2003 Free Software Foundation, Inc. +/* Copyright (C) 2000-2003, 2005-2009 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. + This file is part of GNU Bash. - This program is distributed in the hope that it will be useful, + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* Written by Bruno Haible <bruno@clisp.org>. */ diff --git a/lib/intl/localcharset.h b/lib/intl/localcharset.h index 3b137e7..e529958 100644 --- a/lib/intl/localcharset.h +++ b/lib/intl/localcharset.h @@ -1,21 +1,22 @@ -/* Determine a canonical name for the current locale's character encoding. - Copyright (C) 2000-2003 Free Software Foundation, Inc. - This file is part of the GNU CHARSET Library. +/* localcharset.h - Determine a canonical name for the current locale's character encoding. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 2000-2003, 2005-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef _LOCALCHARSET_H #define _LOCALCHARSET_H diff --git a/lib/intl/locale.alias b/lib/intl/locale.alias index bd7b9b3..51dd21e 100644 --- a/lib/intl/locale.alias +++ b/lib/intl/locale.alias @@ -1,20 +1,20 @@ -# Locale name alias data base. -# Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc. +# locale.alias - Locale name alias data base. # -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2, or (at your option) -# any later version. +# Copyright (C) 1996,1997,1998,1999,2000,2001,2005-2009 Free Software Foundation, Inc. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Library General Public License for more details. +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. # -# You should have received a copy of the GNU Library General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, -# USA. # The format of this file is the same as for the corresponding file of # the X Window System, which normally can be found in diff --git a/lib/intl/localealias.c b/lib/intl/localealias.c index 7c4ce58..d99a48d 100644 --- a/lib/intl/localealias.c +++ b/lib/intl/localealias.c @@ -1,20 +1,22 @@ -/* Handle aliases for locale names. - Copyright (C) 1995-1999, 2000-2001, 2003 Free Software Foundation, Inc. +/* localealias.c - Handle aliases for locale names. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 1995-1999, 2000-2001, 2003, 2005-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* Tell glibc's <string.h> to provide a prototype for mempcpy(). This must come before <config.h> because <config.h> may include diff --git a/lib/intl/localename.c b/lib/intl/localename.c index faacecd..795a34f 100644 --- a/lib/intl/localename.c +++ b/lib/intl/localename.c @@ -1,20 +1,22 @@ -/* Determine the current selected locale. - Copyright (C) 1995-1999, 2000-2002 Free Software Foundation, Inc. +/* localename.c - Determine the current selected locale. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 1995-1999, 2000-2002, 2005-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* Written by Ulrich Drepper <drepper@gnu.org>, 1995. */ /* Win32 code written by Tor Lillqvist <tml@iki.fi>. */ diff --git a/lib/intl/log.c b/lib/intl/log.c index 9c84791..e527e87 100644 --- a/lib/intl/log.c +++ b/lib/intl/log.c @@ -1,20 +1,22 @@ -/* Log file output. - Copyright (C) 2003 Free Software Foundation, Inc. +/* log.c - Log file output. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 2003, 2005-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* Written by Bruno Haible <bruno@clisp.org>. */ diff --git a/lib/intl/ngettext.c b/lib/intl/ngettext.c index 17a27f4..95aafcc 100644 --- a/lib/intl/ngettext.c +++ b/lib/intl/ngettext.c @@ -1,20 +1,22 @@ -/* Implementation of ngettext(3) function. - Copyright (C) 1995, 1997, 2000, 2001, 2002 Free Software Foundation, Inc. +/* ngettext.c - Implementation of ngettext(3) function. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 1995, 1997, 2000, 2001, 2002, 2005-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/lib/intl/os2compat.c b/lib/intl/os2compat.c index c8dc33e..1aa9dff 100644 --- a/lib/intl/os2compat.c +++ b/lib/intl/os2compat.c @@ -1,20 +1,22 @@ -/* OS/2 compatibility functions. - Copyright (C) 2001-2002 Free Software Foundation, Inc. +/* os2compat.c - OS/2 compatibility functions. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 2001-2002, 2005-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #define OS2_AWARE #ifdef HAVE_CONFIG_H diff --git a/lib/intl/os2compat.h b/lib/intl/os2compat.h index 4f74e8c..8de3183 100644 --- a/lib/intl/os2compat.h +++ b/lib/intl/os2compat.h @@ -1,21 +1,23 @@ -/* OS/2 compatibility defines. - This file is intended to be included from config.h - Copyright (C) 2001-2002 Free Software Foundation, Inc. +/* os2compat.h - OS/2 compatibility defines. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* This file is intended to be included from config.h + Copyright (C) 2001-2002, 2005-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* When included from os2compat.h we need all the original definitions */ #ifndef OS2_AWARE diff --git a/lib/intl/osdep.c b/lib/intl/osdep.c index b372598..b030022 100644 --- a/lib/intl/osdep.c +++ b/lib/intl/osdep.c @@ -1,20 +1,22 @@ -/* OS dependent parts of libintl. - Copyright (C) 2001-2002 Free Software Foundation, Inc. +/* osdep.c - OS dependent parts of libintl. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 2001-2002, 2005-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #if defined __EMX__ # include "os2compat.c" diff --git a/lib/intl/plural-exp.c b/lib/intl/plural-exp.c index c937c01..9ed3b16 100644 --- a/lib/intl/plural-exp.c +++ b/lib/intl/plural-exp.c @@ -1,21 +1,23 @@ -/* Expression parsing for plural form selection. - Copyright (C) 2000, 2001 Free Software Foundation, Inc. +/* plural-exp.c - Expression parsing for plural form selection. */ + +/* Copyright (C) 2000, 2001, 2005-2009 Free Software Foundation, Inc. Written by Ulrich Drepper <drepper@cygnus.com>, 2000. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/lib/intl/plural-exp.h b/lib/intl/plural-exp.h index 9e5d165..dcb0dae 100644 --- a/lib/intl/plural-exp.h +++ b/lib/intl/plural-exp.h @@ -1,21 +1,23 @@ -/* Expression parsing and evaluation for plural form selection. - Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. +/* plural-exp.h - defines for expression parsing and evaluation for plural form selection. */ + +/* Copyright (C) 2000, 2001, 2002, 2005-2009 Free Software Foundation, Inc. Written by Ulrich Drepper <drepper@cygnus.com>, 2000. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef _PLURAL_EXP_H #define _PLURAL_EXP_H diff --git a/lib/intl/plural.c b/lib/intl/plural.c index 3a4fa20..a003151 100644 --- a/lib/intl/plural.c +++ b/lib/intl/plural.c @@ -1,41 +1,106 @@ -/* A Bison parser, made from plural.y - by GNU bison 1.35. */ +/* A Bison parser, made by GNU Bison 2.0. */ -#define YYBISON 1 /* Identify Bison output. */ +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ #define yyparse __gettextparse -#define yylex __gettextlex +#define yylex __gettextlex #define yyerror __gettexterror -#define yylval __gettextlval -#define yychar __gettextchar +#define yylval __gettextlval +#define yychar __gettextchar #define yydebug __gettextdebug #define yynerrs __gettextnerrs -# define EQUOP2 257 -# define CMPOP2 258 -# define ADDOP2 259 -# define MULOP2 260 -# define NUMBER 261 -#line 1 "plural.y" -/* Expression parsing for plural form selection. - Copyright (C) 2000, 2001 Free Software Foundation, Inc. +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + EQUOP2 = 258, + CMPOP2 = 259, + ADDOP2 = 260, + MULOP2 = 261, + NUMBER = 262 + }; +#endif +#define EQUOP2 258 +#define CMPOP2 259 +#define ADDOP2 260 +#define MULOP2 261 +#define NUMBER 262 + + + + +/* Copy the first part of user declarations. */ +#line 1 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y" + +/* plural.y - Expression parsing for plural form selection. */ + +/* Copyright (C) 2000, 2001, 2005-2009 Free Software Foundation, Inc. Written by Ulrich Drepper <drepper@cygnus.com>, 2000. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. + This file is part of GNU Bash. - This program is distributed in the hope that it will be useful, + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* The bison generated parser uses alloca. AIX 3 forces us to put this declaration at the beginning of the file. The declaration in bison's @@ -62,17 +127,38 @@ #define YYLEX_PARAM &((struct parse_args *) arg)->cp #define YYPARSE_PARAM arg -#line 49 "plural.y" -#ifndef YYSTYPE -typedef union { + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +#line 51 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y" +typedef union YYSTYPE { unsigned long int num; enum operator op; struct expression *exp; -} yystype; -# define YYSTYPE yystype +} YYSTYPE; +/* Line 190 of yacc.c. */ +#line 152 "/usr/src/local/bash/bash-20080814/lib/intl/plural.c" +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 #endif -#line 55 "plural.y" + + + +/* Copy the second part of user declarations. */ +#line 57 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y" /* Prototypes for local functions. */ static struct expression *new_exp PARAMS ((int nargs, enum operator op, @@ -170,21 +256,131 @@ new_exp_3 (op, bexp, tbranch, fbranch) return new_exp (3, op, args); } -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif +/* Line 213 of yacc.c. */ +#line 262 "/usr/src/local/bash/bash-20080814/lib/intl/plural.c" + +#if ! defined (yyoverflow) || YYERROR_VERBOSE + +# ifndef YYFREE +# define YYFREE free +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# endif + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# else +# define YYSTACK_ALLOC alloca +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ -#define YYFINAL 27 -#define YYFLAG -32768 -#define YYNTBASE 16 -/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ -#define YYTRANSLATE(x) ((unsigned)(x) <= 261 ? yytranslate[x] : 18) +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) -/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ -static const char yytranslate[] = +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short int yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined (__GNUC__) && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short int yysigned_char; +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 9 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 54 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 16 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 3 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 13 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 27 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 262 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -211,251 +407,137 @@ static const char yytranslate[] = 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 6, 7, 8, - 9, 11 + 2, 2, 2, 2, 2, 2, 1, 2, 6, 7, + 8, 9, 11 }; #if YYDEBUG -static const short yyprhs[] = +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned char yyprhs[] = { - 0, 0, 2, 8, 12, 16, 20, 24, 28, 32, - 35, 37, 39 + 0, 0, 3, 5, 11, 15, 19, 23, 27, 31, + 35, 38, 40, 42 }; -static const short yyrhs[] = + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yysigned_char yyrhs[] = { - 17, 0, 17, 3, 17, 12, 17, 0, 17, 4, - 17, 0, 17, 5, 17, 0, 17, 6, 17, 0, - 17, 7, 17, 0, 17, 8, 17, 0, 17, 9, - 17, 0, 10, 17, 0, 13, 0, 11, 0, 14, - 17, 15, 0 + 17, 0, -1, 18, -1, 18, 3, 18, 12, 18, + -1, 18, 4, 18, -1, 18, 5, 18, -1, 18, + 6, 18, -1, 18, 7, 18, -1, 18, 8, 18, + -1, 18, 9, 18, -1, 10, 18, -1, 13, -1, + 11, -1, 14, 18, 15, -1 }; -#endif - -#if YYDEBUG -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const short yyrline[] = +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned char yyrline[] = { - 0, 174, 182, 186, 190, 194, 198, 202, 206, 210, - 214, 218, 223 + 0, 176, 176, 184, 188, 192, 196, 200, 204, 208, + 212, 216, 220, 225 }; #endif - -#if (YYDEBUG) || defined YYERROR_VERBOSE - -/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ +#if YYDEBUG || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "$", "error", "$undefined.", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2", - "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'", - "start", "exp", 0 + "$end", "error", "$undefined", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2", + "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'", + "$accept", "start", "exp", 0 }; #endif -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const short yyr1[] = +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short int yytoknum[] = { - 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17 + 0, 256, 257, 63, 124, 38, 258, 259, 260, 261, + 33, 262, 58, 110, 40, 41 }; +# endif -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const short yyr2[] = +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = { - 0, 1, 5, 3, 3, 3, 3, 3, 3, 2, - 1, 1, 3 + 0, 16, 17, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18 }; -/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE - doesn't specify something else to do. Zero means the default is an - error. */ -static const short yydefact[] = +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = { - 0, 0, 11, 10, 0, 1, 9, 0, 0, 0, - 0, 0, 0, 0, 0, 12, 0, 3, 4, 5, - 6, 7, 8, 0, 2, 0, 0, 0 + 0, 2, 1, 5, 3, 3, 3, 3, 3, 3, + 2, 1, 1, 3 }; -static const short yydefgoto[] = +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = { - 25, 5 + 0, 0, 12, 11, 0, 0, 2, 10, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 13, 0, 4, + 5, 6, 7, 8, 9, 0, 3 }; -static const short yypact[] = +/* YYDEFGOTO[NTERM-NUM]. */ +static const yysigned_char yydefgoto[] = { - -9, -9,-32768,-32768, -9, 34,-32768, 11, -9, -9, - -9, -9, -9, -9, -9,-32768, 24, 39, 43, 16, - 26, -3,-32768, -9, 34, 21, 53,-32768 + -1, 5, 6 }; -static const short yypgoto[] = +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -10 +static const yysigned_char yypact[] = { - -32768, -1 + -9, -9, -10, -10, -9, 8, 36, -10, 13, -10, + -9, -9, -9, -9, -9, -9, -9, -10, 26, 41, + 45, 18, -2, 14, -10, -9, 36 }; - -#define YYLAST 53 - - -static const short yytable[] = +/* YYPGOTO[NTERM-NUM]. */ +static const yysigned_char yypgoto[] = { - 6, 1, 2, 7, 3, 4, 14, 16, 17, 18, - 19, 20, 21, 22, 8, 9, 10, 11, 12, 13, - 14, 26, 24, 12, 13, 14, 15, 8, 9, 10, - 11, 12, 13, 14, 13, 14, 23, 8, 9, 10, - 11, 12, 13, 14, 10, 11, 12, 13, 14, 11, - 12, 13, 14, 27 + -10, -10, -1 }; -static const short yycheck[] = +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const unsigned char yytable[] = { - 1, 10, 11, 4, 13, 14, 9, 8, 9, 10, - 11, 12, 13, 14, 3, 4, 5, 6, 7, 8, - 9, 0, 23, 7, 8, 9, 15, 3, 4, 5, - 6, 7, 8, 9, 8, 9, 12, 3, 4, 5, - 6, 7, 8, 9, 5, 6, 7, 8, 9, 6, - 7, 8, 9, 0 + 7, 1, 2, 8, 3, 4, 15, 16, 9, 18, + 19, 20, 21, 22, 23, 24, 10, 11, 12, 13, + 14, 15, 16, 16, 26, 14, 15, 16, 17, 10, + 11, 12, 13, 14, 15, 16, 0, 0, 25, 10, + 11, 12, 13, 14, 15, 16, 12, 13, 14, 15, + 16, 13, 14, 15, 16 }; -#define YYPURE 1 - -/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/local/share/bison/bison.simple" - -/* Skeleton output parser for bison, - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software - Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* This is the parser code that is written into each bison parser when - the %semantic_parser declaration is not specified in the grammar. - It was written by Richard Stallman by simplifying the hairy parser - used when %semantic_parser is specified. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE) - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca -# else -# ifndef YYSTACK_USE_ALLOCA -# if defined (alloca) || defined (_ALLOCA_H) -# define YYSTACK_ALLOC alloca -# else -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# endif -# endif -# endif -# endif -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# else -# if defined (__STDC__) || defined (__cplusplus) -# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -# define YYSTACK_ALLOC malloc -# define YYSTACK_FREE free -# endif -#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */ - - -#if (! defined (yyoverflow) \ - && (! defined (__cplusplus) \ - || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc +static const yysigned_char yycheck[] = { - short yyss; - YYSTYPE yyvs; -# if YYLSP_NEEDED - YYLTYPE yyls; -# endif + 1, 10, 11, 4, 13, 14, 8, 9, 0, 10, + 11, 12, 13, 14, 15, 16, 3, 4, 5, 6, + 7, 8, 9, 9, 25, 7, 8, 9, 15, 3, + 4, 5, 6, 7, 8, 9, -1, -1, 12, 3, + 4, 5, 6, 7, 8, 9, 5, 6, 7, 8, + 9, 6, 7, 8, 9 }; -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# if YYLSP_NEEDED -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ - + 2 * YYSTACK_GAP_MAX) -# else -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAX) -# endif - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - register YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (0) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (0) - -#endif - +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = +{ + 0, 10, 11, 13, 14, 17, 18, 18, 18, 0, + 3, 4, 5, 6, 7, 8, 9, 15, 18, 18, + 18, 18, 18, 18, 18, 12, 18 +}; #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) # define YYSIZE_T __SIZE_TYPE__ @@ -475,71 +557,93 @@ union yyalloc #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) -#define YYEMPTY -2 +#define YYEMPTY (-2) #define YYEOF 0 + #define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrlab1 +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ + #define YYFAIL goto yyerrlab + #define YYRECOVERING() (!!yyerrstatus) + #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ - yychar1 = YYTRANSLATE (yychar); \ + yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { \ - yyerror ("syntax error: cannot back up"); \ + yyerror ("syntax error: cannot back up");\ YYERROR; \ } \ while (0) + #define YYTERROR 1 #define YYERRCODE 256 -/* YYLLOC_DEFAULT -- Compute the default location (before the actions - are run). - - When YYLLOC_DEFAULT is run, CURRENT is set the location of the - first token. By default, to implement support for ranges, extend - its range to the last symbol. */ +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) #ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - Current.last_line = Rhs[N].last_line; \ - Current.last_column = Rhs[N].last_column; +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (N) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (0) #endif -/* YYLEX -- calling `yylex' with the right arguments. */ +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif -#if YYPURE -# if YYLSP_NEEDED -# ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) -# else -# define YYLEX yylex (&yylval, &yylloc) -# endif -# else /* !YYLSP_NEEDED */ -# ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, YYLEX_PARAM) -# else -# define YYLEX yylex (&yylval) -# endif -# endif /* !YYLSP_NEEDED */ -#else /* !YYPURE */ -# define YYLEX yylex () -#endif /* !YYPURE */ +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval) +#endif /* Enable debugging if requested. */ #if YYDEBUG @@ -554,13 +658,86 @@ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (0) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short int *bottom, short int *top) +#else +static void +yy_stack_print (bottom, top) + short int *bottom; + short int *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; +#endif +{ + int yyi; + unsigned int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + yyrule - 1, yylno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) + /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ + /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 @@ -573,15 +750,13 @@ int yydebug; SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ -#if YYMAXDEPTH == 0 -# undef YYMAXDEPTH -#endif - #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif + -#ifdef YYERROR_VERBOSE + +#if YYERROR_VERBOSE # ifndef yystrlen # if defined (__GLIBC__) && defined (_STRING_H) @@ -631,86 +806,139 @@ yystpcpy (yydest, yysrc) } # endif # endif -#endif + +#endif /* !YYERROR_VERBOSE */ + -#line 315 "/usr/local/share/bison/bison.simple" +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); +} + +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); -/* The user can define YYPARSE_PARAM as the name of an argument to be passed - into yyparse. The argument should have type void *. - It should actually point to an object. - Grammar actions can access the variable by casting it - to the proper pointer type. */ + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM # if defined (__STDC__) || defined (__cplusplus) -# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM -# define YYPARSE_PARAM_DECL +int yyparse (void *YYPARSE_PARAM); # else -# define YYPARSE_PARAM_ARG YYPARSE_PARAM -# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; +int yyparse (); # endif -#else /* !YYPARSE_PARAM */ -# define YYPARSE_PARAM_ARG -# define YYPARSE_PARAM_DECL -#endif /* !YYPARSE_PARAM */ - -/* Prevent warning if -Wstrict-prototypes. */ -#ifdef __GNUC__ -# ifdef YYPARSE_PARAM -int yyparse (void *); -# else +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) int yyparse (void); -# endif +#else +int yyparse (); #endif +#endif /* ! YYPARSE_PARAM */ + -/* YY_DECL_VARIABLES -- depending whether we use a pure parser, - variables are global, or local to YYPARSE. */ - -#define YY_DECL_NON_LSP_VARIABLES \ -/* The lookahead symbol. */ \ -int yychar; \ - \ -/* The semantic value of the lookahead symbol. */ \ -YYSTYPE yylval; \ - \ -/* Number of parse errors so far. */ \ -int yynerrs; -#if YYLSP_NEEDED -# define YY_DECL_VARIABLES \ -YY_DECL_NON_LSP_VARIABLES \ - \ -/* Location data for the lookahead symbol. */ \ -YYLTYPE yylloc; -#else -# define YY_DECL_VARIABLES \ -YY_DECL_NON_LSP_VARIABLES -#endif -/* If nonreentrant, generate the variables here. */ -#if !YYPURE -YY_DECL_VARIABLES -#endif /* !YYPURE */ +/*----------. +| yyparse. | +`----------*/ +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) int -yyparse (YYPARSE_PARAM_ARG) - YYPARSE_PARAM_DECL +yyparse (void) +#else +int +yyparse () + +#endif +#endif { - /* If reentrant, generate the variables here. */ -#if YYPURE - YY_DECL_VARIABLES -#endif /* !YYPURE */ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; register int yystate; register int yyn; int yyresult; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; - /* Lookahead token as an internal (translated) token number. */ - int yychar1 = 0; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; /* Three stacks and their tools: `yyss': related to states, @@ -720,41 +948,29 @@ yyparse (YYPARSE_PARAM_ARG) Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ - /* The state stack. */ - short yyssa[YYINITDEPTH]; - short *yyss = yyssa; - register short *yyssp; + /* The state stack. */ + short int yyssa[YYINITDEPTH]; + short int *yyss = yyssa; + register short int *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs = yyvsa; register YYSTYPE *yyvsp; -#if YYLSP_NEEDED - /* The location stack. */ - YYLTYPE yylsa[YYINITDEPTH]; - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; -#endif -#if YYLSP_NEEDED -# define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) -#else -# define YYPOPSTACK (yyvsp--, yyssp--) -#endif - YYSIZE_T yystacksize = YYINITDEPTH; +#define YYPOPSTACK (yyvsp--, yyssp--) + YYSIZE_T yystacksize = YYINITDEPTH; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; -#if YYLSP_NEEDED - YYLTYPE yyloc; -#endif + /* When reducing, the number of symbols on the RHS of the reduced - rule. */ + rule. */ int yylen; YYDPRINTF ((stderr, "Starting parse\n")); @@ -771,9 +987,10 @@ yyparse (YYPARSE_PARAM_ARG) yyssp = yyss; yyvsp = yyvs; -#if YYLSP_NEEDED - yylsp = yyls; -#endif + + + yyvsp[0] = yylval; + goto yysetstate; /*------------------------------------------------------------. @@ -788,7 +1005,7 @@ yyparse (YYPARSE_PARAM_ARG) yysetstate: *yyssp = yystate; - if (yyssp >= yyss + yystacksize - 1) + if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; @@ -799,26 +1016,19 @@ yyparse (YYPARSE_PARAM_ARG) these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; + short int *yyss1 = yyss; + /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. */ -# if YYLSP_NEEDED - YYLTYPE *yyls1 = yyls; - /* This used to be a conditional around just the two extra args, - but that might be undefined if yyoverflow is a macro. */ - yyoverflow ("parser stack overflow", - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yyls1, yysize * sizeof (*yylsp), - &yystacksize); - yyls = yyls1; -# else + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ yyoverflow ("parser stack overflow", &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); -# endif + yyss = yyss1; yyvs = yyvs1; } @@ -827,24 +1037,22 @@ yyparse (YYPARSE_PARAM_ARG) goto yyoverflowlab; # else /* Extend the stack our own way. */ - if (yystacksize >= YYMAXDEPTH) + if (YYMAXDEPTH <= yystacksize) goto yyoverflowlab; yystacksize *= 2; - if (yystacksize > YYMAXDEPTH) + if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { - short *yyss1 = yyss; + short int *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyoverflowlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs); -# if YYLSP_NEEDED - YYSTACK_RELOCATE (yyls); -# endif -# undef YYSTACK_RELOCATE + +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } @@ -853,14 +1061,12 @@ yyparse (YYPARSE_PARAM_ARG) yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; -#if YYLSP_NEEDED - yylsp = yyls + yysize - 1; -#endif + YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); - if (yyssp >= yyss + yystacksize - 1) + if (yyss + yystacksize - 1 <= yyssp) YYABORT; } @@ -868,101 +1074,67 @@ yyparse (YYPARSE_PARAM_ARG) goto yybackup; - /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ +/* Read a look-ahead token if we need one and don't already have one. */ /* yyresume: */ - /* First try to decide what to do without reference to lookahead token. */ + /* First try to decide what to do without reference to look-ahead token. */ yyn = yypact[yystate]; - if (yyn == YYFLAG) + if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a lookahead token if don't already have one. */ - - /* yychar is either YYEMPTY or YYEOF - or a valid token in external form. */ + /* Not known => get a look-ahead token if don't already have one. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } - /* Convert token to internal form (in yychar1) for indexing tables with */ - - if (yychar <= 0) /* This means end of input. */ + if (yychar <= YYEOF) { - yychar1 = 0; - yychar = YYEOF; /* Don't call YYLEX any more */ - + yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { - yychar1 = YYTRANSLATE (yychar); - -#if YYDEBUG - /* We have to keep this `#if YYDEBUG', since we use variables - which are defined only if `YYDEBUG' is set. */ - if (yydebug) - { - YYFPRINTF (stderr, "Next token is %d (%s", - yychar, yytname[yychar1]); - /* Give the individual parser a way to print the precise - meaning of a token, for further debugging info. */ -# ifdef YYPRINT - YYPRINT (stderr, yychar, yylval); -# endif - YYFPRINTF (stderr, ")\n"); - } -#endif + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } - yyn += yychar1; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; - yyn = yytable[yyn]; - - /* yyn is what to do for this token type in this state. - Negative => reduce, -yyn is rule number. - Positive => shift, yyn is new state. - New state is final state => don't bother to shift, - just return success. - 0, or most negative number => error. */ - - if (yyn < 0) + if (yyn <= 0) { - if (yyn == YYFLAG) + if (yyn == 0 || yyn == YYTABLE_NINF) goto yyerrlab; yyn = -yyn; goto yyreduce; } - else if (yyn == 0) - goto yyerrlab; if (yyn == YYFINAL) YYACCEPT; - /* Shift the lookahead token. */ - YYDPRINTF ((stderr, "Shifting token %d (%s), ", - yychar, yytname[yychar1])); + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; -#if YYLSP_NEEDED - *++yylsp = yylloc; -#endif + /* Count tokens shifted since error; after three, turn off error status. */ @@ -993,140 +1165,118 @@ yyreduce: /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. - Otherwise, the following line sets YYVAL to the semantic value of - the lookahead token. This behavior is undocumented and Bison + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; -#if YYLSP_NEEDED - /* Similarly for the default location. Let the user run additional - commands if for instance locations are ranges. */ - yyloc = yylsp[1-yylen]; - YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); -#endif -#if YYDEBUG - /* We have to keep this `#if YYDEBUG', since we use variables which - are defined only if `YYDEBUG' is set. */ - if (yydebug) + YY_REDUCE_PRINT (yyn); + switch (yyn) { - int yyi; - - YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", - yyn, yyrline[yyn]); - - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++) - YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); - YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); - } -#endif - - switch (yyn) { - -case 1: -#line 175 "plural.y" -{ - if (yyvsp[0].exp == NULL) + case 2: +#line 177 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y" + { + if ((yyvsp[0].exp) == NULL) YYABORT; - ((struct parse_args *) arg)->res = yyvsp[0].exp; + ((struct parse_args *) arg)->res = (yyvsp[0].exp); } break; -case 2: -#line 183 "plural.y" -{ - yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp); + + case 3: +#line 185 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y" + { + (yyval.exp) = new_exp_3 (qmop, (yyvsp[-4].exp), (yyvsp[-2].exp), (yyvsp[0].exp)); } break; -case 3: -#line 187 "plural.y" -{ - yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp); + + case 4: +#line 189 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y" + { + (yyval.exp) = new_exp_2 (lor, (yyvsp[-2].exp), (yyvsp[0].exp)); } break; -case 4: -#line 191 "plural.y" -{ - yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp); + + case 5: +#line 193 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y" + { + (yyval.exp) = new_exp_2 (land, (yyvsp[-2].exp), (yyvsp[0].exp)); } break; -case 5: -#line 195 "plural.y" -{ - yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp); + + case 6: +#line 197 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y" + { + (yyval.exp) = new_exp_2 ((yyvsp[-1].op), (yyvsp[-2].exp), (yyvsp[0].exp)); } break; -case 6: -#line 199 "plural.y" -{ - yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp); + + case 7: +#line 201 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y" + { + (yyval.exp) = new_exp_2 ((yyvsp[-1].op), (yyvsp[-2].exp), (yyvsp[0].exp)); } break; -case 7: -#line 203 "plural.y" -{ - yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp); + + case 8: +#line 205 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y" + { + (yyval.exp) = new_exp_2 ((yyvsp[-1].op), (yyvsp[-2].exp), (yyvsp[0].exp)); } break; -case 8: -#line 207 "plural.y" -{ - yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp); + + case 9: +#line 209 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y" + { + (yyval.exp) = new_exp_2 ((yyvsp[-1].op), (yyvsp[-2].exp), (yyvsp[0].exp)); } break; -case 9: -#line 211 "plural.y" -{ - yyval.exp = new_exp_1 (lnot, yyvsp[0].exp); + + case 10: +#line 213 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y" + { + (yyval.exp) = new_exp_1 (lnot, (yyvsp[0].exp)); } break; -case 10: -#line 215 "plural.y" -{ - yyval.exp = new_exp_0 (var); + + case 11: +#line 217 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y" + { + (yyval.exp) = new_exp_0 (var); } break; -case 11: -#line 219 "plural.y" -{ - if ((yyval.exp = new_exp_0 (num)) != NULL) - yyval.exp->val.num = yyvsp[0].num; + + case 12: +#line 221 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y" + { + if (((yyval.exp) = new_exp_0 (num)) != NULL) + (yyval.exp)->val.num = (yyvsp[0].num); } break; -case 12: -#line 224 "plural.y" -{ - yyval.exp = yyvsp[-1].exp; + + case 13: +#line 226 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y" + { + (yyval.exp) = (yyvsp[-1].exp); } break; -} -#line 705 "/usr/local/share/bison/bison.simple" + } + +/* Line 1037 of yacc.c. */ +#line 1270 "/usr/src/local/bash/bash-20080814/lib/intl/plural.c" yyvsp -= yylen; yyssp -= yylen; -#if YYLSP_NEEDED - yylsp -= yylen; -#endif -#if YYDEBUG - if (yydebug) - { - short *yyssp1 = yyss - 1; - YYFPRINTF (stderr, "state stack now"); - while (yyssp1 != yyssp) - YYFPRINTF (stderr, " %d", *++yyssp1); - YYFPRINTF (stderr, "\n"); - } -#endif + + YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; -#if YYLSP_NEEDED - *++yylsp = yyloc; -#endif + /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule @@ -1134,11 +1284,11 @@ case 12: yyn = yyr1[yyn]; - yystate = yypgoto[yyn - YYNTBASE] + *yyssp; - if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else - yystate = yydefgoto[yyn - YYNTBASE]; + yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; @@ -1151,155 +1301,159 @@ yyerrlab: if (!yyerrstatus) { ++yynerrs; - -#ifdef YYERROR_VERBOSE +#if YYERROR_VERBOSE yyn = yypact[yystate]; - if (yyn > YYFLAG && yyn < YYLAST) + if (YYPACT_NINF < yyn && yyn < YYLAST) { YYSIZE_T yysize = 0; + int yytype = YYTRANSLATE (yychar); + const char* yyprefix; char *yymsg; - int yyx, yycount; + int yyx; - yycount = 0; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ - for (yyx = yyn < 0 ? -yyn : 0; - yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) - if (yycheck[yyx + yyn] == yyx) - yysize += yystrlen (yytname[yyx]) + 15, yycount++; - yysize += yystrlen ("parse error, unexpected ") + 1; - yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 0; + + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); + yycount += 1; + if (yycount == 5) + { + yysize = 0; + break; + } + } + yysize += (sizeof ("syntax error, unexpected ") + + yystrlen (yytname[yytype])); yymsg = (char *) YYSTACK_ALLOC (yysize); if (yymsg != 0) { - char *yyp = yystpcpy (yymsg, "parse error, unexpected "); - yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); + char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); + yyp = yystpcpy (yyp, yytname[yytype]); if (yycount < 5) { - yycount = 0; - for (yyx = yyn < 0 ? -yyn : 0; - yyx < (int) (sizeof (yytname) / sizeof (char *)); - yyx++) - if (yycheck[yyx + yyn] == yyx) + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { - const char *yyq = ! yycount ? ", expecting " : " or "; - yyp = yystpcpy (yyp, yyq); + yyp = yystpcpy (yyp, yyprefix); yyp = yystpcpy (yyp, yytname[yyx]); - yycount++; + yyprefix = " or "; } } yyerror (yymsg); YYSTACK_FREE (yymsg); } else - yyerror ("parse error; also virtual memory exhausted"); + yyerror ("syntax error; also virtual memory exhausted"); } else -#endif /* defined (YYERROR_VERBOSE) */ - yyerror ("parse error"); +#endif /* YYERROR_VERBOSE */ + yyerror ("syntax error"); } - goto yyerrlab1; -/*--------------------------------------------------. -| yyerrlab1 -- error raised explicitly by an action | -`--------------------------------------------------*/ -yyerrlab1: + if (yyerrstatus == 3) { - /* If just tried and failed to reuse lookahead token after an + /* If just tried and failed to reuse look-ahead token after an error, discard it. */ - /* return failure if at end of input */ - if (yychar == YYEOF) - YYABORT; - YYDPRINTF ((stderr, "Discarding token %d (%s).\n", - yychar, yytname[yychar1])); - yychar = YYEMPTY; + if (yychar <= YYEOF) + { + /* If at end of input, pop the error token, + then the rest of the stack, then return failure. */ + if (yychar == YYEOF) + for (;;) + { + + YYPOPSTACK; + if (yyssp == yyss) + YYABORT; + yydestruct ("Error: popping", + yystos[*yyssp], yyvsp); + } + } + else + { + yydestruct ("Error: discarding", yytoken, &yylval); + yychar = YYEMPTY; + } } - /* Else will try to reuse lookahead token after shifting the error + /* Else will try to reuse look-ahead token after shifting the error token. */ - - yyerrstatus = 3; /* Each real token shifted decrements this */ - - goto yyerrhandle; + goto yyerrlab1; -/*-------------------------------------------------------------------. -| yyerrdefault -- current state does not do anything special for the | -| error token. | -`-------------------------------------------------------------------*/ -yyerrdefault: -#if 0 - /* This is wrong; only states that explicitly want error tokens - should shift them. */ +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: - /* If its default is to accept any token, ok. Otherwise pop it. */ - yyn = yydefact[yystate]; - if (yyn) - goto yydefault; +#ifdef __GNUC__ + /* Pacify GCC when the user code never invokes YYERROR and the label + yyerrorlab therefore never appears in user code. */ + if (0) + goto yyerrorlab; #endif +yyvsp -= yylen; + yyssp -= yylen; + yystate = *yyssp; + goto yyerrlab1; + -/*---------------------------------------------------------------. -| yyerrpop -- pop the current state because it cannot handle the | -| error token | -`---------------------------------------------------------------*/ -yyerrpop: - if (yyssp == yyss) - YYABORT; - yyvsp--; - yystate = *--yyssp; -#if YYLSP_NEEDED - yylsp--; -#endif +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ -#if YYDEBUG - if (yydebug) + for (;;) { - short *yyssp1 = yyss - 1; - YYFPRINTF (stderr, "Error: state stack now"); - while (yyssp1 != yyssp) - YYFPRINTF (stderr, " %d", *++yyssp1); - YYFPRINTF (stderr, "\n"); - } -#endif + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } -/*--------------. -| yyerrhandle. | -`--------------*/ -yyerrhandle: - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yyerrdefault; + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; - yyn += YYTERROR; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) - goto yyerrdefault; - yyn = yytable[yyn]; - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrpop; - yyn = -yyn; - goto yyreduce; + yydestruct ("Error: popping", yystos[yystate], yyvsp); + YYPOPSTACK; + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); } - else if (yyn == 0) - goto yyerrpop; if (yyn == YYFINAL) YYACCEPT; - YYDPRINTF ((stderr, "Shifting error token, ")); - *++yyvsp = yylval; -#if YYLSP_NEEDED - *++yylsp = yylloc; -#endif + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; @@ -1316,16 +1470,21 @@ yyacceptlab: | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: + yydestruct ("Error: discarding lookahead", + yytoken, &yylval); + yychar = YYEMPTY; yyresult = 1; goto yyreturn; -/*---------------------------------------------. -| yyoverflowab -- parser overflow comes here. | -`---------------------------------------------*/ +#ifndef yyoverflow +/*----------------------------------------------. +| yyoverflowlab -- parser overflow comes here. | +`----------------------------------------------*/ yyoverflowlab: yyerror ("parser stack overflow"); yyresult = 2; /* Fall through. */ +#endif yyreturn: #ifndef yyoverflow @@ -1334,7 +1493,9 @@ yyreturn: #endif return yyresult; } -#line 229 "plural.y" + + +#line 231 "/usr/src/local/bash/bash-20080814/lib/intl/plural.y" void diff --git a/lib/intl/plural.y b/lib/intl/plural.y index 616b7c1..8b8cec7 100644 --- a/lib/intl/plural.y +++ b/lib/intl/plural.y @@ -1,22 +1,24 @@ %{ -/* Expression parsing for plural form selection. - Copyright (C) 2000, 2001 Free Software Foundation, Inc. +/* plural.y - Expression parsing for plural form selection. */ + +/* Copyright (C) 2000, 2001, 2005-2009 Free Software Foundation, Inc. Written by Ulrich Drepper <drepper@cygnus.com>, 2000. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* The bison generated parser uses alloca. AIX 3 forces us to put this declaration at the beginning of the file. The declaration in bison's diff --git a/lib/intl/ref-add.sin b/lib/intl/ref-add.sin index 167374e..6fd32ed 100644..100755 --- a/lib/intl/ref-add.sin +++ b/lib/intl/ref-add.sin @@ -2,20 +2,18 @@ # # Copyright (C) 2000 Free Software Foundation, Inc. # -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2, or (at your option) -# any later version. +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Library General Public License for more details. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU Library General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, -# USA. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. # # Written by Bruno Haible <haible@clisp.cons.org>. # diff --git a/lib/intl/ref-del.sin b/lib/intl/ref-del.sin index 613cf37..65ce9af 100644..100755 --- a/lib/intl/ref-del.sin +++ b/lib/intl/ref-del.sin @@ -2,20 +2,18 @@ # # Copyright (C) 2000 Free Software Foundation, Inc. # -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2, or (at your option) -# any later version. +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Library General Public License for more details. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU Library General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, -# USA. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. # # Written by Bruno Haible <haible@clisp.cons.org>. # diff --git a/lib/intl/relocatable.c b/lib/intl/relocatable.c index 16f79a5..34b2b18 100644 --- a/lib/intl/relocatable.c +++ b/lib/intl/relocatable.c @@ -1,22 +1,23 @@ -/* Provide relocatable packages. - Copyright (C) 2003 Free Software Foundation, Inc. +/* relocatable.c - Provide relocatable packages. */ + +/* Copyright (C) 2003, 2005-2009 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2003. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. + This file is part of GNU Bash. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* Tell glibc's <stdio.h> to provide a prototype for getline(). This must come before <config.h> because <config.h> may include diff --git a/lib/intl/relocatable.h b/lib/intl/relocatable.h index d141200..de57f44 100644 --- a/lib/intl/relocatable.h +++ b/lib/intl/relocatable.h @@ -1,21 +1,23 @@ -/* Provide relocatable packages. - Copyright (C) 2003 Free Software Foundation, Inc. +/* relocatable.h - Provide relocatable packages. */ + +/* Copyright (C) 2003, 2005-2009 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2003. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef _RELOCATABLE_H #define _RELOCATABLE_H diff --git a/lib/intl/textdomain.c b/lib/intl/textdomain.c index f259c69..4bb0e80 100644 --- a/lib/intl/textdomain.c +++ b/lib/intl/textdomain.c @@ -1,20 +1,22 @@ -/* Implementation of the textdomain(3) function. - Copyright (C) 1995-1998, 2000, 2001, 2002 Free Software Foundation, Inc. +/* textdomain.c - Implementation of the textdomain(3) function. */ - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. +/* Copyright (C) 1995-1998, 2000, 2001, 2002, 2005-2009 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, + This file is part of GNU Bash. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/lib/malloc/Makefile.in b/lib/malloc/Makefile.in index b2c785b..e40f00a 100644 --- a/lib/malloc/Makefile.in +++ b/lib/malloc/Makefile.in @@ -1,21 +1,19 @@ # Skeleton Makefile for the GNU malloc code # -# -# Copyright (C) 1996-2005 Free Software Foundation, Inc. +# Copyright (C) 1996-2009 Free Software Foundation, Inc. -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. srcdir = @srcdir@ VPATH = .:@srcdir@ diff --git a/lib/malloc/getpagesize.h b/lib/malloc/getpagesize.h index 835f5da..7f32340 100644 --- a/lib/malloc/getpagesize.h +++ b/lib/malloc/getpagesize.h @@ -1,19 +1,21 @@ /* Emulation of getpagesize() for systems that need it. Copyright (C) 1991-2003 Free Software Foundation, Inc. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This file is part of GNU Bash, the Bourne-Again SHell. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #if defined (HAVE_UNISTD_H) # ifdef _MINIX diff --git a/lib/malloc/imalloc.h b/lib/malloc/imalloc.h index 72ba65a..34df10a 100644 --- a/lib/malloc/imalloc.h +++ b/lib/malloc/imalloc.h @@ -4,19 +4,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* Must be included *after* config.h */ diff --git a/lib/malloc/malloc.c b/lib/malloc/malloc.c index f9a08da..bca68e8 100644 --- a/lib/malloc/malloc.c +++ b/lib/malloc/malloc.c @@ -2,23 +2,21 @@ /* Copyright (C) 1985-2005 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This file is part of GNU Bash, the Bourne-Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -In other words, you are welcome to use, share and improve this program. -You are forbidden to forbid anyone else to use, share and improve -what you give them. Help stamp out software-hoarding! */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* * @(#)nmalloc.c 1 (Caltech) 2/21/82 @@ -231,7 +229,7 @@ static int maxbuck; /* highest bucket receiving allocation request. */ static char *memtop; /* top of heap */ -static unsigned long binsizes[NBUCKETS] = { +static const unsigned long binsizes[NBUCKETS] = { 8UL, 16UL, 32UL, 64UL, 128UL, 256UL, 512UL, 1024UL, 2048UL, 4096UL, 8192UL, 16384UL, 32768UL, 65536UL, 131072UL, 262144UL, 524288UL, 1048576UL, 2097152UL, 4194304UL, 8388608UL, 16777216UL, 33554432UL, @@ -312,7 +310,7 @@ xbotch (mem, e, s, file, line) int line; { fprintf (stderr, _("\r\nmalloc: %s:%d: assertion botched\r\n"), - file ? file : "unknown", line); + file ? file : _("unknown"), line); #ifdef MALLOC_REGISTER if (mem != NULL && malloc_register) mregister_describe_mem (mem, stderr); diff --git a/lib/malloc/mstats.h b/lib/malloc/mstats.h index 3153744..11389ff 100644 --- a/lib/malloc/mstats.h +++ b/lib/malloc/mstats.h @@ -2,19 +2,21 @@ /* Copyright (C) 2001-2003 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This file is part of GNU Bash, the Bourne-Again SHell. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef _MSTATS_H #define _MSTATS_H diff --git a/lib/malloc/shmalloc.h b/lib/malloc/shmalloc.h index e51e92b..2dac615 100644 --- a/lib/malloc/shmalloc.h +++ b/lib/malloc/shmalloc.h @@ -2,19 +2,21 @@ tracking. */ /* Copyright (C) 2001-2003 Free Software Foundation, Inc. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + This file is part of GNU Bash, the Bourne-Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef _SH_MALLOC_H #define _SH_MALLOC_H diff --git a/lib/malloc/stats.c b/lib/malloc/stats.c index 0d119fa..8665918 100644 --- a/lib/malloc/stats.c +++ b/lib/malloc/stats.c @@ -2,19 +2,21 @@ /* Copyright (C) 2001-2003 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This file is part of GNU Bash, the Bourne-Again SHell. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifdef HAVE_CONFIG_H # include <config.h> @@ -181,7 +183,7 @@ _imalloc_fopen (s, fn, def, defbuf, defsiz) sprintf (pidbuf, "%ld", l); if ((strlen (pidbuf) + strlen (fn) + 2) >= sizeof (fname)) - return; + return ((FILE *)0); for (sp = 0, p = fname, q = fn; *q; ) { if (sp == 0 && *q == '%' && q[1] == 'p') diff --git a/lib/malloc/stub.c b/lib/malloc/stub.c index 770e3f9..a60a624 100644 --- a/lib/malloc/stub.c +++ b/lib/malloc/stub.c @@ -2,19 +2,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ void bash_malloc_stub() diff --git a/lib/malloc/table.c b/lib/malloc/table.c index b9310a6..cf89b3c 100644 --- a/lib/malloc/table.c +++ b/lib/malloc/table.c @@ -4,19 +4,20 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ + #ifdef HAVE_CONFIG_H # include <config.h> #endif diff --git a/lib/malloc/table.h b/lib/malloc/table.h index 0d22376..41ce9f7 100644 --- a/lib/malloc/table.h +++ b/lib/malloc/table.h @@ -2,19 +2,21 @@ /* Copyright (C) 2001-2003 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + This file is part of GNU Bash, the Bourne-Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef _MTABLE_H #define _MTABLE_H diff --git a/lib/malloc/trace.c b/lib/malloc/trace.c index 79f4668..6d93f99 100644 --- a/lib/malloc/trace.c +++ b/lib/malloc/trace.c @@ -4,19 +4,20 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ + #ifdef HAVE_CONFIG_H # include <config.h> #endif diff --git a/lib/malloc/watch.c b/lib/malloc/watch.c index 11ab744..00c8a82 100644 --- a/lib/malloc/watch.c +++ b/lib/malloc/watch.c @@ -4,19 +4,20 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ + #ifdef HAVE_CONFIG_H # include <config.h> #endif @@ -43,17 +44,17 @@ watch_warn (addr, file, line, type, data) char *tag; if (type == W_ALLOC) - tag = _("allocated"); + tag = "allocated"; else if (type == W_FREE) - tag = _("freed"); + tag = "freed"; else if (type == W_REALLOC) - tag = _("requesting resize"); + tag = "requesting resize"; else if (type == W_RESIZED) - tag = _("just resized"); + tag = "just resized"; else - tag = _("bug: unknown operation"); + tag = "bug: unknown operation"; - fprintf (stderr, _("malloc: watch alert: %p %s "), addr, tag); + fprintf (stderr, "malloc: watch alert: %p %s ", addr, tag); if (data != (unsigned long)-1) fprintf (stderr, "(size %lu) ", data); fprintf (stderr, "from '%s:%d'\n", file ? file : "unknown", line); diff --git a/lib/malloc/watch.h b/lib/malloc/watch.h index 757bbd2..6782acc 100644 --- a/lib/malloc/watch.h +++ b/lib/malloc/watch.h @@ -2,19 +2,21 @@ /* Copyright (C) 2001-2003 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + This file is part of GNU Bash, the Bourne-Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef _MWATCH_H #define _MWATCH_H diff --git a/lib/malloc/xmalloc.c b/lib/malloc/xmalloc.c index ab7c91a..f6dec67 100644 --- a/lib/malloc/xmalloc.c +++ b/lib/malloc/xmalloc.c @@ -5,19 +5,19 @@ This file is part of GNU Readline, a library for reading lines of text with interactive input and history editing. - Readline is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Readline is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with Readline; see the file COPYING. If not, write to the Free - Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if defined (HAVE_CONFIG_H) #include <config.h> diff --git a/lib/readline/COPYING b/lib/readline/COPYING index 1bf1526..94a9ed0 100644 --- a/lib/readline/COPYING +++ b/lib/readline/COPYING @@ -1,285 +1,626 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111 USA + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Preamble + Preamble - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of this License. - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Programs + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it @@ -287,15 +628,15 @@ free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least +state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> - Copyright (C) 19yy <name of author> + Copyright (C) <year> <name of author> - This program is free software; you can redistribute it and/or modify + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -304,36 +645,30 @@ the "copyright" line and a pointer to where the full notice is found. GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + along with this program. If not, see <http://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. diff --git a/lib/readline/Makefile.in b/lib/readline/Makefile.in index 5ab97b8..2204628 100644 --- a/lib/readline/Makefile.in +++ b/lib/readline/Makefile.in @@ -4,21 +4,20 @@ # # ############################################################################# -# Copyright (C) 1994-2005 Free Software Foundation, Inc. +# Copyright (C) 1994-2009 Free Software Foundation, Inc. -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. PACKAGE = @PACKAGE_NAME@ VERSION = @PACKAGE_VERSION@ @@ -33,6 +32,8 @@ VPATH = .:@srcdir@ topdir = @top_srcdir@ BUILD_DIR = @BUILD_DIR@ +datarootdir = @datarootdir@ + INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ @@ -98,6 +99,12 @@ OBJECTS = readline.o vi_mode.o funmap.o keymaps.o parens.o search.o \ util.o kill.o undo.o macro.o input.o callback.o terminal.o \ text.o nls.o misc.o $(HISTOBJ) $(TILDEOBJ) xmalloc.o compat.o +# The texinfo files which document this library. +DOCSOURCE = doc/rlman.texinfo doc/rltech.texinfo doc/rluser.texinfo +DOCOBJECT = doc/readline.dvi +DOCSUPPORT = doc/Makefile +DOCUMENTATION = $(DOCSOURCE) $(DOCOBJECT) $(DOCSUPPORT) + SUPPORT = Makefile ChangeLog $(DOCSUPPORT) examples/[-a-z.]* SOURCES = $(CSOURCES) $(HSOURCES) $(DOCSOURCE) @@ -123,6 +130,7 @@ libhistory.a: $(HISTOBJ) xmalloc.o documentation: force test -d doc || mkdir doc + -( cd doc && $(MAKE) $(MFLAGS) ) # Since tilde.c is shared between readline and bash, make sure we compile # it with the right flags when it's built as part of readline @@ -146,10 +154,13 @@ tags: force clean: force $(RM) $(OBJECTS) *.a + -( cd doc && $(MAKE) $(MFLAGS) $@ ) mostlyclean: clean + -( cd doc && $(MAKE) $(MFLAGS) $@ ) distclean maintainer-clean: clean + -( cd doc && $(MAKE) $(MFLAGS) $@ ) $(RM) Makefile $(RM) TAGS tags diff --git a/lib/readline/ansi_stdlib.h b/lib/readline/ansi_stdlib.h index db13cd2..7dc2ee0 100644 --- a/lib/readline/ansi_stdlib.h +++ b/lib/readline/ansi_stdlib.h @@ -6,19 +6,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #if !defined (_STDLIB_H_) #define _STDLIB_H_ 1 diff --git a/lib/readline/bind.c b/lib/readline/bind.c index 67d14d6..fc8c2a2 100644 --- a/lib/readline/bind.c +++ b/lib/readline/bind.c @@ -1,24 +1,23 @@ /* bind.c -- key binding and startup file support for the readline library. */ -/* Copyright (C) 1987-2006 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #define READLINE_LIBRARY @@ -80,7 +79,7 @@ static int glean_key_from_name PARAMS((char *)); static int find_boolean_var PARAMS((const char *)); static char *_rl_get_string_variable_value PARAMS((const char *)); -static int substring_member_of_array PARAMS((char *, const char **)); +static int substring_member_of_array PARAMS((const char *, const char * const *)); static int currently_reading_init_file; @@ -317,7 +316,7 @@ rl_macro_bind (keyseq, macro, map) if (rl_translate_keyseq (macro, macro_keys, ¯o_keys_len)) { - free (macro_keys); + xfree (macro_keys); return -1; } rl_generic_bind (ISMACR, keyseq, macro_keys, map); @@ -347,7 +346,7 @@ rl_generic_bind (type, keyseq, data, map) if (keyseq == 0 || *keyseq == 0) { if (type == ISMACR) - free (data); + xfree (data); return -1; } @@ -358,7 +357,7 @@ rl_generic_bind (type, keyseq, data, map) KEYS into KEYS_LEN. */ if (rl_translate_keyseq (keyseq, keys, &keys_len)) { - free (keys); + xfree (keys); return -1; } @@ -371,7 +370,7 @@ rl_generic_bind (type, keyseq, data, map) ic = uc; if (ic < 0 || ic >= KEYMAP_SIZE) { - free (keys); + xfree (keys); return -1; } @@ -414,11 +413,18 @@ rl_generic_bind (type, keyseq, data, map) else { if (map[ic].type == ISMACR) - free ((char *)map[ic].function); + xfree ((char *)map[ic].function); else if (map[ic].type == ISKMAP) { map = FUNCTION_TO_KEYMAP (map, ic); ic = ANYOTHERKEY; + /* If we're trying to override a keymap with a null function + (e.g., trying to unbind it), we can't use a null pointer + here because that's indistinguishable from having not been + overridden. We use a special bindable function that does + nothing. */ + if (type == ISFUNC && data == 0) + data = (char *)_rl_null_function; } map[ic].function = KEYMAP_TO_FUNCTION (data); @@ -427,7 +433,7 @@ rl_generic_bind (type, keyseq, data, map) rl_binding_keymap = map; } - free (keys); + xfree (keys); return 0; } @@ -752,9 +758,6 @@ rl_function_of_keyseq (keyseq, map, type) /* The last key bindings file read. */ static char *last_readline_init_file = (char *)NULL; -/* Flag to read system init file */ -static int read_system_init_file = 0; - /* The file we're currently reading key bindings from. */ static const char *current_readline_init_file; static int current_readline_init_include_level; @@ -796,10 +799,12 @@ _rl_read_file (filename, sizep) if (i < 0) { - free (buffer); + xfree (buffer); return ((char *)NULL); } + RL_CHECK_SIGNALS (); + buffer[i] = '\0'; if (sizep) *sizep = i; @@ -866,8 +871,9 @@ _rl_read_init_file (filename, include_level) openname = tilde_expand (filename); buffer = _rl_read_file (openname, &file_size); - free (openname); + xfree (openname); + RL_CHECK_SIGNALS (); if (buffer == 0) return (errno); @@ -914,7 +920,7 @@ _rl_read_init_file (filename, include_level) current_readline_init_lineno++; } - free (buffer); + xfree (buffer); currently_reading_init_file = 0; return (0); } @@ -924,10 +930,10 @@ _rl_init_file_error (msg) const char *msg; { if (currently_reading_init_file) - fprintf (stderr, "readline: %s: line %d: %s\n", current_readline_init_file, + _rl_errmsg ("%s: line %d: %s\n", current_readline_init_file, current_readline_init_lineno, msg); else - fprintf (stderr, "readline: %s\n", msg); + _rl_errmsg ("%s", msg); } /* **************************************************************** */ @@ -939,11 +945,11 @@ _rl_init_file_error (msg) typedef int _rl_parser_func_t PARAMS((char *)); /* Things that mean `Control'. */ -const char *_rl_possible_control_prefixes[] = { +const char * const _rl_possible_control_prefixes[] = { "Control-", "C-", "CTRL-", (const char *)NULL }; -const char *_rl_possible_meta_prefixes[] = { +const char * const _rl_possible_meta_prefixes[] = { "Meta", "M-", (const char *)NULL }; @@ -1005,7 +1011,7 @@ parser_if (args) `$if term=sun-cmd' into their .inputrc. */ _rl_parsing_conditionalized_out = _rl_stricmp (args + 5, tname) && _rl_stricmp (args + 5, rl_terminal_name); - free (tname); + xfree (tname); } #if defined (VI_MODE) else if (_rl_strnicmp (args, "mode=", 5) == 0) @@ -1102,8 +1108,8 @@ parser_include (args) } /* Associate textual names with actual functions. */ -static struct { - const char *name; +static const struct { + const char * const name; _rl_parser_func_t *function; } parser_directives [] = { { "if", parser_if }, @@ -1355,7 +1361,7 @@ rl_parse_and_bind (string) else rl_bind_keyseq (seq, rl_named_function (funname)); - free (seq); + xfree (seq); return 0; } @@ -1409,8 +1415,8 @@ rl_parse_and_bind (string) #define V_SPECIAL 0x1 -static struct { - const char *name; +static const struct { + const char * const name; int *value; int flags; } boolean_varlist [] = { @@ -1420,7 +1426,9 @@ static struct { { "completion-ignore-case", &_rl_completion_case_fold, 0 }, { "convert-meta", &_rl_convert_meta_chars_to_ascii, 0 }, { "disable-completion", &rl_inhibit_completion, 0 }, + { "echo-control-characters", &_rl_echo_control_chars, 0 }, { "enable-keypad", &_rl_enable_keypad, 0 }, + { "enable-meta-key", &_rl_enable_meta, 0 }, { "expand-tilde", &rl_complete_with_tilde_expansion, 0 }, { "history-preserve-point", &_rl_history_preserve_point, 0 }, { "horizontal-scroll-mode", &_rl_horizontal_scroll_mode, 0 }, @@ -1434,8 +1442,10 @@ static struct { { "page-completions", &_rl_page_completions, 0 }, { "prefer-visible-bell", &_rl_prefer_visible_bell, V_SPECIAL }, { "print-completions-horizontally", &_rl_print_completions_horizontally, 0 }, + { "revert-all-at-newline", &_rl_revert_all_at_newline, 0 }, { "show-all-if-ambiguous", &_rl_complete_show_all, 0 }, { "show-all-if-unmodified", &_rl_complete_show_unmodified, 0 }, + { "skip-completed-text", &_rl_skip_completed_text, 0 }, #if defined (VISIBLE_STATS) { "visible-stats", &rl_visible_stats, 0 }, #endif /* VISIBLE_STATS */ @@ -1492,20 +1502,24 @@ typedef int _rl_sv_func_t PARAMS((const char *)); /* Forward declarations */ static int sv_bell_style PARAMS((const char *)); static int sv_combegin PARAMS((const char *)); +static int sv_dispprefix PARAMS((const char *)); static int sv_compquery PARAMS((const char *)); static int sv_editmode PARAMS((const char *)); +static int sv_histsize PARAMS((const char *)); static int sv_isrchterm PARAMS((const char *)); static int sv_keymap PARAMS((const char *)); -static struct { - const char *name; +static const struct { + const char * const name; int flags; _rl_sv_func_t *set_func; } string_varlist[] = { { "bell-style", V_STRING, sv_bell_style }, { "comment-begin", V_STRING, sv_combegin }, + { "completion-prefix-display-length", V_INT, sv_dispprefix }, { "completion-query-items", V_INT, sv_compquery }, { "editing-mode", V_STRING, sv_editmode }, + { "history-size", V_INT, sv_histsize }, { "isearch-terminators", V_STRING, sv_isrchterm }, { "keymap", V_STRING, sv_keymap }, { (char *)NULL, 0 } @@ -1617,6 +1631,22 @@ sv_combegin (value) } static int +sv_dispprefix (value) + const char *value; +{ + int nval = 0; + + if (value && *value) + { + nval = atoi (value); + if (nval < 0) + nval = 0; + } + _rl_completion_prefix_display_length = nval; + return 0; +} + +static int sv_compquery (value) const char *value; { @@ -1633,6 +1663,22 @@ sv_compquery (value) } static int +sv_histsize (value) + const char *value; +{ + int nval = 500; + + if (value && *value) + { + nval = atoi (value); + if (nval < 0) + return 1; + } + stifle_history (nval); + return 0; +} + +static int sv_keymap (value) const char *value; { @@ -1696,7 +1742,7 @@ sv_isrchterm (value) rl_translate_keyseq (v + beg, _rl_isearch_terminators, &end); _rl_isearch_terminators[end] = '\0'; - free (v); + xfree (v); return 0; } @@ -1704,11 +1750,11 @@ sv_isrchterm (value) For example, `Space' returns ' '. */ typedef struct { - const char *name; + const char * const name; int value; } assoc_list; -static assoc_list name_key_alist[] = { +static const assoc_list name_key_alist[] = { { "DEL", 0x7f }, { "ESC", '\033' }, { "Escape", '\033' }, @@ -1737,8 +1783,8 @@ glean_key_from_name (name) } /* Auxiliary functions to manage keymaps. */ -static struct { - const char *name; +static const struct { + const char * const name; Keymap map; } keymap_names[] = { { "emacs", emacs_standard_keymap }, @@ -1841,7 +1887,7 @@ rl_list_funmap_names () for (i = 0; funmap_names[i]; i++) fprintf (rl_outstream, "%s\n", funmap_names[i]); - free (funmap_names); + xfree (funmap_names); } static char * @@ -2007,7 +2053,7 @@ rl_invoking_keyseqs_in_map (function, map) } strcat (keyname, seqs[i]); - free (seqs[i]); + xfree (seqs[i]); if (result_index + 2 > result_size) { @@ -2019,7 +2065,7 @@ rl_invoking_keyseqs_in_map (function, map) result[result_index] = (char *)NULL; } - free (seqs); + xfree (seqs); } break; } @@ -2071,10 +2117,10 @@ rl_function_dumper (print_readably) { fprintf (rl_outstream, "\"%s\": %s\n", invokers[j], name); - free (invokers[j]); + xfree (invokers[j]); } - free (invokers); + xfree (invokers); } } else @@ -2098,9 +2144,9 @@ rl_function_dumper (print_readably) fprintf (rl_outstream, "...\n"); for (j = 0; invokers[j]; j++) - free (invokers[j]); + xfree (invokers[j]); - free (invokers); + xfree (invokers); } } } @@ -2146,8 +2192,8 @@ _rl_macro_dumper_internal (print_readably, map, prefix) fprintf (rl_outstream, "%s%s outputs %s\n", prefix ? prefix : "", keyname, out ? out : ""); - free (keyname); - free (out); + xfree (keyname); + xfree (out); break; case ISFUNC: break; @@ -2170,13 +2216,13 @@ _rl_macro_dumper_internal (print_readably, map, prefix) out = (char *)xmalloc (strlen (keyname) + prefix_len + 1); strcpy (out, prefix); strcpy (out + prefix_len, keyname); - free (keyname); + xfree (keyname); keyname = out; } } _rl_macro_dumper_internal (print_readably, FUNCTION_TO_KEYMAP (map, key), keyname); - free (keyname); + xfree (keyname); break; } } @@ -2222,6 +2268,11 @@ _rl_get_string_variable_value (name) } else if (_rl_stricmp (name, "comment-begin") == 0) return (_rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT); + else if (_rl_stricmp (name, "completion-prefix-display-length") == 0) + { + sprintf (numbuf, "%d", _rl_completion_prefix_display_length); + return (numbuf); + } else if (_rl_stricmp (name, "completion-query-items") == 0) { sprintf (numbuf, "%d", rl_completion_query_items); @@ -2229,6 +2280,11 @@ _rl_get_string_variable_value (name) } else if (_rl_stricmp (name, "editing-mode") == 0) return (rl_get_keymap_name_from_edit_mode ()); + else if (_rl_stricmp (name, "history-size") == 0) + { + sprintf (numbuf, "%d", history_is_stifled() ? history_max_entries : 0); + return (numbuf); + } else if (_rl_stricmp (name, "isearch-terminators") == 0) { if (_rl_isearch_terminators == 0) @@ -2237,7 +2293,7 @@ _rl_get_string_variable_value (name) if (ret) { strncpy (numbuf, ret, sizeof (numbuf) - 1); - free (ret); + xfree (ret); numbuf[sizeof(numbuf) - 1] = '\0'; } else @@ -2301,8 +2357,8 @@ rl_dump_variables (count, key) /* Return non-zero if any members of ARRAY are a substring in STRING. */ static int substring_member_of_array (string, array) - char *string; - const char **array; + const char *string; + const char * const *array; { while (*array) { diff --git a/lib/readline/callback.c b/lib/readline/callback.c index ada04d8..6c52ac0 100644 --- a/lib/readline/callback.c +++ b/lib/readline/callback.c @@ -1,24 +1,24 @@ /* callback.c -- functions to use readline as an X `callback' mechanism. */ -/* Copyright (C) 1987-2005 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) @@ -87,6 +87,7 @@ _rl_callback_newline () } readline_internal_setup (); + RL_CHECK_SIGNALS (); } /* Install a readline handler, set up the terminal, and issue the prompt. */ @@ -111,22 +112,23 @@ rl_callback_read_char () if (rl_linefunc == NULL) { - fprintf (stderr, "readline: readline_callback_read_char() called with no handler!\r\n"); + _rl_errmsg ("readline_callback_read_char() called with no handler!"); abort (); } - memcpy ((void *)olevel, (void *)readline_top_level, sizeof (procenv_t)); - jcode = setjmp (readline_top_level); + memcpy ((void *)olevel, (void *)_rl_top_level, sizeof (procenv_t)); + jcode = setjmp (_rl_top_level); if (jcode) { (*rl_redisplay_function) (); _rl_want_redisplay = 0; - memcpy ((void *)readline_top_level, (void *)olevel, sizeof (procenv_t)); + memcpy ((void *)_rl_top_level, (void *)olevel, sizeof (procenv_t)); return; } do { + RL_CHECK_SIGNALS (); if (RL_ISSTATE (RL_STATE_ISEARCH)) { eof = _rl_isearch_callback (_rl_iscxt); @@ -186,6 +188,7 @@ rl_callback_read_char () else eof = readline_internal_char (); + RL_CHECK_SIGNALS (); if (rl_done == 0 && _rl_want_redisplay) { (*rl_redisplay_function) (); @@ -223,6 +226,7 @@ rl_callback_handler_remove () { rl_linefunc = NULL; RL_UNSETSTATE (RL_STATE_CALLBACK); + RL_CHECK_SIGNALS (); if (in_handler) { in_handler = 0; @@ -251,8 +255,7 @@ _rl_callback_data_alloc (count) void _rl_callback_data_dispose (arg) _rl_callback_generic_arg *arg; { - if (arg) - free (arg); + xfree (arg); } #endif diff --git a/lib/readline/chardefs.h b/lib/readline/chardefs.h index def3a11..e76c34b 100644 --- a/lib/readline/chardefs.h +++ b/lib/readline/chardefs.h @@ -1,24 +1,23 @@ /* chardefs.h -- Character definitions for readline. */ -/* Copyright (C) 1994 Free Software Foundation, Inc. +/* Copyright (C) 1994-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef _CHARDEFS_H_ #define _CHARDEFS_H_ diff --git a/lib/readline/compat.c b/lib/readline/compat.c index a66d210..2af5120 100644 --- a/lib/readline/compat.c +++ b/lib/readline/compat.c @@ -1,24 +1,24 @@ /* compat.c -- backwards compatibility functions. */ -/* Copyright (C) 2000 Free Software Foundation, Inc. +/* Copyright (C) 2000-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) diff --git a/lib/readline/complete.c b/lib/readline/complete.c index 73f834a..ad9ca05 100644 --- a/lib/readline/complete.c +++ b/lib/readline/complete.c @@ -1,24 +1,24 @@ /* complete.c -- filename completion for readline. */ -/* Copyright (C) 1987-2005 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) @@ -110,8 +110,8 @@ static int get_y_or_n PARAMS((int)); static int _rl_internal_pager PARAMS((int)); static char *printable_part PARAMS((char *)); static int fnwidth PARAMS((const char *)); -static int fnprint PARAMS((const char *)); -static int print_filename PARAMS((char *, char *)); +static int fnprint PARAMS((const char *, int)); +static int print_filename PARAMS((char *, char *, int)); static char **gen_completion_matches PARAMS((char *, int, int, rl_compentry_func_t *, int, int)); @@ -164,6 +164,12 @@ int _rl_completion_case_fold; Unix) when doing filename completion. */ int _rl_match_hidden_files = 1; +/* Length in characters of a common prefix replaced with an ellipsis (`...') + when displaying completion matches. Matches whose printable portion has + more than this number of displaying characters in common will have the common + display prefix replaced with an ellipsis. */ +int _rl_completion_prefix_display_length = 0; + /* Global variables available to applications using readline. */ #if defined (VISIBLE_STATS) @@ -173,6 +179,12 @@ int _rl_match_hidden_files = 1; int rl_visible_stats = 0; #endif /* VISIBLE_STATS */ +/* If non-zero, when completing in the middle of a word, don't insert + characters from the match that match characters following point in + the word. This means, for instance, completing when the cursor is + after the `e' in `Makefile' won't result in `Makefilefile'. */ +int _rl_skip_completed_text = 0; + /* If non-zero, then this is the address of a function to call when completing on a directory name. The function is called with the address of a string (the current directory name) as an arg. */ @@ -180,6 +192,17 @@ rl_icppfunc_t *rl_directory_completion_hook = (rl_icppfunc_t *)NULL; rl_icppfunc_t *rl_directory_rewrite_hook = (rl_icppfunc_t *)NULL; +/* If non-zero, this is the address of a function to call when reading + directory entries from the filesystem for completion and comparing + them to the partial word to be completed. The function should + either return its first argument (if no conversion takes place) or + newly-allocated memory. This can, for instance, convert filenames + between character sets for comparison against what's typed at the + keyboard. The returned value is what is added to the list of + matches. The second argument is the length of the filename to be + converted. */ +rl_dequote_func_t *rl_filename_rewrite_hook = (rl_dequote_func_t *)NULL; + /* Non-zero means readline completion functions perform tilde expansion. */ int rl_complete_with_tilde_expansion = 0; @@ -188,6 +211,10 @@ int rl_complete_with_tilde_expansion = 0; completer. */ rl_compentry_func_t *rl_completion_entry_function = (rl_compentry_func_t *)NULL; +/* Pointer to generator function for rl_menu_complete (). NULL means to use + *rl_completion_entry_function (see above). */ +rl_compentry_func_t *rl_menu_completion_entry_function = (rl_compentry_func_t *)NULL; + /* Pointer to alternative function to create matches. Function is called with TEXT, START, and END. START and END are indices in RL_LINE_BUFFER saying what the boundaries @@ -325,11 +352,20 @@ int rl_completion_mark_symlink_dirs; /* If non-zero, inhibit completion (temporarily). */ int rl_inhibit_completion; +/* Set to the last key used to invoke one of the completion functions */ +int rl_completion_invoking_key; + +/* If non-zero, sort the completion matches. On by default. */ +int rl_sort_completion_matches = 1; + /* Variables local to this file. */ /* Local variable states what happened during the last completion attempt. */ static int completion_changed_buffer; +/* The result of the query to the user about displaying completion matches */ +static int completion_y_or_n; + /*************************************/ /* */ /* Bindable completion functions */ @@ -343,6 +379,8 @@ int rl_complete (ignore, invoking_key) int ignore, invoking_key; { + rl_completion_invoking_key = invoking_key; + if (rl_inhibit_completion) return (_rl_insert_char (ignore, invoking_key)); else if (rl_last_func == rl_complete && !completion_changed_buffer) @@ -360,6 +398,7 @@ int rl_possible_completions (ignore, invoking_key) int ignore, invoking_key; { + rl_completion_invoking_key = invoking_key; return (rl_complete_internal ('?')); } @@ -367,6 +406,7 @@ int rl_insert_completions (ignore, invoking_key) int ignore, invoking_key; { + rl_completion_invoking_key = invoking_key; return (rl_complete_internal ('*')); } @@ -395,6 +435,14 @@ rl_completion_mode (cfunc) /* */ /************************************/ +/* Reset readline state on a signal or other event. */ +void +_rl_reset_completion_state () +{ + rl_completion_found_quote = 0; + rl_completion_quote_character = 0; +} + /* Set default values for readline word completion. These are the variables that application completion functions can change or inspect. */ static void @@ -406,6 +454,7 @@ set_completion_defaults (what_to_do) rl_filename_quoting_desired = 1; rl_completion_type = what_to_do; rl_completion_suppress_append = rl_completion_suppress_quote = 0; + rl_completion_append_character = ' '; /* The completion entry function may optionally change this. */ rl_completion_mark_symlink_dirs = _rl_complete_mark_symlink_dirs; @@ -428,7 +477,7 @@ get_y_or_n (for_pager) return (1); if (c == 'n' || c == 'N' || c == RUBOUT) return (0); - if (c == ABORT_CHAR) + if (c == ABORT_CHAR || c < 0) _rl_abort_internal (); if (for_pager && (c == NEWLINE || c == RETURN)) return (2); @@ -481,6 +530,13 @@ stat_char (filename) struct stat finfo; int character, r; + /* Short-circuit a //server on cygwin, since that will always behave as + a directory. */ +#if __CYGWIN__ + if (filename[0] == '/' && filename[1] == '/' && strchr (filename+2, '/') == 0) + return '/'; +#endif + #if defined (HAVE_LSTAT) && defined (S_ISLNK) r = lstat (filename, &finfo); #else @@ -581,7 +637,7 @@ fnwidth (string) width = pos = 0; while (string[pos]) { - if (CTRL_CHAR (*string) || *string == RUBOUT) + if (CTRL_CHAR (string[pos]) || string[pos] == RUBOUT) { width += 2; pos++; @@ -614,17 +670,20 @@ fnwidth (string) return width; } +#define ELLIPSIS_LEN 3 + static int -fnprint (to_print) +fnprint (to_print, prefix_bytes) const char *to_print; + int prefix_bytes; { - int printed_len; + int printed_len, w; const char *s; #if defined (HANDLE_MULTIBYTE) mbstate_t ps; const char *end; size_t tlen; - int width, w; + int width; wchar_t wc; end = to_print + strlen (to_print) + 1; @@ -632,7 +691,23 @@ fnprint (to_print) #endif printed_len = 0; - s = to_print; + + /* Don't print only the ellipsis if the common prefix is one of the + possible completions */ + if (to_print[prefix_bytes] == '\0') + prefix_bytes = 0; + + if (prefix_bytes) + { + char ellipsis; + + ellipsis = (to_print[prefix_bytes] == '.') ? '_' : '.'; + for (w = 0; w < ELLIPSIS_LEN; w++) + putc (ellipsis, rl_outstream); + printed_len = ELLIPSIS_LEN; + } + + s = to_print + prefix_bytes; while (*s) { if (CTRL_CHAR (*s)) @@ -691,14 +766,15 @@ fnprint (to_print) filenames. Return the number of characters we output. */ static int -print_filename (to_print, full_pathname) +print_filename (to_print, full_pathname, prefix_bytes) char *to_print, *full_pathname; + int prefix_bytes; { int printed_len, extension_char, slen, tlen; char *s, c, *new_full_pathname, *dn; extension_char = 0; - printed_len = fnprint (to_print); + printed_len = fnprint (to_print, prefix_bytes); #if defined (VISIBLE_STATS) if (rl_filename_completion_desired && (rl_visible_stats || _rl_complete_mark_directories)) @@ -960,7 +1036,10 @@ gen_completion_matches (text, start, end, our_func, found_quote, quote_char) variable rl_attempted_completion_function. */ if (rl_attempted_completion_function) { + _rl_interrupt_immediately++; matches = (*rl_attempted_completion_function) (text, start, end); + if (_rl_interrupt_immediately > 0) + _rl_interrupt_immediately--; if (matches || rl_attempted_completion_over) { @@ -992,7 +1071,7 @@ remove_duplicate_matches (matches) /* Sort the array without matches[0], since we need it to stay in place no matter what. */ - if (i) + if (i && rl_sort_completion_matches) qsort (matches+1, i-1, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare); /* Remember the lowest common denominator for it may be unique. */ @@ -1256,8 +1335,24 @@ rl_display_match_list (matches, len, max) int len, max; { int count, limit, printed_len, lines; - int i, j, k, l; - char *temp; + int i, j, k, l, common_length, sind; + char *temp, *t; + + /* Find the length of the prefix common to all items: length as displayed + characters (common_length) and as a byte index into the matches (sind) */ + common_length = sind = 0; + if (_rl_completion_prefix_display_length > 0) + { + t = printable_part (matches[0]); + temp = strrchr (t, '/'); + common_length = temp ? fnwidth (temp) : fnwidth (t); + sind = temp ? strlen (temp) : strlen (t); + + if (common_length > _rl_completion_prefix_display_length && common_length > ELLIPSIS_LEN) + max -= common_length - ELLIPSIS_LEN; + else + common_length = sind = 0; + } /* How many items of MAX length can we fit in the screen window? */ max += 2; @@ -1278,7 +1373,7 @@ rl_display_match_list (matches, len, max) 0 < len <= limit implies count = 1. */ /* Sort the items if they are not already sorted. */ - if (rl_ignore_completion_duplicates == 0) + if (rl_ignore_completion_duplicates == 0 && rl_sort_completion_matches) qsort (matches + 1, len, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare); rl_crlf (); @@ -1296,7 +1391,7 @@ rl_display_match_list (matches, len, max) else { temp = printable_part (matches[l]); - printed_len = print_filename (temp, matches[l]); + printed_len = print_filename (temp, matches[l], sind); if (j + 1 < limit) for (k = 0; k < max - printed_len; k++) @@ -1320,7 +1415,7 @@ rl_display_match_list (matches, len, max) for (i = 1; matches[i]; i++) { temp = printable_part (matches[i]); - printed_len = print_filename (temp, matches[i]); + printed_len = print_filename (temp, matches[i], sind); /* Have we reached the end of this line? */ if (matches[i+1]) { @@ -1370,7 +1465,7 @@ display_matches (matches) { temp = printable_part (matches[0]); rl_crlf (); - print_filename (temp, matches[0]); + print_filename (temp, matches[0], 0); rl_crlf (); rl_forced_update_display (); @@ -1406,7 +1501,7 @@ display_matches (matches) rl_crlf (); fprintf (rl_outstream, "Display all %d possibilities? (y or n)", len); fflush (rl_outstream); - if (get_y_or_n (0) == 0) + if ((completion_y_or_n = get_y_or_n (0)) == 0) { rl_crlf (); @@ -1474,8 +1569,9 @@ insert_match (match, start, mtype, qc) int start, mtype; char *qc; { - char *replacement; + char *replacement, *r; char oqc; + int end, rlen; oqc = qc ? *qc : '\0'; replacement = make_quoted_replacement (match, mtype, qc); @@ -1483,6 +1579,7 @@ insert_match (match, start, mtype, qc) /* Now insert the match. */ if (replacement) { + rlen = strlen (replacement); /* Don't double an opening quote character. */ if (qc && *qc && start && rl_line_buffer[start - 1] == *qc && replacement[0] == *qc) @@ -1492,7 +1589,24 @@ insert_match (match, start, mtype, qc) else if (qc && (*qc != oqc) && start && rl_line_buffer[start - 1] == oqc && replacement[0] != oqc) start--; - _rl_replace_text (replacement, start, rl_point - 1); + end = rl_point - 1; + /* Don't double a closing quote character */ + if (qc && *qc && end && rl_line_buffer[rl_point] == *qc && replacement[rlen - 1] == *qc) + end++; + if (_rl_skip_completed_text) + { + r = replacement; + while (start < rl_end && *r && rl_line_buffer[start] == *r) + { + start++; + r++; + } + if (start <= end || *r) + _rl_replace_text (r, start, end); + rl_point = start + strlen (r); + } + else + _rl_replace_text (replacement, start, end); if (replacement != match) free (replacement); } @@ -1678,6 +1792,7 @@ rl_complete_internal (what_to_do) FREE (saved_line_buffer); completion_changed_buffer = 0; RL_UNSETSTATE(RL_STATE_COMPLETING); + _rl_reset_completion_state (); return (0); } @@ -1692,6 +1807,7 @@ rl_complete_internal (what_to_do) FREE (saved_line_buffer); completion_changed_buffer = 0; RL_UNSETSTATE(RL_STATE_COMPLETING); + _rl_reset_completion_state (); return (0); } @@ -1742,10 +1858,11 @@ rl_complete_internal (what_to_do) break; default: - fprintf (stderr, "\r\nreadline: bad value %d for what_to_do in rl_complete\n", what_to_do); + _rl_ttymsg ("bad value %d for what_to_do in rl_complete", what_to_do); rl_ding (); FREE (saved_line_buffer); RL_UNSETSTATE(RL_STATE_COMPLETING); + _rl_reset_completion_state (); return 1; } @@ -1759,6 +1876,7 @@ rl_complete_internal (what_to_do) } RL_UNSETSTATE(RL_STATE_COMPLETING); + _rl_reset_completion_state (); return 0; } @@ -1802,6 +1920,7 @@ rl_completion_matches (text, entry_function) match_list = (char **)xmalloc ((match_list_size + 1) * sizeof (char *)); match_list[1] = (char *)NULL; + _rl_interrupt_immediately++; while (string = (*entry_function) (text, matches)) { if (matches + 1 == match_list_size) @@ -1811,6 +1930,8 @@ rl_completion_matches (text, entry_function) match_list[++matches] = string; match_list[matches + 1] = (char *)NULL; } + if (_rl_interrupt_immediately > 0) + _rl_interrupt_immediately--; /* If there were any matches, then look through them finding out the lowest common denominator. That then becomes match_list[0]. */ @@ -1898,8 +2019,8 @@ rl_filename_completion_function (text, state) static char *dirname = (char *)NULL; static char *users_dirname = (char *)NULL; static int filename_len; - char *temp; - int dirlen; + char *temp, *dentry, *convfn; + int dirlen, dentlen, convlen; struct dirent *entry; /* If we don't have any state, then do some initialization. */ @@ -2003,6 +2124,15 @@ rl_filename_completion_function (text, state) entry = (struct dirent *)NULL; while (directory && (entry = readdir (directory))) { + convfn = dentry = entry->d_name; + convlen = dentlen = D_NAMLEN (entry); + + if (rl_filename_rewrite_hook) + { + convfn = (*rl_filename_rewrite_hook) (dentry, dentlen); + convlen = (convfn == dentry) ? dentlen : strlen (convfn); + } + /* Special case for no filename. If the user has disabled the `match-hidden-files' variable, skip filenames beginning with `.'. All other entries except "." and ".." match. */ @@ -2011,9 +2141,8 @@ rl_filename_completion_function (text, state) if (_rl_match_hidden_files == 0 && HIDDEN_FILE (entry->d_name)) continue; - if (entry->d_name[0] != '.' || - (entry->d_name[1] && - (entry->d_name[1] != '.' || entry->d_name[2]))) + if (convfn[0] != '.' || + (convfn[1] && (convfn[1] != '.' || convfn[2]))) break; } else @@ -2022,16 +2151,16 @@ rl_filename_completion_function (text, state) it is a match. */ if (_rl_completion_case_fold) { - if ((_rl_to_lower (entry->d_name[0]) == _rl_to_lower (filename[0])) && - (((int)D_NAMLEN (entry)) >= filename_len) && - (_rl_strnicmp (filename, entry->d_name, filename_len) == 0)) + if ((_rl_to_lower (convfn[0]) == _rl_to_lower (filename[0])) && + (convlen >= filename_len) && + (_rl_strnicmp (filename, convfn, filename_len) == 0)) break; } else { - if ((entry->d_name[0] == filename[0]) && - (((int)D_NAMLEN (entry)) >= filename_len) && - (strncmp (filename, entry->d_name, filename_len) == 0)) + if ((convfn[0] == filename[0]) && + (convlen >= filename_len) && + (strncmp (filename, convfn, filename_len) == 0)) break; } } @@ -2093,22 +2222,145 @@ rl_filename_completion_function (text, state) strcpy (temp + dirlen, entry->d_name); } else - temp = savestring (entry->d_name); + temp = savestring (convfn); + + if (convfn != dentry) + free (convfn); return (temp); } } /* An initial implementation of a menu completion function a la tcsh. The - first time (if the last readline command was not rl_menu_complete), we + first time (if the last readline command was not rl_old_menu_complete), we generate the list of matches. This code is very similar to the code in rl_complete_internal -- there should be a way to combine the two. Then, for each item in the list of matches, we insert the match in an undoable fashion, with the appropriate character appended (this happens on the - second and subsequent consecutive calls to rl_menu_complete). When we + second and subsequent consecutive calls to rl_old_menu_complete). When we hit the end of the match list, we restore the original unmatched text, ring the bell, and reset the counter to zero. */ int +rl_old_menu_complete (count, invoking_key) + int count, invoking_key; +{ + rl_compentry_func_t *our_func; + int matching_filenames, found_quote; + + static char *orig_text; + static char **matches = (char **)0; + static int match_list_index = 0; + static int match_list_size = 0; + static int orig_start, orig_end; + static char quote_char; + static int delimiter; + + /* The first time through, we generate the list of matches and set things + up to insert them. */ + if (rl_last_func != rl_old_menu_complete) + { + /* Clean up from previous call, if any. */ + FREE (orig_text); + if (matches) + _rl_free_match_list (matches); + + match_list_index = match_list_size = 0; + matches = (char **)NULL; + + rl_completion_invoking_key = invoking_key; + + RL_SETSTATE(RL_STATE_COMPLETING); + + /* Only the completion entry function can change these. */ + set_completion_defaults ('%'); + + our_func = rl_menu_completion_entry_function; + if (our_func == 0) + our_func = rl_completion_entry_function + ? rl_completion_entry_function + : rl_filename_completion_function; + + /* We now look backwards for the start of a filename/variable word. */ + orig_end = rl_point; + found_quote = delimiter = 0; + quote_char = '\0'; + + if (rl_point) + /* This (possibly) changes rl_point. If it returns a non-zero char, + we know we have an open quote. */ + quote_char = _rl_find_completion_word (&found_quote, &delimiter); + + orig_start = rl_point; + rl_point = orig_end; + + orig_text = rl_copy_text (orig_start, orig_end); + matches = gen_completion_matches (orig_text, orig_start, orig_end, + our_func, found_quote, quote_char); + + /* If we are matching filenames, the attempted completion function will + have set rl_filename_completion_desired to a non-zero value. The basic + rl_filename_completion_function does this. */ + matching_filenames = rl_filename_completion_desired; + + if (matches == 0 || postprocess_matches (&matches, matching_filenames) == 0) + { + rl_ding (); + FREE (matches); + matches = (char **)0; + FREE (orig_text); + orig_text = (char *)0; + completion_changed_buffer = 0; + RL_UNSETSTATE(RL_STATE_COMPLETING); + return (0); + } + + RL_UNSETSTATE(RL_STATE_COMPLETING); + + for (match_list_size = 0; matches[match_list_size]; match_list_size++) + ; + /* matches[0] is lcd if match_list_size > 1, but the circular buffer + code below should take care of it. */ + + if (match_list_size > 1 && _rl_complete_show_all) + display_matches (matches); + } + + /* Now we have the list of matches. Replace the text between + rl_line_buffer[orig_start] and rl_line_buffer[rl_point] with + matches[match_list_index], and add any necessary closing char. */ + + if (matches == 0 || match_list_size == 0) + { + rl_ding (); + FREE (matches); + matches = (char **)0; + completion_changed_buffer = 0; + return (0); + } + + match_list_index += count; + if (match_list_index < 0) + match_list_index += match_list_size; + else + match_list_index %= match_list_size; + + if (match_list_index == 0 && match_list_size > 1) + { + rl_ding (); + insert_match (orig_text, orig_start, MULT_MATCH, "e_char); + } + else + { + insert_match (matches[match_list_index], orig_start, SINGLE_MATCH, "e_char); + append_to_match (matches[match_list_index], delimiter, quote_char, + strcmp (orig_text, matches[match_list_index])); + } + + completion_changed_buffer = 1; + return (0); +} + +int rl_menu_complete (count, ignore) int count, ignore; { @@ -2119,13 +2371,15 @@ rl_menu_complete (count, ignore) static char **matches = (char **)0; static int match_list_index = 0; static int match_list_size = 0; + static int nontrivial_lcd = 0; + static int full_completion = 0; /* set to 1 if menu completion should reinitialize on next call */ static int orig_start, orig_end; static char quote_char; static int delimiter; /* The first time through, we generate the list of matches and set things up to insert them. */ - if (rl_last_func != rl_menu_complete) + if ((rl_last_func != rl_menu_complete && rl_last_func != rl_backward_menu_complete) || full_completion) { /* Clean up from previous call, if any. */ FREE (orig_text); @@ -2135,10 +2389,16 @@ rl_menu_complete (count, ignore) match_list_index = match_list_size = 0; matches = (char **)NULL; + full_completion = 0; + + RL_SETSTATE(RL_STATE_COMPLETING); + /* Only the completion entry function can change these. */ set_completion_defaults ('%'); - our_func = rl_completion_entry_function + our_func = rl_menu_completion_entry_function; + if (our_func == 0) + our_func = rl_completion_entry_function ? rl_completion_entry_function : rl_filename_completion_function; @@ -2159,6 +2419,8 @@ rl_menu_complete (count, ignore) matches = gen_completion_matches (orig_text, orig_start, orig_end, our_func, found_quote, quote_char); + nontrivial_lcd = matches && strcmp (orig_text, matches[0]) != 0; + /* If we are matching filenames, the attempted completion function will have set rl_filename_completion_desired to a non-zero value. The basic rl_filename_completion_function does this. */ @@ -2172,13 +2434,55 @@ rl_menu_complete (count, ignore) FREE (orig_text); orig_text = (char *)0; completion_changed_buffer = 0; + RL_UNSETSTATE(RL_STATE_COMPLETING); return (0); } + RL_UNSETSTATE(RL_STATE_COMPLETING); + for (match_list_size = 0; matches[match_list_size]; match_list_size++) ; + + if (match_list_size == 0) + { + rl_ding (); + FREE (matches); + matches = (char **)0; + match_list_index = 0; + completion_changed_buffer = 0; + return (0); + } + /* matches[0] is lcd if match_list_size > 1, but the circular buffer code below should take care of it. */ + if (*matches[0]) + { + insert_match (matches[0], orig_start, matches[1] ? MULT_MATCH : SINGLE_MATCH, "e_char); + orig_end = orig_start + strlen (matches[0]); + completion_changed_buffer = STREQ (orig_text, matches[0]) == 0; + } + + if (match_list_size > 1 && _rl_complete_show_all) + { + display_matches (matches); + /* If there are so many matches that the user has to be asked + whether or not he wants to see the matches, menu completion + is unwieldy. */ + if (rl_completion_query_items > 0 && match_list_size >= rl_completion_query_items) + { + rl_ding (); + FREE (matches); + matches = (char **)0; + full_completion = 1; + return (0); + } + } + else if (match_list_size <= 1) + { + append_to_match (matches[0], delimiter, quote_char, nontrivial_lcd); + full_completion = 1; + return (0); + } } /* Now we have the list of matches. Replace the text between @@ -2203,7 +2507,7 @@ rl_menu_complete (count, ignore) if (match_list_index == 0 && match_list_size > 1) { rl_ding (); - insert_match (orig_text, orig_start, MULT_MATCH, "e_char); + insert_match (matches[0], orig_start, MULT_MATCH, "e_char); } else { @@ -2215,3 +2519,12 @@ rl_menu_complete (count, ignore) completion_changed_buffer = 1; return (0); } + +int +rl_backward_menu_complete (count, key) + int count, key; +{ + /* Positive arguments to backward-menu-complete translate into negative + arguments for menu-complete, and vice versa. */ + return (rl_menu_complete (-count, key)); +} diff --git a/lib/readline/display.c b/lib/readline/display.c index 47ff061..e4105ee 100644 --- a/lib/readline/display.c +++ b/lib/readline/display.c @@ -1,24 +1,24 @@ /* display.c -- readline redisplay facility. */ -/* Copyright (C) 1987-2006 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) @@ -65,15 +65,39 @@ static void delete_chars PARAMS((int)); static void insert_some_chars PARAMS((char *, int, int)); static void cr PARAMS((void)); +/* State of visible and invisible lines. */ +struct line_state + { + char *line; + int *lbreaks; + int lbsize; #if defined (HANDLE_MULTIBYTE) -static int _rl_col_width PARAMS((const char *, int, int)); -static int *_rl_wrapped_line; -#else -# define _rl_col_width(l, s, e) (((e) <= (s)) ? 0 : (e) - (s)) + int *wrapped_line; + int wbsize; #endif + }; + +/* The line display buffers. One is the line currently displayed on + the screen. The other is the line about to be displayed. */ +static struct line_state line_state_array[2]; +static struct line_state *line_state_visible = &line_state_array[0]; +static struct line_state *line_state_invisible = &line_state_array[1]; +static int line_structures_initialized = 0; -static int *inv_lbreaks, *vis_lbreaks; -static int inv_lbsize, vis_lbsize; +/* Backwards-compatible names. */ +#define inv_lbreaks (line_state_invisible->lbreaks) +#define inv_lbsize (line_state_invisible->lbsize) +#define vis_lbreaks (line_state_visible->lbreaks) +#define vis_lbsize (line_state_visible->lbsize) + +#define visible_line (line_state_visible->line) +#define invisible_line (line_state_invisible->line) + +#if defined (HANDLE_MULTIBYTE) +static int _rl_col_width PARAMS((const char *, int, int, int)); +#else +# define _rl_col_width(l, s, e, f) (((e) <= (s)) ? 0 : (e) - (s)) +#endif /* Heuristic used to decide whether it is faster to move from CUR to NEW by backing up or outputting a carriage return and moving forward. CUR @@ -83,7 +107,7 @@ static int inv_lbsize, vis_lbsize; /* _rl_last_c_pos is an absolute cursor position in multibyte locales and a buffer index in others. This macro is used when deciding whether the current cursor position is in the middle of a prompt string containing - invisible characters. */ + invisible characters. XXX - might need to take `modmark' into account. */ #define PROMPT_ENDING_INDEX \ ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) ? prompt_physical_chars : prompt_last_invisible+1) @@ -141,6 +165,7 @@ int _rl_last_v_pos = 0; static int cpos_adjusted; static int cpos_buffer_position; +static int prompt_multibyte_chars; /* Number of lines currently on screen minus 1. */ int _rl_vis_botlin = 0; @@ -150,11 +175,6 @@ int _rl_vis_botlin = 0; doing horizontal scrolling. It shifts in thirds of a screenwidth. */ static int last_lmargin; -/* The line display buffers. One is the line currently displayed on - the screen. The other is the line about to be displayed. */ -static char *visible_line = (char *)NULL; -static char *invisible_line = (char *)NULL; - /* A buffer for `modeline' messages. */ static char msg_buf[128]; @@ -195,6 +215,10 @@ static int prompt_last_screen_line; static int prompt_physical_chars; +/* set to a non-zero value by rl_redisplay if we are marking modified history + lines and the current line is so marked. */ +static int modmark; + /* Variables to save and restore prompt and display information. */ /* These are getting numerous enough that it's time to create a struct. */ @@ -282,8 +306,13 @@ expand_prompt (pmt, lp, lip, niflp, vlp) *r++ = *p++; if (!ignoring) { + /* rl ends up being assigned to prompt_visible_length, + which is the number of characters in the buffer that + contribute to characters on the screen, which might + not be the same as the number of physical characters + on the screen in the presence of multibyte characters */ rl += ind - pind; - physchars += _rl_col_width (pmt, pind, ind); + physchars += _rl_col_width (pmt, pind, ind, 0); } else ninvis += ind - pind; @@ -391,14 +420,14 @@ rl_expand_prompt (prompt) t = ++p; local_prompt = expand_prompt (p, &prompt_visible_length, &prompt_last_invisible, - (int *)NULL, + &prompt_invis_chars_first_line, &prompt_physical_chars); c = *t; *t = '\0'; /* The portion of the prompt string up to and including the final newline is now null-terminated. */ local_prompt_prefix = expand_prompt (prompt, &prompt_prefix_length, (int *)NULL, - &prompt_invis_chars_first_line, + (int *)NULL, (int *)NULL); *t = c; local_prompt_len = local_prompt ? strlen (local_prompt) : 0; @@ -443,13 +472,21 @@ init_line_structures (minsize) { /* should be enough. */ inv_lbsize = vis_lbsize = 256; - inv_lbreaks = (int *)xmalloc (inv_lbsize * sizeof (int)); - vis_lbreaks = (int *)xmalloc (vis_lbsize * sizeof (int)); + #if defined (HANDLE_MULTIBYTE) - _rl_wrapped_line = (int *)xmalloc (vis_lbsize * sizeof (int)); + line_state_visible->wbsize = vis_lbsize; + line_state_visible->wrapped_line = (int *)xmalloc (line_state_visible->wbsize * sizeof (int)); + + line_state_invisible->wbsize = inv_lbsize; + line_state_invisible->wrapped_line = (int *)xmalloc (line_state_invisible->wbsize * sizeof (int)); #endif + + inv_lbreaks = (int *)xmalloc (inv_lbsize * sizeof (int)); + vis_lbreaks = (int *)xmalloc (vis_lbsize * sizeof (int)); inv_lbreaks[0] = vis_lbreaks[0] = 0; } + + line_structures_initialized = 1; } /* Basic redisplay algorithm. */ @@ -459,7 +496,7 @@ rl_redisplay () register int in, out, c, linenum, cursor_linenum; register char *line; int inv_botlin, lb_botlin, lb_linenum, o_cpos; - int newlines, lpos, temp, modmark, n0, num; + int newlines, lpos, temp, n0, num, prompt_lines_estimate; char *prompt_this_line; #if defined (HANDLE_MULTIBYTE) wchar_t wc; @@ -469,13 +506,18 @@ rl_redisplay () int _rl_wrapped_multicolumn = 0; #endif - if (!readline_echoing_p) + if (_rl_echoing_p == 0) return; + /* Block keyboard interrupts because this function manipulates global + data structures. */ + _rl_block_sigint (); + RL_SETSTATE (RL_STATE_REDISPLAYING); + if (!rl_display_prompt) rl_display_prompt = ""; - if (invisible_line == 0 || vis_lbreaks == 0) + if (line_structures_initialized == 0) { init_line_structures (0); rl_on_new_line (); @@ -484,6 +526,8 @@ rl_redisplay () /* Draw the line into the buffer. */ cpos_buffer_position = -1; + prompt_multibyte_chars = prompt_visible_length - prompt_physical_chars; + line = invisible_line; out = inv_botlin = 0; @@ -580,10 +624,14 @@ rl_redisplay () { \ inv_lbsize *= 2; \ inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \ - _rl_wrapped_line = (int *)xrealloc (_rl_wrapped_line, inv_lbsize * sizeof (int)); \ } \ inv_lbreaks[++newlines] = out; \ - _rl_wrapped_line[newlines] = _rl_wrapped_multicolumn; \ + if (newlines >= (line_state_invisible->wbsize - 1)) \ + { \ + line_state_invisible->wbsize *= 2; \ + line_state_invisible->wrapped_line = (int *)xrealloc (line_state_invisible->wrapped_line, line_state_invisible->wbsize * sizeof(int)); \ + } \ + line_state_invisible->wrapped_line[newlines] = _rl_wrapped_multicolumn; \ lpos = 0; \ } \ } while (0) @@ -606,21 +654,20 @@ rl_redisplay () /* inv_lbreaks[i] is where line i starts in the buffer. */ inv_lbreaks[newlines = 0] = 0; -#if 0 - lpos = out - wrap_offset; -#else lpos = prompt_physical_chars + modmark; -#endif #if defined (HANDLE_MULTIBYTE) - memset (_rl_wrapped_line, 0, vis_lbsize); + memset (line_state_invisible->wrapped_line, 0, line_state_invisible->wbsize * sizeof (int)); num = 0; #endif /* prompt_invis_chars_first_line is the number of invisible characters in the first physical line of the prompt. wrap_offset - prompt_invis_chars_first_line is the number of invis - chars on the second line. */ + chars on the second (or, more generally, last) line. */ + + /* This is zero-based, used to set the newlines */ + prompt_lines_estimate = lpos / _rl_screenwidth; /* what if lpos is already >= _rl_screenwidth before we start drawing the contents of the command line? */ @@ -635,13 +682,13 @@ rl_redisplay () prompts that exceed two physical lines? Additional logic fix from Edward Catmur <ed@catmur.co.uk> */ #if defined (HANDLE_MULTIBYTE) - if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0) { n0 = num; temp = local_prompt_len; while (num < temp) { - z = _rl_col_width (local_prompt, n0, num); + z = _rl_col_width (local_prompt, n0, num, 1); if (z > _rl_screenwidth) { num = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY); @@ -658,14 +705,16 @@ rl_redisplay () temp = ((newlines + 1) * _rl_screenwidth); /* Now account for invisible characters in the current line. */ + /* XXX - this assumes that the invisible characters may be split, but only + between the first and the last lines. */ temp += ((local_prompt_prefix == 0) ? ((newlines == 0) ? prompt_invis_chars_first_line - : ((newlines == 1) ? wrap_offset : 0)) - : ((newlines == 0) ? wrap_offset :0)); + : ((newlines == prompt_lines_estimate) ? wrap_offset : prompt_invis_chars_first_line)) + : ((newlines == 0) ? wrap_offset : 0)); inv_lbreaks[++newlines] = temp; #if defined (HANDLE_MULTIBYTE) - if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) - lpos -= _rl_col_width (local_prompt, n0, num); + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0) + lpos -= _rl_col_width (local_prompt, n0, num, 1); else #endif lpos -= _rl_screenwidth; @@ -684,6 +733,7 @@ rl_redisplay () if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) { memset (&ps, 0, sizeof (mbstate_t)); + /* XXX - what if wc_bytes ends up <= 0? check for MB_INVALIDCH */ wc_bytes = mbrtowc (&wc, rl_line_buffer, rl_end, &ps); } else @@ -844,6 +894,7 @@ rl_redisplay () if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) { in += wc_bytes; + /* XXX - what if wc_bytes ends up <= 0? check for MB_INVALIDCH */ wc_bytes = mbrtowc (&wc, rl_line_buffer + in, rl_end - in, &ps); } else @@ -898,6 +949,10 @@ rl_redisplay () second and subsequent lines start at inv_lbreaks[N], offset by OFFSET (which has already been calculated above). */ +#define INVIS_FIRST() (prompt_physical_chars > _rl_screenwidth ? prompt_invis_chars_first_line : wrap_offset) +#define WRAP_OFFSET(line, offset) ((line == 0) \ + ? (offset ? INVIS_FIRST() : 0) \ + : ((line == prompt_last_screen_line) ? wrap_offset-prompt_invis_chars_first_line : 0)) #define W_OFFSET(line, offset) ((line) == 0 ? offset : 0) #define VIS_LLEN(l) ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l])) #define INV_LLEN(l) (inv_lbreaks[l+1] - inv_lbreaks[l]) @@ -905,6 +960,11 @@ rl_redisplay () #define VIS_LINE(line) ((line) > _rl_vis_botlin) ? "" : VIS_CHARS(line) #define INV_LINE(line) (invisible_line + inv_lbreaks[line]) +#define OLD_CPOS_IN_PROMPT() (cpos_adjusted == 0 && \ + _rl_last_c_pos != o_cpos && \ + _rl_last_c_pos > wrap_offset && \ + o_cpos < prompt_last_invisible) + /* For each line in the buffer, do the updating display. */ for (linenum = 0; linenum <= inv_botlin; linenum++) { @@ -919,7 +979,7 @@ rl_redisplay () take invisible characters into account, since _rl_last_c_pos is an absolute cursor position in a multibyte locale. See if compensating here is the right thing, or if we have to - change update_line itself. There is one case in which + change update_line itself. There are several cases in which update_line adjusts _rl_last_c_pos itself (so it can pass _rl_move_cursor_relative accurate values); it communicates this back by setting cpos_adjusted. If we assume that @@ -927,12 +987,14 @@ rl_redisplay () time update_line is called, then we can assume in our calculations that o_cpos does not need to be adjusted by wrap_offset. */ - if (linenum == 0 && (MB_CUR_MAX > 1 && rl_byte_oriented == 0) && - cpos_adjusted == 0 && - _rl_last_c_pos != o_cpos && - _rl_last_c_pos > wrap_offset && - o_cpos < prompt_last_invisible) - _rl_last_c_pos -= wrap_offset; + if (linenum == 0 && (MB_CUR_MAX > 1 && rl_byte_oriented == 0) && OLD_CPOS_IN_PROMPT()) + _rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */ + else if (linenum == prompt_last_screen_line && prompt_physical_chars > _rl_screenwidth && + (MB_CUR_MAX > 1 && rl_byte_oriented == 0) && + cpos_adjusted == 0 && + _rl_last_c_pos != o_cpos && + _rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - prompt_invis_chars_first_line)) + _rl_last_c_pos -= (wrap_offset-prompt_invis_chars_first_line); /* If this is the line with the prompt, we might need to compensate for invisible characters in the new line. Do @@ -952,6 +1014,19 @@ rl_redisplay () if (nleft) _rl_clear_to_eol (nleft); } +#if 0 + /* This segment is intended to handle the case where the prompt + has invisible characters on the second line and the new line + to be displayed needs to clear the rest of the old characters + out (e.g., when printing the i-search prompt). In general, + the case of the new line being shorter than the old. + Incomplete */ + else if (linenum == prompt_last_screen_line && + prompt_physical_chars > _rl_screenwidth && + wrap_offset != prompt_invis_chars_first_line && + _rl_last_c_pos == out && +#endif + /* Since the new first line is now visible, save its length. */ if (linenum == 0) @@ -1007,11 +1082,14 @@ rl_redisplay () if (_rl_term_cr) tputs (_rl_term_cr, 1, _rl_output_character_function); #endif + if (modmark) + _rl_output_some_chars ("*", 1); + _rl_output_some_chars (local_prompt, nleft); if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) - _rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft) - wrap_offset; + _rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft, 1) - wrap_offset + modmark; else - _rl_last_c_pos = nleft; + _rl_last_c_pos = nleft + modmark; } /* Where on that line? And where does that line start @@ -1033,10 +1111,10 @@ rl_redisplay () { /* TX == new physical cursor position in multibyte locale. */ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) - tx = _rl_col_width (&visible_line[pos], 0, nleft) - visible_wrap_offset; + tx = _rl_col_width (&visible_line[pos], 0, nleft, 1) - visible_wrap_offset; else tx = nleft; - if (_rl_last_c_pos > tx) + if (tx >= 0 && _rl_last_c_pos > tx) { _rl_backspace (_rl_last_c_pos - tx); /* XXX */ _rl_last_c_pos = tx; @@ -1114,9 +1192,11 @@ rl_redisplay () if (t < out) line[t - 1] = '>'; - if (!rl_display_fixed || forced_display || lmargin != last_lmargin) + if (rl_display_fixed == 0 || forced_display || lmargin != last_lmargin) { forced_display = 0; + o_cpos = _rl_last_c_pos; + cpos_adjusted = 0; update_line (&visible_line[last_lmargin], &invisible_line[lmargin], 0, @@ -1124,6 +1204,9 @@ rl_redisplay () _rl_screenwidth + (lmargin ? 0 : wrap_offset), 0); + if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && OLD_CPOS_IN_PROMPT()) + _rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */ + /* If the visible new line is shorter than the old, but the number of invisible characters is greater, and we are at the end of the new line, we need to clear to eol. */ @@ -1147,17 +1230,10 @@ rl_redisplay () /* Swap visible and non-visible lines. */ { - char *vtemp = visible_line; - int *itemp = vis_lbreaks, ntemp = vis_lbsize; - - visible_line = invisible_line; - invisible_line = vtemp; - - vis_lbreaks = inv_lbreaks; - inv_lbreaks = itemp; + struct line_state *vtemp = line_state_visible; - vis_lbsize = inv_lbsize; - inv_lbsize = ntemp; + line_state_visible = line_state_invisible; + line_state_invisible = vtemp; rl_display_fixed = 0; /* If we are displaying on a single line, and last_lmargin is > 0, we @@ -1168,6 +1244,9 @@ rl_redisplay () else visible_wrap_offset = wrap_offset; } + + RL_UNSETSTATE (RL_STATE_REDISPLAYING); + _rl_release_sigint (); } /* PWP: update_line() is based on finding the middle difference of each @@ -1192,7 +1271,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) int current_line, omax, nmax, inv_botlin; { register char *ofd, *ols, *oe, *nfd, *nls, *ne; - int temp, lendiff, wsatend, od, nd; + int temp, lendiff, wsatend, od, nd, twidth, o_cpos; int current_invis_chars; int col_lendiff, col_temp; #if defined (HANDLE_MULTIBYTE) @@ -1208,7 +1287,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) temp = _rl_last_c_pos; else - temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset); + temp = _rl_last_c_pos - WRAP_OFFSET (_rl_last_v_pos, visible_wrap_offset); if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode && _rl_last_v_pos == current_line - 1) { @@ -1223,8 +1302,8 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) /* This fixes only double-column characters, but if the wrapped character comsumes more than three columns, spaces will be inserted in the string buffer. */ - if (_rl_wrapped_line[current_line] > 0) - _rl_clear_to_eol (_rl_wrapped_line[current_line]); + if (current_line < line_state_visible->wbsize && line_state_visible->wrapped_line[current_line] > 0) + _rl_clear_to_eol (line_state_visible->wrapped_line[current_line]); memset (&ps, 0, sizeof (mbstate_t)); ret = mbrtowc (&wc, new, MB_CUR_MAX, &ps); @@ -1240,7 +1319,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) if (tempwidth > 0) { - int count; + int count, i; bytes = ret; for (count = 0; count < bytes; count++) putc (new[count], rl_outstream); @@ -1251,10 +1330,13 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) if (ret != 0 && bytes != 0) { if (MB_INVALIDCH (ret)) - memmove (old+bytes, old+1, strlen (old+1)); - else - memmove (old+bytes, old+ret, strlen (old+ret)); + ret = 1; + memmove (old+bytes, old+ret, strlen (old+ret)); memcpy (old, new, bytes); + /* Fix up indices if we copy data from one line to another */ + omax += bytes - ret; + for (i = current_line+1; i < inv_botlin+1; i++) + vis_lbreaks[i] += bytes - ret; } } else @@ -1288,7 +1370,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) /* See if the old line is a subset of the new line, so that the only change is adding characters. */ temp = (omax < nmax) ? omax : nmax; - if (memcmp (old, new, temp) == 0) + if (memcmp (old, new, temp) == 0) /* adding at the end */ { ofd = old + temp; nfd = new + temp; @@ -1441,18 +1523,22 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) #else tputs (_rl_term_cr, 1, _rl_output_character_function); #endif + if (modmark) + _rl_output_some_chars ("*", 1); _rl_output_some_chars (local_prompt, lendiff); if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) { /* We take wrap_offset into account here so we can pass correct information to _rl_move_cursor_relative. */ - _rl_last_c_pos = _rl_col_width (local_prompt, 0, lendiff) - wrap_offset; + _rl_last_c_pos = _rl_col_width (local_prompt, 0, lendiff, 1) - wrap_offset + modmark; cpos_adjusted = 1; } else - _rl_last_c_pos = lendiff; + _rl_last_c_pos = lendiff + modmark; } + o_cpos = _rl_last_c_pos; + /* When this function returns, _rl_last_c_pos is correct, and an absolute cursor postion in multibyte mode, but a buffer index when not in a multibyte locale. */ @@ -1462,7 +1548,9 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) /* We need to indicate that the cursor position is correct in the presence of invisible characters in the prompt string. Let's see if setting this when we make sure we're at the end of the drawn prompt string works. */ - if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 && _rl_last_c_pos == prompt_physical_chars) + if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 && + (_rl_last_c_pos > 0 || o_cpos > 0) && + _rl_last_c_pos == prompt_physical_chars) cpos_adjusted = 1; #endif #endif @@ -1473,7 +1561,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) When not using multibyte characters, these are equal */ lendiff = (nls - nfd) - (ols - ofd); if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) - col_lendiff = _rl_col_width (new, nfd - new, nls - new) - _rl_col_width (old, ofd - old, ols - old); + col_lendiff = _rl_col_width (new, nfd - new, nls - new, 1) - _rl_col_width (old, ofd - old, ols - old, 1); else col_lendiff = lendiff; @@ -1498,7 +1586,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) /* Insert (diff (len (old), len (new)) ch. */ temp = ne - nfd; if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) - col_temp = _rl_col_width (new, nfd - new, ne - new); + col_temp = _rl_col_width (new, nfd - new, ne - new, 1); else col_temp = temp; @@ -1506,22 +1594,60 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) { /* Non-zero if we're increasing the number of lines. */ int gl = current_line >= _rl_vis_botlin && inv_botlin > _rl_vis_botlin; + /* If col_lendiff is > 0, implying that the new string takes up more + screen real estate than the old, but lendiff is < 0, meaning that it + takes fewer bytes, we need to just output the characters starting + from the first difference. These will overwrite what is on the + display, so there's no reason to do a smart update. This can really + only happen in a multibyte environment. */ + if (lendiff < 0) + { + _rl_output_some_chars (nfd, temp); + _rl_last_c_pos += _rl_col_width (nfd, 0, temp, 1); + /* If nfd begins before any invisible characters in the prompt, + adjust _rl_last_c_pos to account for wrap_offset and set + cpos_adjusted to let the caller know. */ + if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible)) + { + _rl_last_c_pos -= wrap_offset; + cpos_adjusted = 1; + } + return; + } /* Sometimes it is cheaper to print the characters rather than use the terminal's capabilities. If we're growing the number of lines, make sure we actually cause the new line to wrap around on auto-wrapping terminals. */ - if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl)) + else if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl)) { /* If lendiff > prompt_visible_length and _rl_last_c_pos == 0 and _rl_horizontal_scroll_mode == 1, inserting the characters with _rl_term_IC or _rl_term_ic will screw up the screen because of the invisible characters. We need to just draw them. */ - if (*ols && (!_rl_horizontal_scroll_mode || _rl_last_c_pos > 0 || - lendiff <= prompt_visible_length || !current_invis_chars)) + /* The same thing happens if we're trying to draw before the last + invisible character in the prompt string or we're increasing the + number of invisible characters in the line and we're not drawing + the entire prompt string. */ + if (*ols && ((_rl_horizontal_scroll_mode && + _rl_last_c_pos == 0 && + lendiff > prompt_visible_length && + current_invis_chars > 0) == 0) && + (((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && + current_line == 0 && wrap_offset && + ((nfd - new) <= prompt_last_invisible) && + (col_lendiff < prompt_visible_length)) == 0) && + (visible_wrap_offset >= current_invis_chars)) { insert_some_chars (nfd, lendiff, col_lendiff); _rl_last_c_pos += col_lendiff; } +#if 0 /* XXX - for now */ + else if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && _rl_last_c_pos == 0 && wrap_offset && (nfd-new) <= prompt_last_invisible && col_lendiff < prompt_visible_length && visible_wrap_offset >= current_invis_chars) + { + _rl_output_some_chars (nfd, lendiff); + _rl_last_c_pos += col_lendiff; + } +#endif else if ((MB_CUR_MAX == 1 || rl_byte_oriented != 0) && *ols == 0 && lendiff > 0) { /* At the end of a line the characters do not have to @@ -1533,11 +1659,16 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) } else { - /* We have horizontal scrolling and we are not inserting at - the end. We have invisible characters in this line. This - is a dumb update. */ _rl_output_some_chars (nfd, temp); _rl_last_c_pos += col_temp; + /* If nfd begins before the last invisible character in the + prompt, adjust _rl_last_c_pos to account for wrap_offset + and set cpos_adjusted to let the caller know. */ + if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible)) + { + _rl_last_c_pos -= wrap_offset; + cpos_adjusted = 1; + } return; } /* Copy (new) chars to screen from first diff to last match. */ @@ -1545,15 +1676,23 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) if ((temp - lendiff) > 0) { _rl_output_some_chars (nfd + lendiff, temp - lendiff); -#if 1 /* XXX -- this bears closer inspection. Fixes a redisplay bug reported against bash-3.0-alpha by Andreas Schwab involving multibyte characters and prompt strings with invisible characters, but was previously disabled. */ - _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-col_lendiff); -#else - _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-lendiff); -#endif + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + twidth = _rl_col_width (nfd+lendiff, 0, temp-col_lendiff, 1); + else + twidth = temp - lendiff; + _rl_last_c_pos += twidth; + /* If nfd begins before the last invisible character in the + prompt, adjust _rl_last_c_pos to account for wrap_offset + and set cpos_adjusted to let the caller know. */ + if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible)) + { + _rl_last_c_pos -= wrap_offset; + cpos_adjusted = 1; + } } } else @@ -1565,6 +1704,14 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) char in the current line (which implies we just output some invisible characters) we need to adjust _rl_last_c_pos, since it represents a physical character position. */ + if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && + current_line == prompt_last_screen_line && wrap_offset && + wrap_offset != prompt_invis_chars_first_line && + ((nfd-new) < (prompt_last_invisible-(current_line*_rl_screenwidth)))) + { + _rl_last_c_pos -= wrap_offset - prompt_invis_chars_first_line; + cpos_adjusted = 1; + } } } else /* Delete characters from line. */ @@ -1586,8 +1733,22 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) temp = nls - nfd; if (temp > 0) { + /* If nfd begins at the prompt, or before the invisible + characters in the prompt, we need to adjust _rl_last_c_pos + in a multibyte locale to account for the wrap offset and + set cpos_adjusted accordingly. */ _rl_output_some_chars (nfd, temp); - _rl_last_c_pos += _rl_col_width (nfd, 0, temp);; + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + _rl_last_c_pos += _rl_col_width (nfd, 0, temp, 1); + if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible)) + { + _rl_last_c_pos -= wrap_offset; + cpos_adjusted = 1; + } + } + else + _rl_last_c_pos += temp; } } /* Otherwise, print over the existing material. */ @@ -1595,16 +1756,37 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) { if (temp > 0) { + /* If nfd begins at the prompt, or before the invisible + characters in the prompt, we need to adjust _rl_last_c_pos + in a multibyte locale to account for the wrap offset and + set cpos_adjusted accordingly. */ _rl_output_some_chars (nfd, temp); _rl_last_c_pos += col_temp; /* XXX */ + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible)) + { + _rl_last_c_pos -= wrap_offset; + cpos_adjusted = 1; + } + } } lendiff = (oe - old) - (ne - new); if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) - col_lendiff = _rl_col_width (old, 0, oe - old) - _rl_col_width (new, 0, ne - new); + col_lendiff = _rl_col_width (old, 0, oe - old, 1) - _rl_col_width (new, 0, ne - new, 1); else col_lendiff = lendiff; +#if 0 if (col_lendiff) +#else + /* If we've already printed over the entire width of the screen, + including the old material, then col_lendiff doesn't matter and + space_to_eol will insert too many spaces. XXX - maybe we should + adjust col_lendiff based on the difference between _rl_last_c_pos + and _rl_screenwidth */ + if (col_lendiff && ((MB_CUR_MAX == 1 || rl_byte_oriented) || (_rl_last_c_pos < _rl_screenwidth))) +#endif { if (_rl_term_autowrap && current_line < inv_botlin) space_to_eol (col_lendiff); @@ -1658,7 +1840,7 @@ rl_on_new_line_with_prompt () l = strlen (prompt_last_line); if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) - _rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l); /* XXX */ + _rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l, 1); /* XXX */ else _rl_last_c_pos = l; @@ -1720,9 +1902,14 @@ _rl_move_cursor_relative (new, data) register int i; int woff; /* number of invisible chars on current line */ int cpos, dpos; /* current and desired cursor positions */ + int adjust; - woff = W_OFFSET (_rl_last_v_pos, wrap_offset); + woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset); cpos = _rl_last_c_pos; + + if (cpos == 0 && cpos == new) + return; + #if defined (HANDLE_MULTIBYTE) /* If we have multibyte characters, NEW is indexed by the buffer point in a multibyte string, but _rl_last_c_pos is the display position. In @@ -1731,8 +1918,35 @@ _rl_move_cursor_relative (new, data) as long as we are past them and they are counted by _rl_col_width. */ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) { - dpos = _rl_col_width (data, 0, new); - if (dpos > prompt_last_invisible) /* XXX - don't use woff here */ + adjust = 1; + /* Try to short-circuit common cases and eliminate a bunch of multibyte + character function calls. */ + /* 1. prompt string */ + if (new == local_prompt_len && memcmp (data, local_prompt, new) == 0) + { + dpos = prompt_physical_chars; + cpos_adjusted = 1; + adjust = 0; + } + /* 2. prompt_string + line contents */ + else if (new > local_prompt_len && local_prompt && memcmp (data, local_prompt, local_prompt_len) == 0) + { + dpos = prompt_physical_chars + _rl_col_width (data, local_prompt_len, new, 1); + cpos_adjusted = 1; + adjust = 0; + } + else + dpos = _rl_col_width (data, 0, new, 1); + + /* Use NEW when comparing against the last invisible character in the + prompt string, since they're both buffer indices and DPOS is a + desired display position. */ + if (adjust && ((new > prompt_last_invisible) || /* XXX - don't use woff here */ + (prompt_physical_chars >= _rl_screenwidth && + _rl_last_v_pos == prompt_last_screen_line && + wrap_offset >= woff && dpos >= woff && + new > (prompt_last_invisible-(_rl_screenwidth*_rl_last_v_pos)-wrap_offset)))) + /* XXX last comparison might need to be >= */ { dpos -= woff; /* Since this will be assigned to _rl_last_c_pos at the end (more @@ -2145,7 +2359,7 @@ insert_some_chars (string, count, col) /* DEBUGGING */ if (MB_CUR_MAX == 1 || rl_byte_oriented) if (count != col) - fprintf(stderr, "readline: debug: insert_some_chars: count (%d) != col (%d)\n", count, col); + _rl_ttymsg ("debug: insert_some_chars: count (%d) != col (%d)", count, col); /* If IC is defined, then we do not have to "enter" insert mode. */ if (_rl_term_IC) @@ -2286,10 +2500,14 @@ _rl_redisplay_after_sigwinch () { char *t; - /* Clear the current line and put the cursor at column 0. Make sure - the right thing happens if we have wrapped to a new screen line. */ + /* Clear the last line (assuming that the screen size change will result in + either more or fewer characters on that line only) and put the cursor at + column 0. Make sure the right thing happens if we have wrapped to a new + screen line. */ if (_rl_term_cr) { + _rl_move_vert (_rl_vis_botlin); + #if defined (__MSDOS__) putc ('\r', rl_outstream); #else @@ -2325,7 +2543,7 @@ _rl_redisplay_after_sigwinch () void _rl_clean_up_for_exit () { - if (readline_echoing_p) + if (_rl_echoing_p) { _rl_move_vert (_rl_vis_botlin); _rl_vis_botlin = 0; @@ -2370,9 +2588,9 @@ _rl_current_display_line () In the case of multibyte characters with stateful encoding, we have to scan from the beginning of the string to take the state into account. */ static int -_rl_col_width (str, start, end) +_rl_col_width (str, start, end, flags) const char *str; - int start, end; + int start, end, flags; { wchar_t wc; mbstate_t ps; @@ -2380,12 +2598,31 @@ _rl_col_width (str, start, end) if (end <= start) return 0; + if (MB_CUR_MAX == 1 || rl_byte_oriented) +{ +_rl_ttymsg ("_rl_col_width: called with MB_CUR_MAX == 1"); + return (end - start); +} memset (&ps, 0, sizeof (mbstate_t)); point = 0; max = end; + /* Try to short-circuit common cases. The adjustment to remove wrap_offset + is done by the caller. */ + /* 1. prompt string */ + if (flags && start == 0 && end == local_prompt_len && memcmp (str, local_prompt, local_prompt_len) == 0) + return (prompt_physical_chars + wrap_offset); + /* 2. prompt string + line contents */ + else if (flags && start == 0 && local_prompt_len > 0 && end > local_prompt_len && local_prompt && memcmp (str, local_prompt, local_prompt_len) == 0) + { + tmp = prompt_physical_chars + wrap_offset; + /* XXX - try to call ourselves recursively with non-prompt portion */ + tmp += _rl_col_width (str, local_prompt_len, end, flags); + return (tmp); + } + while (point < start) { tmp = mbrlen (str + point, max, &ps); diff --git a/lib/readline/doc/._fdl.texi b/lib/readline/doc/._fdl.texi Binary files differnew file mode 100644 index 0000000..3dd8e43 --- /dev/null +++ b/lib/readline/doc/._fdl.texi diff --git a/lib/readline/doc/Makefile b/lib/readline/doc/Makefile index 817c2af..af5ee3e 100644 --- a/lib/readline/doc/Makefile +++ b/lib/readline/doc/Makefile @@ -2,21 +2,22 @@ # This makefile for Readline library documentation is in -*- text -*- mode. # Emacs likes it that way. -# Copyright (C) 1996-2002 Free Software Foundation, Inc. +# Copyright (C) 1996-2002 Free Software Foundation, Inc. # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + topdir = . srcdir = . diff --git a/lib/readline/doc/fdl.texi b/lib/readline/doc/fdl.texi index 47ead9f..8805f1a 100644 --- a/lib/readline/doc/fdl.texi +++ b/lib/readline/doc/fdl.texi @@ -1,13 +1,12 @@ +@c The GNU Free Documentation License. +@center Version 1.3, 3 November 2008 -@node GNU Free Documentation License -@appendixsec GNU Free Documentation License - -@cindex FDL, GNU Free Documentation License -@center Version 1.2, November 2002 +@c This file is intended to be included within another document, +@c hence no sectioning command or @node. @display -Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307, USA +Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. +@uref{http://fsf.org/} Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -112,6 +111,9 @@ formats which do not have any title page as such, ``Title Page'' means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text. +The ``publisher'' means any person or entity that distributes copies +of the Document to the public. + A section ``Entitled XYZ'' means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a @@ -344,7 +346,7 @@ and independent documents or works, in or on a volume of a storage or distribution medium, is called an ``aggregate'' if the copyright resulting from the compilation is not used to limit the legal rights of the compilation's users beyond what the individual works permit. -When the Document is included an aggregate, this License does not +When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document. @@ -380,13 +382,30 @@ title. @item TERMINATION -You may not copy, modify, sublicense, or distribute the Document except -as expressly provided for under this License. Any other attempt to -copy, modify, sublicense or distribute the Document is void, and will -automatically terminate your rights under this License. However, -parties who have received copies, or rights, from you under this -License will not have their licenses terminated so long as such -parties remain in full compliance. +You may not copy, modify, sublicense, or distribute the Document +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense, or distribute it is void, and +will automatically terminate your rights under this License. + +However, if you cease all violation of this License, then your license +from a particular copyright holder is reinstated (a) provisionally, +unless and until the copyright holder explicitly and finally +terminates your license, and (b) permanently, if the copyright holder +fails to notify you of the violation by some reasonable means prior to +60 days after the cessation. + +Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, receipt of a copy of some or all of the same material does +not give you any rights to use it. @item FUTURE REVISIONS OF THIS LICENSE @@ -404,11 +423,46 @@ following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not -as a draft) by the Free Software Foundation. +as a draft) by the Free Software Foundation. If the Document +specifies that a proxy can decide which future versions of this +License can be used, that proxy's public statement of acceptance of a +version permanently authorizes you to choose that version for the +Document. + +@item +RELICENSING + +``Massive Multiauthor Collaboration Site'' (or ``MMC Site'') means any +World Wide Web server that publishes copyrightable works and also +provides prominent facilities for anybody to edit those works. A +public wiki that anybody can edit is an example of such a server. A +``Massive Multiauthor Collaboration'' (or ``MMC'') contained in the +site means any set of copyrightable works thus published on the MMC +site. + +``CC-BY-SA'' means the Creative Commons Attribution-Share Alike 3.0 +license published by Creative Commons Corporation, a not-for-profit +corporation with a principal place of business in San Francisco, +California, as well as future copyleft versions of that license +published by that same organization. + +``Incorporate'' means to publish or republish a Document, in whole or +in part, as part of another Document. + +An MMC is ``eligible for relicensing'' if it is licensed under this +License, and if all works that were first published under this License +somewhere other than this MMC, and subsequently incorporated in whole +or in part into the MMC, (1) had no cover texts or invariant sections, +and (2) were thus incorporated prior to November 1, 2008. + +The operator of an MMC Site may republish an MMC contained in the site +under CC-BY-SA on the same site at any time before August 1, 2009, +provided the MMC is eligible for relicensing. + @end enumerate @page -@appendixsubsec ADDENDUM: How to use this License for your documents +@heading ADDENDUM: How to use this License for your documents To use this License in a document you have written, include a copy of the License in the document and put the following copyright and @@ -418,16 +472,16 @@ license notices just after the title page: @group Copyright (C) @var{year} @var{your name}. Permission is granted to copy, distribute and/or modify this document - under the terms of the GNU Free Documentation License, Version 1.2 + under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; - with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. - A copy of the license is included in the section entitled ``GNU + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover + Texts. A copy of the license is included in the section entitled ``GNU Free Documentation License''. @end group @end smallexample If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, -replace the ``with...Texts.'' line with this: +replace the ``with@dots{}Texts.'' line with this: @smallexample @group diff --git a/lib/readline/doc/history.texi b/lib/readline/doc/history.texi index 1af40c7..afdb901 100644 --- a/lib/readline/doc/history.texi +++ b/lib/readline/doc/history.texi @@ -4,8 +4,6 @@ @settitle GNU History Library @c %**end of header (This is for running Texinfo on a region.) -@setchapternewpage odd - @include version.texi @copying @@ -14,7 +12,7 @@ This document describes the GNU History library a programming tool that provides a consistent user interface for recalling lines of previously typed input. -Copyright @copyright{} 1988-2006 Free Software Foundation, Inc. +Copyright @copyright{} 1988--2009 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -22,15 +20,16 @@ are preserved on all copies. @quotation Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.2 or +under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no -Invariant Sections, with the Front-Cover texts being ``A GNU Manual,'' +Invariant Sections, with the Front-Cover texts being ``A GNU Manual'', and with the Back-Cover Texts as in (a) below. A copy of the license is -included in the section entitled ``GNU Free Documentation License.'' +included in the section entitled ``GNU Free Documentation License''. + +(a) The FSF's Back-Cover Text is: You are free to copy and modify +this GNU manual. Buying copies from GNU Press supports the FSF in +developing GNU and promoting software freedom.'' -(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify -this GNU Manual, like GNU software. Copies published by the Free -Software Foundation raise funds for GNU development.'' @end quotation @end copying @@ -72,7 +71,7 @@ typed input. @menu * Using History Interactively:: GNU History User's Manual. * Programming with GNU History:: GNU History Programmer's Manual. -* Copying This Manual:: Copying This Manual. +* GNU Free Documentation License:: License for copying this manual. * Concept Index:: Index of concepts described in this manual. * Function and Variable Index:: Index of externally visible functions and variables. @@ -84,12 +83,8 @@ typed input. @include hsuser.texi @include hstech.texi -@node Copying This Manual -@appendix Copying This Manual - -@menu -* GNU Free Documentation License:: License for copying this manual. -@end menu +@node GNU Free Documentation License +@appendix GNU Free Documentation License @include fdl.texi diff --git a/lib/readline/doc/hstech.texi b/lib/readline/doc/hstech.texi index 47ba8a5..c4e5a75 100644 --- a/lib/readline/doc/hstech.texi +++ b/lib/readline/doc/hstech.texi @@ -1,7 +1,7 @@ @ignore This file documents the user interface to the GNU History library. -Copyright (C) 1988-2006 Free Software Foundation, Inc. +Copyright (C) 1988-2007 Free Software Foundation, Inc. Authored by Brian Fox and Chet Ramey. Permission is granted to make and distribute verbatim copies of this manual diff --git a/lib/readline/doc/hsuser.texi b/lib/readline/doc/hsuser.texi index f98983b..87b3541 100644 --- a/lib/readline/doc/hsuser.texi +++ b/lib/readline/doc/hsuser.texi @@ -1,7 +1,7 @@ @ignore This file documents the user interface to the GNU History library. -Copyright (C) 1988-2006 Free Software Foundation, Inc. +Copyright (C) 1988-2007 Free Software Foundation, Inc. Authored by Brian Fox and Chet Ramey. Permission is granted to make and distribute verbatim copies of this manual @@ -97,7 +97,11 @@ to contain no more than @env{$HISTFILESIZE} lines. If @env{HISTFILESIZE} is not set, no truncation is performed. If the @env{HISTTIMEFORMAT} is set, the time stamp information -associated with each history entry is written to the history file. +associated with each history entry is written to the history file, +marked with the history comment character. +When the history file is read, lines beginning with the history +comment character followed immediately by a digit are interpreted +as timestamps for the previous history line. The builtin command @code{fc} may be used to list or edit and re-execute a portion of the history list. @@ -133,7 +137,7 @@ history list and history file. @item fc @btindex fc @example -@code{fc [-e @var{ename}] [-nlr] [@var{first}] [@var{last}]} +@code{fc [-e @var{ename}] [-lnr] [@var{first}] [@var{last}]} @code{fc -s [@var{pat}=@var{rep}] [@var{command}]} @end example @@ -277,7 +281,10 @@ them, so that they are available for subsequent recall. This is most useful in conjunction with Readline. The shell allows control of the various characters used by the -history expansion mechanism with the @code{histchars} variable. +history expansion mechanism with the @code{histchars} variable, +as explained above (@pxref{Bash Variables}). The shell uses +the history comment character to mark history timestamps when +writing the history file. @end ifset @menu @@ -412,7 +419,7 @@ of the following modifiers, each preceded by a @samp{:}. Remove a trailing pathname component, leaving only the head. @item t -Remove all leading pathname components, leaving the tail. +Remove all leading pathname components, leaving the tail. @item r Remove a trailing suffix of the form @samp{.@var{suffix}}, leaving diff --git a/lib/readline/doc/rlman.texi b/lib/readline/doc/rlman.texi index e14c655..be24709 100644 --- a/lib/readline/doc/rlman.texi +++ b/lib/readline/doc/rlman.texi @@ -4,7 +4,6 @@ @settitle GNU Readline Library @comment %**end of header (This is for running Texinfo on a region.) @synindex vr fn -@setchapternewpage odd @include version.texi @@ -14,7 +13,7 @@ This manual describes the GNU Readline Library consistency of user interface across discrete programs which provide a command line interface. -Copyright @copyright{} 1988-2006 Free Software Foundation, Inc. +Copyright @copyright{} 1988--2009 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -22,15 +21,16 @@ are preserved on all copies. @quotation Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.2 or +under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no -Invariant Sections, with the Front-Cover texts being ``A GNU Manual,'' +Invariant Sections, with the Front-Cover texts being ``A GNU Manual'', and with the Back-Cover Texts as in (a) below. A copy of the license is -included in the section entitled ``GNU Free Documentation License.'' +included in the section entitled ``GNU Free Documentation License''. + +(a) The FSF's Back-Cover Text is: You are free to copy and modify +this GNU manual. Buying copies from GNU Press supports the FSF in +developing GNU and promoting software freedom.'' -(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify -this GNU Manual, like GNU software. Copies published by the Free -Software Foundation raise funds for GNU development.'' @end quotation @end copying @@ -71,7 +71,7 @@ provide a command line interface. @menu * Command Line Editing:: GNU Readline User's Manual. * Programming with GNU Readline:: GNU Readline Programmer's Manual. -* Copying This Manual:: Copying this manual. +* GNU Free Documentation License:: License for copying this manual. * Concept Index:: Index of concepts described in this manual. * Function and Variable Index:: Index of externally visible functions and variables. @@ -81,12 +81,8 @@ provide a command line interface. @include rluser.texi @include rltech.texi -@node Copying This Manual -@appendix Copying This Manual - -@menu -* GNU Free Documentation License:: License for copying this manual. -@end menu +@node GNU Free Documentation License +@appendix GNU Free Documentation License @include fdl.texi diff --git a/lib/readline/doc/rltech.texi b/lib/readline/doc/rltech.texi index ecff106..04c8489 100644 --- a/lib/readline/doc/rltech.texi +++ b/lib/readline/doc/rltech.texi @@ -1,14 +1,13 @@ @comment %**start of header (This is for running Texinfo on a region.) @setfilename rltech.info @comment %**end of header (This is for running Texinfo on a region.) -@setchapternewpage odd @ifinfo This document describes the GNU Readline Library, a utility for aiding in the consistency of user interface across discrete programs that need to provide a command line interface. -Copyright (C) 1988-2006 Free Software Foundation, Inc. +Copyright (C) 1988-2007 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -351,6 +350,12 @@ The @code{rl_set_prompt()} function (@pxref{Redisplay}) may be used to modify the prompt string after calling @code{readline()}. @end deftypevar +@deftypevar {char *} rl_display_prompt +The string displayed as the prompt. This is usually identical to +@var{rl_prompt}, but may be changed temporarily by functions that +use the prompt string as a message area, such as incremental search. +@end deftypevar + @deftypevar int rl_already_prompted If an application wishes to display the prompt itself, rather than have Readline do it the first time @code{readline()} is called, it should set @@ -518,6 +523,20 @@ Readline is performing word completion. Readline is currently executing the readline signal handler. @item RL_STATE_UNDOING Readline is performing an undo. +@item RL_STATE_INPUTPENDING +Readline has input pending due to a call to @code{rl_execute_next()}. +@item RL_STATE_TTYCSAVED +Readline has saved the values of the terminal's special characters. +@item RL_STATE_CALLBACK +Readline is currently using the alternate (callback) interface +(@pxref{Alternate Interface}). +@item RL_STATE_VIMOTION +Readline is reading the argument to a vi-mode "motion" command. +@item RL_STATE_MULTIKEY +Readline is reading a multiple-keystroke command. +@item RL_STATE_VICMDONCE +Readline has entered vi command (movement) mode at least one time during +the current call to @code{readline()}. @item RL_STATE_DONE Readline has read a key sequence bound to @code{accept-line} and is about to return the line to the caller. @@ -603,7 +622,7 @@ Readline which keymap to use. @deftypefun Keymap rl_make_bare_keymap (void) Returns a new, empty keymap. The space for the keymap is allocated with @code{malloc()}; the caller should free it by calling -@code{rl_discard_keymap()} when done. +@code{rl_free_keymap()} when done. @end deftypefun @deftypefun Keymap rl_copy_keymap (Keymap map) @@ -617,7 +636,13 @@ the Meta digits bound to produce numeric arguments. @end deftypefun @deftypefun void rl_discard_keymap (Keymap keymap) -Free the storage associated with @var{keymap}. +Free the storage associated with the data in @var{keymap}. +The caller should free @var{keymap}. +@end deftypefun + +@deftypefun void rl_free_keymap (Keymap keymap) +Free all storage associated with @var{keymap}. This calls +@code{rl_discard_keymap} to free subordindate keymaps and macros. @end deftypefun Readline has several internal keymaps. These functions allow you to @@ -793,7 +818,8 @@ Print the names of all bindable Readline functions to @code{rl_outstream}. @deftypefun {const char **} rl_funmap_names (void) Return a NULL terminated array of known function names. The array is sorted. The array itself is allocated, but not the strings inside. You -should @code{free()} the array when you are done, but not the pointers. +should free the array, but not the pointers, using @code{free} or +@code{rl_free} when you are done. @end deftypefun @deftypefun int rl_add_funmap_entry (const char *name, rl_command_func_t *function) @@ -1077,6 +1103,26 @@ environment variable is used. @node Utility Functions @subsection Utility Functions +@deftypefun int rl_save_state (struct readline_state *sp) +Save a snapshot of Readline's internal state to @var{sp}. +The contents of the @var{readline_state} structure are documented +in @file{readline.h}. +The caller is responsible for allocating the structure. +@end deftypefun + +@deftypefun int rl_restore_state (struct readline_state *sp) +Restore Readline's internal state to that stored in @var{sp}, which must +have been saved by a call to @code{rl_save_state}. +The contents of the @var{readline_state} structure are documented +in @file{readline.h}. +The caller is responsible for freeing the structure. +@end deftypefun + +@deftypefun void rl_free (void *mem) +Deallocate the memory pointed to by @var{mem}. @var{mem} must have been +allocated by @code{malloc}. +@end deftypefun + @deftypefun void rl_replace_line (const char *text, int clear_undo) Replace the contents of @code{rl_line_buffer} with @var{text}. The point and mark are preserved, if possible. @@ -1084,7 +1130,7 @@ If @var{clear_undo} is non-zero, the undo list associated with the current line is cleared. @end deftypefun -@deftypefun int rl_extend_line_buffer (int len) +@deftypefun void rl_extend_line_buffer (int len) Ensure that @code{rl_line_buffer} has enough space to hold @var{len} characters, possibly reallocating it if necessary. @end deftypefun @@ -1394,6 +1440,13 @@ call @code{rl_resize_terminal()} or @code{rl_set_screen_size()} to force Readline to update its idea of the terminal size when a @code{SIGWINCH} is received. +@deftypefun void rl_echo_signal_char (int sig) +If an application wishes to install its own signal handlers, but still +have readline display characters that generate signals, calling this +function with @var{sig} set to @code{SIGINT}, @code{SIGQUIT}, or +@code{SIGTSTP} will display the character generating that signal. +@end deftypefun + @deftypefun void rl_resize_terminal (void) Update Readline's internal screen size by reading values from the kernel. @end deftypefun @@ -1675,6 +1728,35 @@ remove any quote characters from the directory name, because its result will be passed directly to @code{opendir()}. @end deftypevar +@ignore +@deftypevar extern rl_icppfunc_t *rl_directory_rewrite_hook; +If non-zero, this is the address of a function to call when completing +a directory name. This function takes the address of the directory name +to be modified as an argument. Unlike @code{rl_directory_completion_hook}, +it only modifies the directory name used in @code{opendir}, not what is +displayed when the possible completions are printed or inserted. It is +called before rl_directory_completion_hook. + +I'm not happy with how this worksyet, so it's undocumented. +@end deftypevar +@end ignore + +@deftypevar {rl_dequote_func_t *} rl_filename_rewrite_hook +If non-zero, this is the address of a function called when reading +directory entries from the filesystem for completion and comparing +them to the partial word to be completed. The function should +perform any necesary application or system-specific conversion on +the filename, such as converting between character sets or converting +from a filesystem format to a character input format. +The function takes two arguments: @var{fname}, the filename to be converted, +and @var{fnlen}, its length in bytes. +It must either return its first argument (if no conversion takes place) +or the converted filename in newly-allocated memory. The converted +form is used to compare against the word to be completed, and, if it +matches, is added to the list of matches. Readline will free the +allocated string. +@end deftypevar + @deftypevar {rl_compdisp_func_t *} rl_completion_display_matches_hook If non-zero, then this is the address of a function to call when completing a word would normally display the list of possible matches. @@ -1827,6 +1909,15 @@ if the application's completion function returns no matches. It should be set only by an application's completion function. @end deftypevar +@deftypevar int rl_sort_completion_matches +If an application sets this variable to 0, Readline will not sort the +list of completions (which implies that it cannot remove any duplicate +completions). The default value is 1, which means that Readline will +sort the completions and, depending on the value of +@code{rl_ignore_completion_duplicates}, will attempt to remove duplicate +matches. +@end deftypevar + @deftypevar int rl_completion_type Set to a character describing the type of completion Readline is currently attempting; see the description of @code{rl_complete_internal()} @@ -1836,6 +1927,13 @@ completion function is called, allowing such functions to present the same interface as @code{rl_complete()}. @end deftypevar +@deftypevar int rl_completion_invoking_key +Set to the final character in the key sequence that invoked one of the +completion functions that call @code{rl_complete_internal()}. This is +set to the appropriate value before any application-specific completion +function is called. +@end deftypevar + @deftypevar int rl_inhibit_completion If this variable is non-zero, completion is inhibited. The completion character will be inserted as any other bound to @code{self-insert}. @@ -1856,27 +1954,51 @@ history list. GNU Readline library. This application interactively allows users to manipulate files and their modes. */ -#include <stdio.h> +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include <sys/types.h> -#include <sys/file.h> +#ifdef HAVE_SYS_FILE_H +# include <sys/file.h> +#endif #include <sys/stat.h> -#include <sys/errno.h> + +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif + +#include <fcntl.h> +#include <stdio.h> +#include <errno.h> + +#if defined (HAVE_STRING_H) +# include <string.h> +#else /* !HAVE_STRING_H */ +# include <strings.h> +#endif /* !HAVE_STRING_H */ + +#ifdef HAVE_STDLIB_H +# include <stdlib.h> +#endif + +#include <time.h> #include <readline/readline.h> #include <readline/history.h> -extern char *xmalloc (); +extern char *xmalloc PARAMS((size_t)); /* The names of functions that actually do the manipulation. */ -int com_list __P((char *)); -int com_view __P((char *)); -int com_rename __P((char *)); -int com_stat __P((char *)); -int com_pwd __P((char *)); -int com_delete __P((char *)); -int com_help __P((char *)); -int com_cd __P((char *)); -int com_quit __P((char *)); +int com_list PARAMS((char *)); +int com_view PARAMS((char *)); +int com_rename PARAMS((char *)); +int com_stat PARAMS((char *)); +int com_pwd PARAMS((char *)); +int com_delete PARAMS((char *)); +int com_help PARAMS((char *)); +int com_cd PARAMS((char *)); +int com_quit PARAMS((char *)); /* A structure which contains information on the commands this program can understand. */ @@ -1909,12 +2031,12 @@ COMMAND *find_command (); /* The name of this program, as taken from argv[0]. */ char *progname; -/* When non-zero, this means the user is done using this program. */ +/* When non-zero, this global means the user is done using this program. */ int done; char * dupstr (s) - int s; + char *s; @{ char *r; @@ -2039,12 +2161,12 @@ stripwhite (string) /* */ /* **************************************************************** */ -char *command_generator __P((const char *, int)); -char **fileman_completion __P((const char *, int, int)); +char *command_generator PARAMS((const char *, int)); +char **fileman_completion PARAMS((const char *, int, int)); -/* Tell the GNU Readline library how to complete. We want to try to - complete on command names if this is the first word in the line, or - on filenames if not. */ +/* Tell the GNU Readline library how to complete. We want to try to complete + on command names if this is the first word in the line, or on filenames + if not. */ initialize_readline () @{ /* Allow conditional parsing of the ~/.inputrc file. */ @@ -2054,11 +2176,11 @@ initialize_readline () rl_attempted_completion_function = fileman_completion; @} -/* Attempt to complete on the contents of TEXT. START and END - bound the region of rl_line_buffer that contains the word to - complete. TEXT is the word to complete. We can use the entire - contents of rl_line_buffer in case we want to do some simple - parsing. Returnthe array of matches, or NULL if there aren't any. */ +/* Attempt to complete on the contents of TEXT. START and END bound the + region of rl_line_buffer that contains the word to complete. TEXT is + the word to complete. We can use the entire contents of rl_line_buffer + in case we want to do some simple parsing. Return the array of matches, + or NULL if there aren't any. */ char ** fileman_completion (text, start, end) const char *text; @@ -2077,9 +2199,9 @@ fileman_completion (text, start, end) return (matches); @} -/* Generator function for command completion. STATE lets us - know whether to start from scratch; without any state - (i.e. STATE == 0), then we start at the top of the list. */ +/* Generator function for command completion. STATE lets us know whether + to start from scratch; without any state (i.e. STATE == 0), then we + start at the top of the list. */ char * command_generator (text, state) const char *text; @@ -2088,17 +2210,16 @@ command_generator (text, state) static int list_index, len; char *name; - /* If this is a new word to complete, initialize now. This - includes saving the length of TEXT for efficiency, and - initializing the index variable to 0. */ + /* If this is a new word to complete, initialize now. This includes + saving the length of TEXT for efficiency, and initializing the index + variable to 0. */ if (!state) @{ list_index = 0; len = strlen (text); @} - /* Return the next name which partially matches from the - command list. */ + /* Return the next name which partially matches from the command list. */ while (name = commands[list_index].name) @{ list_index++; @@ -2138,7 +2259,12 @@ com_view (arg) if (!valid_argument ("view", arg)) return 1; +#if defined (__MSDOS__) + /* more.com doesn't grok slashes in pathnames */ + sprintf (syscom, "less %s", arg); +#else sprintf (syscom, "more %s", arg); +#endif return (system (syscom)); @} @@ -2165,7 +2291,8 @@ com_stat (arg) printf ("Statistics for `%s':\n", arg); - printf ("%s has %d link%s, and is %d byte%s in length.\n", arg, + printf ("%s has %d link%s, and is %d byte%s in length.\n", + arg, finfo.st_nlink, (finfo.st_nlink == 1) ? "" : "s", finfo.st_size, @@ -2254,8 +2381,7 @@ com_pwd (ignore) return 0; @} -/* The user wishes to quit using this program. Just set DONE - non-zero. */ +/* The user wishes to quit using this program. Just set DONE non-zero. */ com_quit (arg) char *arg; @{ @@ -2268,13 +2394,12 @@ too_dangerous (caller) char *caller; @{ fprintf (stderr, - "%s: Too dangerous for me to distribute.\n", + "%s: Too dangerous for me to distribute. Write it yourself.\n", caller); - fprintf (stderr, "Write it yourself.\n"); @} -/* Return non-zero if ARG is a valid argument for CALLER, - else print an error message and return zero. */ +/* Return non-zero if ARG is a valid argument for CALLER, else print + an error message and return zero. */ int valid_argument (caller, arg) char *caller, *arg; diff --git a/lib/readline/doc/rluser.texi b/lib/readline/doc/rluser.texi index 5c6467a..519c0de 100644 --- a/lib/readline/doc/rluser.texi +++ b/lib/readline/doc/rluser.texi @@ -1,7 +1,6 @@ @comment %**start of header (This is for running Texinfo on a region.) @setfilename rluser.info @comment %**end of header (This is for running Texinfo on a region.) -@setchapternewpage odd @ignore This file documents the end user interface to the GNU command line @@ -10,7 +9,7 @@ use these features. There is a document entitled "readline.texinfo" which contains both end-user and programmer documentation for the GNU Readline Library. -Copyright (C) 1988-2006 Free Software Foundation, Inc. +Copyright (C) 1988--2009 Free Software Foundation, Inc. Authored by Brian Fox and Chet Ramey. @@ -48,6 +47,16 @@ command line editing interface. @ifset BashFeatures Command line editing is provided by the Readline library, which is used by several different programs, including Bash. +Command line editing is enabled by default when using an interactive shell, +unless the @option{--noediting} option is supplied at shell invocation. +Line editing is also used when using the @option{-e} option to the +@code{read} builtin command (@pxref{Bash Builtins}). +By default, the line editing commands are similar to those of emacs. +A vi-style line editing interface is also available. +Line editing can be enabled at any time using the @option{-o emacs} or +@option{-o vi} options to the @code{set} builtin command +(@pxref{The Set Builtin}), or disabled using the @option{+o emacs} or +@option{+o vi} options to @code{set}. @end ifset @menu @@ -427,6 +436,13 @@ If set to @samp{on}, Readline performs filename matching and completion in a case-insensitive fashion. The default value is @samp{off}. +@item completion-prefix-display-length +@vindex completion-prefix-display-length +The length in characters of the common prefix of a list of possible +completions that is displayed without modification. When set to a +value greater than zero, common prefixes longer than this value are +replaced with an ellipsis when displaying possible completions. + @item completion-query-items @vindex completion-query-items The number of possible completions that determines when the user is @@ -458,12 +474,23 @@ key bindings is used. By default, Readline starts up in Emacs editing mode, where the keystrokes are most similar to Emacs. This variable can be set to either @samp{emacs} or @samp{vi}. +@item echo-control-characters +When set to @samp{on}, on operating systems that indicate they support it, +readline echoes a character corresponding to a signal generated from the +keyboard. The default is @samp{on}. + @item enable-keypad @vindex enable-keypad When set to @samp{on}, Readline will try to enable the application keypad when it is called. Some systems need this to enable the arrow keys. The default is @samp{off}. +@item enable-meta-key +When set to @samp{on}, Readline will try to enable any meta modifier +key the terminal claims to support when it is called. On many terminals, +the meta key is used to send eight-bit characters. +The default is @samp{on}. + @item expand-tilde @vindex expand-tilde If set to @samp{on}, tilde expansion is performed when Readline @@ -471,10 +498,16 @@ attempts word completion. The default is @samp{off}. @item history-preserve-point @vindex history-preserve-point -If set to @samp{on}, the history code attempts to place point at the +If set to @samp{on}, the history code attempts to place the point (the +current cursor position) at the same location on each history line retrieved with @code{previous-history} or @code{next-history}. The default is @samp{off}. +@item history-size +@vindex history-size +Set the maximum number of history entries saved in the history list. If +set to zero, the number of entries in the history list is not limited. + @item horizontal-scroll-mode @vindex horizontal-scroll-mode This variable can be set to either @samp{on} or @samp{off}. Setting it @@ -558,6 +591,13 @@ If set to @samp{on}, Readline will display completions with matches sorted horizontally in alphabetical order, rather than down the screen. The default is @samp{off}. +@item revert-all-at-newline +@vindex revert-all-at-newline +If set to @samp{on}, Readline will undo all changes to history lines +before returning when @code{accept-line} is executed. By default, +history lines may be modified and retain individual undo lists across +calls to @code{readline}. The default is @samp{off}. + @item show-all-if-ambiguous @vindex show-all-if-ambiguous This alters the default behavior of the completion functions. If @@ -577,6 +617,20 @@ a common prefix) cause the matches to be listed immediately instead of ringing the bell. The default value is @samp{off}. +@item skip-completed-text +@vindex skip-completed-text +If set to @samp{on}, this alters the default completion behavior when +inserting a single match into the line. It's only active when +performing completion in the middle of a word. If enabled, readline +does not insert characters from the completion that match characters +after point in the word being completed, so portions of the word +following the cursor are not duplicated. +For instance, if this is enabled, attempting completion when the cursor +is after the @samp{e} in @samp{Makefile} will result in @samp{Makefile} +rather than @samp{Makefilefile}, assuming there is a single possible +completion. +The default value is @samp{off}. + @item visible-stats @vindex visible-stats If set to @samp{on}, a character denoting a file's type @@ -941,12 +995,22 @@ Move forward a character. Move back a character. @item forward-word (M-f) -Move forward to the end of the next word. Words are composed of -letters and digits. +Move forward to the end of the next word. +Words are composed of letters and digits. @item backward-word (M-b) -Move back to the start of the current or previous word. Words are -composed of letters and digits. +Move back to the start of the current or previous word. +Words are composed of letters and digits. + +@ifset BashFeatures +@item shell-forward-word () +Move forward to the end of the next word. +Words are delimited by non-quoted shell metacharacters. + +@item shell-backward-word () +Move back to the start of the current or previous word. +Words are delimited by non-quoted shell metacharacters. +@end ifset @item clear-screen (C-l) Clear the screen and redraw the current line, @@ -1142,6 +1206,17 @@ Word boundaries are the same as @code{forward-word}. Kill the word behind point. Word boundaries are the same as @code{backward-word}. +@ifset BashFeatures +@item shell-kill-word () +Kill from point to the end of the current word, or if between +words, to the end of the next word. +Word boundaries are the same as @code{shell-forward-word}. + +@item backward-kill-word () +Kill the word behind point. +Word boundaries are the same as @code{shell-backward-word}. +@end ifset + @item unix-word-rubout (C-w) Kill the word behind point, using white space as a word boundary. The killed text is saved on the kill-ring. @@ -1242,6 +1317,11 @@ through the list. This command is intended to be bound to @key{TAB}, but is unbound by default. +@item menu-complete-backward () +Identical to @code{menu-complete}, but moves backward through the list +of possible completions, as if @code{menu-complete} had been given a +negative argument. + @item delete-char-or-list () Deletes the character under the cursor if not at the beginning or end of the line (like @code{delete-char}). @@ -1297,6 +1377,11 @@ Attempt completion on the text before point, comparing the text against lines from the history list for possible completion matches. +@item dabbrev-expand () +Attempt menu completion on the text before point, comparing +the text against lines from the history list for possible +completion matches. + @item complete-into-braces (M-@{) Perform filename completion and insert the list of possible completions enclosed within braces so the list is available to the shell @@ -1376,6 +1461,15 @@ A character is read and point is moved to the previous occurrence of that character. A negative count searches for subsequent occurrences. +@item skip-csi-sequence () +Read enough characters to consume a multi-key sequence such as those +defined for keys like Home and End. Such sequences begin with a +Control Sequence Indicator (CSI), usually ESC-[. If this sequence is +bound to "\e[", keys producing such sequences will have no effect +unless explicitly bound to a readline command, instead of inserting +stray characters into the editing buffer. This is unbound by default, +but usually bound to ESC-[. + @item insert-comment (M-#) Without a numeric argument, the value of the @code{comment-begin} variable is inserted at the beginning of the current line. @@ -1519,10 +1613,15 @@ the programmable completion facilities are invoked. First, the command name is identified. If a compspec has been defined for that command, the compspec is used to generate the list of possible completions for the word. +If the command word is the empty string (completion attempted at the +beginning of an empty line), any compspec defined with +the @option{-E} option to @code{complete} is used. If the command word is a full pathname, a compspec for the full pathname is searched for first. If no compspec is found for the full pathname, an attempt is made to find a compspec for the portion following the final slash. +If those searches do not result in a compspec, any compspec defined with +the @option{-D} option to @code{complete} is used as the default. Once a compspec has been found, it is used to generate the list of matching words. @@ -1559,9 +1658,9 @@ completed, and the matching words become the possible completions. After these matches have been generated, any shell function or command specified with the @option{-F} and @option{-C} options is invoked. -When the command or function is invoked, the @env{COMP_LINE} and -@env{COMP_POINT} variables are assigned values as described above -(@pxref{Bash Variables}). +When the command or function is invoked, the @env{COMP_LINE}, +@env{COMP_POINT}, @env{COMP_KEY}, and @env{COMP_TYPE} variables are +assigned values as described above (@pxref{Bash Variables}). If a shell function is being invoked, the @env{COMP_WORDS} and @env{COMP_CWORD} variables are also set. When the function or command is invoked, the first argument is the @@ -1574,7 +1673,7 @@ the matches. Any function specified with @option{-F} is invoked first. The function may use any of the shell facilities, including the -@code{compgen} builtin described below +@code{compgen} and @code{compopt} builtins described below (@pxref{Programmable Completion Builtins}), to generate the matches. It must put the possible completions in the @env{COMPREPLY} array variable. @@ -1626,6 +1725,30 @@ to completed names which are symbolic links to directories, subject to the value of the @var{mark-directories} Readline variable, regardless of the setting of the @var{mark-symlinked-directories} Readline variable. +There is some support for dynamically modifying completions. This is +most useful when used in combination with a default completion specified +with @option{-D}. It's possible for shell functions executed as completion +handlers to indicate that completion should be retried by returning an +exit status of 124. If a shell function returns 124, and changes +the compspec associated with the command on which completion is being +attempted (supplied as the first argument when the function is executed), +programmable completion restarts from the beginning, with an +attempt to find a compspec for that command. This allows a set of +completions to be built dynamically as completion is attempted, rather than +being loaded all at once. + +For instance, assuming that there is a library of compspecs, each kept in a +file corresponding to the name of the command, the following default +completion function would load completions dynamically: + +@example +_completion_loader() +@{ + . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124 +@} +complete -D -F _completion_loader +@end example + @node Programmable Completion Builtins @section Programmable Completion Builtins @cindex completion builtins @@ -1661,10 +1784,10 @@ matches were generated. @item complete @btindex complete @example -@code{complete [-abcdefgjksuv] [-o @var{comp-option}] [-A @var{action}] [-G @var{globpat}] [-W @var{wordlist}] -[-P @var{prefix}] [-S @var{suffix}] [-X @var{filterpat}] [-F @var{function}] -[-C @var{command}] @var{name} [@var{name} @dots{}]} -@code{complete -pr [@var{name} @dots{}]} +@code{complete [-abcdefgjksuv] [-o @var{comp-option}] [-DE] [-A @var{action}] [-G @var{globpat}] [-W @var{wordlist}] +[-F @var{function}] [-C @var{command}] [-X @var{filterpat}] +[-P @var{prefix}] [-S @var{suffix}] @var{name} [@var{name} @dots{}]} +@code{complete -pr [-DE] [@var{name} @dots{}]} @end example Specify how arguments to each @var{name} should be completed. @@ -1674,9 +1797,16 @@ reused as input. The @option{-r} option removes a completion specification for each @var{name}, or, if no @var{name}s are supplied, all completion specifications. +The @option{-D} option indicates that the remaining options and actions should +apply to the ``default'' command completion; that is, completion attempted +on a command for which no completion has previously been defined. +The @option{-E} option indicates that the remaining options and actions should +apply to ``empty'' command completion; that is, completion attempted on a +blank line. The process of applying these completion specifications when word completion -is attempted is described above (@pxref{Programmable Completion}). +is attempted is described above (@pxref{Programmable Completion}). The +@option{-D} option takes precedence over @option{-E}. Other options, if specified, have the following meanings. The arguments to the @option{-G}, @option{-W}, and @option{-X} options @@ -1706,9 +1836,10 @@ Perform directory name completion if the compspec generates no matches. @item filenames Tell Readline that the compspec generates filenames, so it can perform any -filename-specific processing (like adding a slash to directory names or -suppressing trailing spaces). This option is intended to be used with -shell functions specified with @option{-F}. +filename-specific processing (like adding a slash to directory names +quoting special characters, or suppressing trailing spaces). +This option is intended to be used with shell functions specified +with @option{-F}. @item nospace Tell Readline not to append a space (the default) to words completed at @@ -1846,5 +1977,31 @@ argument, an attempt is made to remove a completion specification for a @var{name} for which no specification exists, or an error occurs adding a completion specification. +@item compopt +@btindex compopt +@example +@code{compopt} [-o @var{option}] [-DE] [+o @var{option}] [@var{name}] +@end example +Modify completion options for each @var{name} according to the +@var{option}s, or for the currently-execution completion if no @var{name}s +are supplied. +If no @var{option}s are given, display the completion options for each +@var{name} or the current completion. +The possible values of @var{option} are those valid for the @code{complete} +builtin described above. +The @option{-D} option indicates that the remaining options should +apply to the ``default'' command completion; that is, completion attempted +on a command for which no completion has previously been defined. +The @option{-E} option indicates that the remaining options should +apply to ``empty'' command completion; that is, completion attempted on a +blank line. + +The @option{-D} option takes precedence over @option{-E}. + +The return value is true unless an invalid option is supplied, an attempt +is made to modify the options for a @var{name} for which no completion +specification exists, or an output error occurs. + @end table + @end ifset diff --git a/lib/readline/doc/rluserman.texi b/lib/readline/doc/rluserman.texi index 086aa83..49d9a2c 100644 --- a/lib/readline/doc/rluserman.texi +++ b/lib/readline/doc/rluserman.texi @@ -4,8 +4,6 @@ @settitle GNU Readline Library @comment %**end of header (This is for running Texinfo on a region.) -@setchapternewpage odd - @include version.texi @copying @@ -14,7 +12,7 @@ This manual describes the end user interface of the GNU Readline Library consistency of user interface across discrete programs which provide a command line interface. -Copyright @copyright{} 1988-2006 Free Software Foundation, Inc. +Copyright @copyright{} 1988--2009 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -22,15 +20,16 @@ are preserved on all copies. @quotation Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.2 or +under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no -Invariant Sections, with the Front-Cover texts being ``A GNU Manual,'' +Invariant Sections, with the Front-Cover texts being ``A GNU Manual'', and with the Back-Cover Texts as in (a) below. A copy of the license is -included in the section entitled ``GNU Free Documentation License.'' +included in the section entitled ``GNU Free Documentation License''. + +(a) The FSF's Back-Cover Text is: You are free to copy and modify +this GNU manual. Buying copies from GNU Press supports the FSF in +developing GNU and promoting software freedom.'' -(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify -this GNU Manual, like GNU software. Copies published by the Free -Software Foundation raise funds for GNU development.'' @end quotation @end copying @@ -70,18 +69,14 @@ programs which provide a command line interface. @menu * Command Line Editing:: GNU Readline User's Manual. -* Copying This Manual:: Copying This Manual. +* GNU Free Documentation License:: License for copying this manual. @end menu @end ifnottex @include rluser.texi -@node Copying This Manual -@appendix Copying This Manual - -@menu -* GNU Free Documentation License:: License for copying this manual. -@end menu +@node GNU Free Documentation License +@appendix GNU Free Documentation License @include fdl.texi diff --git a/lib/readline/doc/version.texi b/lib/readline/doc/version.texi index 654e837..823b3ba 100644 --- a/lib/readline/doc/version.texi +++ b/lib/readline/doc/version.texi @@ -1,10 +1,10 @@ @ignore -Copyright (C) 1988-2006 Free Software Foundation, Inc. +Copyright (C) 1988-2009 Free Software Foundation, Inc. @end ignore -@set EDITION 5.2 -@set VERSION 5.2 -@set UPDATED 26 April 2006 -@set UPDATED-MONTH April 2006 +@set EDITION 6.1 +@set VERSION 6.1 +@set UPDATED 9 October 2009 +@set UPDATED-MONTH October 2009 -@set LASTCHANGE Wed Apr 26 09:22:57 EDT 2006 +@set LASTCHANGE Fri Oct 9 12:57:58 EDT 2009 diff --git a/lib/readline/emacs_keymap.c b/lib/readline/emacs_keymap.c index ca9d134..cb6e140 100644 --- a/lib/readline/emacs_keymap.c +++ b/lib/readline/emacs_keymap.c @@ -1,24 +1,23 @@ /* emacs_keymap.c -- the keymap for emacs_mode in readline (). */ -/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if !defined (BUFSIZ) #include <stdio.h> diff --git a/lib/readline/examples/Inputrc b/lib/readline/examples/Inputrc index d7fdb42..a358bc4 100644 --- a/lib/readline/examples/Inputrc +++ b/lib/readline/examples/Inputrc @@ -4,21 +4,21 @@ # on which program is running, or what terminal is active. # -# Copyright (C) 1989-2002 Free Software Foundation, Inc. +# Copyright (C) 1989-2009 Free Software Foundation, Inc. # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. # In all programs, all terminals, make sure this is bound. "\C-x\C-r": re-read-init-file diff --git a/lib/readline/examples/Makefile b/lib/readline/examples/Makefile index 636a1dc..2df2240 100644 --- a/lib/readline/examples/Makefile +++ b/lib/readline/examples/Makefile @@ -2,19 +2,19 @@ # # Copyright (C) 1994 Free Software Foundation, Inc. -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# EXECUTABLES = fileman rltest rl CFLAGS = -g -I../.. -I.. -DREADLINE_LIBRARY diff --git a/lib/readline/examples/fileman.c b/lib/readline/examples/fileman.c index 340eee7..f7eed8a 100644 --- a/lib/readline/examples/fileman.c +++ b/lib/readline/examples/fileman.c @@ -1,22 +1,23 @@ -/* Copyright (C) 1987-2002 Free Software Foundation, Inc. +/* fileman.c - file manager example for readline library. */ - This file is part of the GNU Readline Library, a library for +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. + + This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ /* fileman.c -- A tiny application which demonstrates how to use the GNU Readline library. This application interactively allows users @@ -50,6 +51,8 @@ # include <stdlib.h> #endif +#include <time.h> + #ifdef READLINE_LIBRARY # include "readline.h" # include "history.h" @@ -58,7 +61,7 @@ # include <readline/history.h> #endif -extern char *xmalloc (); +extern char *xmalloc PARAMS((size_t)); /* The names of functions that actually do the manipulation. */ int com_list PARAMS((char *)); diff --git a/lib/readline/examples/histexamp.c b/lib/readline/examples/histexamp.c index 4f059c1..3b43674 100644 --- a/lib/readline/examples/histexamp.c +++ b/lib/readline/examples/histexamp.c @@ -1,22 +1,23 @@ -/* Copyright (C) 1987-2002 Free Software Foundation, Inc. +/* histexamp.c - history library example program. */ - This file is part of the GNU Readline Library, a library for +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. + + This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #include <stdio.h> diff --git a/lib/readline/examples/manexamp.c b/lib/readline/examples/manexamp.c index 9c6cf2c..351c628 100644 --- a/lib/readline/examples/manexamp.c +++ b/lib/readline/examples/manexamp.c @@ -1,24 +1,23 @@ /* manexamp.c -- The examples which appear in the documentation are here. */ -/* Copyright (C) 1987-2002 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for + This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #include <stdio.h> #include <readline/readline.h> diff --git a/lib/readline/examples/rl.c b/lib/readline/examples/rl.c index c608c15..845a4b1 100644 --- a/lib/readline/examples/rl.c +++ b/lib/readline/examples/rl.c @@ -5,25 +5,24 @@ * usage: rl [-p prompt] [-u unit] [-d default] [-n nchars] */ -/* Copyright (C) 1987-2002 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for + This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if defined (HAVE_CONFIG_H) # include <config.h> diff --git a/lib/readline/examples/rlcat.c b/lib/readline/examples/rlcat.c index 33aea4a..fa9e06f 100644 --- a/lib/readline/examples/rlcat.c +++ b/lib/readline/examples/rlcat.c @@ -4,25 +4,24 @@ * usage: rlcat */ -/* Copyright (C) 1987-2002 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for + This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if defined (HAVE_CONFIG_H) # include <config.h> diff --git a/lib/readline/examples/rltest.c b/lib/readline/examples/rltest.c index cb67bab..78e2608 100644 --- a/lib/readline/examples/rltest.c +++ b/lib/readline/examples/rltest.c @@ -4,25 +4,24 @@ /* */ /* **************************************************************** */ -/* Copyright (C) 1987-2002 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for + This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if defined (HAVE_CONFIG_H) #include <config.h> diff --git a/lib/readline/funmap.c b/lib/readline/funmap.c index 9c760cc..cccddb6 100644 --- a/lib/readline/funmap.c +++ b/lib/readline/funmap.c @@ -1,24 +1,24 @@ /* funmap.c -- attach names to functions. */ -/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) @@ -56,7 +56,7 @@ static int funmap_entry; program specific function. */ int funmap_program_specific_entry_start; -static FUNMAP default_funmap[] = { +static const FUNMAP default_funmap[] = { { "abort", rl_abort }, { "accept-line", rl_newline }, { "arrow-key-prefix", rl_arrow_keys }, @@ -105,11 +105,13 @@ static FUNMAP default_funmap[] = { { "kill-region", rl_kill_region }, { "kill-word", rl_kill_word }, { "menu-complete", rl_menu_complete }, + { "menu-complete-backward", rl_backward_menu_complete }, { "next-history", rl_get_next_history }, { "non-incremental-forward-search-history", rl_noninc_forward_search }, { "non-incremental-reverse-search-history", rl_noninc_reverse_search }, { "non-incremental-forward-search-history-again", rl_noninc_forward_search_again }, { "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again }, + { "old-menu-complete", rl_old_menu_complete }, { "overwrite-mode", rl_overwrite_mode }, #ifdef __CYGWIN__ { "paste-from-clipboard", rl_paste_from_clipboard }, @@ -123,6 +125,7 @@ static FUNMAP default_funmap[] = { { "revert-line", rl_revert_line }, { "self-insert", rl_insert }, { "set-mark", rl_set_mark }, + { "skip-csi-sequence", rl_skip_csi_sequence }, { "start-kbd-macro", rl_start_kbd_macro }, { "tab-insert", rl_tab_insert }, { "tilde-expand", rl_tilde_expand }, diff --git a/lib/readline/histexpand.c b/lib/readline/histexpand.c index f46c0b2..42498d2 100644 --- a/lib/readline/histexpand.c +++ b/lib/readline/histexpand.c @@ -1,24 +1,23 @@ /* histexpand.c -- history expansion. */ -/* Copyright (C) 1989-2004 Free Software Foundation, Inc. +/* Copyright (C) 1989-2009 Free Software Foundation, Inc. - This file contains the GNU History Library (the Library), a set of + This file contains the GNU History Library (History), a set of routines for managing the text of previously typed lines. - The Library is free software; you can redistribute it and/or modify + History is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - The Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + History is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with History. If not, see <http://www.gnu.org/licenses/>. +*/ #define READLINE_LIBRARY @@ -64,9 +63,11 @@ static int subst_lhs_len; static int subst_rhs_len; static char *get_history_word_specifier PARAMS((char *, char *, int *)); -static char *history_find_word PARAMS((char *, int)); static int history_tokenize_word PARAMS((const char *, int)); +static char **history_tokenize_internal PARAMS((const char *, int, int *)); static char *history_substring PARAMS((const char *, int, int)); +static void freewords PARAMS((char **, int)); +static char *history_find_word PARAMS((char *, int)); static char *quote_breaks PARAMS((char *)); @@ -304,16 +305,20 @@ get_history_event (string, caller_index, delimiting_quote) /* Extract the contents of STRING as if it is enclosed in single quotes. SINDEX, when passed in, is the offset of the character immediately following the opening single quote; on exit, SINDEX is left pointing - to the closing single quote. */ + to the closing single quote. FLAGS currently used to allow backslash + to escape a single quote (e.g., for bash $'...'). */ static void -hist_string_extract_single_quoted (string, sindex) +hist_string_extract_single_quoted (string, sindex, flags) char *string; - int *sindex; + int *sindex, flags; { register int i; for (i = *sindex; string[i] && string[i] != '\''; i++) - ; + { + if ((flags & 1) && string[i] == '\\' && string[i+1]) + i++; + } *sindex = i; } @@ -923,7 +928,7 @@ history_expand (hstring, output) char **output; { register int j; - int i, r, l, passc, cc, modified, eindex, only_printing, dquote; + int i, r, l, passc, cc, modified, eindex, only_printing, dquote, flag; char *string; /* The output string, and its length. */ @@ -1015,7 +1020,7 @@ history_expand (hstring, output) } else if (string[i] == history_expansion_char) { - if (!cc || member (cc, history_no_expand_chars)) + if (cc == 0 || member (cc, history_no_expand_chars)) continue; /* If the calling application has set history_inhibit_expansion_function to a function that checks @@ -1043,8 +1048,9 @@ history_expand (hstring, output) else if (dquote == 0 && history_quotes_inhibit_expansion && string[i] == '\'') { /* If this is bash, single quotes inhibit history expansion. */ + flag = (i > 0 && string[i - 1] == '$'); i++; - hist_string_extract_single_quoted (string, &i); + hist_string_extract_single_quoted (string, &i, flag); } else if (history_quotes_inhibit_expansion && string[i] == '\\') { @@ -1095,7 +1101,7 @@ history_expand (hstring, output) if (strlen (mb) > 1) { ADD_STRING (mb); - break; + continue; } } #endif /* HANDLE_MULTIBYTE */ @@ -1129,8 +1135,9 @@ history_expand (hstring, output) { int quote, slen; + flag = (i > 0 && string[i - 1] == '$'); quote = i++; - hist_string_extract_single_quoted (string, &i); + hist_string_extract_single_quoted (string, &i, flag); slen = i - quote + 2; temp = (char *)xmalloc (slen); @@ -1163,7 +1170,8 @@ history_expand (hstring, output) /* If the history_expansion_char is followed by one of the characters in history_no_expand_chars, then it is not a candidate for expansion of any kind. */ - if (member (cc, history_no_expand_chars)) + if (cc == 0 || member (cc, history_no_expand_chars) || + (history_inhibit_expansion_function && (*history_inhibit_expansion_function) (string, i))) { ADD_CHAR (string[i]); break; @@ -1433,17 +1441,21 @@ history_tokenize_word (string, ind) i += 2; return i; } - else + else if ((peek == '&' && (string[i] == '>' || string[i] == '<')) || + (peek == '>' && string[i] == '&') || + (peek == '(' && (string[i] == '>' || string[i] == '<')) || /* ) */ + (peek == '(' && string[i] == '$')) /* ) */ { - if ((peek == '&' && (string[i] == '>' || string[i] == '<')) || - (peek == '>' && string[i] == '&') || - (peek == '(' && (string[i] == '>' || string[i] == '<')) || /* ) */ - (peek == '(' && string[i] == '$')) /* ) */ - { - i += 2; - return i; - } + i += 2; + return i; } +#if 0 + else if (peek == '\'' && string[i] == '$') + { + i += 2; /* XXX */ + return i; + } +#endif if (string[i] != '$') { @@ -1569,6 +1581,18 @@ history_tokenize (string) return (history_tokenize_internal (string, -1, (int *)NULL)); } +/* Free members of WORDS from START to an empty string */ +static void +freewords (words, start) + char **words; + int start; +{ + register int i; + + for (i = start; words[i]; i++) + free (words[i]); +} + /* Find and return the word which contains the character at index IND in the history line LINE. Used to save the word matched by the last history !?string? search. */ @@ -1582,12 +1606,16 @@ history_find_word (line, ind) words = history_tokenize_internal (line, ind, &wind); if (wind == -1 || words == 0) - return ((char *)NULL); + { + if (words) + freewords (words, 0); + FREE (words); + return ((char *)NULL); + } s = words[wind]; for (i = 0; i < wind; i++) free (words[i]); - for (i = wind + 1; words[i]; i++) - free (words[i]); + freewords (words, wind + 1); free (words); return s; } diff --git a/lib/readline/histfile.c b/lib/readline/histfile.c index 2f051a3..a75fc16 100644 --- a/lib/readline/histfile.c +++ b/lib/readline/histfile.c @@ -1,24 +1,23 @@ /* histfile.c - functions to manipulate the history file. */ -/* Copyright (C) 1989-2003 Free Software Foundation, Inc. +/* Copyright (C) 1989-2009 Free Software Foundation, Inc. - This file contains the GNU History Library (the Library), a set of + This file contains the GNU History Library (History), a set of routines for managing the text of previously typed lines. - The Library is free software; you can redistribute it and/or modify + History is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - The Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + History is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with History. If not, see <http://www.gnu.org/licenses/>. +*/ /* The goal is to make the implementation transparent, so that you don't have to know what data types are used, just what functions @@ -53,7 +52,9 @@ # include <unistd.h> #endif -#if defined (__EMX__) || defined (__CYGWIN__) +#include <ctype.h> + +#if defined (__EMX__) # undef HAVE_MMAP #endif @@ -103,7 +104,7 @@ int history_write_timestamps = 0; /* Does S look like the beginning of a history timestamp entry? Placeholder for more extensive tests. */ -#define HIST_TIMESTAMP_START(s) (*(s) == history_comment_char) +#define HIST_TIMESTAMP_START(s) (*(s) == history_comment_char && isdigit ((s)[1]) ) /* Return the string that should be used in the place of this filename. This only matters when you don't specify the diff --git a/lib/readline/histlib.h b/lib/readline/histlib.h index c39af71..c938a10 100644 --- a/lib/readline/histlib.h +++ b/lib/readline/histlib.h @@ -1,23 +1,23 @@ /* histlib.h -- internal definitions for the history library. */ -/* Copyright (C) 1989, 1992 Free Software Foundation, Inc. - This file contains the GNU History Library (the Library), a set of +/* Copyright (C) 1989-2009 Free Software Foundation, Inc. + + This file contains the GNU History Library (History), a set of routines for managing the text of previously typed lines. - The Library is free software; you can redistribute it and/or modify + History is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - The Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + History is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with History. If not, see <http://www.gnu.org/licenses/>. +*/ #if !defined (_HISTLIB_H_) #define _HISTLIB_H_ diff --git a/lib/readline/history.c b/lib/readline/history.c index 1ccf4db..8e613bb 100644 --- a/lib/readline/history.c +++ b/lib/readline/history.c @@ -1,24 +1,23 @@ /* history.c -- standalone history library */ -/* Copyright (C) 1989-2005 Free Software Foundation, Inc. +/* Copyright (C) 1989-2009 Free Software Foundation, Inc. - This file contains the GNU History Library (the Library), a set of + This file contains the GNU History Library (History), a set of routines for managing the text of previously typed lines. - The Library is free software; you can redistribute it and/or modify + History is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - The Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + History is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with History. If not, see <http://www.gnu.org/licenses/>. +*/ /* The goal is to make the implementation transparent, so that you don't have to know what data types are used, just what functions @@ -158,7 +157,7 @@ history_set_pos (pos) return (1); } -/* Return the current history array. The caller has to be carefull, since this +/* Return the current history array. The caller has to be careful, since this is the actual array of data, and could be bashed or made corrupt easily. The array is terminated with a NULL pointer. */ HIST_ENTRY ** @@ -319,6 +318,8 @@ add_history_time (string) { HIST_ENTRY *hs; + if (string == 0) + return; hs = the_history[history_length - 1]; FREE (hs->timestamp); hs->timestamp = savestring (string); @@ -483,7 +484,7 @@ stifle_history (max) /* Stop stifling the history. This returns the previous maximum number of history entries. The value is positive if the history - was stifled, negative if it wasn't. */ + was stifled, negative if it wasn't. */ int unstifle_history () { diff --git a/lib/readline/history.h b/lib/readline/history.h index 14ca2a9..1257e66 100644 --- a/lib/readline/history.h +++ b/lib/readline/history.h @@ -1,23 +1,23 @@ /* history.h -- the names of functions that you can call in history. */ -/* Copyright (C) 1989-2003 Free Software Foundation, Inc. - This file contains the GNU History Library (the Library), a set of +/* Copyright (C) 1989-2009 Free Software Foundation, Inc. + + This file contains the GNU History Library (History), a set of routines for managing the text of previously typed lines. - The Library is free software; you can redistribute it and/or modify + History is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - The Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + History is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with History. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef _HISTORY_H_ #define _HISTORY_H_ diff --git a/lib/readline/histsearch.c b/lib/readline/histsearch.c index 1cc5875..1ad55d2 100644 --- a/lib/readline/histsearch.c +++ b/lib/readline/histsearch.c @@ -1,24 +1,23 @@ /* histsearch.c -- searching the history list. */ -/* Copyright (C) 1989, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1989, 1992-2009 Free Software Foundation, Inc. - This file contains the GNU History Library (the Library), a set of + This file contains the GNU History Library (History), a set of routines for managing the text of previously typed lines. - The Library is free software; you can redistribute it and/or modify + History is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - The Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + History is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with History. If not, see <http://www.gnu.org/licenses/>. +*/ #define READLINE_LIBRARY diff --git a/lib/readline/input.c b/lib/readline/input.c index da5d771..b5876da 100644 --- a/lib/readline/input.c +++ b/lib/readline/input.c @@ -1,24 +1,24 @@ /* input.c -- character input functions for readline. */ -/* Copyright (C) 1994-2005 Free Software Foundation, Inc. +/* Copyright (C) 1994-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (__TANDEM) @@ -45,14 +45,7 @@ # include "ansi_stdlib.h" #endif /* HAVE_STDLIB_H */ -#if defined (HAVE_SELECT) -# if !defined (HAVE_SYS_SELECT_H) || !defined (M_UNIX) -# include <sys/time.h> -# endif -#endif /* HAVE_SELECT */ -#if defined (HAVE_SYS_SELECT_H) -# include <sys/select.h> -#endif +#include "posixselect.h" #if defined (FIONREAD_IN_SYS_IOCTL) # include <sys/ioctl.h> @@ -133,8 +126,11 @@ rl_get_char (key) return (0); *key = ibuffer[pop_index++]; - +#if 0 if (pop_index >= ibuffer_len) +#else + if (pop_index > ibuffer_len) +#endif pop_index = 0; return (1); @@ -151,7 +147,7 @@ _rl_unget_char (key) { pop_index--; if (pop_index < 0) - pop_index = ibuffer_len - 1; + pop_index = ibuffer_len; ibuffer[pop_index] = key; return (1); } @@ -187,8 +183,7 @@ rl_gather_tyi () FD_ZERO (&exceptfds); FD_SET (tty, &readfds); FD_SET (tty, &exceptfds); - timeout.tv_sec = 0; - timeout.tv_usec = _keyboard_input_timeout; + USEC_TO_TIMEVAL (_keyboard_input_timeout, timeout); result = select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout); if (result <= 0) return 0; /* Nothing to read. */ @@ -249,8 +244,10 @@ rl_gather_tyi () { while (chars_avail--) { + RL_CHECK_SIGNALS (); k = (*rl_getc_function) (rl_instream); - rl_stuff_char (k); + if (rl_stuff_char (k) == 0) + break; /* some problem; no more room */ if (k == NEWLINE || k == RETURN) break; } @@ -354,7 +351,7 @@ _rl_insert_typein (c) string[i] = '\0'; rl_insert_text (string); - free (string); + xfree (string); } /* Add KEY to the buffer of characters to be read. Returns 1 if the @@ -373,7 +370,11 @@ rl_stuff_char (key) RL_SETSTATE (RL_STATE_INPUTPENDING); } ibuffer[push_index++] = key; +#if 0 if (push_index >= ibuffer_len) +#else + if (push_index > ibuffer_len) +#endif push_index = 0; return 1; @@ -429,6 +430,7 @@ rl_read_key () while (rl_event_hook && rl_get_char (&c) == 0) { (*rl_event_hook) (); + RL_CHECK_SIGNALS (); if (rl_done) /* XXX - experimental */ return ('\n'); if (rl_gather_tyi () < 0) /* XXX - EIO */ @@ -442,6 +444,7 @@ rl_read_key () { if (rl_get_char (&c) == 0) c = (*rl_getc_function) (rl_instream); + RL_CHECK_SIGNALS (); } } @@ -457,6 +460,8 @@ rl_getc (stream) while (1) { + RL_CHECK_SIGNALS (); + #if defined (__MINGW32__) if (isatty (fileno (stream))) return (getch ()); @@ -513,20 +518,26 @@ _rl_read_mbchar (mbchar, size) char *mbchar; int size; { - int mb_len = 0; + int mb_len, c; size_t mbchar_bytes_length; wchar_t wc; mbstate_t ps, ps_back; memset(&ps, 0, sizeof (mbstate_t)); memset(&ps_back, 0, sizeof (mbstate_t)); - + + mb_len = 0; while (mb_len < size) { RL_SETSTATE(RL_STATE_MOREINPUT); - mbchar[mb_len++] = rl_read_key (); + c = rl_read_key (); RL_UNSETSTATE(RL_STATE_MOREINPUT); + if (c < 0) + break; + + mbchar[mb_len++] = c; + mbchar_bytes_length = mbrtowc (&wc, mbchar, mb_len, &ps); if (mbchar_bytes_length == (size_t)(-1)) break; /* invalid byte sequence for the current locale */ @@ -564,7 +575,7 @@ _rl_read_mbstring (first, mb, mlen) c = first; memset (mb, 0, mlen); - for (i = 0; i < mlen; i++) + for (i = 0; c >= 0 && i < mlen; i++) { mb[i] = (char)c; memset (&ps, 0, sizeof (mbstate_t)); diff --git a/lib/readline/isearch.c b/lib/readline/isearch.c index 9f67bfc..f3f46a7 100644 --- a/lib/readline/isearch.c +++ b/lib/readline/isearch.c @@ -1,29 +1,30 @@ +/* isearch.c - incremental searching */ + /* **************************************************************** */ /* */ /* I-Search and Searching */ /* */ /* **************************************************************** */ -/* Copyright (C) 1987-2005 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file contains the Readline Library (the Library), a set of - routines for providing Emacs style line input to programs that ask - for it. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The Library is free software; you can redistribute it and/or modify + Readline is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - The Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) @@ -75,7 +76,7 @@ static int _rl_isearch_cleanup PARAMS((_rl_search_cxt *, int)); static char *last_isearch_string; static int last_isearch_string_len; -static char *default_isearch_terminators = "\033\012"; +static char * const default_isearch_terminators = "\033\012"; _rl_search_cxt * _rl_scxt_alloc (type, flags) @@ -125,7 +126,7 @@ _rl_scxt_dispose (cxt, flags) FREE (cxt->allocated_line); FREE (cxt->lines); - free (cxt); + xfree (cxt); } /* Search backwards through the history looking for a string which is typed @@ -192,7 +193,7 @@ rl_display_search (search_string, reverse_p, where) strcpy (message + msglen, "': "); rl_message ("%s", message); - free (message); + xfree (message); (*rl_redisplay_function) (); } @@ -327,8 +328,15 @@ _rl_isearch_dispatch (cxt, c) rl_command_func_t *f; f = (rl_command_func_t *)NULL; - - /* Translate the keys we do something with to opcodes. */ + + if (c < 0) + { + cxt->sflags |= SF_FAILED; + cxt->history_pos = cxt->last_found_line; + return -1; + } + + /* Translate the keys we do something with to opcodes. */ if (c >= 0 && _rl_keymap[c].type == ISFUNC) { f = _rl_keymap[c].function; @@ -375,7 +383,7 @@ _rl_isearch_dispatch (cxt, c) { if (cxt->lastc >= 0 && (cxt->mb[0] && cxt->mb[1] == '\0') && ENDSRCH_CHAR (cxt->lastc)) { - /* This sets rl_pending_input to c; it will be picked up the next + /* This sets rl_pending_input to LASTC; it will be picked up the next time rl_read_key is called. */ rl_execute_next (cxt->lastc); return (0); diff --git a/lib/readline/keymaps.c b/lib/readline/keymaps.c index 70d0cc0..9379dec 100644 --- a/lib/readline/keymaps.c +++ b/lib/readline/keymaps.c @@ -1,23 +1,24 @@ /* keymaps.c -- Functions and keymaps for the GNU Readline library. */ -/* Copyright (C) 1988,1989 Free Software Foundation, Inc. +/* Copyright (C) 1988,1989-2009 Free Software Foundation, Inc. - This file is part of GNU Readline, a library for reading lines - of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - Readline is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Readline is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with Readline; see the file COPYING. If not, write to the Free - Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) @@ -56,8 +57,9 @@ Keymap rl_make_bare_keymap () { register int i; - Keymap keymap = (Keymap)xmalloc (KEYMAP_SIZE * sizeof (KEYMAP_ENTRY)); + Keymap keymap; + keymap = (Keymap)xmalloc (KEYMAP_SIZE * sizeof (KEYMAP_ENTRY)); for (i = 0; i < KEYMAP_SIZE; i++) { keymap[i].type = ISFUNC; @@ -75,7 +77,8 @@ rl_make_bare_keymap () return (keymap); } -/* Return a new keymap which is a copy of MAP. */ +/* Return a new keymap which is a copy of MAP. Just copies pointers, does + not copy text of macros or descend into child keymaps. */ Keymap rl_copy_keymap (map) Keymap map; @@ -127,7 +130,7 @@ rl_discard_keymap (map) { int i; - if (!map) + if (map == 0) return; for (i = 0; i < KEYMAP_SIZE; i++) @@ -139,6 +142,7 @@ rl_discard_keymap (map) case ISKMAP: rl_discard_keymap ((Keymap)map[i].function); + free ((char *)map[i].function); break; case ISMACR: @@ -147,3 +151,12 @@ rl_discard_keymap (map) } } } + +/* Convenience function that discards, then frees, MAP. */ +void +rl_free_keymap (map) + Keymap map; +{ + rl_discard_keymap (map); + free ((char *)map); +} diff --git a/lib/readline/keymaps.h b/lib/readline/keymaps.h index 66fa2a5..6c4611d 100644 --- a/lib/readline/keymaps.h +++ b/lib/readline/keymaps.h @@ -2,23 +2,22 @@ /* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef _KEYMAPS_H_ #define _KEYMAPS_H_ diff --git a/lib/readline/kill.c b/lib/readline/kill.c index 031ddf4..a4d6d14 100644 --- a/lib/readline/kill.c +++ b/lib/readline/kill.c @@ -2,23 +2,23 @@ /* Copyright (C) 1994 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) @@ -115,7 +115,7 @@ _rl_copy_to_kill_ring (text, append) if (slot == rl_max_kills) { register int i; - free (rl_kill_ring[0]); + xfree (rl_kill_ring[0]); for (i = 0; i < slot; i++) rl_kill_ring[i] = rl_kill_ring[i + 1]; } @@ -146,7 +146,7 @@ _rl_copy_to_kill_ring (text, append) strcpy (new, text); strcat (new, old); } - free (old); + xfree (old); free (text); rl_kill_ring[slot] = new; } @@ -686,7 +686,7 @@ rl_paste_from_clipboard (count, key) _rl_set_mark_at_pos (rl_point); rl_insert_text (ptr); if (ptr != data) - free (ptr); + xfree (ptr); CloseClipboard (); } return (0); diff --git a/lib/readline/macro.c b/lib/readline/macro.c index 00cd58d..c2fac8a 100644 --- a/lib/readline/macro.c +++ b/lib/readline/macro.c @@ -1,24 +1,24 @@ /* macro.c -- keyboard macros for readline. */ -/* Copyright (C) 1994 Free Software Foundation, Inc. +/* Copyright (C) 1994-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) @@ -152,7 +152,7 @@ _rl_pop_executing_macro () rl_executing_macro = macro_list->string; executing_macro_index = macro_list->sindex; macro_list = macro_list->next; - free (macro); + xfree (macro); } if (rl_executing_macro == 0) @@ -181,7 +181,7 @@ _rl_kill_kbd_macro () { if (current_macro) { - free (current_macro); + xfree (current_macro); current_macro = (char *) NULL; } current_macro_size = current_macro_index = 0; diff --git a/lib/readline/mbutil.c b/lib/readline/mbutil.c index 17dde53..eeb7e55 100644 --- a/lib/readline/mbutil.c +++ b/lib/readline/mbutil.c @@ -1,24 +1,24 @@ /* mbutil.c -- readline multibyte character utility functions */ -/* Copyright (C) 2001-2005 Free Software Foundation, Inc. +/* Copyright (C) 2001-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) @@ -77,7 +77,7 @@ _rl_find_next_mbchar_internal (string, seed, count, find_non_zero) char *string; int seed, count, find_non_zero; { - size_t tmp; + size_t tmp, len; mbstate_t ps; int point; wchar_t wc; @@ -91,17 +91,21 @@ _rl_find_next_mbchar_internal (string, seed, count, find_non_zero) return seed; point = seed + _rl_adjust_point (string, seed, &ps); - /* if this is true, means that seed was not pointed character - started byte. So correct the point and consume count */ + /* if this is true, means that seed was not pointing to a byte indicating + the beginning of a multibyte character. Correct the point and consume + one char. */ if (seed < point) count--; while (count > 0) { - tmp = mbrtowc (&wc, string+point, strlen(string + point), &ps); + len = strlen (string + point); + if (len == 0) + break; + tmp = mbrtowc (&wc, string+point, len, &ps); if (MB_INVALIDCH ((size_t)tmp)) { - /* invalid bytes. asume a byte represents a character */ + /* invalid bytes. assume a byte represents a character */ point++; count--; /* reset states. */ @@ -128,12 +132,10 @@ _rl_find_next_mbchar_internal (string, seed, count, find_non_zero) if (find_non_zero) { tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps); - while (tmp > 0 && wcwidth (wc) == 0) + while (MB_NULLWCH (tmp) == 0 && MB_INVALIDCH (tmp) == 0 && wcwidth (wc) == 0) { point += tmp; tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps); - if (MB_NULLWCH (tmp) || MB_INVALIDCH (tmp)) - break; } } diff --git a/lib/readline/misc.c b/lib/readline/misc.c index 94ecb25..12ae4a5 100644 --- a/lib/readline/misc.c +++ b/lib/readline/misc.c @@ -1,24 +1,24 @@ /* misc.c -- miscellaneous bindable readline functions. */ -/* Copyright (C) 1987-2005 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) @@ -146,6 +146,8 @@ _rl_arg_dispatch (cxt, c) rl_restore_prompt (); rl_clear_message (); RL_UNSETSTATE(RL_STATE_NUMERICARG); + if (key < 0) + return -1; return (_rl_dispatch (key, _rl_keymap)); } } @@ -429,6 +431,56 @@ rl_replace_from_history (entry, flags) rl_mark = rl_end; } #endif +} + +/* Process and free undo lists attached to each history entry prior to the + current entry, inclusive, reverting each line to its saved state. This + is destructive, and state about the current line is lost. This is not + intended to be called while actively editing, and the current line is + not assumed to have been added to the history list. */ +void +_rl_revert_all_lines () +{ + int hpos; + HIST_ENTRY *entry; + UNDO_LIST *ul, *saved_undo_list; + char *lbuf; + + lbuf = savestring (rl_line_buffer); + saved_undo_list = rl_undo_list; + hpos = where_history (); + + entry = (hpos == history_length) ? previous_history () : current_history (); + while (entry) + { + if (ul = (UNDO_LIST *)entry->data) + { + if (ul == saved_undo_list) + saved_undo_list = 0; + /* Set up rl_line_buffer and other variables from history entry */ + rl_replace_from_history (entry, 0); /* entry->line is now current */ + /* Undo all changes to this history entry */ + while (rl_undo_list) + rl_do_undo (); + /* And copy the reverted line back to the history entry, preserving + the timestamp. */ + FREE (entry->line); + entry->line = savestring (rl_line_buffer); + entry->data = 0; + } + entry = previous_history (); + } + + /* Restore history state */ + rl_undo_list = saved_undo_list; /* may have been set to null */ + history_set_pos (hpos); + + /* reset the line buffer */ + rl_replace_line (lbuf, 0); + _rl_set_the_line (); + + /* and clean up */ + free (lbuf); } /* **************************************************************** */ @@ -558,7 +610,7 @@ rl_vi_editing_mode (count, key) #if defined (VI_MODE) _rl_set_insert_mode (RL_IM_INSERT, 1); /* vi mode ignores insert mode */ rl_editing_mode = vi_mode; - rl_vi_insertion_mode (1, key); + rl_vi_insert_mode (1, key); #endif /* VI_MODE */ return 0; diff --git a/lib/readline/nls.c b/lib/readline/nls.c index bcee875..7f10f01 100644 --- a/lib/readline/nls.c +++ b/lib/readline/nls.c @@ -1,24 +1,24 @@ /* nls.c -- skeletal internationalization code. */ -/* Copyright (C) 1996 Free Software Foundation, Inc. +/* Copyright (C) 1996-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) diff --git a/lib/readline/parens.c b/lib/readline/parens.c index 737f767..9c98488 100644 --- a/lib/readline/parens.c +++ b/lib/readline/parens.c @@ -1,24 +1,24 @@ -/* parens.c -- Implementation of matching parentheses feature. */ +/* parens.c -- implementation of matching parentheses feature. */ -/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1987, 1989, 1992-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (__TANDEM) @@ -38,16 +38,7 @@ # include <unistd.h> #endif -#if defined (FD_SET) && !defined (HAVE_SELECT) -# define HAVE_SELECT -#endif - -#if defined (HAVE_SELECT) -# include <sys/time.h> -#endif /* HAVE_SELECT */ -#if defined (HAVE_SYS_SELECT_H) -# include <sys/select.h> -#endif +#include "posixselect.h" #if defined (HAVE_STRING_H) # include <string.h> @@ -130,8 +121,7 @@ rl_insert_close (count, invoking_key) FD_ZERO (&readfds); FD_SET (fileno (rl_instream), &readfds); - timer.tv_sec = 0; - timer.tv_usec = _paren_blink_usec; + USEC_TO_TIMEVAL (_paren_blink_usec, timer); orig_point = rl_point; rl_point = match_point; diff --git a/lib/readline/posixdir.h b/lib/readline/posixdir.h index 91f6d96..bd33694 100644 --- a/lib/readline/posixdir.h +++ b/lib/readline/posixdir.h @@ -4,19 +4,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Bash is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - License for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with Bash; see the file COPYING. If not, write to the Free - Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* This file should be included instead of <dirent.h> or <sys/dir.h>. */ diff --git a/lib/readline/posixjmp.h b/lib/readline/posixjmp.h index b52aa00..49bfecf 100644 --- a/lib/readline/posixjmp.h +++ b/lib/readline/posixjmp.h @@ -4,19 +4,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Bash is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - License for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with Bash; see the file COPYING. If not, write to the Free - Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef _POSIXJMP_H_ #define _POSIXJMP_H_ diff --git a/lib/readline/posixselect.h b/lib/readline/posixselect.h new file mode 100644 index 0000000..da6a1ac --- /dev/null +++ b/lib/readline/posixselect.h @@ -0,0 +1,47 @@ +/* posixselect.h -- wrapper for select(2) includes and definitions */ + +/* Copyright (C) 2009 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _POSIXSELECT_H_ +#define _POSIXSELECT_H_ + +#if defined (FD_SET) && !defined (HAVE_SELECT) +# define HAVE_SELECT 1 +#endif + +#if defined (HAVE_SELECT) +# if !defined (HAVE_SYS_SELECT_H) || !defined (M_UNIX) +# include <sys/time.h> +# endif +#endif /* HAVE_SELECT */ +#if defined (HAVE_SYS_SELECT_H) +# include <sys/select.h> +#endif + +#ifndef USEC_PER_SEC +# define USEC_PER_SEC 1000000 +#endif + +#define USEC_TO_TIMEVAL(us, tv) \ +do { \ + (tv).tv_sec = (us) / USEC_PER_SEC; \ + (tv).tv_usec = (us) % USEC_PER_SEC; \ +} while (0) + +#endif /* _POSIXSELECT_H_ */ diff --git a/lib/readline/posixstat.h b/lib/readline/posixstat.h index c93b528..3eb7f29 100644 --- a/lib/readline/posixstat.h +++ b/lib/readline/posixstat.h @@ -5,19 +5,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Bash is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - License for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with Bash; see the file COPYING. If not, write to the Free - Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* This file should be included instead of <sys/stat.h>. It relies on the local sys/stat.h to work though. */ diff --git a/lib/readline/readline.c b/lib/readline/readline.c index c2b7400..c0e78d4 100644 --- a/lib/readline/readline.c +++ b/lib/readline/readline.c @@ -1,25 +1,25 @@ /* readline.c -- a general facility for reading lines of input with emacs style editing and completion. */ -/* Copyright (C) 1987-2005 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) @@ -163,7 +163,7 @@ int rl_done; rl_command_func_t *rl_last_func = (rl_command_func_t *)NULL; /* Top level environment for readline_internal (). */ -procenv_t readline_top_level; +procenv_t _rl_top_level; /* The streams we interact with. */ FILE *_rl_in_stream, *_rl_out_stream; @@ -176,7 +176,7 @@ FILE *rl_outstream = (FILE *)NULL; set to 1 if there is a controlling terminal, we can get its attributes, and the attributes include `echo'. Look at rltty.c:prepare_terminal_settings for the code that sets it. */ -int readline_echoing_p = 0; +int _rl_echoing_p = 0; /* Current prompt. */ char *rl_prompt = (char *)NULL; @@ -270,6 +270,15 @@ int _rl_output_meta_chars = 0; them to equivalent readline functions at startup. */ int _rl_bind_stty_chars = 1; +/* Non-zero means to go through the history list at every newline (or + whenever rl_done is set and readline returns) and revert each line to + its initial state. */ +int _rl_revert_all_at_newline = 0; + +/* Non-zero means to honor the termios ECHOCTL bit and echo control + characters corresponding to keyboard-generated signals. */ +int _rl_echo_control_chars = 1; + /* **************************************************************** */ /* */ /* Top Level Functions */ @@ -300,6 +309,9 @@ readline (prompt) const char *prompt; { char *value; +#if 0 + int in_callback; +#endif /* If we are at EOF return a NULL string. */ if (rl_pending_input == EOF) @@ -308,6 +320,15 @@ readline (prompt) return ((char *)NULL); } +#if 0 + /* If readline() is called after installing a callback handler, temporarily + turn off the callback state to avoid ensuing messiness. Patch supplied + by the gdb folks. XXX -- disabled. This can be fooled and readline + left in a strange state by a poorly-timed longjmp. */ + if (in_callback = RL_ISSTATE (RL_STATE_CALLBACK)) + RL_UNSETSTATE (RL_STATE_CALLBACK); +#endif + rl_set_prompt (prompt); rl_initialize (); @@ -326,6 +347,11 @@ readline (prompt) rl_clear_signals (); #endif +#if 0 + if (in_callback) + RL_SETSTATE (RL_STATE_CALLBACK); +#endif + return (value); } @@ -349,7 +375,7 @@ readline_internal_setup () /* If we're not echoing, we still want to at least print a prompt, because rl_redisplay will not do it for us. If the calling application has a custom redisplay function, though, let that function handle it. */ - if (readline_echoing_p == 0 && rl_redisplay_function == rl_redisplay) + if (_rl_echoing_p == 0 && rl_redisplay_function == rl_redisplay) { if (rl_prompt && rl_already_prompted == 0) { @@ -370,11 +396,13 @@ readline_internal_setup () #if defined (VI_MODE) if (rl_editing_mode == vi_mode) - rl_vi_insertion_mode (1, 'i'); + rl_vi_insert_mode (1, 'i'); #endif /* VI_MODE */ if (rl_pre_input_hook) (*rl_pre_input_hook) (); + + RL_CHECK_SIGNALS (); } STATIC_CALLBACK char * @@ -384,6 +412,8 @@ readline_internal_teardown (eof) char *temp; HIST_ENTRY *entry; + RL_CHECK_SIGNALS (); + /* Restore the original of this history line, iff the line that we are editing was originally in the history, AND the line has changed. */ entry = current_history (); @@ -399,6 +429,9 @@ readline_internal_teardown (eof) free (temp); } + if (_rl_revert_all_at_newline) + _rl_revert_all_lines (); + /* At any rate, it is highly likely that this line has an undo list. Get rid of it now. */ if (rl_undo_list) @@ -459,7 +492,7 @@ readline_internal_charloop () #endif lk = _rl_last_command_was_kill; - code = setjmp (readline_top_level); + code = setjmp (_rl_top_level); if (code) { @@ -467,7 +500,7 @@ readline_internal_charloop () _rl_want_redisplay = 0; /* If we get here, we're not being called from something dispatched from _rl_callback_read_char(), which sets up its own value of - readline_top_level (saving and restoring the old, of course), so + _rl_top_level (saving and restoring the old, of course), so we can just return here. */ if (RL_ISSTATE (RL_STATE_CALLBACK)) return (0); @@ -517,6 +550,7 @@ readline_internal_charloop () lastc = c; _rl_dispatch ((unsigned char)c, _rl_keymap); + RL_CHECK_SIGNALS (); /* If there was no change in _rl_last_command_was_kill, then no kill has taken place. Note that if input is pending we are reading @@ -637,7 +671,6 @@ _rl_dispatch_callback (cxt) int nkey, r; /* For now */ -#if 1 /* The first time this context is used, we want to read input and dispatch on it. When traversing the chain of contexts back `up', we want to use the value from the next context down. We're simulating recursion using @@ -645,18 +678,22 @@ _rl_dispatch_callback (cxt) if ((cxt->flags & KSEQ_DISPATCHED) == 0) { nkey = _rl_subseq_getchar (cxt->okey); + if (nkey < 0) + { + _rl_abort_internal (); + return -1; + } r = _rl_dispatch_subseq (nkey, cxt->dmap, cxt->subseq_arg); cxt->flags |= KSEQ_DISPATCHED; } else r = cxt->childval; -#else - r = _rl_dispatch_subseq (nkey, cxt->dmap, cxt->subseq_arg); -#endif /* For now */ - r = _rl_subseq_result (r, cxt->oldmap, cxt->okey, (cxt->flags & KSEQ_SUBSEQ)); + if (r != -3) /* don't do this if we indicate there will be other matches */ + r = _rl_subseq_result (r, cxt->oldmap, cxt->okey, (cxt->flags & KSEQ_SUBSEQ)); + RL_CHECK_SIGNALS (); if (r == 0) /* success! */ { _rl_keyseq_chain_dispose (); @@ -743,6 +780,8 @@ _rl_dispatch_subseq (key, map, got_subseq) remember the last command executed in this variable. */ if (rl_pending_input == 0 && map[key].function != rl_digit_argument) rl_last_func = map[key].function; + + RL_CHECK_SIGNALS (); } else if (map[ANYOTHERKEY].function) { @@ -797,7 +836,7 @@ _rl_dispatch_subseq (key, map, got_subseq) { /* Return 0 only the first time, to indicate success to _rl_callback_read_char. The rest of the time, we're called - from _rl_dispatch_callback, so we return 3 to indicate + from _rl_dispatch_callback, so we return -3 to indicate special handling is necessary. */ r = RL_ISSTATE (RL_STATE_MULTIKEY) ? -3 : 0; cxt = _rl_keyseq_cxt_alloc (); @@ -861,7 +900,7 @@ _rl_subseq_result (r, map, key, got_subseq) Keymap m; int type, nt; rl_command_func_t *func, *nf; - + if (r == -2) /* We didn't match anything, and the keymap we're indexed into shadowed a function previously bound to that prefix. Call @@ -1135,6 +1174,10 @@ bind_arrow_keys () #if defined (VI_MODE) bind_arrow_keys_internal (vi_movement_keymap); + /* Unbind vi_movement_keymap[ESC] to allow users to repeatedly hit ESC + in vi command mode while still allowing the arrow keys to work. */ + if (vi_movement_keymap[ESC].type == ISKMAP) + rl_bind_keyseq_in_map ("\033", (rl_command_func_t *)NULL, vi_movement_keymap); bind_arrow_keys_internal (vi_insertion_keymap); #endif } diff --git a/lib/readline/readline.h b/lib/readline/readline.h index b71bf98..7a4ffaa 100644 --- a/lib/readline/readline.h +++ b/lib/readline/readline.h @@ -1,24 +1,23 @@ /* Readline.h -- the names of functions callable from within readline. */ -/* Copyright (C) 1987-2005 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if !defined (_READLINE_H_) #define _READLINE_H_ @@ -40,9 +39,9 @@ extern "C" { #endif /* Hex-encoded Readline version number. */ -#define RL_READLINE_VERSION 0x0502 /* Readline 5.2 */ -#define RL_VERSION_MAJOR 5 -#define RL_VERSION_MINOR 2 +#define RL_READLINE_VERSION 0x0600 /* Readline 6.0 */ +#define RL_VERSION_MAJOR 6 +#define RL_VERSION_MINOR 0 /* Readline data structures. */ @@ -96,6 +95,7 @@ extern int rl_forward_word PARAMS((int, int)); extern int rl_backward_word PARAMS((int, int)); extern int rl_refresh_line PARAMS((int, int)); extern int rl_clear_screen PARAMS((int, int)); +extern int rl_skip_csi_sequence PARAMS((int, int)); extern int rl_arrow_keys PARAMS((int, int)); /* Bindable commands for inserting and deleting text. */ @@ -151,7 +151,9 @@ extern int rl_dump_variables PARAMS((int, int)); extern int rl_complete PARAMS((int, int)); extern int rl_possible_completions PARAMS((int, int)); extern int rl_insert_completions PARAMS((int, int)); +extern int rl_old_menu_complete PARAMS((int, int)); extern int rl_menu_complete PARAMS((int, int)); +extern int rl_backward_menu_complete PARAMS((int, int)); /* Bindable commands for killing and yanking text, and managing the kill ring. */ extern int rl_kill_word PARAMS((int, int)); @@ -233,6 +235,7 @@ extern int rl_vi_append_mode PARAMS((int, int)); extern int rl_vi_append_eol PARAMS((int, int)); extern int rl_vi_eof_maybe PARAMS((int, int)); extern int rl_vi_insertion_mode PARAMS((int, int)); +extern int rl_vi_insert_mode PARAMS((int, int)); extern int rl_vi_movement_mode PARAMS((int, int)); extern int rl_vi_arg_digit PARAMS((int, int)); extern int rl_vi_change_case PARAMS((int, int)); @@ -420,6 +423,7 @@ extern int rl_set_keyboard_input_timeout PARAMS((int)); extern void rl_extend_line_buffer PARAMS((int)); extern int rl_ding PARAMS((void)); extern int rl_alphabetic PARAMS((int)); +extern void rl_free PARAMS((void *)); /* Readline signal handling, from signals.c */ extern int rl_set_signals PARAMS((void)); @@ -427,7 +431,9 @@ extern int rl_clear_signals PARAMS((void)); extern void rl_cleanup_after_signal PARAMS((void)); extern void rl_reset_after_signal PARAMS((void)); extern void rl_free_line_state PARAMS((void)); - + +extern void rl_echo_signal_char PARAMS((int)); + extern int rl_set_paren_blink_timeout PARAMS((int)); /* Undocumented. */ @@ -493,6 +499,10 @@ extern const char *rl_readline_name; readline (), and should not be assigned to directly. */ extern char *rl_prompt; +/* The prompt string that is actually displayed by rl_redisplay. Public so + applications can more easily supply their own redisplay functions. */ +extern char *rl_display_prompt; + /* The line buffer that is in use. */ extern char *rl_line_buffer; @@ -599,6 +609,10 @@ extern int rl_catch_sigwinch; filename completer. */ extern rl_compentry_func_t *rl_completion_entry_function; +/* Optional generator for menu completion. Default is + rl_completion_entry_function (rl_filename_completion_function). */ + extern rl_compentry_func_t *rl_menu_completion_entry_function; + /* If rl_ignore_some_completions_function is non-NULL it is the address of a function to call after all of the possible matches have been generated, but before the actual completion is done to the input line. @@ -664,6 +678,17 @@ extern rl_icppfunc_t *rl_directory_completion_hook; yet, so it's undocumented. */ extern rl_icppfunc_t *rl_directory_rewrite_hook; +/* If non-zero, this is the address of a function to call when reading + directory entries from the filesystem for completion and comparing + them to the partial word to be completed. The function should + either return its first argument (if no conversion takes place) or + newly-allocated memory. This can, for instance, convert filenames + between character sets for comparison against what's typed at the + keyboard. The returned value is what is added to the list of + matches. The second argument is the length of the filename to be + converted. */ +extern rl_dequote_func_t *rl_filename_rewrite_hook; + /* Backwards compatibility with previous versions of readline. */ #define rl_symbolic_link_hook rl_directory_completion_hook @@ -713,6 +738,9 @@ extern int rl_attempted_completion_over; functions. */ extern int rl_completion_type; +/* Set to the last key used to invoke one of the completion functions */ +extern int rl_completion_invoking_key; + /* Up to this many items will be displayed in response to a possible-completions call. After that, we ask the user if she is sure she wants to see them all. The default value is 100. */ @@ -739,6 +767,9 @@ extern int rl_completion_found_quote; application-specific completion function. */ extern int rl_completion_suppress_quote; +/* If non-zero, readline will sort the completion matches. On by default. */ +extern int rl_sort_completion_matches; + /* If non-zero, a slash will be appended to completed filenames that are symbolic links to directory names, subject to the value of the mark-directories variable (which is user-settable). This exists so @@ -797,8 +828,9 @@ extern int rl_inhibit_completion; #define RL_STATE_VIMOTION 0x100000 /* reading vi motion arg */ #define RL_STATE_MULTIKEY 0x200000 /* reading multiple-key command */ #define RL_STATE_VICMDONCE 0x400000 /* entered vi command mode at least once */ +#define RL_STATE_REDISPLAYING 0x800000 /* updating terminal display */ -#define RL_STATE_DONE 0x800000 /* done; accepted line */ +#define RL_STATE_DONE 0x1000000 /* done; accepted line */ #define RL_SETSTATE(x) (rl_readline_state |= (x)) #define RL_UNSETSTATE(x) (rl_readline_state &= ~(x)) diff --git a/lib/readline/rlconf.h b/lib/readline/rlconf.h index aa52b6d..39f94db 100644 --- a/lib/readline/rlconf.h +++ b/lib/readline/rlconf.h @@ -1,25 +1,23 @@ /* rlconf.h -- readline configuration definitions */ -/* Copyright (C) 1994 Free Software Foundation, Inc. +/* Copyright (C) 1992-2009 Free Software Foundation, Inc. - This file contains the Readline Library (the Library), a set of - routines for providing Emacs style line input to programs that ask - for it. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The Library is free software; you can redistribute it and/or modify + Readline is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - The Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if !defined (_RLCONF_H_) #define _RLCONF_H_ @@ -39,7 +37,6 @@ /* The next-to-last-ditch effort file name for a user-specific init file. */ #define DEFAULT_INPUTRC "~/.inputrc" -#define SYSTEM_INPUTRC "/etc/inputrc" /* The ultimate last-ditch filenname for an init file -- system-wide. */ #define SYS_INPUTRC "/etc/inputrc" diff --git a/lib/readline/rldefs.h b/lib/readline/rldefs.h index 0f6c874..0257754 100644 --- a/lib/readline/rldefs.h +++ b/lib/readline/rldefs.h @@ -2,26 +2,24 @@ for readline. This should be included after any files that define system-specific constants like _POSIX_VERSION or USG. */ -/* Copyright (C) 1987-2005 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file contains the Readline Library (the Library), a set of - routines for providing Emacs style line input to programs that ask - for it. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The Library is free software; you can redistribute it and/or modify + Readline is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - The Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if !defined (_RLDEFS_H_) #define _RLDEFS_H_ @@ -32,6 +30,10 @@ #include "rlstdc.h" +#if defined (STRCOLL_BROKEN) +# undef HAVE_STRCOLL +#endif + #if defined (_POSIX_VERSION) && !defined (TERMIOS_MISSING) # define TERMIOS_TTY_DRIVER #else diff --git a/lib/readline/rlmbutil.h b/lib/readline/rlmbutil.h index dd317e2..7716a70 100644 --- a/lib/readline/rlmbutil.h +++ b/lib/readline/rlmbutil.h @@ -1,24 +1,23 @@ /* rlmbutil.h -- utility functions for multibyte characters. */ -/* Copyright (C) 2001 Free Software Foundation, Inc. +/* Copyright (C) 2001-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if !defined (_RL_MBUTIL_H_) #define _RL_MBUTIL_H_ diff --git a/lib/readline/rlprivate.h b/lib/readline/rlprivate.h index 64aa7bd..819f127 100644 --- a/lib/readline/rlprivate.h +++ b/lib/readline/rlprivate.h @@ -1,25 +1,24 @@ /* rlprivate.h -- functions and variables global to the readline library, but not intended for use by applications. */ -/* Copyright (C) 1999-2005 Free Software Foundation, Inc. +/* Copyright (C) 1999-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if !defined (_RL_PRIVATE_H_) #define _RL_PRIVATE_H_ @@ -30,6 +29,21 @@ /************************************************************************* * * + * Convenience definitions * + * * + *************************************************************************/ + +#define EMACS_MODE() (rl_editing_mode == emacs_mode) +#define VI_COMMAND_MODE() (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap) +#define VI_INSERT_MODE() (rl_editing_mode == vi_mode && _rl_keymap == vi_insertion_keymap) + +#define RL_CHECK_SIGNALS() \ + do { \ + if (_rl_caught_signal) _rl_signal_handler (_rl_caught_signal); \ + } while (0) + +/************************************************************************* + * * * Global structs undocumented in texinfo manual and not in readline.h * * * *************************************************************************/ @@ -139,12 +153,9 @@ extern int rl_visible_stats; extern int rl_line_buffer_len; extern int rl_arg_sign; extern int rl_visible_prompt_length; -extern int readline_echoing_p; extern int rl_key_sequence_length; extern int rl_byte_oriented; -extern _rl_keyseq_cxt *_rl_kscxt; - /* display.c */ extern int rl_display_fixed; @@ -206,6 +217,7 @@ extern void _rl_callback_data_dispose PARAMS((_rl_callback_generic_arg *)); /* bind.c */ /* complete.c */ +extern void _rl_reset_completion_state PARAMS((void)); extern char _rl_find_completion_word PARAMS((int *, int *)); extern void _rl_free_match_list PARAMS((char **)); @@ -261,6 +273,8 @@ extern void _rl_start_using_history PARAMS((void)); extern int _rl_free_saved_history_line PARAMS((void)); extern void _rl_set_insert_mode PARAMS((int, int)); +extern void _rl_revert_all_lines PARAMS((void)); + /* nls.c */ extern int _rl_init_eightbit PARAMS((void)); @@ -281,6 +295,14 @@ extern int _rl_restore_tty_signals PARAMS((void)); /* search.c */ extern int _rl_nsearch_callback PARAMS((_rl_search_cxt *)); +/* signals.c */ +extern void _rl_signal_handler PARAMS((int)); + +extern void _rl_block_sigint PARAMS((void)); +extern void _rl_release_sigint PARAMS((void)); +extern void _rl_block_sigwinch PARAMS((void)); +extern void _rl_release_sigwinch PARAMS((void)); + /* terminal.c */ extern void _rl_get_screen_size PARAMS((int, int)); extern int _rl_init_terminal_io PARAMS((const char *)); @@ -314,7 +336,20 @@ extern UNDO_LIST *_rl_copy_undo_entry PARAMS((UNDO_LIST *)); extern UNDO_LIST *_rl_copy_undo_list PARAMS((UNDO_LIST *)); /* util.c */ +#if defined (USE_VARARGS) && defined (PREFER_STDARG) +extern void _rl_ttymsg (const char *, ...) __attribute__((__format__ (printf, 1, 2))); +extern void _rl_errmsg (const char *, ...) __attribute__((__format__ (printf, 1, 2))); +extern void _rl_trace (const char *, ...) __attribute__((__format__ (printf, 1, 2))); +#else +extern void _rl_ttymsg (); +extern void _rl_errmsg (); +extern void _rl_trace (); +#endif + +extern int _rl_tropen PARAMS((void)); + extern int _rl_abort_internal PARAMS((void)); +extern int _rl_null_function PARAMS((int, int)); extern char *_rl_strindex PARAMS((const char *, const char *)); extern int _rl_qsort_string_compare PARAMS((char **, char **)); extern int (_rl_uppercase_p) PARAMS((int)); @@ -337,8 +372,8 @@ extern void _rl_vi_done_inserting PARAMS((void)); *************************************************************************/ /* bind.c */ -extern const char *_rl_possible_control_prefixes[]; -extern const char *_rl_possible_meta_prefixes[]; +extern const char * const _rl_possible_control_prefixes[]; +extern const char * const _rl_possible_meta_prefixes[]; /* callback.c */ extern _rl_callback_func_t *_rl_callback_func; @@ -349,17 +384,18 @@ extern int _rl_complete_show_all; extern int _rl_complete_show_unmodified; extern int _rl_complete_mark_directories; extern int _rl_complete_mark_symlink_dirs; +extern int _rl_completion_prefix_display_length; extern int _rl_print_completions_horizontally; extern int _rl_completion_case_fold; extern int _rl_match_hidden_files; extern int _rl_page_completions; +extern int _rl_skip_completed_text; /* display.c */ extern int _rl_vis_botlin; extern int _rl_last_c_pos; extern int _rl_suppress_redisplay; extern int _rl_want_redisplay; -extern char *rl_display_prompt; /* isearch.c */ extern char *_rl_isearch_terminators; @@ -376,6 +412,7 @@ extern int _rl_history_saved_point; extern _rl_arg_cxt _rl_argcxt; /* readline.c */ +extern int _rl_echoing_p; extern int _rl_horizontal_scroll_mode; extern int _rl_mark_modified_lines; extern int _rl_bell_preference; @@ -383,6 +420,8 @@ extern int _rl_meta_flag; extern int _rl_convert_meta_chars_to_ascii; extern int _rl_output_meta_chars; extern int _rl_bind_stty_chars; +extern int _rl_revert_all_at_newline; +extern int _rl_echo_control_chars; extern char *_rl_comment_begin; extern unsigned char _rl_parsing_conditionalized_out; extern Keymap _rl_keymap; @@ -390,11 +429,22 @@ extern FILE *_rl_in_stream; extern FILE *_rl_out_stream; extern int _rl_last_command_was_kill; extern int _rl_eof_char; -extern procenv_t readline_top_level; +extern procenv_t _rl_top_level; +extern _rl_keyseq_cxt *_rl_kscxt; /* search.c */ extern _rl_search_cxt *_rl_nscxt; +/* signals.c */ +extern int _rl_interrupt_immediately; +extern int volatile _rl_caught_signal; + +extern int _rl_echoctl; + +extern int _rl_intr_char; +extern int _rl_quit_char; +extern int _rl_susp_char; + /* terminal.c */ extern int _rl_enable_keypad; extern int _rl_enable_meta; diff --git a/lib/readline/rlshell.h b/lib/readline/rlshell.h index 3c03fba..3e17d8b 100644 --- a/lib/readline/rlshell.h +++ b/lib/readline/rlshell.h @@ -1,24 +1,23 @@ /* rlshell.h -- utility functions normally provided by bash. */ -/* Copyright (C) 1999 Free Software Foundation, Inc. +/* Copyright (C) 1999-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if !defined (_RL_SHELL_H_) #define _RL_SHELL_H_ diff --git a/lib/readline/rlstdc.h b/lib/readline/rlstdc.h index 847fa9c..a6d2394 100644 --- a/lib/readline/rlstdc.h +++ b/lib/readline/rlstdc.h @@ -1,23 +1,23 @@ -/* stdc.h -- macros to make source compile on both ANSI C and K&R C - compilers. */ +/* stdc.h -- macros to make source compile on both ANSI C and K&R C compilers. */ -/* Copyright (C) 1993 Free Software Foundation, Inc. +/* Copyright (C) 1993-2009 Free Software Foundation, Inc. - This file is part of GNU Bash, the Bourne Again SHell. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - Bash is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Bash is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - License for more details. + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with Bash; see the file COPYING. If not, write to the Free - Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if !defined (_RL_STDC_H_) #define _RL_STDC_H_ diff --git a/lib/readline/rltty.c b/lib/readline/rltty.c index 0a570f8..0dd5d10 100644 --- a/lib/readline/rltty.c +++ b/lib/readline/rltty.c @@ -3,23 +3,23 @@ /* Copyright (C) 1992-2005 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) @@ -52,77 +52,10 @@ extern int errno; rl_vintfunc_t *rl_prep_term_function = rl_prep_terminal; rl_voidfunc_t *rl_deprep_term_function = rl_deprep_terminal; -static void block_sigint PARAMS((void)); -static void release_sigint PARAMS((void)); - static void set_winsize PARAMS((int)); /* **************************************************************** */ /* */ -/* Signal Management */ -/* */ -/* **************************************************************** */ - -#if defined (HAVE_POSIX_SIGNALS) -static sigset_t sigint_set, sigint_oset; -#else /* !HAVE_POSIX_SIGNALS */ -# if defined (HAVE_BSD_SIGNALS) -static int sigint_oldmask; -# endif /* HAVE_BSD_SIGNALS */ -#endif /* !HAVE_POSIX_SIGNALS */ - -static int sigint_blocked; - -/* Cause SIGINT to not be delivered until the corresponding call to - release_sigint(). */ -static void -block_sigint () -{ - if (sigint_blocked) - return; - -#if defined (HAVE_POSIX_SIGNALS) - sigemptyset (&sigint_set); - sigemptyset (&sigint_oset); - sigaddset (&sigint_set, SIGINT); - sigprocmask (SIG_BLOCK, &sigint_set, &sigint_oset); -#else /* !HAVE_POSIX_SIGNALS */ -# if defined (HAVE_BSD_SIGNALS) - sigint_oldmask = sigblock (sigmask (SIGINT)); -# else /* !HAVE_BSD_SIGNALS */ -# if defined (HAVE_USG_SIGHOLD) - sighold (SIGINT); -# endif /* HAVE_USG_SIGHOLD */ -# endif /* !HAVE_BSD_SIGNALS */ -#endif /* !HAVE_POSIX_SIGNALS */ - - sigint_blocked = 1; -} - -/* Allow SIGINT to be delivered. */ -static void -release_sigint () -{ - if (sigint_blocked == 0) - return; - -#if defined (HAVE_POSIX_SIGNALS) - sigprocmask (SIG_SETMASK, &sigint_oset, (sigset_t *)NULL); -#else -# if defined (HAVE_BSD_SIGNALS) - sigsetmask (sigint_oldmask); -# else /* !HAVE_BSD_SIGNALS */ -# if defined (HAVE_USG_SIGHOLD) - sigrelse (SIGINT); -# endif /* HAVE_USG_SIGHOLD */ -# endif /* !HAVE_BSD_SIGNALS */ -#endif /* !HAVE_POSIX_SIGNALS */ - - sigint_blocked = 0; -} - -/* **************************************************************** */ -/* */ /* Saving and Restoring the TTY */ /* */ /* **************************************************************** */ @@ -204,8 +137,9 @@ save_tty_chars (tiop) if (tiop->flags & TCHARS_SET) { - _rl_tty_chars.t_intr = tiop->tchars.t_intrc; - _rl_tty_chars.t_quit = tiop->tchars.t_quitc; + _rl_intr_char = _rl_tty_chars.t_intr = tiop->tchars.t_intrc; + _rl_quit_char = _rl_tty_chars.t_quit = tiop->tchars.t_quitc; + _rl_tty_chars.t_start = tiop->tchars.t_startc; _rl_tty_chars.t_stop = tiop->tchars.t_stopc; _rl_tty_chars.t_eof = tiop->tchars.t_eofc; @@ -215,7 +149,8 @@ save_tty_chars (tiop) if (tiop->flags & LTCHARS_SET) { - _rl_tty_chars.t_susp = tiop->ltchars.t_suspc; + _rl_susp_char = _rl_tty_chars.t_susp = tiop->ltchars.t_suspc; + _rl_tty_chars.t_dsusp = tiop->ltchars.t_dsuspc; _rl_tty_chars.t_reprint = tiop->ltchars.t_rprntc; _rl_tty_chars.t_flush = tiop->ltchars.t_flushc; @@ -268,7 +203,7 @@ set_tty_settings (tty, tiop) ioctl (tty, TIOCSETN, &(tiop->sgttyb)); tiop->flags &= ~SGTTY_SET; } - readline_echoing_p = 1; + _rl_echoing_p = 1; #if defined (TIOCLSET) if (tiop->flags & LFLAG_SET) @@ -302,7 +237,8 @@ prepare_terminal_settings (meta_flag, oldtio, tiop) int meta_flag; TIOTYPE oldtio, *tiop; { - readline_echoing_p = (oldtio.sgttyb.sg_flags & ECHO); + _rl_echoing_p = (oldtio.sgttyb.sg_flags & ECHO); + _rl_echoctl = (oldtio.sgttyb.sg_flags & ECHOCTL); /* Copy the original settings to the structure we're going to use for our settings. */ @@ -433,10 +369,10 @@ save_tty_chars (tiop) #ifdef VREPRINT _rl_tty_chars.t_reprint = tiop->c_cc[VREPRINT]; #endif - _rl_tty_chars.t_intr = tiop->c_cc[VINTR]; - _rl_tty_chars.t_quit = tiop->c_cc[VQUIT]; + _rl_intr_char = _rl_tty_chars.t_intr = tiop->c_cc[VINTR]; + _rl_quit_char = _rl_tty_chars.t_quit = tiop->c_cc[VQUIT]; #ifdef VSUSP - _rl_tty_chars.t_susp = tiop->c_cc[VSUSP]; + _rl_susp_char = _rl_tty_chars.t_susp = tiop->c_cc[VSUSP]; #endif #ifdef VDSUSP _rl_tty_chars.t_dsusp = tiop->c_cc[VDSUSP]; @@ -464,7 +400,7 @@ static void rltty_warning (msg) char *msg; { - fprintf (stderr, "readline: warning: %s\n", msg); + _rl_errmsg ("warning: %s", msg); } #endif @@ -475,7 +411,7 @@ TIOTYPE *tp; { if ((tp->c_oflag & OPOST) == 0) { - rltty_warning ("turning on OPOST for terminal\r"); + _rl_errmsg ("warning: turning on OPOST for terminal\r"); tp->c_oflag |= OPOST|ONLCR; } } @@ -500,8 +436,8 @@ _get_tty_settings (tty, tiop) } if (OUTPUT_BEING_FLUSHED (tiop)) { -#if defined (FLUSHO) && defined (_AIX41) - rltty_warning ("turning off output flushing"); +#if defined (FLUSHO) + _rl_errmsg ("warning: turning off output flushing"); tiop->c_lflag &= ~FLUSHO; break; #else @@ -580,7 +516,10 @@ prepare_terminal_settings (meta_flag, oldtio, tiop) int meta_flag; TIOTYPE oldtio, *tiop; { - readline_echoing_p = (oldtio.c_lflag & ECHO); + _rl_echoing_p = (oldtio.c_lflag & ECHO); +#if defined (ECHOCTL) + _rl_echoctl = (oldtio.c_lflag & ECHOCTL); +#endif tiop->c_lflag &= ~(ICANON | ECHO); @@ -643,7 +582,7 @@ void rl_prep_terminal (meta_flag) int meta_flag; { - readline_echoing_p = 1; + _rl_echoing_p = 1; } void @@ -663,20 +602,22 @@ rl_prep_terminal (meta_flag) return; /* Try to keep this function from being INTerrupted. */ - block_sigint (); + _rl_block_sigint (); tty = fileno (rl_instream); if (get_tty_settings (tty, &tio) < 0) { #if defined (ENOTSUP) - /* MacOS X, at least, lies about the value of errno if tcgetattr fails. */ - if (errno == ENOTTY || errno == ENOTSUP) + /* MacOS X and Linux, at least, lie about the value of errno if + tcgetattr fails. */ + if (errno == ENOTTY || errno == EINVAL || errno == ENOTSUP) #else - if (errno == ENOTTY) + if (errno == ENOTTY || errno == EINVAL) #endif - readline_echoing_p = 1; /* XXX */ - release_sigint (); + _rl_echoing_p = 1; /* XXX */ + + _rl_release_sigint (); return; } @@ -711,7 +652,7 @@ rl_prep_terminal (meta_flag) if (set_tty_settings (tty, &tio) < 0) { - release_sigint (); + _rl_release_sigint (); return; } @@ -722,7 +663,7 @@ rl_prep_terminal (meta_flag) terminal_prepped = 1; RL_SETSTATE(RL_STATE_TERMPREPPED); - release_sigint (); + _rl_release_sigint (); } /* Restore the terminal's normal settings and modes. */ @@ -735,7 +676,7 @@ rl_deprep_terminal () return; /* Try to keep this function from being interrupted. */ - block_sigint (); + _rl_block_sigint (); tty = fileno (rl_instream); @@ -746,14 +687,14 @@ rl_deprep_terminal () if (set_tty_settings (tty, &otio) < 0) { - release_sigint (); + _rl_release_sigint (); return; } terminal_prepped = 0; RL_UNSETSTATE(RL_STATE_TERMPREPPED); - release_sigint (); + _rl_release_sigint (); } #endif /* !NO_TTY_DRIVER */ @@ -862,7 +803,7 @@ set_special_char (kmap, tiop, sc, func) } #define RESET_SPECIAL(c) \ - if (c != -1 && kmap[(unsigned char)c].type == ISFUNC) + if (c != -1 && kmap[(unsigned char)c].type == ISFUNC) \ kmap[(unsigned char)c].function = rl_insert; static void diff --git a/lib/readline/rltty.h b/lib/readline/rltty.h index 142e96b..5bcc946 100644 --- a/lib/readline/rltty.h +++ b/lib/readline/rltty.h @@ -1,25 +1,23 @@ /* rltty.h - tty driver-related definitions used by some library files. */ -/* Copyright (C) 1995 Free Software Foundation, Inc. +/* Copyright (C) 1995-2009 Free Software Foundation, Inc. - This file contains the Readline Library (the Library), a set of - routines for providing Emacs style line input to programs that ask - for it. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The Library is free software; you can redistribute it and/or modify + Readline is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - The Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if !defined (_RLTTY_H_) #define _RLTTY_H_ diff --git a/lib/readline/rltypedefs.h b/lib/readline/rltypedefs.h index 862bdb8..60f29a1 100644 --- a/lib/readline/rltypedefs.h +++ b/lib/readline/rltypedefs.h @@ -1,24 +1,23 @@ /* rltypedefs.h -- Type declarations for readline functions. */ -/* Copyright (C) 2000-2004 Free Software Foundation, Inc. +/* Copyright (C) 2000-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef _RL_TYPEDEFS_H_ #define _RL_TYPEDEFS_H_ diff --git a/lib/readline/rlwinsize.h b/lib/readline/rlwinsize.h index 7838154..d198fcf 100644 --- a/lib/readline/rlwinsize.h +++ b/lib/readline/rlwinsize.h @@ -1,26 +1,24 @@ /* rlwinsize.h -- an attempt to isolate some of the system-specific defines for `struct winsize' and TIOCGWINSZ. */ -/* Copyright (C) 1997 Free Software Foundation, Inc. +/* Copyright (C) 1997-2009 Free Software Foundation, Inc. - This file contains the Readline Library (the Library), a set of - routines for providing Emacs style line input to programs that ask - for it. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The Library is free software; you can redistribute it and/or modify + Readline is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - The Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if !defined (_RLWINSIZE_H_) #define _RLWINSIZE_H_ @@ -53,5 +51,8 @@ # endif /* HAVE_SYS_PTE_H */ #endif /* !STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */ -#endif /* _RL_WINSIZE_H */ +#if defined (M_UNIX) && !defined (_SCO_DS) && !defined (tcflow) +# define tcflow(fd, action) ioctl(fd, TCXONC, action) +#endif +#endif /* _RL_WINSIZE_H */ diff --git a/lib/readline/savestring.c b/lib/readline/savestring.c index 820428d..63f467a 100644 --- a/lib/readline/savestring.c +++ b/lib/readline/savestring.c @@ -1,24 +1,24 @@ -/* savestring.c */ +/* savestring.c - function version of savestring for backwards compatibility */ /* Copyright (C) 1998,2003 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #include <config.h> diff --git a/lib/readline/search.c b/lib/readline/search.c index 33cc4fc..82984f1 100644 --- a/lib/readline/search.c +++ b/lib/readline/search.c @@ -1,25 +1,24 @@ /* search.c - code for non-incremental searching in emacs and vi modes. */ -/* Copyright (C) 1992-2005 Free Software Foundation, Inc. +/* Copyright (C) 1992-2009 Free Software Foundation, Inc. - This file is part of the Readline Library (the Library), a set of - routines for providing Emacs style line input to programs that ask - for it. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The Library is free software; you can redistribute it and/or modify + Readline is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - The Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) diff --git a/lib/readline/shell.c b/lib/readline/shell.c index 346f811..18b4f03 100644 --- a/lib/readline/shell.c +++ b/lib/readline/shell.c @@ -1,25 +1,25 @@ /* shell.c -- readline utility functions that are normally provided by bash when readline is linked as part of the shell. */ -/* Copyright (C) 1997 Free Software Foundation, Inc. +/* Copyright (C) 1997-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) diff --git a/lib/readline/signals.c b/lib/readline/signals.c index 54f2a64..4fbc019 100644 --- a/lib/readline/signals.c +++ b/lib/readline/signals.c @@ -1,24 +1,24 @@ /* signals.c -- signal handling support for readline. */ -/* Copyright (C) 1987-2005 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) @@ -40,13 +40,14 @@ # include <sys/ioctl.h> #endif /* GWINSZ_IN_SYS_IOCTL */ -#if defined (HANDLE_SIGNALS) /* Some standard library routines. */ #include "readline.h" #include "history.h" #include "rlprivate.h" +#if defined (HANDLE_SIGNALS) + #if !defined (RETSIGTYPE) # if defined (VOID_SIGHANDLER) # define RETSIGTYPE void @@ -80,6 +81,9 @@ typedef struct { SigHandler *sa_handler; int sa_mask, sa_flags; } sighandler_cxt static SigHandler *rl_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *)); static void rl_maybe_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *)); +static RETSIGTYPE rl_signal_handler PARAMS((int)); +static RETSIGTYPE _rl_handle_signal PARAMS((int)); + /* Exported variables for use by applications. */ /* If non-zero, readline will install its own signal handlers for @@ -93,6 +97,18 @@ int rl_catch_sigwinch = 1; int rl_catch_sigwinch = 0; /* for the readline state struct in readline.c */ #endif +/* Private variables. */ +int _rl_interrupt_immediately = 0; +int volatile _rl_caught_signal = 0; /* should be sig_atomic_t, but that requires including <signal.h> everywhere */ + +/* If non-zero, print characters corresponding to received signals as long as + the user has indicated his desire to do so (_rl_echo_control_chars). */ +int _rl_echoctl = 0; + +int _rl_intr_char = 0; +int _rl_quit_char = 0; +int _rl_susp_char = 0; + static int signals_set_flag; static int sigwinch_set_flag; @@ -112,10 +128,35 @@ static sighandler_cxt old_winch; /* Readline signal handler functions. */ +/* Called from RL_CHECK_SIGNALS() macro */ +RETSIGTYPE +_rl_signal_handler (sig) +{ + _rl_caught_signal = 0; /* XXX */ + + _rl_handle_signal (sig); + SIGHANDLER_RETURN; +} + static RETSIGTYPE rl_signal_handler (sig) int sig; { + if (_rl_interrupt_immediately || RL_ISSTATE(RL_STATE_CALLBACK)) + { + _rl_interrupt_immediately = 0; + _rl_handle_signal (sig); + } + else + _rl_caught_signal = sig; + + SIGHANDLER_RETURN; +} + +static RETSIGTYPE +_rl_handle_signal (sig) + int sig; +{ #if defined (HAVE_POSIX_SIGNALS) sigset_t set; #else /* !HAVE_POSIX_SIGNALS */ @@ -142,6 +183,7 @@ rl_signal_handler (sig) switch (sig) { case SIGINT: + _rl_reset_completion_state (); rl_free_line_state (); /* FALLTHROUGH */ @@ -157,6 +199,7 @@ rl_signal_handler (sig) #if defined (SIGQUIT) case SIGQUIT: #endif + rl_echo_signal_char (sig); rl_cleanup_after_signal (); #if defined (HAVE_POSIX_SIGNALS) @@ -252,7 +295,11 @@ rl_set_sighandler (sig, handler, ohandler) struct sigaction act; act.sa_handler = handler; +# if defined (SIGWINCH) act.sa_flags = (sig == SIGWINCH) ? SA_RESTART : 0; +# else + act.sa_flags = 0; +# endif /* SIGWINCH */ sigemptyset (&act.sa_mask); sigemptyset (&ohandler->sa_mask); sigaction (sig, &act, &old_handler); @@ -300,7 +347,7 @@ rl_set_signals () sigemptyset (&bset); sigaddset (&bset, SIGINT); - sigaddset (&bset, SIGINT); + sigaddset (&bset, SIGTERM); #if defined (SIGQUIT) sigaddset (&bset, SIGQUIT); #endif @@ -464,3 +511,160 @@ rl_free_line_state () } #endif /* HANDLE_SIGNALS */ + +/* **************************************************************** */ +/* */ +/* SIGINT Management */ +/* */ +/* **************************************************************** */ + +#if defined (HAVE_POSIX_SIGNALS) +static sigset_t sigint_set, sigint_oset; +static sigset_t sigwinch_set, sigwinch_oset; +#else /* !HAVE_POSIX_SIGNALS */ +# if defined (HAVE_BSD_SIGNALS) +static int sigint_oldmask; +static int sigwinch_oldmask; +# endif /* HAVE_BSD_SIGNALS */ +#endif /* !HAVE_POSIX_SIGNALS */ + +static int sigint_blocked; +static int sigwinch_blocked; + +/* Cause SIGINT to not be delivered until the corresponding call to + release_sigint(). */ +void +_rl_block_sigint () +{ + if (sigint_blocked) + return; + +#if defined (HAVE_POSIX_SIGNALS) + sigemptyset (&sigint_set); + sigemptyset (&sigint_oset); + sigaddset (&sigint_set, SIGINT); + sigprocmask (SIG_BLOCK, &sigint_set, &sigint_oset); +#else /* !HAVE_POSIX_SIGNALS */ +# if defined (HAVE_BSD_SIGNALS) + sigint_oldmask = sigblock (sigmask (SIGINT)); +# else /* !HAVE_BSD_SIGNALS */ +# if defined (HAVE_USG_SIGHOLD) + sighold (SIGINT); +# endif /* HAVE_USG_SIGHOLD */ +# endif /* !HAVE_BSD_SIGNALS */ +#endif /* !HAVE_POSIX_SIGNALS */ + + sigint_blocked = 1; +} + +/* Allow SIGINT to be delivered. */ +void +_rl_release_sigint () +{ + if (sigint_blocked == 0) + return; + +#if defined (HAVE_POSIX_SIGNALS) + sigprocmask (SIG_SETMASK, &sigint_oset, (sigset_t *)NULL); +#else +# if defined (HAVE_BSD_SIGNALS) + sigsetmask (sigint_oldmask); +# else /* !HAVE_BSD_SIGNALS */ +# if defined (HAVE_USG_SIGHOLD) + sigrelse (SIGINT); +# endif /* HAVE_USG_SIGHOLD */ +# endif /* !HAVE_BSD_SIGNALS */ +#endif /* !HAVE_POSIX_SIGNALS */ + + sigint_blocked = 0; +} + +/* Cause SIGWINCH to not be delivered until the corresponding call to + release_sigwinch(). */ +void +_rl_block_sigwinch () +{ + if (sigwinch_blocked) + return; + +#if defined (HAVE_POSIX_SIGNALS) + sigemptyset (&sigwinch_set); + sigemptyset (&sigwinch_oset); + sigaddset (&sigwinch_set, SIGWINCH); + sigprocmask (SIG_BLOCK, &sigwinch_set, &sigwinch_oset); +#else /* !HAVE_POSIX_SIGNALS */ +# if defined (HAVE_BSD_SIGNALS) + sigwinch_oldmask = sigblock (sigmask (SIGWINCH)); +# else /* !HAVE_BSD_SIGNALS */ +# if defined (HAVE_USG_SIGHOLD) + sighold (SIGWINCH); +# endif /* HAVE_USG_SIGHOLD */ +# endif /* !HAVE_BSD_SIGNALS */ +#endif /* !HAVE_POSIX_SIGNALS */ + + sigwinch_blocked = 1; +} + +/* Allow SIGWINCH to be delivered. */ +void +_rl_release_sigwinch () +{ + if (sigwinch_blocked == 0) + return; + +#if defined (HAVE_POSIX_SIGNALS) + sigprocmask (SIG_SETMASK, &sigwinch_oset, (sigset_t *)NULL); +#else +# if defined (HAVE_BSD_SIGNALS) + sigsetmask (sigwinch_oldmask); +# else /* !HAVE_BSD_SIGNALS */ +# if defined (HAVE_USG_SIGHOLD) + sigrelse (SIGWINCH); +# endif /* HAVE_USG_SIGHOLD */ +# endif /* !HAVE_BSD_SIGNALS */ +#endif /* !HAVE_POSIX_SIGNALS */ + + sigwinch_blocked = 0; +} + +/* **************************************************************** */ +/* */ +/* Echoing special control characters */ +/* */ +/* **************************************************************** */ +void +rl_echo_signal_char (sig) + int sig; +{ + char cstr[3]; + int cslen, c; + + if (_rl_echoctl == 0 || _rl_echo_control_chars == 0) + return; + + switch (sig) + { + case SIGINT: c = _rl_intr_char; break; +#if defined (SIGQUIT) + case SIGQUIT: c = _rl_quit_char; break; +#endif +#if defined (SIGTSTP) + case SIGTSTP: c = _rl_susp_char; break; +#endif + default: return; + } + + if (CTRL_CHAR (c) || c == RUBOUT) + { + cstr[0] = '^'; + cstr[1] = CTRL_CHAR (c) ? UNCTRL (c) : '?'; + cstr[cslen = 2] = '\0'; + } + else + { + cstr[0] = c; + cstr[cslen = 1] = '\0'; + } + + _rl_output_some_chars (cstr, cslen); +} diff --git a/lib/readline/tcap.h b/lib/readline/tcap.h index 58ab894..9d09b7a 100644 --- a/lib/readline/tcap.h +++ b/lib/readline/tcap.h @@ -1,25 +1,23 @@ /* tcap.h -- termcap library functions and variables. */ -/* Copyright (C) 1996 Free Software Foundation, Inc. +/* Copyright (C) 1996-2009 Free Software Foundation, Inc. - This file contains the Readline Library (the Library), a set of - routines for providing Emacs style line input to programs that ask - for it. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The Library is free software; you can redistribute it and/or modify + Readline is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - The Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if !defined (_RLTCAP_H_) #define _RLTCAP_H_ diff --git a/lib/readline/terminal.c b/lib/readline/terminal.c index 547f6f5..ee13092 100644 --- a/lib/readline/terminal.c +++ b/lib/readline/terminal.c @@ -1,24 +1,24 @@ /* terminal.c -- controlling the terminal with termcap. */ -/* Copyright (C) 1996-2006 Free Software Foundation, Inc. +/* Copyright (C) 1996-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) @@ -350,24 +350,24 @@ rl_reset_screen_size () void rl_resize_terminal () { - if (readline_echoing_p) + if (_rl_echoing_p) { _rl_get_screen_size (fileno (rl_instream), 1); if (CUSTOM_REDISPLAY_FUNC ()) rl_forced_update_display (); - else + else if (RL_ISSTATE(RL_STATE_REDISPLAYING) == 0) _rl_redisplay_after_sigwinch (); } } struct _tc_string { - const char *tc_var; + const char * const tc_var; char **tc_value; }; /* This should be kept sorted, just in case we decide to change the search algorithm to something smarter. */ -static struct _tc_string tc_strings[] = +static const struct _tc_string tc_strings[] = { { "@7", &_rl_term_at7 }, { "DC", &_rl_term_DC }, @@ -528,8 +528,8 @@ _rl_init_terminal_io (terminal_name) /* Check to see if this terminal has a meta key and clear the capability variables if there is none. */ - term_has_meta = (tgetflag ("km") || tgetflag ("MT")); - if (!term_has_meta) + term_has_meta = tgetflag ("km") != 0; + if (term_has_meta == 0) _rl_term_mm = _rl_term_mo = (char *)NULL; /* Attempt to find and bind the arrow keys. Do not override already @@ -641,10 +641,10 @@ _rl_backspace (count) int rl_crlf () { -#if defined (NEW_TTY_DRIVER) +#if defined (NEW_TTY_DRIVER) || defined (__MINT__) if (_rl_term_cr) tputs (_rl_term_cr, 1, _rl_output_character_function); -#endif /* NEW_TTY_DRIVER */ +#endif /* NEW_TTY_DRIVER || __MINT__ */ putc ('\n', _rl_out_stream); return 0; } @@ -653,7 +653,7 @@ rl_crlf () int rl_ding () { - if (readline_echoing_p) + if (_rl_echoing_p) { switch (_rl_bell_preference) { diff --git a/lib/readline/text.c b/lib/readline/text.c index 399a48c..fc39189 100644 --- a/lib/readline/text.c +++ b/lib/readline/text.c @@ -1,24 +1,24 @@ /* text.c -- text handling commands for readline. */ -/* Copyright (C) 1987-2005 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) @@ -67,6 +67,10 @@ static int _rl_insert_next_callback PARAMS((_rl_callback_generic_arg *)); static int _rl_char_search_callback PARAMS((_rl_callback_generic_arg *)); #endif +/* The largest chunk of text that can be inserted in one call to + rl_insert_text. Text blocks larger than this are divided. */ +#define TEXT_COUNT_MAX 1024 + /* **************************************************************** */ /* */ /* Insert and Delete */ @@ -185,10 +189,13 @@ _rl_replace_text (text, start, end) { int n; + n = 0; rl_begin_undo_group (); - rl_delete_text (start, end + 1); + if (start <= end) + rl_delete_text (start, end + 1); rl_point = start; - n = rl_insert_text (text); + if (*text) + n = rl_insert_text (text); rl_end_undo_group (); return n; @@ -260,7 +267,7 @@ rl_forward_byte (count, key) { int end = rl_point + count; #if defined (VI_MODE) - int lend = rl_end > 0 ? rl_end - (rl_editing_mode == vi_mode) : rl_end; + int lend = rl_end > 0 ? rl_end - (VI_COMMAND_MODE()) : rl_end; #else int lend = rl_end; #endif @@ -296,10 +303,16 @@ rl_forward_char (count, key) if (count > 0) { + if (rl_point == rl_end && EMACS_MODE()) + { + rl_ding (); + return 0; + } + point = _rl_find_next_mbchar (rl_line_buffer, rl_point, count, MB_FIND_NONZERO); #if defined (VI_MODE) - if (rl_end <= point && rl_editing_mode == vi_mode) + if (point >= rl_end && VI_COMMAND_MODE()) point = _rl_find_prev_mbchar (rl_line_buffer, rl_end, MB_FIND_NONZERO); #endif @@ -565,6 +578,21 @@ rl_clear_screen (count, key) } int +rl_skip_csi_sequence (count, key) + int count, key; +{ + int ch; + + RL_SETSTATE (RL_STATE_MOREINPUT); + do + ch = rl_read_key (); + while (ch >= 0x20 && ch < 0x40); + RL_UNSETSTATE (RL_STATE_MOREINPUT); + + return 0; +} + +int rl_arrow_keys (count, c) int count, c; { @@ -701,7 +729,7 @@ _rl_insert_char (count, c) /* If we can optimize, then do it. But don't let people crash readline because of extra large arguments. */ - if (count > 1 && count <= 1024) + if (count > 1 && count <= TEXT_COUNT_MAX) { #if defined (HANDLE_MULTIBYTE) string_size = count * incoming_length; @@ -729,11 +757,11 @@ _rl_insert_char (count, c) return 0; } - if (count > 1024) + if (count > TEXT_COUNT_MAX) { int decreaser; #if defined (HANDLE_MULTIBYTE) - string_size = incoming_length * 1024; + string_size = incoming_length * TEXT_COUNT_MAX; string = (char *)xmalloc (1 + string_size); i = 0; @@ -745,7 +773,7 @@ _rl_insert_char (count, c) while (count) { - decreaser = (count > 1024) ? 1024 : count; + decreaser = (count > TEXT_COUNT_MAX) ? TEXT_COUNT_MAX : count; string[decreaser*incoming_length] = '\0'; rl_insert_text (string); count -= decreaser; @@ -755,14 +783,14 @@ _rl_insert_char (count, c) incoming_length = 0; stored_count = 0; #else /* !HANDLE_MULTIBYTE */ - char str[1024+1]; + char str[TEXT_COUNT_MAX+1]; - for (i = 0; i < 1024; i++) + for (i = 0; i < TEXT_COUNT_MAX; i++) str[i] = c; while (count) { - decreaser = (count > 1024 ? 1024 : count); + decreaser = (count > TEXT_COUNT_MAX ? TEXT_COUNT_MAX : count); str[decreaser] = '\0'; rl_insert_text (str); count -= decreaser; @@ -857,6 +885,9 @@ _rl_insert_next (count) c = rl_read_key (); RL_UNSETSTATE(RL_STATE_MOREINPUT); + if (c < 0) + return -1; + #if defined (HANDLE_SIGNALS) if (RL_ISSTATE (RL_STATE_CALLBACK) == 0) _rl_restore_tty_signals (); @@ -940,7 +971,7 @@ rl_newline (count, key) if (rl_erase_empty_line && rl_point == 0 && rl_end == 0) return 0; - if (readline_echoing_p) + if (_rl_echoing_p) _rl_update_final (); return 0; } @@ -1120,7 +1151,7 @@ int rl_delete_horizontal_space (count, ignore) int count, ignore; { - int start = rl_point; + int start; while (rl_point && whitespace (rl_line_buffer[rl_point - 1])) rl_point--; @@ -1238,6 +1269,7 @@ rl_change_case (count, op) wchar_t wc, nwc; char mb[MB_LEN_MAX+1]; int mlen; + size_t m; mbstate_t mps; #endif @@ -1290,7 +1322,11 @@ rl_change_case (count, op) #if defined (HANDLE_MULTIBYTE) else { - mbrtowc (&wc, rl_line_buffer + start, end - start, &mps); + m = mbrtowc (&wc, rl_line_buffer + start, end - start, &mps); + if (MB_INVALIDCH (m)) + wc = (wchar_t)rl_line_buffer[start]; + else if (MB_NULLWCH (m)) + wc = L'\0'; nwc = (nop == UpCase) ? _rl_to_wupper (wc) : _rl_to_wlower (wc); if (nwc != wc) /* just skip unchanged characters */ { @@ -1520,6 +1556,9 @@ _rl_char_search (count, fdir, bdir) mb_len = _rl_read_mbchar (mbchar, MB_LEN_MAX); + if (mb_len <= 0) + return -1; + if (count < 0) return (_rl_char_search_internal (-count, bdir, mbchar, mb_len)); else @@ -1536,6 +1575,9 @@ _rl_char_search (count, fdir, bdir) c = rl_read_key (); RL_UNSETSTATE(RL_STATE_MOREINPUT); + if (c < 0) + return -1; + if (count < 0) return (_rl_char_search_internal (-count, bdir, c)); else diff --git a/lib/readline/tilde.c b/lib/readline/tilde.c index 1b76c9f..088ff15 100644 --- a/lib/readline/tilde.c +++ b/lib/readline/tilde.c @@ -1,23 +1,23 @@ /* tilde.c -- Tilde expansion code (~/foo := $HOME/foo). */ -/* Copyright (C) 1988,1989 Free Software Foundation, Inc. +/* Copyright (C) 1988-2009 Free Software Foundation, Inc. - This file is part of GNU Readline, a library for reading lines - of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - Readline is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Readline is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with Readline; see the file COPYING. If not, write to the Free - Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if defined (HAVE_CONFIG_H) # include <config.h> @@ -236,7 +236,7 @@ tilde_expand (string) string += end; expansion = tilde_expand_word (tilde_word); - free (tilde_word); + xfree (tilde_word); len = strlen (expansion); #ifdef __CYGWIN__ @@ -251,7 +251,7 @@ tilde_expand (string) strcpy (result + result_index, expansion); result_index += len; } - free (expansion); + xfree (expansion); } result[result_index] = '\0'; @@ -377,7 +377,7 @@ tilde_expand_word (filename) if (expansion) { dirname = glue_prefix_and_suffix (expansion, filename, user_len); - free (username); + xfree (username); free (expansion); return (dirname); } @@ -414,7 +414,7 @@ tilde_expand_word (filename) dirname = glue_prefix_and_suffix (user_entry->pw_dir, filename, user_len); #endif - free (username); + xfree (username); #if defined (HAVE_GETPWENT) endpwent (); #endif diff --git a/lib/readline/tilde.h b/lib/readline/tilde.h index c58ce20..e26dd04 100644 --- a/lib/readline/tilde.h +++ b/lib/readline/tilde.h @@ -1,25 +1,24 @@ /* tilde.h: Externally available variables and function in libtilde.a. */ -/* Copyright (C) 1992 Free Software Foundation, Inc. +/* Copyright (C) 1992-2009 Free Software Foundation, Inc. - This file contains the Readline Library (the Library), a set of + This file contains the Readline Library (Readline), a set of routines for providing Emacs style line input to programs that ask for it. - The Library is free software; you can redistribute it and/or modify + Readline is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - The Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if !defined (_TILDE_H_) # define _TILDE_H_ diff --git a/lib/readline/undo.c b/lib/readline/undo.c index 9d9bd25..eb042b2 100644 --- a/lib/readline/undo.c +++ b/lib/readline/undo.c @@ -1,25 +1,25 @@ /* readline.c -- a general facility for reading lines of input with emacs style editing and completion. */ -/* Copyright (C) 1987, 1989, 1992, 2006 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) @@ -114,9 +114,9 @@ rl_free_undo_list () rl_undo_list = rl_undo_list->next; if (release->what == UNDO_DELETE) - free (release->text); + xfree (release->text); - free (release); + xfree (release); } rl_undo_list = (UNDO_LIST *)NULL; replace_history_data (-1, (histdata_t *)orig_list, (histdata_t *)NULL); @@ -139,6 +139,9 @@ _rl_copy_undo_list (head) { UNDO_LIST *list, *new, *roving, *c; + if (head == 0) + return head; + list = head; new = 0; while (list) @@ -171,7 +174,7 @@ rl_do_undo () start = end = waiting_for_begin = 0; do { - if (!rl_undo_list) + if (rl_undo_list == 0) return (0); _rl_doing_an_undo = 1; @@ -191,7 +194,7 @@ rl_do_undo () case UNDO_DELETE: rl_point = start; rl_insert_text (rl_undo_list->text); - free (rl_undo_list->text); + xfree (rl_undo_list->text); break; /* Undoing inserts means deleting some text. */ @@ -221,7 +224,7 @@ rl_do_undo () rl_undo_list = rl_undo_list->next; replace_history_data (-1, (histdata_t *)release, (histdata_t *)rl_undo_list); - free (release); + xfree (release); } while (waiting_for_begin); @@ -291,7 +294,7 @@ int rl_revert_line (count, key) int count, key; { - if (!rl_undo_list) + if (rl_undo_list == 0) rl_ding (); else { diff --git a/lib/readline/util.c b/lib/readline/util.c index e44ef64..6bb64c2 100644 --- a/lib/readline/util.c +++ b/lib/readline/util.c @@ -1,24 +1,24 @@ /* util.c -- readline utility functions */ -/* Copyright (C) 1987-2005 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) @@ -66,7 +66,7 @@ in words, or 1 if it is. */ int _rl_allow_pathname_alphabetic_chars = 0; -static const char *pathname_alphabetic_chars = "/-_=~.#$"; +static const char * const pathname_alphabetic_chars = "/-_=~.#$"; int rl_alphabetic (c) @@ -81,8 +81,7 @@ rl_alphabetic (c) #if defined (HANDLE_MULTIBYTE) int -_rl_walphabetic (wc) - wchar_t wc; +_rl_walphabetic (wchar_t wc) { int c; @@ -109,7 +108,7 @@ _rl_abort_internal () _rl_pop_executing_macro (); rl_last_func = (rl_command_func_t *)NULL; - longjmp (readline_top_level, 1); + longjmp (_rl_top_level, 1); return (0); } @@ -121,6 +120,13 @@ rl_abort (count, key) } int +_rl_null_function (count, key) + int count, key; +{ + return 0; +} + +int rl_tty_status (count, key) int count, key; { @@ -185,6 +191,7 @@ rl_tilde_expand (ignore, key) { homedir = tilde_expand ("~"); _rl_replace_text (homedir, start, end); + xfree (homedir); return (0); } else if (rl_line_buffer[start] != '~') @@ -212,14 +219,96 @@ rl_tilde_expand (ignore, key) strncpy (temp, rl_line_buffer + start, len); temp[len] = '\0'; homedir = tilde_expand (temp); - free (temp); + xfree (temp); _rl_replace_text (homedir, start, end); + xfree (homedir); } return (0); } +#if defined (USE_VARARGS) +void +#if defined (PREFER_STDARG) +_rl_ttymsg (const char *format, ...) +#else +_rl_ttymsg (va_alist) + va_dcl +#endif +{ + va_list args; +#if defined (PREFER_VARARGS) + char *format; +#endif + +#if defined (PREFER_STDARG) + va_start (args, format); +#else + va_start (args); + format = va_arg (args, char *); +#endif + + fprintf (stderr, "readline: "); + vfprintf (stderr, format, args); + fprintf (stderr, "\n"); + fflush (stderr); + + va_end (args); + + rl_forced_update_display (); +} + +void +#if defined (PREFER_STDARG) +_rl_errmsg (const char *format, ...) +#else +_rl_errmsg (va_alist) + va_dcl +#endif +{ + va_list args; +#if defined (PREFER_VARARGS) + char *format; +#endif + +#if defined (PREFER_STDARG) + va_start (args, format); +#else + va_start (args); + format = va_arg (args, char *); +#endif + + fprintf (stderr, "readline: "); + vfprintf (stderr, format, args); + fprintf (stderr, "\n"); + fflush (stderr); + + va_end (args); +} + +#else /* !USE_VARARGS */ +void +_rl_ttymsg (format, arg1, arg2) + char *format; +{ + fprintf (stderr, "readline: "); + fprintf (stderr, format, arg1, arg2); + fprintf (stderr, "\n"); + + rl_forced_update_display (); +} + +void +_rl_errmsg (format, arg1, arg2) + char *format; +{ + fprintf (stderr, "readline: "); + fprintf (stderr, format, arg1, arg2); + fprintf (stderr, "\n"); +} +#endif /* !USE_VARARGS */ + /* **************************************************************** */ /* */ /* String Utility Functions */ @@ -344,6 +433,16 @@ FUNCTION_FOR_MACRO (_rl_to_lower) FUNCTION_FOR_MACRO (_rl_to_upper) FUNCTION_FOR_MACRO (_rl_uppercase_p) +/* A convenience function, to force memory deallocation to be performed + by readline. DLLs on Windows apparently require this. */ +void +rl_free (mem) + void *mem; +{ + if (mem) + free (mem); +} + /* Backwards compatibility, now that savestring has been removed from all `public' readline header files. */ #undef _rl_savestring @@ -353,3 +452,60 @@ _rl_savestring (s) { return (strcpy ((char *)xmalloc (1 + (int)strlen (s)), (s))); } + +#if defined (USE_VARARGS) +static FILE *_rl_tracefp; + +void +#if defined (PREFER_STDARG) +_rl_trace (const char *format, ...) +#else +_rl_trace (va_alist) + va_dcl +#endif +{ + va_list args; +#if defined (PREFER_VARARGS) + char *format; +#endif + +#if defined (PREFER_STDARG) + va_start (args, format); +#else + va_start (args); + format = va_arg (args, char *); +#endif + + if (_rl_tracefp == 0) + _rl_tropen (); + vfprintf (_rl_tracefp, format, args); + fprintf (_rl_tracefp, "\n"); + fflush (_rl_tracefp); + + va_end (args); +} + +int +_rl_tropen () +{ + char fnbuf[128]; + + if (_rl_tracefp) + fclose (_rl_tracefp); + sprintf (fnbuf, "/var/tmp/rltrace.%ld", getpid()); + unlink(fnbuf); + _rl_tracefp = fopen (fnbuf, "w+"); + return _rl_tracefp != 0; +} + +int +_rl_trclose () +{ + int r; + + r = fclose (_rl_tracefp); + _rl_tracefp = 0; + return r; +} + +#endif diff --git a/lib/readline/vi_keymap.c b/lib/readline/vi_keymap.c index 4b48c75..ba5a27b 100644 --- a/lib/readline/vi_keymap.c +++ b/lib/readline/vi_keymap.c @@ -1,24 +1,23 @@ /* vi_keymap.c -- the keymap for vi_mode in readline (). */ -/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if !defined (BUFSIZ) #include <stdio.h> @@ -151,7 +150,7 @@ KEYMAP_ENTRY_ARRAY vi_movement_keymap = { { ISFUNC, rl_vi_char_search }, /* f */ { ISFUNC, (rl_command_func_t *)0x0 }, /* g */ { ISFUNC, rl_backward_char }, /* h */ - { ISFUNC, rl_vi_insertion_mode }, /* i */ + { ISFUNC, rl_vi_insert_mode }, /* i */ { ISFUNC, rl_get_next_history }, /* j */ { ISFUNC, rl_get_previous_history }, /* k */ { ISFUNC, rl_forward_char }, /* l */ @@ -327,9 +326,9 @@ KEYMAP_ENTRY_ARRAY vi_insertion_keymap = { { ISFUNC, rl_insert }, /* Control-k */ { ISFUNC, rl_insert }, /* Control-l */ { ISFUNC, rl_newline }, /* Control-m */ - { ISFUNC, rl_insert }, /* Control-n */ + { ISFUNC, rl_menu_complete}, /* Control-n */ { ISFUNC, rl_insert }, /* Control-o */ - { ISFUNC, rl_insert }, /* Control-p */ + { ISFUNC, rl_backward_menu_complete }, /* Control-p */ { ISFUNC, rl_insert }, /* Control-q */ { ISFUNC, rl_reverse_search_history }, /* Control-r */ { ISFUNC, rl_forward_search_history }, /* Control-s */ diff --git a/lib/readline/vi_mode.c b/lib/readline/vi_mode.c index d0b7e33..2a120c0 100644 --- a/lib/readline/vi_mode.c +++ b/lib/readline/vi_mode.c @@ -1,25 +1,25 @@ /* vi_mode.c -- A vi emulation mode for Bash. Derived from code written by Jeff Sparkes (jsparkes@bnr.ca). */ -/* Copyright (C) 1987-2005 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY /* **************************************************************** */ @@ -69,7 +69,7 @@ int _rl_vi_last_command = 'i'; /* default `.' puts you in insert mode */ static int _rl_vi_doing_insert; /* Command keys which do movement for xxx_to commands. */ -static const char *vi_motion = " hl^$0ftFT;,%wbeWBE|"; +static const char * const vi_motion = " hl^$0ftFT;,%wbeWBE|`"; /* Keymap used for vi replace characters. Created dynamically since rarely used. */ @@ -101,7 +101,7 @@ static int _rl_vi_last_key_before_insert; static int vi_redoing; /* Text modification commands. These are the `redoable' commands. */ -static const char *vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~"; +static const char * const vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~"; /* Arrays for the saved marks. */ static int vi_mark_chars['z' - 'a' + 1]; @@ -131,9 +131,10 @@ static int _rl_vi_callback_char_search PARAMS((_rl_callback_generic_arg *)); void _rl_vi_initialize_line () { - register int i; + register int i, n; - for (i = 0; i < sizeof (vi_mark_chars) / sizeof (int); i++) + n = sizeof (vi_mark_chars) / sizeof (vi_mark_chars[0]); + for (i = 0; i < n; i++) vi_mark_chars[i] = -1; RL_UNSETSTATE(RL_STATE_VICMDONCE); @@ -211,6 +212,15 @@ rl_vi_redo (count, c) if (rl_point > 0) _rl_vi_backup (); } + /* Ditto for redoing an insert with `I', but move to the beginning of the + line like the `I' command does. */ + else if (_rl_vi_last_command == 'I' && vi_insert_buffer && *vi_insert_buffer) + { + rl_beg_of_line (1, 'I'); + _rl_vi_stuff_insert (count); + if (rl_point > 0) + _rl_vi_backup (); + } /* Ditto for redoing an insert with `a', but move forward a character first like the `a' command does. */ else if (_rl_vi_last_command == 'a' && vi_insert_buffer && *vi_insert_buffer) @@ -220,6 +230,15 @@ rl_vi_redo (count, c) if (rl_point > 0) _rl_vi_backup (); } + /* Ditto for redoing an insert with `A', but move to the end of the line + like the `A' command does. */ + else if (_rl_vi_last_command == 'A' && vi_insert_buffer && *vi_insert_buffer) + { + rl_end_of_line (1, 'A'); + _rl_vi_stuff_insert (count); + if (rl_point > 0) + _rl_vi_backup (); + } else r = _rl_dispatch (_rl_vi_last_command, _rl_keymap); vi_redoing = 0; @@ -584,7 +603,7 @@ rl_vi_insert_beg (count, key) int count, key; { rl_beg_of_line (1, key); - rl_vi_insertion_mode (1, key); + rl_vi_insert_mode (1, key); return (0); } @@ -647,6 +666,14 @@ rl_vi_insertion_mode (count, key) return (0); } +int +rl_vi_insert_mode (count, key) + int count, key; +{ + rl_vi_start_inserting (key, 1, rl_arg_sign); + return (0); +} + static void _rl_vi_save_insert (up) UNDO_LIST *up; @@ -690,7 +717,10 @@ _rl_vi_done_inserting () } else { - if ((_rl_vi_last_key_before_insert == 'i' || _rl_vi_last_key_before_insert == 'a') && rl_undo_list) + if (rl_undo_list && (_rl_vi_last_key_before_insert == 'i' || + _rl_vi_last_key_before_insert == 'a' || + _rl_vi_last_key_before_insert == 'I' || + _rl_vi_last_key_before_insert == 'A')) _rl_vi_save_insert (rl_undo_list); /* XXX - Other keys probably need to be checked. */ else if (_rl_vi_last_key_before_insert == 'C') @@ -739,6 +769,7 @@ _rl_vi_change_mbchar_case (count) wchar_t wc; char mb[MB_LEN_MAX+1]; int mlen, p; + size_t m; mbstate_t ps; memset (&ps, 0, sizeof (mbstate_t)); @@ -746,7 +777,11 @@ _rl_vi_change_mbchar_case (count) count--; while (count-- && rl_point < rl_end) { - mbrtowc (&wc, rl_line_buffer + rl_point, rl_end - rl_point, &ps); + m = mbrtowc (&wc, rl_line_buffer + rl_point, rl_end - rl_point, &ps); + if (MB_INVALIDCH (m)) + wc = (wchar_t)rl_line_buffer[rl_point]; + else if (MB_NULLWCH (m)) + wc = L'\0'; if (iswupper (wc)) wc = towlower (wc); else if (iswlower (wc)) @@ -886,6 +921,13 @@ rl_vi_domove (key, nextkey) RL_SETSTATE(RL_STATE_MOREINPUT); c = rl_read_key (); RL_UNSETSTATE(RL_STATE_MOREINPUT); + + if (c < 0) + { + *nextkey = 0; + return -1; + } + *nextkey = c; if (!member (c, vi_motion)) @@ -902,6 +944,11 @@ rl_vi_domove (key, nextkey) RL_SETSTATE(RL_STATE_MOREINPUT); c = rl_read_key (); /* real command */ RL_UNSETSTATE(RL_STATE_MOREINPUT); + if (c < 0) + { + *nextkey = 0; + return -1; + } *nextkey = c; } else if (key == c && (key == 'd' || key == 'y' || key == 'c')) @@ -1033,13 +1080,15 @@ int rl_vi_delete_to (count, key) int count, key; { - int c; + int c, start_pos; if (_rl_uppercase_p (key)) rl_stuff_char ('$'); else if (vi_redoing) rl_stuff_char (_rl_vi_last_motion); + start_pos = rl_point; + if (rl_vi_domove (key, &c)) { rl_ding (); @@ -1048,7 +1097,8 @@ rl_vi_delete_to (count, key) /* These are the motion commands that do not require adjusting the mark. */ - if ((strchr (" l|h^0bB", c) == 0) && (rl_mark < rl_end)) + if (((strchr (" l|h^0bBFT`", c) == 0) && (rl_point >= start_pos)) && + (rl_mark < rl_end)) rl_mark++; rl_kill_text (rl_point, rl_mark); @@ -1077,7 +1127,8 @@ rl_vi_change_to (count, key) /* These are the motion commands that do not require adjusting the mark. c[wW] are handled by special-case code in rl_vi_domove(), and already leave the mark at the correct location. */ - if ((strchr (" l|hwW^0bB", c) == 0) && (rl_mark < rl_end)) + if (((strchr (" l|hwW^0bBFT`", c) == 0) && (rl_point >= start_pos)) && + (rl_mark < rl_end)) rl_mark++; /* The cursor never moves with c[wW]. */ @@ -1112,12 +1163,13 @@ int rl_vi_yank_to (count, key) int count, key; { - int c, save; + int c, start_pos; - save = rl_point; if (_rl_uppercase_p (key)) rl_stuff_char ('$'); + start_pos = rl_point; + if (rl_vi_domove (key, &c)) { rl_ding (); @@ -1126,14 +1178,15 @@ rl_vi_yank_to (count, key) /* These are the motion commands that do not require adjusting the mark. */ - if ((strchr (" l|h^0%bB", c) == 0) && (rl_mark < rl_end)) + if (((strchr (" l|h^0%bBFT`", c) == 0) && (rl_point >= start_pos)) && + (rl_mark < rl_end)) rl_mark++; rl_begin_undo_group (); rl_kill_text (rl_point, rl_mark); rl_end_undo_group (); rl_do_undo (); - rl_point = save; + rl_point = start_pos; return (0); } @@ -1224,14 +1277,22 @@ static int _rl_vi_callback_char_search (data) _rl_callback_generic_arg *data; { + int c; #if defined (HANDLE_MULTIBYTE) - _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX); + c = _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX); #else RL_SETSTATE(RL_STATE_MOREINPUT); - _rl_vi_last_search_char = rl_read_key (); + c = rl_read_key (); RL_UNSETSTATE(RL_STATE_MOREINPUT); #endif + if (c <= 0) + return -1; + +#if !defined (HANDLE_MULTIBYTE) + _rl_vi_last_search_char = c; +#endif + _rl_callback_func = 0; _rl_want_redisplay = 1; @@ -1247,6 +1308,7 @@ int rl_vi_char_search (count, key) int count, key; { + int c; #if defined (HANDLE_MULTIBYTE) static char *target; static int tlen; @@ -1293,11 +1355,17 @@ rl_vi_char_search (count, key) else { #if defined (HANDLE_MULTIBYTE) - _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX); + c = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX); + if (c <= 0) + return -1; + _rl_vi_last_search_mblen = c; #else RL_SETSTATE(RL_STATE_MOREINPUT); - _rl_vi_last_search_char = rl_read_key (); + c = rl_read_key (); RL_UNSETSTATE(RL_STATE_MOREINPUT); + if (c < 0) + return -1; + _rl_vi_last_search_char = c; #endif } } @@ -1467,6 +1535,9 @@ _rl_vi_callback_getchar (mb, mlen) c = rl_read_key (); RL_UNSETSTATE(RL_STATE_MOREINPUT); + if (c < 0) + return -1; + #if defined (HANDLE_MULTIBYTE) if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) c = _rl_read_mbstring (c, mb, mlen); @@ -1485,6 +1556,9 @@ _rl_vi_callback_change_char (data) _rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX); + if (c < 0) + return -1; + _rl_callback_func = 0; _rl_want_redisplay = 1; @@ -1516,6 +1590,9 @@ rl_vi_change_char (count, key) else _rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX); + if (c < 0) + return -1; + return (_rl_vi_change_char (count, c, mb)); } @@ -1650,7 +1727,7 @@ _rl_vi_set_mark () ch = rl_read_key (); RL_UNSETSTATE(RL_STATE_MOREINPUT); - if (ch < 'a' || ch > 'z') + if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */ { rl_ding (); return -1; @@ -1702,7 +1779,7 @@ _rl_vi_goto_mark () rl_point = rl_mark; return 0; } - else if (ch < 'a' || ch > 'z') + else if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */ { rl_ding (); return -1; diff --git a/lib/readline/xmalloc.c b/lib/readline/xmalloc.c index 8985d34..97d8f2e 100644 --- a/lib/readline/xmalloc.c +++ b/lib/readline/xmalloc.c @@ -1,23 +1,24 @@ /* xmalloc.c -- safe versions of malloc and realloc */ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991-2009 Free Software Foundation, Inc. - This file is part of GNU Readline, a library for reading lines - of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - Readline is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Readline is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with Readline; see the file COPYING. If not, write to the Free - Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) diff --git a/lib/readline/xmalloc.h b/lib/readline/xmalloc.h index 9cb08ba..f40d7a5 100644 --- a/lib/readline/xmalloc.h +++ b/lib/readline/xmalloc.h @@ -1,24 +1,23 @@ /* xmalloc.h -- memory allocation that aborts on errors. */ -/* Copyright (C) 1999 Free Software Foundation, Inc. +/* Copyright (C) 1999-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for - reading lines of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - The GNU Readline Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Readline Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if !defined (_XMALLOC_H_) #define _XMALLOC_H_ diff --git a/lib/sh/Makefile.in b/lib/sh/Makefile.in index bf95d19..80f6cc5 100644 --- a/lib/sh/Makefile.in +++ b/lib/sh/Makefile.in @@ -2,21 +2,20 @@ # Makefile for the Bash library # # -# Copyright (C) 1998-2005 Free Software Foundation, Inc. +# Copyright (C) 1998-2009 Free Software Foundation, Inc. -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. PACKAGE = @PACKAGE_NAME@ VERSION = @PACKAGE_VERSION@ @@ -40,6 +39,8 @@ INTL_BUILDDIR = ${LIBBUILD}/intl INTL_INC = @INTL_INC@ LIBINTL_H = @LIBINTL_H@ +datarootdir = @datarootdir@ + INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ @@ -85,11 +86,12 @@ CSOURCES = clktck.c clock.c getcwd.c getenv.c oslib.c setlinebuf.c \ vprint.c itos.c rename.c zread.c zwrite.c shtty.c \ inet_aton.c netconn.c netopen.c strpbrk.c timeval.c makepath.c \ pathcanon.c pathphys.c tmpfile.c stringlist.c stringvec.c spell.c \ - shquote.c strtrans.c strindex.c snprintf.c mailstat.c \ + shquote.c strtrans.c strcasestr.c snprintf.c mailstat.c \ fmtulong.c fmtullong.c fmtumax.c shmatch.c strnlen.c \ strtoll.c strtoull.c strtoimax.c strtoumax.c memset.c strstr.c \ - mktime.c strftime.c xstrchr.c zcatfd.c winsize.c eaccess.c \ - wcsdup.c + mktime.c strftime.c mbschr.c zcatfd.c zmapfd.c winsize.c eaccess.c \ + wcsdup.c fpurge.c zgetline.c mbscmp.c uconvert.c ufuncs.c \ + casemod.c fdprintf.c input_avail.c mbscasecmp.c fnxform.c # The header files for this library. HSOURCES = @@ -100,9 +102,10 @@ OBJECTS = clktck.o clock.o getenv.o oslib.o setlinebuf.o strnlen.o \ itos.o zread.o zwrite.o shtty.o shmatch.o eaccess.o \ netconn.o netopen.o timeval.o makepath.o pathcanon.o \ pathphys.o tmpfile.o stringlist.o stringvec.o spell.o shquote.o \ - strtrans.o strindex.o snprintf.o mailstat.o fmtulong.o \ - fmtullong.o fmtumax.o xstrchr.o zcatfd.o winsize.o wcsdup.o \ - ${LIBOBJS} + strtrans.o snprintf.o mailstat.o fmtulong.o \ + fmtullong.o fmtumax.o zcatfd.o zmapfd.o winsize.o wcsdup.o \ + fpurge.o zgetline.o mbscmp.o uconvert.o ufuncs.o casemod.o \ + fdprintf.o input_avail.o mbscasecmp.o fnxform.o ${LIBOBJS} SUPPORT = Makefile @@ -133,19 +136,29 @@ mostlyclean: clean ${BUILD_DIR}/version.h: ${BUILD_DIR}/config.h ${BUILD_DIR}/Makefile Makefile -( cd ${BUILD_DIR} && ${MAKE} ${MFLAGS} version.h ) +${BUILD_DIR}/pathnames.h: ${BUILD_DIR}/config.h ${BUILD_DIR}/Makefile Makefile + -( cd ${BUILD_DIR} && ${MAKE} ${MFLAGS} pathnames.h ) + # rules for losing makes, like SunOS +casemod.o: casemod.c clktck.o: clktck.c clock.o: clock.c eaccess.o: eaccess.c +fdprintf.o: fdprintf.c fmtullong.o: fmtullong.c fmtulong.o: fmtulong.c fmtumax.o: fmtumax.c +fnxform.o: fnxform.c +fpurge.o: fpurge.c getcwd.o: getcwd.c getenv.o: getenv.c inet_aton.o: inet_aton.c +input_avail.o: input_avail.c itos.o: itos.c mailstat.o: mailstat.c makepath.o: makepath.c +mbscasecmp.o: mbscasecmp.c +mbscmp.o: mbscmp.c memset.o: memset.c mktime.o: mktime.c netconn.o: netconn.c @@ -162,7 +175,7 @@ spell.o: spell.c strcasecmp.o: strcasecmp.c strerror.o: strerror.c strftime.o: strftime.c -strindex.o: strindex.c +strcasestr.o: strcasestr.c stringlist.o: stringlist.c stringvec.o: stringvec.c strnlen.o: strnlen.c @@ -178,10 +191,14 @@ strtrans.o: strtrans.c times.o: times.c timeval.o: timeval.c tmpfile.o: tmpfile.c +uconvert.o: uconvert.c +ufuncs.o: ufuncs.c vprint.o: vprint.c wcsdup.o: wcsdup.c -xstrchr.o: xstrchr.c +mbschr.o: mbschr.c zcatfd.o: zcatfd.c +zmapfd.o: zmapfd.c +zgetline.o: zgetline.c zread.o: zread.c zwrite.o: zwrite.c @@ -193,18 +210,25 @@ strtoul.o: strtol.c strtoull.o: strtol.c # all files in the library depend on config.h +casemod.o: ${BUILD_DIR}/config.h clktck.o: ${BUILD_DIR}/config.h clock.o: ${BUILD_DIR}/config.h eaccess.o: ${BUILD_DIR}/config.h +fdprintf.o: ${BUILD_DIR}/config.h fmtullong.o: ${BUILD_DIR}/config.h fmtulong.o: ${BUILD_DIR}/config.h fmtumax.o: ${BUILD_DIR}/config.h +fnxform.o: ${BUILD_DIR}/config.h +fpurge.o: ${BUILD_DIR}/config.h getcwd.o: ${BUILD_DIR}/config.h getenv.o: ${BUILD_DIR}/config.h inet_aton.o: ${BUILD_DIR}/config.h +input_avail.o: ${BUILD_DIR}/config.h itos.o: ${BUILD_DIR}/config.h mailstat.o: ${BUILD_DIR}/config.h makepath.o: ${BUILD_DIR}/config.h +mbscasecmp.o: ${BUILD_DIR}/config.h +mbscmp.o: ${BUILD_DIR}/config.h memset.o: ${BUILD_DIR}/config.h mktime.o: ${BUILD_DIR}/config.h netconn.o: ${BUILD_DIR}/config.h @@ -221,7 +245,7 @@ spell.o: ${BUILD_DIR}/config.h strcasecmp.o: ${BUILD_DIR}/config.h strerror.o: ${BUILD_DIR}/config.h strftime.o: ${BUILD_DIR}/config.h -strindex.o: ${BUILD_DIR}/config.h +strcasestr.o: ${BUILD_DIR}/config.h stringlist.o: ${BUILD_DIR}/config.h stringvec.o: ${BUILD_DIR}/config.h strnlen.o: ${BUILD_DIR}/config.h @@ -237,10 +261,14 @@ strtrans.o: ${BUILD_DIR}/config.h times.o: ${BUILD_DIR}/config.h timeval.o: ${BUILD_DIR}/config.h tmpfile.o: ${BUILD_DIR}/config.h +uconvert.o: ${BUILD_DIR}/config.h +ufuncs.o: ${BUILD_DIR}/config.h vprint.o: ${BUILD_DIR}/config.h wcsdup.o: ${BUILD_DIR}/config.h -xstrchr.o: ${BUILD_DIR}/config.h +mbschr.o: ${BUILD_DIR}/config.h zcatfd.o: ${BUILD_DIR}/config.h +zgetline.o: ${BUILD_DIR}/config.h +zmapfd.o: ${BUILD_DIR}/config.h zread.o: ${BUILD_DIR}/config.h zwrite.o: ${BUILD_DIR}/config.h @@ -372,8 +400,8 @@ strerror.o: ${topdir}/unwind_prot.h ${topdir}/dispose_cmd.h strerror.o: ${topdir}/make_cmd.h ${topdir}/subst.h ${topdir}/sig.h strerror.o: ${BUILD_DIR}/pathnames.h ${topdir}/externs.h ${BUILD_DIR}/version.h -strindex.o: ${BASHINCDIR}/stdc.h ${topdir}/bashansi.h -strindex.o: ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/chartypes.h +strcasestr.o: ${BASHINCDIR}/stdc.h ${topdir}/bashansi.h +strcasestr.o: ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/chartypes.h stringlist.o: ${topdir}/bashansi.h stringlist.o: ${topdir}/shell.h ${topdir}/syntax.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h @@ -439,6 +467,10 @@ tmpfile.o: ${topdir}/bashtypes.h tmpfile.o: ${BASHINCDIR}/posixstat.h tmpfile.o: ${BASHINCDIR}/filecntl.h +uconvert.o: ${topdir}/bashtypes.h + +ufuncs.o: ${topdir}/bashtypes.h + clock.o: ${BASHINCDIR}/posixtime.h mailstat.o: ${topdir}/bashansi.h @@ -473,6 +505,40 @@ wcsdup.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h wcsdup.o: ${BASHINCDIR}/stdc.h wcsdup.o: ${topdir}/xmalloc.h -xstrchr.o: ${topdir}/bashansi.h -xstrchr.o: ${BASHINCDIR}/ansi_stdlib.h -xstrchr.o: ${BASHINCDIR}/shmbutil.h +mbschr.o: ${topdir}/bashansi.h +mbschr.o: ${BASHINCDIR}/ansi_stdlib.h +mbschr.o: ${BASHINCDIR}/shmbutil.h + +zgetline.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h +zgetline.o: ${BASHINCDIR}/stdc.h +zgetline.o: ${topdir}/xmalloc.h +zgetline.o: ${topdir}/bashtypes.h + +mbscasecmp.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h +mbscasecmp.o: ${BASHINCDIR}/stdc.h +mbscasecmp.o: ${topdir}/xmalloc.h + +mbscmp.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h +mbscmp.o: ${BASHINCDIR}/stdc.h +mbscmp.o: ${topdir}/xmalloc.h + +casemod.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h +casemod.o: ${BASHINCDIR}/stdc.h +casemod.o: ${topdir}/xmalloc.h +casemod.o: ${topdir}/bashtypes.h +casemod.o: ${BASHINCDIR}/shmbutil.h +casemod.o: ${topdir}/bashintl.h ${LIBINTL_H} ${BASHINCDIR}/gettext.h + +fdprintf.o: ${BASHINCDIR}/stdc.h + +input_avail.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h +input_avail.o: ${BASHINCDIR}/stdc.h +input_avail.o: ${topdir}/xmalloc.h ${BASHINCDIR}/posixselect.h + +mktime.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h +mktime.o: ${BASHINCDIR}/stdc.h + +fnxform.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h +fnxform.o: ${BASHINCDIR}/stdc.h +fnxform.o: ${topdir}/bashtypes.h +fnxform.o: ${topdir}/bashintl.h ${LIBINTL_H} ${BASHINCDIR}/gettext.h diff --git a/lib/sh/casemod.c b/lib/sh/casemod.c new file mode 100644 index 0000000..d85549a --- /dev/null +++ b/lib/sh/casemod.c @@ -0,0 +1,244 @@ +/* casemod.c -- functions to change case of strings */ + +/* Copyright (C) 2008,2009 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ + +#if defined (HAVE_CONFIG_H) +# include <config.h> +#endif + +#if defined (HAVE_UNISTD_H) +# include <unistd.h> +#endif /* HAVE_UNISTD_H */ + +#include <stdc.h> + +#include <bashansi.h> +#include <bashintl.h> +#include <bashtypes.h> + +#include <stdio.h> +#include <ctype.h> +#include <xmalloc.h> + +#include <shmbutil.h> +#include <chartypes.h> + +#include <glob/strmatch.h> + +#define _to_wupper(wc) (iswlower (wc) ? towupper (wc) : (wc)) +#define _to_wlower(wc) (iswupper (wc) ? towlower (wc) : (wc)) + +#if !defined (HANDLE_MULTIBYTE) +# define cval(s, i) ((s)[(i)]) +# define iswalnum(c) (isalnum(c)) +# define TOGGLE(x) (ISUPPER (x) ? tolower (x) : (TOUPPER (x))) +#else +# define TOGGLE(x) (iswupper (x) ? towlower (x) : (_to_wupper(x))) +#endif + +/* These must agree with the defines in externs.h */ +#define CASE_NOOP 0x0000 +#define CASE_LOWER 0x0001 +#define CASE_UPPER 0x0002 +#define CASE_CAPITALIZE 0x0004 +#define CASE_UNCAP 0x0008 +#define CASE_TOGGLE 0x0010 +#define CASE_TOGGLEALL 0x0020 +#define CASE_UPFIRST 0x0040 +#define CASE_LOWFIRST 0x0080 + +#define CASE_USEWORDS 0x1000 /* modify behavior to act on words in passed string */ + +extern char *substring __P((char *, int, int)); + +#if defined (HANDLE_MULTIBYTE) +static wchar_t +cval (s, i) + char *s; + int i; +{ + size_t tmp; + wchar_t wc; + int l; + mbstate_t mps; + + if (MB_CUR_MAX == 1) + return ((wchar_t)s[i]); + l = strlen (s); + if (i >= (l - 1)) + return ((wchar_t)s[i]); + memset (&mps, 0, sizeof (mbstate_t)); + tmp = mbrtowc (&wc, s + i, l - i, &mps); + if (MB_INVALIDCH (tmp) || MB_NULLWCH (tmp)) + return ((wchar_t)s[i]); + return wc; +} +#endif + +/* Modify the case of characters in STRING matching PAT based on the value of + FLAGS. If PAT is null, modify the case of each character */ +char * +sh_modcase (string, pat, flags) + const char *string; + char *pat; + int flags; +{ + int start, next, end; + int inword, c, nc, nop, match, usewords; + char *ret, *s; + wchar_t wc; +#if defined (HANDLE_MULTIBYTE) + wchar_t nwc; + char mb[MB_LEN_MAX+1]; + int mlen; + size_t m; + mbstate_t state; +#endif + +#if defined (HANDLE_MULTIBYTE) + memset (&state, 0, sizeof (mbstate_t)); +#endif + + start = 0; + end = strlen (string); + + ret = (char *)xmalloc (end + 1); + strcpy (ret, string); + + /* See if we are supposed to split on alphanumerics and operate on each word */ + usewords = (flags & CASE_USEWORDS); + flags &= ~CASE_USEWORDS; + + inword = 0; + while (start < end) + { + wc = cval (ret, start); + + if (iswalnum (wc) == 0) + { + inword = 0; + ADVANCE_CHAR (ret, end, start); + continue; + } + + if (pat) + { + next = start; + ADVANCE_CHAR (ret, end, next); + s = substring (ret, start, next); + match = strmatch (pat, s, FNM_EXTMATCH) != FNM_NOMATCH; + free (s); + if (match == 0) + { + start = next; + inword = 1; + continue; + } + } + + /* XXX - for now, the toggling operators work on the individual + words in the string, breaking on alphanumerics. Should I + leave the capitalization operators to do that also? */ + if (flags == CASE_CAPITALIZE) + { + if (usewords) + nop = inword ? CASE_LOWER : CASE_UPPER; + else + nop = (start > 0) ? CASE_LOWER : CASE_UPPER; + inword = 1; + } + else if (flags == CASE_UNCAP) + { + if (usewords) + nop = inword ? CASE_UPPER : CASE_LOWER; + else + nop = (start > 0) ? CASE_UPPER : CASE_LOWER; + inword = 1; + } + else if (flags == CASE_UPFIRST) + { + if (usewords) + nop = inword ? CASE_NOOP : CASE_UPPER; + else + nop = (start > 0) ? CASE_NOOP : CASE_UPPER; + inword = 1; + } + else if (flags == CASE_LOWFIRST) + { + if (usewords) + nop = inword ? CASE_NOOP : CASE_LOWER; + else + nop = (start > 0) ? CASE_NOOP : CASE_LOWER; + inword = 1; + } + else if (flags == CASE_TOGGLE) + { + nop = inword ? CASE_NOOP : CASE_TOGGLE; + inword = 1; + } + else + nop = flags; + + if (MB_CUR_MAX == 1 || isascii (wc)) + { + switch (nop) + { + default: + case CASE_NOOP: nc = wc; break; + case CASE_UPPER: nc = TOUPPER (wc); break; + case CASE_LOWER: nc = TOLOWER (wc); break; + case CASE_TOGGLEALL: + case CASE_TOGGLE: nc = TOGGLE (wc); break; + } + ret[start] = nc; + } +#if defined (HANDLE_MULTIBYTE) + else + { + m = mbrtowc (&wc, string + start, end - start, &state); + if (MB_INVALIDCH (m)) + wc = (wchar_t)string[start]; + else if (MB_NULLWCH (m)) + wc = L'\0'; + switch (nop) + { + default: + case CASE_NOOP: nwc = wc; break; + case CASE_UPPER: nwc = TOUPPER (wc); break; + case CASE_LOWER: nwc = TOLOWER (wc); break; + case CASE_TOGGLEALL: + case CASE_TOGGLE: nwc = TOGGLE (wc); break; + } + if (nwc != wc) /* just skip unchanged characters */ + { + mlen = wcrtomb (mb, nwc, &state); + if (mlen > 0) + mb[mlen] = '\0'; + /* Assume the same width */ + strncpy (ret + start, mb, mlen); + } + } +#endif + + /* This assumes that the upper and lower case versions are the same width. */ + ADVANCE_CHAR (ret, end, start); + } + + return ret; +} diff --git a/lib/sh/clktck.c b/lib/sh/clktck.c index 546b49c..096ce06 100644 --- a/lib/sh/clktck.c +++ b/lib/sh/clktck.c @@ -4,19 +4,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/clock.c b/lib/sh/clock.c index 1186a19..84cdbc5 100644 --- a/lib/sh/clock.c +++ b/lib/sh/clock.c @@ -4,19 +4,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/eaccess.c b/lib/sh/eaccess.c index 1cff692..989bc22 100644 --- a/lib/sh/eaccess.c +++ b/lib/sh/eaccess.c @@ -4,19 +4,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #if defined (HAVE_CONFIG_H) # include <config.h> diff --git a/lib/sh/fdprintf.c b/lib/sh/fdprintf.c new file mode 100644 index 0000000..27d3a4b --- /dev/null +++ b/lib/sh/fdprintf.c @@ -0,0 +1,70 @@ +/* fdprintf -- printf to a file descriptor */ + +/* Copyright (C) 2008,2009 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <stdc.h> + +#if defined (HAVE_UNISTD_H) +# include <unistd.h> +#endif + +#if defined (PREFER_STDARG) +# include <stdarg.h> +#else +# include <varargs.h> +#endif + +#include <stdio.h> + +int +#if defined (PREFER_STDARG) +fdprintf(int fd, const char *format, ...) +#else +fdprintf(fd, format, va_alist) + int fd; + const char *format; + va_dcl +#endif +{ + FILE *fp; + int fd2, rc, r2; + va_list args; + + if ((fd2 = dup(fd)) < 0) + return -1; + fp = fdopen (fd2, "w"); + if (fp == 0) + { + close (fd2); + return -1; + } + + SH_VA_START (args, format); + rc = vfprintf (fp, format, args); + fflush (fp); + va_end (args); + + r2 = fclose (fp); /* check here */ + + return rc; +} diff --git a/lib/sh/fmtullong.c b/lib/sh/fmtullong.c index df27944..97a1dc1 100644 --- a/lib/sh/fmtullong.c +++ b/lib/sh/fmtullong.c @@ -2,19 +2,21 @@ /* Copyright (C) 2001-2002 Free Software Foundation, Inc. -This program is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software Foundation, -Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/fmtulong.c b/lib/sh/fmtulong.c index 43fdffd..214b146 100644 --- a/lib/sh/fmtulong.c +++ b/lib/sh/fmtulong.c @@ -4,19 +4,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/lib/sh/fmtumax.c b/lib/sh/fmtumax.c index 9bb4718..f2786b5 100644 --- a/lib/sh/fmtumax.c +++ b/lib/sh/fmtumax.c @@ -2,19 +2,21 @@ /* Copyright (C) 2002 Free Software Foundation, Inc. -This program is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software Foundation, -Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/fnxform.c b/lib/sh/fnxform.c new file mode 100644 index 0000000..d95274f --- /dev/null +++ b/lib/sh/fnxform.c @@ -0,0 +1,199 @@ +/* fnxform - use iconv(3) to transform strings to and from "filename" format */ + +/* Copyright (C) 2009 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <config.h> +#if defined (HAVE_UNISTD_H) +# include <unistd.h> +#endif +#include "bashansi.h" +#include <stdio.h> +#include "bashtypes.h" + +#include "stdc.h" +#include "bashintl.h" +#include <xmalloc.h> + +#if defined (HAVE_ICONV) +# include <iconv.h> +#endif + +#if defined (HAVE_LOCALE_CHARSET) +extern const char *locale_charset __P((void)); +#else +extern char *get_locale_var __P((char *)); +#endif + +#if defined (HAVE_ICONV) +static iconv_t conv_fromfs = (iconv_t)-1; +static iconv_t conv_tofs = (iconv_t)-1; + +#define OUTLEN_MAX 4096 + +static char *outbuf = 0; +static size_t outlen = 0; + +static char *curencoding __P((void)); +static void init_tofs __P((void)); +static void init_fromfs __P((void)); + +static char * +curencoding () +{ + char *loc; +#if defined (HAVE_LOCALE_CHARSET) + loc = (char *)locale_charset (); + return loc; +#else + char *dot, *mod; + + loc = get_locale_var ("LC_CTYPE"); + if (loc == 0 || *loc == 0) + return ""; + dot = strchr (loc, '.'); + if (dot == 0) + return loc; + mod = strchr (dot, '@'); + if (mod) + *mod = '\0'; + return dot; +#endif +} + +static void +init_tofs () +{ + char *cur; + + cur = curencoding (); + conv_tofs = iconv_open ("UTF-8-MAC", cur); +} + +static void +init_fromfs () +{ + char *cur; + + cur = curencoding (); + conv_fromfs = iconv_open (cur, "UTF-8-MAC"); +} + +char * +fnx_tofs (string, len) + char *string; + size_t len; +{ +#ifdef MACOSX + ICONV_CONST char *inbuf; + char *tempbuf; + size_t templen; + + if (conv_tofs == (iconv_t)-1) + init_tofs (); + if (conv_tofs == (iconv_t)-1) + return string; + + /* Free and reallocate outbuf if it's *too* big */ + if (outlen >= OUTLEN_MAX && len < OUTLEN_MAX - 8) + { + free (outbuf); + outbuf = 0; + outlen = 0; + } + + inbuf = string; + if (outbuf == 0 || outlen < len + 8) + { + outlen = len + 8; + outbuf = outbuf ? xrealloc (outbuf, outlen + 1) : xmalloc (outlen + 1); + } + tempbuf = outbuf; + templen = outlen; + + iconv (conv_tofs, NULL, NULL, NULL, NULL); + + if (iconv (conv_tofs, &inbuf, &len, &tempbuf, &templen) == (size_t)-1) + return string; + + *tempbuf = '\0'; + return outbuf; +#else + return string; +#endif +} + +char * +fnx_fromfs (string, len) + char *string; + size_t len; +{ +#ifdef MACOSX + ICONV_CONST char *inbuf; + char *tempbuf; + size_t templen; + + if (conv_fromfs == (iconv_t)-1) + init_fromfs (); + if (conv_fromfs == (iconv_t)-1) + return string; + + /* Free and reallocate outbuf if it's *too* big */ + if (outlen >= OUTLEN_MAX && len < OUTLEN_MAX - 8) + { + free (outbuf); + outbuf = 0; + outlen = 0; + } + + inbuf = string; + if (outbuf == 0 || outlen < (len + 8)) + { + outlen = len + 8; + outbuf = outbuf ? xrealloc (outbuf, outlen + 1) : xmalloc (outlen + 1); + } + tempbuf = outbuf; + templen = outlen; + + iconv (conv_fromfs, NULL, NULL, NULL, NULL); + + if (iconv (conv_fromfs, &inbuf, &len, &tempbuf, &templen) == (size_t)-1) + return string; + + *tempbuf = '\0'; + return outbuf; +#else + return string; +#endif +} + +#else +char * +fnx_tofs (string) + char *string; +{ + return string; +} + +char * +fnx_fromfs (string) + char *string; +{ + return string; +} +#endif diff --git a/lib/sh/fpurge.c b/lib/sh/fpurge.c new file mode 100644 index 0000000..f9e1b9d --- /dev/null +++ b/lib/sh/fpurge.c @@ -0,0 +1,148 @@ +/* fpurge - Flushing buffers of a FILE stream. */ + +/* Copyright (C) 2007 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <config.h> + +#include "stdc.h" + +#include <stdio.h> + +/* Specification. Same as in ../../externs.h. */ +#define NEED_FPURGE_DECL +#if HAVE_FPURGE +# define fpurge _bash_fpurge +#endif +extern int fpurge __P((FILE *stream)); + +#if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7 */ +# include <stdio_ext.h> +#endif +#include <stdlib.h> + +int +fpurge (FILE *fp) +{ +#if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7 */ + + __fpurge (fp); + /* The __fpurge function does not have a return value. */ + return 0; + +#elif HAVE_FPURGE /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X */ + + /* Call the system's fpurge function. */ +# undef fpurge +# if !HAVE_DECL_FPURGE + extern int fpurge (FILE *); +# endif + int result = fpurge (fp); +# if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */ + if (result == 0) + /* Correct the invariants that fpurge broke. + <stdio.h> on BSD systems says: + "The following always hold: if _flags & __SRD, _w is 0." + If this invariant is not fulfilled and the stream is read-write but + currently writing, subsequent putc or fputc calls will write directly + into the buffer, although they shouldn't be allowed to. */ + if ((fp->_flags & __SRD) != 0) + fp->_w = 0; +# endif + return result; + +#else + + /* Most systems provide FILE as a struct and the necessary bitmask in + <stdio.h>, because they need it for implementing getc() and putc() as + fast macros. */ +# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + fp->_IO_read_end = fp->_IO_read_ptr; + fp->_IO_write_ptr = fp->_IO_write_base; + /* Avoid memory leak when there is an active ungetc buffer. */ + if (fp->_IO_save_base != NULL) + { + free (fp->_IO_save_base); + fp->_IO_save_base = NULL; + } + return 0; +# elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */ + fp_->_p = fp_->_bf._base; + fp_->_r = 0; + fp_->_w = ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */ + ? fp_->_bf._size + : 0); + /* Avoid memory leak when there is an active ungetc buffer. */ + if (fp_ub._base != NULL) + { + if (fp_ub._base != fp_->_ubuf) + free (fp_ub._base); + fp_ub._base = NULL; + } + return 0; +# elif defined __EMX__ /* emx+gcc */ + fp->_ptr = fp->_buffer; + fp->_rcount = 0; + fp->_wcount = 0; + fp->_ungetc_count = 0; + return 0; +# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw */ + fp->_ptr = fp->_base; + if (fp->_ptr != NULL) + fp->_cnt = 0; + return 0; +# elif defined __UCLIBC__ /* uClibc */ +# ifdef __STDIO_BUFFERS + if (fp->__modeflags & __FLAG_WRITING) + fp->__bufpos = fp->__bufstart; + else if (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) + fp->__bufpos = fp->__bufread; +# endif + return 0; +# elif defined __QNX__ /* QNX */ + fp->_Rback = fp->_Back + sizeof (fp->_Back); + fp->_Rsave = NULL; + if (fp->_Mode & 0x2000 /* _MWRITE */) + /* fp->_Buf <= fp->_Next <= fp->_Wend */ + fp->_Next = fp->_Buf; + else + /* fp->_Buf <= fp->_Next <= fp->_Rend */ + fp->_Rend = fp->_Next; + return 0; +# elif defined __MINT__ /* Atari FreeMiNT */ + if (fp->__pushed_back) + { + fp->__bufp = fp->__pushback_bufp; + fp->__pushed_back = 0; + } + /* Preserve the current file position. */ + if (fp->__target != -1) + fp->__target += fp->__bufp - fp->__buffer; + fp->__bufp = fp->__buffer; + /* Nothing in the buffer, next getc is nontrivial. */ + fp->__get_limit = fp->__bufp; + /* Nothing in the buffer, next putc is nontrivial. */ + fp->__put_limit = fp->__buffer; + return 0; +# else +# warning "Please port gnulib fpurge.c to your platform! Look at the definitions of fflush, setvbuf and ungetc on your system, then report this to bug-gnulib." + return 0; +# endif + +#endif +} diff --git a/lib/sh/getcwd.c b/lib/sh/getcwd.c index cd724f6..07eb817 100644 --- a/lib/sh/getcwd.c +++ b/lib/sh/getcwd.c @@ -1,22 +1,22 @@ -/* getcwd.c -- stolen from the GNU C library and modified to work with bash. */ +/* getcwd.c -- get pathname of current directory */ /* Copyright (C) 1991 Free Software Foundation, Inc. - This file is part of the GNU C Library. - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. + This file is part of GNU Bash, the Bourne Again SHell. - The GNU C Library is distributed in the hope that it will be useful, + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If - not, write to the Free Software Foundation, Inc., - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> @@ -26,6 +26,10 @@ #pragma alloca #endif /* _AIX && RISC6000 && !__GNUC__ */ +#if defined (__QNX__) +# undef HAVE_LSTAT +#endif + #include <bashtypes.h> #include <errno.h> @@ -44,6 +48,12 @@ #include <bashansi.h> +#if defined (BROKEN_DIRENT_D_INO) +# include "command.h" +# include "general.h" +# include "externs.h" +#endif + #include <xmalloc.h> #if !defined (errno) @@ -58,6 +68,33 @@ extern int errno; # define NULL 0 #endif +/* If the d_fileno member of a struct dirent doesn't return anything useful, + we need to check inode number equivalence the hard way. Return 1 if + the inode corresponding to PATH/DIR is identical to THISINO. */ +#if defined (BROKEN_DIRENT_D_INO) +static int +_path_checkino (dotp, name, thisino) + char *dotp; + char *name; + ino_t thisino; +{ + char *fullpath; + int r, e; + struct stat st; + + e = errno; + fullpath = sh_makepath (dotp, name, MP_RMDOT); + if (stat (fullpath, &st) < 0) + { + errno = e; + return 0; + } + free (fullpath); + errno = e; + return (st.st_ino == thisino); +} +#endif + /* Get the pathname of the current working directory, and put it in SIZE bytes of BUF. Returns NULL if the directory couldn't be determined or SIZE was too small. @@ -169,7 +206,11 @@ getcwd (buf, size) (d->d_name[1] == '\0' || (d->d_name[1] == '.' && d->d_name[2] == '\0'))) continue; +#if !defined (BROKEN_DIRENT_D_INO) if (mount_point || d->d_fileno == thisino) +#else + if (mount_point || _path_checkino (dotp, d->d_name, thisino)) +#endif { char *name; @@ -251,19 +292,21 @@ getcwd (buf, size) { size_t len = pathbuf + pathsize - pathp; + if (buf == NULL && size <= 0) + size = len; + + if ((size_t) size < len) + { + errno = ERANGE; + goto lose2; + } if (buf == NULL) { - if (len < (size_t) size) - len = size; - buf = (char *) malloc (len); + buf = (char *) malloc (size); if (buf == NULL) goto lose2; } - else if ((size_t) size < len) - { - errno = ERANGE; - goto lose2; - } + (void) memcpy((PTR_T) buf, (PTR_T) pathp, len); } diff --git a/lib/sh/getenv.c b/lib/sh/getenv.c index c3fbf75..8b5e340 100644 --- a/lib/sh/getenv.c +++ b/lib/sh/getenv.c @@ -5,19 +5,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/inet_aton.c b/lib/sh/inet_aton.c index 2835d62..4b48456 100644 --- a/lib/sh/inet_aton.c +++ b/lib/sh/inet_aton.c @@ -1,3 +1,5 @@ +/* inet_aton - convert string to numeric IP address */ + /* Snagged from GNU C library, version 2.0.3. */ /* diff --git a/lib/sh/input_avail.c b/lib/sh/input_avail.c new file mode 100644 index 0000000..ac157a9 --- /dev/null +++ b/lib/sh/input_avail.c @@ -0,0 +1,98 @@ +/* input_avail.c -- check whether or not data is available for reading on a + specified file descriptor. */ + +/* Copyright (C) 2008,2009 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ + +#if defined (__TANDEM) +# include <floss.h> +#endif + +#if defined (HAVE_CONFIG_H) +# include <config.h> +#endif + +#include <sys/types.h> +#include <fcntl.h> +#if defined (HAVE_SYS_FILE_H) +# include <sys/file.h> +#endif /* HAVE_SYS_FILE_H */ + +#if defined (HAVE_UNISTD_H) +# include <unistd.h> +#endif /* HAVE_UNISTD_H */ + +#include "bashansi.h" + +#include "posixselect.h" + +#if defined (FIONREAD_IN_SYS_IOCTL) +# include <sys/ioctl.h> +#endif + +#include <stdio.h> +#include <errno.h> + +#if !defined (errno) +extern int errno; +#endif /* !errno */ + +#if !defined (O_NDELAY) && defined (O_NONBLOCK) +# define O_NDELAY O_NONBLOCK /* Posix style */ +#endif + +/* Return >= 1 if select/FIONREAD indicates data available for reading on + file descriptor FD; 0 if no data available. Return -1 on error. */ +int +input_avail (fd) + int fd; +{ + int result, chars_avail; +#if defined(HAVE_SELECT) + fd_set readfds, exceptfds; + struct timeval timeout; +#endif + + if (fd < 0) + return -1; + + chars_avail = 0; + +#if defined (HAVE_SELECT) + FD_ZERO (&readfds); + FD_ZERO (&exceptfds); + FD_SET (fd, &readfds); + FD_SET (fd, &exceptfds); + timeout.tv_sec = 0; + timeout.tv_usec = 0; + result = select (fd + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout); + return ((result <= 0) ? 0 : 1); + +#endif + + result = -1; +#if defined (FIONREAD) + errno = 0; + result = ioctl (fd, FIONREAD, &chars_avail); + if (result == -1 && errno == EIO) + return -1; + return (chars_avail); +#endif + + return 0; +} diff --git a/lib/sh/itos.c b/lib/sh/itos.c index e9a7942..12e9398 100644 --- a/lib/sh/itos.c +++ b/lib/sh/itos.c @@ -4,19 +4,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/lib/sh/mailstat.c b/lib/sh/mailstat.c index 03782e7..2b2ac0e 100644 --- a/lib/sh/mailstat.c +++ b/lib/sh/mailstat.c @@ -4,19 +4,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/makepath.c b/lib/sh/makepath.c index c496154..43dbab2 100644 --- a/lib/sh/makepath.c +++ b/lib/sh/makepath.c @@ -4,19 +4,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> @@ -42,17 +42,21 @@ # define MP_DOTILDE 0x01 # define MP_DOCWD 0x02 # define MP_RMDOT 0x04 +# define MP_IGNDOT 0x08 #endif extern char *get_working_directory __P((char *)); +static char *nullpath = ""; + /* Take PATH, an element from, e.g., $CDPATH, and DIR, a directory name, and paste them together into PATH/DIR. Tilde expansion is performed on PATH if (flags & MP_DOTILDE) is non-zero. If PATH is NULL or the empty string, it is converted to the current directory. A full pathname is used if (flags & MP_DOCWD) is non-zero, otherwise `./' is used. If (flags & MP_RMDOT) is non-zero, any `./' is removed from the beginning - of DIR. */ + of DIR. If (flags & MP_IGNDOT) is non-zero, a PATH that is "." or "./" + is ignored. */ #define MAKEDOT() \ do { \ @@ -89,6 +93,12 @@ sh_makepath (path, dir, flags) else MAKEDOT(); } + else if ((flags & MP_IGNDOT) && path[0] == '.' && (path[1] == '\0' || + path[1] == '/' && path[2] == '\0')) + { + xpath = nullpath; + pathlen = 0; + } else { xpath = ((flags & MP_DOTILDE) && *path == '~') ? bash_tilde_expand (path, 0) : (char *)path; @@ -107,12 +117,12 @@ sh_makepath (path, dir, flags) s = xpath; while (*s) *r++ = *s++; - if (s[-1] != '/') + if (s > xpath && s[-1] != '/') *r++ = '/'; s = xdir; while (*r++ = *s++) ; - if (xpath != path) + if (xpath != path && xpath != nullpath) free (xpath); return (ret); } diff --git a/lib/sh/mbscasecmp.c b/lib/sh/mbscasecmp.c new file mode 100644 index 0000000..3828164 --- /dev/null +++ b/lib/sh/mbscasecmp.c @@ -0,0 +1,78 @@ +/* mbscasecmp - case-insensitive multibyte string comparison. */ + +/* Copyright (C) 2009 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <config.h> + +#if !defined (HAVE_MBSCASECMP) && defined (HANDLE_MULTIBYTE) + +#include <stdlib.h> +#include <stddef.h> +#include <string.h> + +#include <wchar.h> +#include <wctype.h> + +/* Compare MBS1 and MBS2 without regard to case. */ +int +mbscasecmp (mbs1, mbs2) + const char *mbs1; + const char *mbs2; +{ + int len1, len2; + wchar_t c1, c2, l1, l2; + + len1 = len2 = 0; + /* Reset multibyte characters to their initial state. */ + (void) mblen ((char *) NULL, 0); + + do + { + len1 = mbtowc (&c1, mbs1, MB_CUR_MAX); + len2 = mbtowc (&c2, mbs2, MB_CUR_MAX); + + if (len1 == 0) + return len2 == 0 ? 0 : -1; + else if (len2 == 0) + return 1; + else if (len1 > 0 && len2 < 0) + return -1; + else if (len1 < 0 && len2 > 0) + return 1; + else if (len1 < 0 && len2 < 0) + { + len1 = strlen (mbs1); + len2 = strlen (mbs2); + return (len1 == len2 ? memcmp (mbs1, mbs2, len1) + : ((len1 < len2) ? (memcmp (mbs1, mbs2, len1) > 0 ? 1 : -1) + : (memcmp (mbs1, mbs2, len2) >= 0 ? 1 : -1))); + } + + l1 = towlower (c1); + l2 = towlower (c2); + + mbs1 += len1; + mbs2 += len2; + } + while (l1 == l2); + + return l1 - l2; +} + +#endif diff --git a/lib/sh/xstrchr.c b/lib/sh/mbschr.c index 3272837..5143d64 100644 --- a/lib/sh/xstrchr.c +++ b/lib/sh/mbschr.c @@ -1,22 +1,22 @@ -/* xstrchr.c - strchr(3) that handles multibyte characters. */ +/* mbschr.c - strchr(3) that handles multibyte characters. */ /* Copyright (C) 2002 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> @@ -27,7 +27,7 @@ #include "bashansi.h" #include "shmbutil.h" -#undef xstrchr +#undef mbschr /* In some locales, the non-first byte of some multibyte characters have the same value as some ascii character. Faced with these strings, a @@ -35,9 +35,9 @@ char * #if defined (PROTOTYPES) -xstrchr (const char *s, int c) +mbschr (const char *s, int c) #else -xstrchr (s, c) +mbschr (s, c) const char *s; int c; #endif @@ -63,7 +63,7 @@ xstrchr (s, c) if (mblength == (size_t)-2 || mblength == (size_t)-1 || mblength == (size_t)0) mblength = 1; - if (c == (unsigned char)*pos) + if (mblength == 1 && c == (unsigned char)*pos) return pos; strlength -= mblength; diff --git a/lib/sh/mbscmp.c b/lib/sh/mbscmp.c new file mode 100644 index 0000000..e0eae5d --- /dev/null +++ b/lib/sh/mbscmp.c @@ -0,0 +1,72 @@ +/* mbscmp - multibyte string comparison. */ + +/* Copyright (C) 1995 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <config.h> + +#if !defined (HAVE_MBSCMP) && defined (HANDLE_MULTIBYTE) + +#include <stdlib.h> +#include <stddef.h> +#include <string.h> + +/* Compare MBS1 and MBS2. */ +int +mbscmp (mbs1, mbs2) + const char *mbs1; + const char *mbs2; +{ + int len1, len2; + wchar_t c1, c2; + + len1 = len2 = 0; + /* Reset multibyte characters to their initial state. */ + (void) mblen ((char *) NULL, 0); + + do + { + len1 = mbtowc (&c1, mbs1, MB_CUR_MAX); + len2 = mbtowc (&c2, mbs2, MB_CUR_MAX); + + if (len1 == 0) + return len2 == 0 ? 0 : -1; + else if (len2 == 0) + return 1; + else if (len1 > 0 && len2 < 0) + return -1; + else if (len1 < 0 && len2 > 0) + return 1; + else if (len1 < 0 && len2 < 0) + { + len1 = strlen (mbs1); + len2 = strlen (mbs2); + return (len1 == len2 ? memcmp (mbs1, mbs2, len1) + : ((len1 < len2) ? (memcmp (mbs1, mbs2, len1) > 0 ? 1 : -1) + : (memcmp (mbs1, mbs2, len2) >= 0 ? 1 : -1))); + } + + mbs1 += len1; + mbs2 += len2; + } + while (c1 == c2); + + return c1 - c2; +} + +#endif diff --git a/lib/sh/memset.c b/lib/sh/memset.c index ddc36b6..4ebc418 100644 --- a/lib/sh/memset.c +++ b/lib/sh/memset.c @@ -1,19 +1,22 @@ -/* memset.c -- set an area of memory to a given value - Copyright (C) 1991-2002 Free Software Foundation, Inc. +/* memset.c -- set an area of memory to a given value */ - This program is free software; you can redistribute it and/or modify +/* Copyright (C) 1991-2002 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ char * memset (char *str, int c, unsigned int len) diff --git a/lib/sh/mktime.c b/lib/sh/mktime.c index 81aeb22..7257400 100644 --- a/lib/sh/mktime.c +++ b/lib/sh/mktime.c @@ -1,22 +1,23 @@ +/* mktime - convert struct tm to a time_t value */ + /* Copyright (C) 1993-2002 Free Software Foundation, Inc. - This file is part of the GNU C Library. + + This file is part of GNU Bash, the Bourne Again SHell. Contributed by Paul Eggert (eggert@twinsun.com). - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - The GNU C Library is distributed in the hope that it will be useful, + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* Define this to have a standalone program to test this implementation of mktime. */ /* #define DEBUG 1 */ @@ -49,11 +50,10 @@ #include <limits.h> #endif +#include "bashansi.h" + #if DEBUG #include <stdio.h> -#if STDC_HEADERS -#include <stdlib.h> -#endif /* Make it work even if the system's libc has its own mktime routine. */ #define mktime my_mktime #endif /* DEBUG */ diff --git a/lib/sh/netconn.c b/lib/sh/netconn.c index ae7c249..36e5bf5 100644 --- a/lib/sh/netconn.c +++ b/lib/sh/netconn.c @@ -4,19 +4,18 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Bash is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - License for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with Bash; see the file COPYING. If not, write to the Free - Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. + along with Bash. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> diff --git a/lib/sh/netopen.c b/lib/sh/netopen.c index d8eec75..736d413 100644 --- a/lib/sh/netopen.c +++ b/lib/sh/netopen.c @@ -9,19 +9,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Bash is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - License for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with Bash; see the file COPYING. If not, write to the Free - Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/oslib.c b/lib/sh/oslib.c index 90d7be9..d47f9dc 100644 --- a/lib/sh/oslib.c +++ b/lib/sh/oslib.c @@ -4,19 +4,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/pathcanon.c b/lib/sh/pathcanon.c index 3b427a8..98e41ce 100644 --- a/lib/sh/pathcanon.c +++ b/lib/sh/pathcanon.c @@ -1,22 +1,22 @@ -/* pathcanon.c -- Canonicalize and manipulate pathnames. */ +/* pathcanon.c -- canonicalize and manipulate pathnames. */ /* Copyright (C) 2000 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/pathphys.c b/lib/sh/pathphys.c index 1f73944..15fcd25 100644 --- a/lib/sh/pathphys.c +++ b/lib/sh/pathphys.c @@ -1,22 +1,22 @@ -/* pathphys.c -- Return pathname with all symlinks expanded. */ +/* pathphys.c -- return pathname with all symlinks expanded. */ /* Copyright (C) 2000 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/rename.c b/lib/sh/rename.c index d5c2778..e410b5e 100644 --- a/lib/sh/rename.c +++ b/lib/sh/rename.c @@ -6,19 +6,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Bash is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - License for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with Bash; see the file COPYING. If not, write to the Free - Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/setlinebuf.c b/lib/sh/setlinebuf.c index 3c5d056..6473ddf 100644 --- a/lib/sh/setlinebuf.c +++ b/lib/sh/setlinebuf.c @@ -4,19 +4,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/shmatch.c b/lib/sh/shmatch.c index f03a2ee..6de1dc1 100644 --- a/lib/sh/shmatch.c +++ b/lib/sh/shmatch.c @@ -1,24 +1,24 @@ +/* + * shmatch.c -- shell interface to posix regular expression matching. + */ + /* Copyright (C) 2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ - -/* - * shmatch.c -- shell interface to posix regular expression matching. - */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/lib/sh/shquote.c b/lib/sh/shquote.c index e992a66..a267d38 100644 --- a/lib/sh/shquote.c +++ b/lib/sh/shquote.c @@ -1,20 +1,22 @@ +/* shquote - functions to quote and dequote strings */ + /* Copyright (C) 1999 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/shtty.c b/lib/sh/shtty.c index 15cc82f..0433f5e 100644 --- a/lib/sh/shtty.c +++ b/lib/sh/shtty.c @@ -1,24 +1,24 @@ +/* + * shtty.c -- abstract interface to the terminal, focusing on capabilities. + */ + /* Copyright (C) 1999 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -/* - * shtty.c -- abstract interface to the terminal, focusing on capabilities. - */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifdef HAVE_CONFIG_H # include <config.h> @@ -85,7 +85,7 @@ ttrestore() ttsaved = 0; } -/* Retrieve the attributes associated with tty fd FD. */ +/* Retrieve the internally-saved attributes associated with tty fd FD. */ TTYSTRUCT * ttattr (fd) int fd; @@ -149,6 +149,17 @@ tt_setonechar(ttp) return 0; } +/* Set the tty associated with FD and TTP into one-character-at-a-time mode */ +int +ttfd_onechar (fd, ttp) + int fd; + TTYSTRUCT *ttp; +{ + if (tt_setonechar(ttp) < 0) + return -1; + return (ttsetattr (fd, ttp)); +} + /* Set the terminal into one-character-at-a-time mode */ int ttonechar () @@ -158,9 +169,7 @@ ttonechar () if (ttsaved == 0) return -1; tt = ttin; - if (tt_setonechar(&tt) < 0) - return -1; - return (ttsetattr (0, &tt)); + return (ttfd_onechar (0, &tt)); } /* @@ -180,6 +189,17 @@ tt_setnoecho(ttp) return 0; } +/* Set the tty associated with FD and TTP into no-echo mode */ +int +ttfd_noecho (fd, ttp) + int fd; + TTYSTRUCT *ttp; +{ + if (tt_setnoecho (ttp) < 0) + return -1; + return (ttsetattr (fd, ttp)); +} + /* Set the terminal into no-echo mode */ int ttnoecho () @@ -189,9 +209,7 @@ ttnoecho () if (ttsaved == 0) return -1; tt = ttin; - if (tt_setnoecho (&tt) < 0) - return -1; - return (ttsetattr (0, &tt)); + return (ttfd_noecho (0, &tt)); } /* @@ -213,6 +231,17 @@ tt_seteightbit (ttp) return 0; } +/* Set the tty associated with FD and TTP into eight-bit mode */ +int +ttfd_eightbit (fd, ttp) + int fd; + TTYSTRUCT *ttp; +{ + if (tt_seteightbit (ttp) < 0) + return -1; + return (ttsetattr (fd, ttp)); +} + /* Set the terminal into eight-bit mode */ int tteightbit () @@ -222,9 +251,7 @@ tteightbit () if (ttsaved == 0) return -1; tt = ttin; - if (tt_seteightbit (&tt) < 0) - return -1; - return (ttsetattr (0, &tt)); + return (ttfd_eightbit (0, &tt)); } /* @@ -242,6 +269,17 @@ tt_setnocanon (ttp) return 0; } +/* Set the tty associated with FD and TTP into non-canonical mode */ +int +ttfd_nocanon (fd, ttp) + int fd; + TTYSTRUCT *ttp; +{ + if (tt_setnocanon (ttp) < 0) + return -1; + return (ttsetattr (fd, ttp)); +} + /* Set the terminal into non-canonical mode */ int ttnocanon () @@ -251,9 +289,7 @@ ttnocanon () if (ttsaved == 0) return -1; tt = ttin; - if (tt_setnocanon (&tt) < 0) - return -1; - return (ttsetattr (0, &tt)); + return (ttfd_nocanon (0, &tt)); } /* @@ -269,6 +305,18 @@ tt_setcbreak(ttp) return (tt_setnoecho (ttp)); } +/* Set the tty associated with FD and TTP into cbreak (no-echo, + one-character-at-a-time) mode */ +int +ttfd_cbreak (fd, ttp) + int fd; + TTYSTRUCT *ttp; +{ + if (tt_setcbreak (ttp) < 0) + return -1; + return (ttsetattr (fd, ttp)); +} + /* Set the terminal into cbreak (no-echo, one-character-at-a-time) mode */ int ttcbreak () @@ -278,7 +326,5 @@ ttcbreak () if (ttsaved == 0) return -1; tt = ttin; - if (tt_setcbreak (&tt) < 0) - return -1; - return (ttsetattr (0, &tt)); + return (ttfd_cbreak (0, &tt)); } diff --git a/lib/sh/snprintf.c b/lib/sh/snprintf.c index 4a96474..d681b16 100644 --- a/lib/sh/snprintf.c +++ b/lib/sh/snprintf.c @@ -1,3 +1,5 @@ +/* snprintf - formatted output to strings, with bounds checking and allocation */ + /* build a test version with gcc -g -DDRIVER -I../.. -I../../include -o test-snprintf snprintf.c fmtu*long.o @@ -7,21 +9,22 @@ Unix snprintf implementation. derived from inetutils/libinetutils/snprintf.c Version 1.1 - Copyright (C) 2001 Free Software Foundation, Inc. + Copyright (C) 2001,2006 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General License as published by - the Free Software Foundation; either version 2 of the License, or + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General License for more details. - - You should have received a copy of the GNU General License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. Revision History: @@ -58,6 +61,15 @@ # include <config.h> #endif +/* GCC 4.2 on Snow Leopard doesn't like the snprintf prototype */ +#if defined(DEBUG) && !defined (MACOSX) +# undef HAVE_SNPRINTF +# undef HAVE_ASPRINTF + +# define HAVE_SNPRINTF 0 +# define HAVE_ASPRINTF 0 +#endif + #if defined(DRIVER) && !defined(HAVE_CONFIG_H) #define HAVE_LONG_LONG #define HAVE_LONG_DOUBLE @@ -74,7 +86,7 @@ #define intmax_t long #endif -#if !defined (HAVE_SNPRINTF) || !defined (HAVE_ASPRINTF) +#if !HAVE_SNPRINTF || !HAVE_ASPRINTF #include <bashtypes.h> @@ -291,6 +303,13 @@ static void dfallback __P((struct DATA *, const char *, const char *, double)); static char *groupnum __P((char *)); +#ifndef HAVE_ISINF_IN_LIBC +static int isinf __P((double)); +#endif +#ifndef HAVE_ISNAN_IN_LIBC +static int isnan __P((double)); +#endif + #ifdef DRIVER static void memory_error_and_abort (); static void *xmalloc __P((size_t)); @@ -401,7 +420,7 @@ static void xfree __P((void *)); } \ } while (0) -#if defined (HAVE_LOCALE_H) +#if defined (HAVE_LOCALE_H) && defined (HAVE_LOCALECONV) # define GETLOCALEDATA(d, t, g) \ do \ { \ @@ -471,6 +490,8 @@ pow_10(n) 10^x ~= r * log_10(200) = 2; * log_10(250) = 2; + * + * NOTE: do not call this with r == 0 -- an infinite loop results. */ static int log_10(r) @@ -576,8 +597,11 @@ numtoa(number, base, precision, fract) { integral_part[0] = '0'; integral_part[1] = '\0'; - fraction_part[0] = '0'; - fraction_part[1] = '\0'; + /* The fractional part has to take the precision into account */ + for (ch = 0; ch < precision-1; ch++) + fraction_part[ch] = '0'; + fraction_part[ch] = '0'; + fraction_part[ch+1] = '\0'; if (fract) *fract = fraction_part; return integral_part; @@ -663,7 +687,8 @@ number(p, d, base) p->flags &= ~PF_ZEROPAD; sd = d; /* signed for ' ' padding in base 10 */ - flags = (*p->pf == 'u' || *p->pf == 'U') ? FL_UNSIGNED : 0; + flags = 0; + flags = (*p->pf == 'x' || *p->pf == 'X' || *p->pf == 'o' || *p->pf == 'u' || *p->pf == 'U') ? FL_UNSIGNED : 0; if (*p->pf == 'X') flags |= FL_HEXUPPER; @@ -733,7 +758,7 @@ lnumber(p, d, base) p->flags &= ~PF_ZEROPAD; sd = d; /* signed for ' ' padding in base 10 */ - flags = (*p->pf == 'u' || *p->pf == 'U') ? FL_UNSIGNED : 0; + flags = (*p->pf == 'x' || *p->pf == 'X' || *p->pf == 'o' || *p->pf == 'u' || *p->pf == 'U') ? FL_UNSIGNED : 0; if (*p->pf == 'X') flags |= FL_HEXUPPER; @@ -805,6 +830,7 @@ pointer(p, d) PUT_CHAR(*tmp, p); tmp++; } + PAD_LEFT(p); } @@ -972,11 +998,21 @@ floating(p, d) if ((p->flags & PF_THOUSANDS) && grouping && (t = groupnum (tmp))) tmp = t; + if ((*p->pf == 'g' || *p->pf == 'G') && (p->flags & PF_ALTFORM) == 0) + { + /* smash the trailing zeros unless altform */ + for (i = strlen(tmp2) - 1; i >= 0 && tmp2[i] == '0'; i--) + tmp2[i] = '\0'; + if (tmp2[0] == '\0') + p->precision = 0; + } + /* calculate the padding. 1 for the dot */ p->width = p->width - ((d > 0. && p->justify == RIGHT) ? 1:0) - ((p->flags & PF_SPACE) ? 1:0) - - strlen(tmp) - p->precision - 1; + strlen(tmp) - p->precision - + ((p->precision != 0 || (p->flags & PF_ALTFORM)) ? 1 : 0); /* radix char */ PAD_RIGHT(p); PUT_PLUS(d, p, 0.); PUT_SPACE(d, p, 0.); @@ -991,11 +1027,6 @@ floating(p, d) if (p->precision != 0 || (p->flags & PF_ALTFORM)) PUT_CHAR(decpoint, p); /* put the '.' */ - if ((*p->pf == 'g' || *p->pf == 'G') && (p->flags & PF_ALTFORM) == 0) - /* smash the trailing zeros unless altform */ - for (i = strlen(tmp2) - 1; i >= 0 && tmp2[i] == '0'; i--) - tmp2[i] = '\0'; - for (; *tmp2; tmp2++) PUT_CHAR(*tmp2, p); /* the fraction */ @@ -1011,14 +1042,19 @@ exponent(p, d) char *tmp, *tmp2; int j, i; - if (chkinfnan(p, d, 1) || chkinfnan(p, d, 2)) + if (d != 0 && (chkinfnan(p, d, 1) || chkinfnan(p, d, 2))) return; /* already printed nan or inf */ GETLOCALEDATA(decpoint, thoussep, grouping); DEF_PREC(p); - j = log_10(d); - d = d / pow_10(j); /* get the Mantissa */ - d = ROUND(d, p); + if (d == 0.) + j = 0; + else + { + j = log_10(d); + d = d / pow_10(j); /* get the Mantissa */ + d = ROUND(d, p); + } tmp = dtoa(d, p->precision, &tmp2); /* 1 for unit, 1 for the '.', 1 for 'e|E', @@ -1076,6 +1112,7 @@ exponent(p, d) PUT_CHAR(*tmp, p); tmp++; } + PAD_LEFT(p); } #endif @@ -1358,7 +1395,7 @@ conv_break: STAR_ARGS(data); DEF_PREC(data); d = GETDOUBLE(data); - i = log_10(d); + i = (d != 0.) ? log_10(d) : -1; /* * for '%g|%G' ANSI: use f if exponent * is in the range or [-4,p] exclusively @@ -1614,7 +1651,7 @@ dfallback (data, fs, fe, d) } #endif /* FLOATING_POINT */ -#ifndef HAVE_SNPRINTF +#if !HAVE_SNPRINTF int #if defined (__STDC__) @@ -1664,7 +1701,7 @@ snprintf(string, length, format, va_alist) #endif /* HAVE_SNPRINTF */ -#ifndef HAVE_ASPRINTF +#if !HAVE_ASPRINTF int #if defined (__STDC__) @@ -1709,9 +1746,9 @@ asprintf(stringp, format, va_alist) return rval; } -#endif +#endif /* !HAVE_ASPRINTF */ -#endif +#endif /* !HAVE_SNPRINTF || !HAVE_ASPRINTF */ #ifdef DRIVER diff --git a/lib/sh/spell.c b/lib/sh/spell.c index cff20b2..d0394c2 100644 --- a/lib/sh/spell.c +++ b/lib/sh/spell.c @@ -2,21 +2,21 @@ /* Copyright (C) 2000 Free Software Foundation, Inc. -This file is part of GNU Bash, the Bourne Again SHell. + This file is part of GNU Bash, the Bourne Again SHell. -Bash is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. -Bash is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License along -with Bash; see the file COPYING. If not, write to the Free Software -Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> @@ -186,3 +186,27 @@ spdist(cur, new) return 3; } + +char * +dirspell (dirname) + char *dirname; +{ + int n; + char *guess; + + n = (strlen (dirname) * 3 + 1) / 2 + 1; + guess = (char *)malloc (n); + if (guess == 0) + return 0; + + switch (spname (dirname, guess)) + { + case -1: + default: + free (guess); + return (char *)NULL; + case 0: + case 1: + return guess; + } +} diff --git a/lib/sh/strcasecmp.c b/lib/sh/strcasecmp.c index 33d925b..5542f71 100644 --- a/lib/sh/strcasecmp.c +++ b/lib/sh/strcasecmp.c @@ -4,19 +4,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/strcasestr.c b/lib/sh/strcasestr.c new file mode 100644 index 0000000..c819b3e --- /dev/null +++ b/lib/sh/strcasestr.c @@ -0,0 +1,46 @@ +/* strcasestr.c - Find if one string appears as a substring of another string, + without regard to case. */ + +/* Copyright (C) 2000 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <config.h> + +#include <bashansi.h> +#include <chartypes.h> + +#include <stdc.h> + +/* Determine if s2 occurs in s1. If so, return a pointer to the + match in s1. The compare is case insensitive. This is a + case-insensitive strstr(3). */ +char * +strcasestr (s1, s2) + const char *s1; + const char *s2; +{ + register int i, l, len, c; + + c = TOLOWER ((unsigned char)s2[0]); + len = strlen (s1); + l = strlen (s2); + for (i = 0; (len - i) >= l; i++) + if ((TOLOWER ((unsigned char)s1[i]) == c) && (strncasecmp (s1 + i, s2, l) == 0)) + return ((char *)s1 + i); + return ((char *)0); +} diff --git a/lib/sh/strerror.c b/lib/sh/strerror.c index 4990aa7..4081e9c 100644 --- a/lib/sh/strerror.c +++ b/lib/sh/strerror.c @@ -4,19 +4,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/strftime.c b/lib/sh/strftime.c index 0783d28..572baae 100644 --- a/lib/sh/strftime.c +++ b/lib/sh/strftime.c @@ -1,7 +1,7 @@ +/* strftime - formatted time and date to a string */ /* * Modified slightly by Chet Ramey for inclusion in Bash */ - /* * strftime.c * @@ -471,6 +471,8 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr) * us that muck around with various message processors. */ case 'z': /* time zone offset east of GMT e.g. -0600 */ + if (timeptr->tm_isdst < 0) + break; #ifdef HAVE_TM_NAME /* * Systems with tm_name probably have tm_tzadj as @@ -493,7 +495,7 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr) # ifdef HPUX off = -timezone / 60; # else - off = -(daylight ? timezone : altzone) / 60; + off = -(daylight ? altzone : timezone) / 60; # endif /* !HPUX */ #else /* !HAVE_TZNAME */ gettimeofday(& tv, & zone); diff --git a/lib/sh/strindex.c b/lib/sh/strindex.c deleted file mode 100644 index 9172862..0000000 --- a/lib/sh/strindex.c +++ /dev/null @@ -1,47 +0,0 @@ -/* strindex.c - Find if one string appears as a substring of another string, - without regard to case. */ - -/* Copyright (C) 2000 - Free Software Foundation, Inc. - - This file is part of GNU Bash, the Bourne Again SHell. - - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ - -#include <config.h> - -#include <bashansi.h> -#include <chartypes.h> - -#include <stdc.h> - -/* Determine if s2 occurs in s1. If so, return a pointer to the - match in s1. The compare is case insensitive. This is a - case-insensitive strstr(3). */ -char * -strindex (s1, s2) - const char *s1; - const char *s2; -{ - register int i, l, len, c; - - c = TOLOWER ((unsigned char)s2[0]); - len = strlen (s1); - l = strlen (s2); - for (i = 0; (len - i) >= l; i++) - if ((TOLOWER ((unsigned char)s1[i]) == c) && (strncasecmp (s1 + i, s2, l) == 0)) - return ((char *)s1 + i); - return ((char *)0); -} diff --git a/lib/sh/stringlist.c b/lib/sh/stringlist.c index efc6fa5..b0c272a 100644 --- a/lib/sh/stringlist.c +++ b/lib/sh/stringlist.c @@ -4,19 +4,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/stringvec.c b/lib/sh/stringvec.c index 222fcd6..b0ed416 100644 --- a/lib/sh/stringvec.c +++ b/lib/sh/stringvec.c @@ -4,19 +4,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/strnlen.c b/lib/sh/strnlen.c index da8feec..10414d3 100644 --- a/lib/sh/strnlen.c +++ b/lib/sh/strnlen.c @@ -1,18 +1,22 @@ +/* strnlen - return length of passed string, with length limit */ + /* Copyright (C) 2004 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/lib/sh/strpbrk.c b/lib/sh/strpbrk.c index 3c493a8..4439986 100644 --- a/lib/sh/strpbrk.c +++ b/lib/sh/strpbrk.c @@ -1,20 +1,25 @@ +/* strpbrk.c - locate multiple characters in a string */ + /* Copyright (C) 1991, 1994 Free Software Foundation, Inc. + NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifdef HAVE_CONFIG_H # include <config.h> diff --git a/lib/sh/strstr.c b/lib/sh/strstr.c index c41e903..c43b05e 100644 --- a/lib/sh/strstr.c +++ b/lib/sh/strstr.c @@ -1,19 +1,22 @@ +/* strstr - find a substring within a string */ + /* Copyright (C) 1994, 1999 Free Software Foundation, Inc. -This file is part of the GNU C Library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* * My personal strstr() implementation that beats most other algorithms. diff --git a/lib/sh/strtod.c b/lib/sh/strtod.c index cc3bec9..851d99b 100644 --- a/lib/sh/strtod.c +++ b/lib/sh/strtod.c @@ -1,18 +1,22 @@ +/* strtod.c - convert string to double-precision floating-point value. */ + /* Copyright (C) 1991, 1992 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #if HAVE_CONFIG_H # include <config.h> diff --git a/lib/sh/strtoimax.c b/lib/sh/strtoimax.c index e20c4cc..a4170f0 100644 --- a/lib/sh/strtoimax.c +++ b/lib/sh/strtoimax.c @@ -1,19 +1,22 @@ -/* Convert string representation of a number into an intmax_t value. - Copyright 1999-2005 Free Software Foundation, Inc. +/* strtoimax - convert string representation of a number into an intmax_t value. */ - This program is free software; you can redistribute it and/or modify +/* Copyright 1999-2009 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* Written by Paul Eggert. Modified by Chet Ramey for Bash. */ @@ -25,6 +28,10 @@ # include <inttypes.h> #endif +#if HAVE_STDINT_H +# include <stdint.h> +#endif + #if HAVE_STDLIB_H # include <stdlib.h> #endif diff --git a/lib/sh/strtol.c b/lib/sh/strtol.c index 2adbb89..8aa7478 100644 --- a/lib/sh/strtol.c +++ b/lib/sh/strtol.c @@ -1,21 +1,22 @@ -/* Convert string representation of a number into an integer value. - Copyright (C) 1991,92,94,95,96,97,98,99,2000,2001 Free Software Foundation, Inc. - This file is part of the GNU C Library. +/* strtol - convert string representation of a number into a long integer value. */ - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. +/* Copyright (C) 1991,92,94,95,96,97,98,99,2000,2001 Free Software Foundation, Inc. - The GNU C Library is distributed in the hope that it will be useful, + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/strtoll.c b/lib/sh/strtoll.c index 2000497..f6060ee 100644 --- a/lib/sh/strtoll.c +++ b/lib/sh/strtoll.c @@ -1,18 +1,22 @@ +/* strtoll - convert string representation of a number into a long long value. */ + /* Copyright (C) 1997 Free Software Foundation, Inc. -This program is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software Foundation, -Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/strtoul.c b/lib/sh/strtoul.c index 4a75d76..cbaa484 100644 --- a/lib/sh/strtoul.c +++ b/lib/sh/strtoul.c @@ -1,18 +1,22 @@ +/* strtoul - convert string representation of a number into an unsigned long value. */ + /* Copyright (C) 1997 Free Software Foundation, Inc. -This program is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software Foundation, -Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/strtoull.c b/lib/sh/strtoull.c index 09a2fac..02ddebb 100644 --- a/lib/sh/strtoull.c +++ b/lib/sh/strtoull.c @@ -1,18 +1,22 @@ +/* strtoull - convert string representation of a number into an unsigned long long value. */ + /* Copyright (C) 1997 Free Software Foundation, Inc. -This program is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software Foundation, -Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/strtoumax.c b/lib/sh/strtoumax.c index e723d49..09423ad 100644 --- a/lib/sh/strtoumax.c +++ b/lib/sh/strtoumax.c @@ -1,19 +1,22 @@ -/* Convert string representation of a number into an uintmax_t value. - Copyright 1999-2005 Free Software Foundation, Inc. +/* strtoumax - convert string representation of a number into an uintmax_t value. */ - This program is free software; you can redistribute it and/or modify +/* Copyright 1999-2009 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* Written by Paul Eggert. Modified by Chet Ramey for Bash. */ @@ -25,6 +28,10 @@ # include <inttypes.h> #endif +#if HAVE_STDINT_H +# include <stdint.h> +#endif + #if HAVE_STDLIB_H # include <stdlib.h> #endif diff --git a/lib/sh/strtrans.c b/lib/sh/strtrans.c index 1f0290e..355a306 100644 --- a/lib/sh/strtrans.c +++ b/lib/sh/strtrans.c @@ -1,24 +1,22 @@ -/* strtrans.c - Translate and untranslate strings with ANSI-C escape - sequences. */ +/* strtrans.c - Translate and untranslate strings with ANSI-C escape sequences. */ -/* Copyright (C) 2000 - Free Software Foundation, Inc. +/* Copyright (C) 2000 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/times.c b/lib/sh/times.c index 7136cf2..47ddf57 100644 --- a/lib/sh/times.c +++ b/lib/sh/times.c @@ -4,19 +4,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/timeval.c b/lib/sh/timeval.c index f7f624e..7bd9df8 100644 --- a/lib/sh/timeval.c +++ b/lib/sh/timeval.c @@ -4,19 +4,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/tmpfile.c b/lib/sh/tmpfile.c index 5f2279d..a87c254 100644 --- a/lib/sh/tmpfile.c +++ b/lib/sh/tmpfile.c @@ -6,19 +6,19 @@ This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Bash is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - License for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with Bash; see the file COPYING. If not, write to the Free - Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> @@ -91,6 +91,9 @@ get_tmpdir (flags) char *tdir; tdir = (flags & MT_USETMPDIR) ? get_string_value ("TMPDIR") : (char *)NULL; + if (tdir && (file_iswdir (tdir) == 0 || strlen (tdir) > PATH_MAX)) + tdir = 0; + if (tdir == 0) tdir = get_sys_tmpdir (); diff --git a/lib/sh/uconvert.c b/lib/sh/uconvert.c new file mode 100644 index 0000000..3d656df --- /dev/null +++ b/lib/sh/uconvert.c @@ -0,0 +1,116 @@ +/* uconvert - convert string representations of decimal numbers into whole + number/fractional value pairs. */ + +/* Copyright (C) 2008,2009 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "config.h" + +#include "bashtypes.h" + +#if defined (TIME_WITH_SYS_TIME) +# include <sys/time.h> +# include <time.h> +#else +# if defined (HAVE_SYS_TIME_H) +# include <sys/time.h> +# else +# include <time.h> +# endif +#endif + +#if defined (HAVE_UNISTD_H) +#include <unistd.h> +#endif + +#include <stdio.h> +#include "chartypes.h" + +#include "shell.h" +#include "builtins.h" + +#define DECIMAL '.' /* XXX - should use locale */ + +#define RETURN(x) \ +do { \ + if (ip) *ip = ipart * mult; \ + if (up) *up = upart; \ + return (x); \ +} while (0) + +/* + * An incredibly simplistic floating point converter. + */ +static int multiplier[7] = { 1, 100000, 10000, 1000, 100, 10, 1 }; + +/* Take a decimal number int-part[.[micro-part]] and convert it to the whole + and fractional portions. The fractional portion is returned in + millionths (micro); callers are responsible for multiplying appropriately. + Return 1 if value converted; 0 if invalid integer for either whole or + fractional parts. */ +int +uconvert(s, ip, up) + char *s; + long *ip, *up; +{ + int n, mult; + long ipart, upart; + char *p; + + ipart = upart = 0; + mult = 1; + + if (s && (*s == '-' || *s == '+')) + { + mult = (*s == '-') ? -1 : 1; + p = s + 1; + } + else + p = s; + + for ( ; p && *p; p++) + { + if (*p == DECIMAL) /* decimal point */ + break; + if (DIGIT(*p) == 0) + RETURN(0); + ipart = (ipart * 10) + (*p - '0'); + } + + if (p == 0 || *p == 0) /* callers ensure p can never be 0; this is to shut up clang */ + RETURN(1); + + if (*p == DECIMAL) + p++; + + /* Look for up to six digits past a decimal point. */ + for (n = 0; n < 6 && p[n]; n++) + { + if (DIGIT(p[n]) == 0) + RETURN(0); + upart = (upart * 10) + (p[n] - '0'); + } + + /* Now convert to millionths */ + upart *= multiplier[n]; + + if (n == 6 && p[6] >= '5' && p[6] <= '9') + upart++; /* round up 1 */ + + RETURN(1); +} diff --git a/lib/sh/ufuncs.c b/lib/sh/ufuncs.c new file mode 100644 index 0000000..ed526fe --- /dev/null +++ b/lib/sh/ufuncs.c @@ -0,0 +1,104 @@ +/* ufuncs - sleep and alarm functions that understand fractional values */ + +/* Copyright (C) 2008,2009 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "config.h" + +#include "bashtypes.h" + +#if defined (TIME_WITH_SYS_TIME) +# include <sys/time.h> +# include <time.h> +#else +# if defined (HAVE_SYS_TIME_H) +# include <sys/time.h> +# else +# include <time.h> +# endif +#endif + +#if defined (HAVE_UNISTD_H) +#include <unistd.h> +#endif + +/* A version of `alarm' using setitimer if it's available. */ + +#if defined (HAVE_SETITIMER) +unsigned int +falarm(secs, usecs) + unsigned int secs, usecs; +{ + struct itimerval it, oit; + + it.it_interval.tv_sec = 0; + it.it_interval.tv_usec = 0; + + it.it_value.tv_sec = secs; + it.it_value.tv_usec = usecs; + + if (setitimer(ITIMER_REAL, &it, &oit) < 0) + return (-1); /* XXX will be converted to unsigned */ + + /* Backwards compatibility with alarm(3) */ + if (oit.it_value.tv_usec) + oit.it_value.tv_sec++; + return (oit.it_value.tv_sec); +} +#else +int +falarm (secs, usecs) + unsigned int secs, usecs; +{ + if (secs == 0 && usecs == 0) + return (alarm (0)); + + if (secs == 0 || usecs >= 500000) + { + secs++; + usecs = 0; + } + return (alarm (secs)); +} +#endif /* !HAVE_SETITIMER */ + +/* A version of sleep using fractional seconds and select. I'd like to use + `usleep', but it's already taken */ + +#if defined (HAVE_TIMEVAL) && defined (HAVE_SELECT) +int +fsleep(sec, usec) + unsigned int sec, usec; +{ + struct timeval tv; + + tv.tv_sec = sec; + tv.tv_usec = usec; + + return select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &tv); +} +#else /* !HAVE_TIMEVAL || !HAVE_SELECT */ +int +fsleep(sec, usec) + long sec, usec; +{ + if (usec >= 500000) /* round */ + sec++; + return (sleep(sec)); +} +#endif /* !HAVE_TIMEVAL || !HAVE_SELECT */ diff --git a/lib/sh/vprint.c b/lib/sh/vprint.c index 929bdbc..567fba3 100644 --- a/lib/sh/vprint.c +++ b/lib/sh/vprint.c @@ -2,21 +2,21 @@ /* Copyright (C) 1987,1989 Free Software Foundation, Inc. -This file is part of GNU Bash, the Bourne Again SHell. + This file is part of GNU Bash, the Bourne Again SHell. -Bash is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. -Bash is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License along -with Bash; see the file COPYING. If not, write to the Free Software -Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/wcsdup.c b/lib/sh/wcsdup.c index e045307..62a3c86 100644 --- a/lib/sh/wcsdup.c +++ b/lib/sh/wcsdup.c @@ -1,22 +1,22 @@ -/* wcsdup.c - wcsdup(3) library function */ +/* wcsdup.c - duplicate wide character string */ /* Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/winsize.c b/lib/sh/winsize.c index f4696de..64a9858 100644 --- a/lib/sh/winsize.c +++ b/lib/sh/winsize.c @@ -1,22 +1,22 @@ -/* Handle window size changes and information. */ +/* winsize.c - handle window size changes and information. */ /* Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include "config.h" @@ -30,16 +30,29 @@ #include <sys/ioctl.h> -#if !defined (STRUCT_WINSIZE_IN_SYS_IOCTL) -/* For struct winsize on SCO */ -/* sys/ptem.h has winsize but needs mblk_t from sys/stream.h */ -# if defined (HAVE_SYS_PTEM_H) && defined (TIOCGWINSZ) && defined (SIGWINCH) -# if defined (HAVE_SYS_STREAM_H) -# include <sys/stream.h> -# endif +/* Try to find the definitions of `struct winsize' and TIOGCWINSZ */ + +#if defined (GWINSZ_IN_SYS_IOCTL) && !defined (TIOCGWINSZ) +# include <sys/ioctl.h> +#endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */ + +#if defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined (STRUCT_WINSIZE_IN_SYS_IOCTL) +# include <termios.h> +#endif /* STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */ + +/* Not in either of the standard places, look around. */ +#if !defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined (STRUCT_WINSIZE_IN_SYS_IOCTL) +# if defined (HAVE_SYS_STREAM_H) +# include <sys/stream.h> +# endif /* HAVE_SYS_STREAM_H */ +# if defined (HAVE_SYS_PTEM_H) /* SVR4.2, at least, has it here */ # include <sys/ptem.h> -# endif /* HAVE_SYS_PTEM_H && TIOCGWINSZ && SIGWINCH */ -#endif /* !STRUCT_WINSIZE_IN_SYS_IOCTL */ +# define _IO_PTEM_H /* work around SVR4.2 1.1.4 bug */ +# endif /* HAVE_SYS_PTEM_H */ +# if defined (HAVE_SYS_PTE_H) /* ??? */ +# include <sys/pte.h> +# endif /* HAVE_SYS_PTE_H */ +#endif /* !STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */ #include <stdio.h> diff --git a/lib/sh/zcatfd.c b/lib/sh/zcatfd.c index 24020eb..bdbcd91 100644 --- a/lib/sh/zcatfd.c +++ b/lib/sh/zcatfd.c @@ -1,20 +1,22 @@ +/* zcatfd - copy contents of file descriptor to another */ + /* Copyright (C) 2002 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/sh/zgetline.c b/lib/sh/zgetline.c new file mode 100644 index 0000000..33ac830 --- /dev/null +++ b/lib/sh/zgetline.c @@ -0,0 +1,121 @@ +/* zgetline - read a line of input from a specified file descriptor and return + a pointer to a newly-allocated buffer containing the data. */ + +/* Copyright (C) 2008,2009 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <config.h> + +#include <sys/types.h> + +#if defined (HAVE_UNISTD_H) +# include <unistd.h> +#endif + +#include <errno.h> +#include "xmalloc.h" + +#if !defined (errno) +extern int errno; +#endif + +extern ssize_t zread __P((int, char *, size_t)); +extern ssize_t zreadc __P((int, char *)); +extern ssize_t zreadintr __P((int, char *, size_t)); +extern ssize_t zreadcintr __P((int, char *)); + +typedef ssize_t breadfunc_t __P((int, char *, size_t)); +typedef ssize_t creadfunc_t __P((int, char *)); + +/* Initial memory allocation for automatic growing buffer in zreadlinec */ +#define GET_LINE_INITIAL_ALLOCATION 16 + +/* Derived from GNU libc's getline. + The behavior is almost the same as getline. See man getline. + The differences are + (1) using file descriptor instead of FILE *, + (2) the order of arguments; the file descriptor comes the first, and + (3) the addtion of thired argument, UNBUFFERED_READ; this argument + controls whether get_line uses buffering or not to get a byte data + from FD. get_line uses zreadc if UNBUFFERED_READ is zero; and + uses zread if UNBUFFERED_READ is non-zero. + + Returns number of bytes read or -1 on error. */ + +ssize_t +zgetline (fd, lineptr, n, unbuffered_read) + int fd; + char **lineptr; + size_t *n; + int unbuffered_read; +{ + int nr, retval; + char *line, c; + + if (lineptr == 0 || n == 0 || (*lineptr == 0 && *n != 0)) + return -1; + + nr = 0; + line = *lineptr; + + while (1) + { + retval = unbuffered_read ? zread (fd, &c, 1) : zreadc(fd, &c); + + if (retval <= 0) + { + if (line && nr > 0) + line[nr] = '\0'; + break; + } + + if (nr + 2 >= *n) + { + size_t new_size; + + new_size = (*n == 0) ? GET_LINE_INITIAL_ALLOCATION : *n * 2; + line = (*n >= new_size) ? NULL : xrealloc (*lineptr, new_size); + + if (line) + { + *lineptr = line; + *n = new_size; + } + else + { + if (*n > 0) + { + (*lineptr)[*n - 1] = '\0'; + nr = *n - 2; + } + break; + } + } + + line[nr] = c; + nr++; + + if (c == '\n') + { + line[nr] = '\0'; + break; + } + } + + return nr - 1; +} diff --git a/lib/sh/zmapfd.c b/lib/sh/zmapfd.c new file mode 100644 index 0000000..4000c4a --- /dev/null +++ b/lib/sh/zmapfd.c @@ -0,0 +1,90 @@ +/* zmapfd - read contents of file descriptor into a newly-allocated buffer */ + +/* Copyright (C) 2006 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <config.h> + +#include <sys/types.h> + +#if defined (HAVE_UNISTD_H) +# include <unistd.h> +#endif + +#include <errno.h> + +#include "bashansi.h" +#include "command.h" +#include "general.h" + +#if !defined (errno) +extern int errno; +#endif + +extern ssize_t zread __P((int, char *, size_t)); + +/* Dump contents of file descriptor FD to *OSTR. FN is the filename for + error messages (not used right now). */ +int +zmapfd (fd, ostr, fn) + int fd; + char **ostr; + char *fn; +{ + ssize_t nr; + int rval; + char lbuf[128]; + char *result; + int rsize, rind; + + rval = 0; + result = (char *)xmalloc (rsize = 64); + rind = 0; + + while (1) + { + nr = zread (fd, lbuf, sizeof (lbuf)); + if (nr == 0) + { + rval = rind; + break; + } + else if (nr < 0) + { + rval = -1; + free (result); + if (ostr) + *ostr = (char *)NULL; + break; + } + + RESIZE_MALLOCED_BUFFER (result, rind, nr, rsize, 128); + memcpy (result+rind, lbuf, nr); + rind += nr; + } + + RESIZE_MALLOCED_BUFFER (result, rind, 1, rsize, 128); + result[rind] = '\0'; + + if (ostr) + *ostr = result; + else + free (result); + + return rval; +} diff --git a/lib/sh/zread.c b/lib/sh/zread.c index 460234b..0fd1199 100644 --- a/lib/sh/zread.c +++ b/lib/sh/zread.c @@ -1,20 +1,22 @@ +/* zread - read data from file descriptor into buffer with retries */ + /* Copyright (C) 1999-2002 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> @@ -58,7 +60,7 @@ zread (fd, buf, len) #define NUM_INTR 3 ssize_t -zreadintr (fd, buf, len) +zreadretry (fd, buf, len) int fd; char *buf; size_t len; @@ -73,7 +75,7 @@ zreadintr (fd, buf, len) return r; if (r == -1 && errno == EINTR) { - if (++nintr > NUM_INTR) + if (++nintr >= NUM_INTR) return -1; continue; } @@ -81,6 +83,16 @@ zreadintr (fd, buf, len) } } +/* Call read(2) and allow it to be interrupted. Just a stub for now. */ +ssize_t +zreadintr (fd, buf, len) + int fd; + char *buf; + size_t len; +{ + return (read (fd, buf, len)); +} + /* Read one character from FD and return it in CP. Return values are as in read(2). This does some local buffering to avoid many one-character calls to read(2), like those the `read' builtin performs. */ @@ -111,6 +123,31 @@ zreadc (fd, cp) return 1; } +/* Don't mix calls to zreadc and zreadcintr in the same function, since they + use the same local buffer. */ +ssize_t +zreadcintr (fd, cp) + int fd; + char *cp; +{ + ssize_t nr; + + if (lind == lused || lused == 0) + { + nr = zreadintr (fd, lbuf, sizeof (lbuf)); + lind = 0; + if (nr <= 0) + { + lused = 0; + return nr; + } + lused = nr; + } + if (cp) + *cp = lbuf[lind++]; + return 1; +} + void zreset () { diff --git a/lib/sh/zwrite.c b/lib/sh/zwrite.c index cf1f9e6..3240f4f 100644 --- a/lib/sh/zwrite.c +++ b/lib/sh/zwrite.c @@ -1,20 +1,22 @@ +/* zwrite - write contents of buffer to file descriptor, retrying on error */ + /* Copyright (C) 1999-2002 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. - Bash is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. - - Bash is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with Bash; see the file COPYING. If not, write to the Free Software - Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #include <config.h> diff --git a/lib/termcap/Makefile.in b/lib/termcap/Makefile.in index bf5639f..aeee47f 100644 --- a/lib/termcap/Makefile.in +++ b/lib/termcap/Makefile.in @@ -4,21 +4,20 @@ # # #################################################################### -# Copyright (C) 1996-2005 Free Software Foundation, Inc. +# Copyright (C) 1996-2009 Free Software Foundation, Inc. -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. srcdir = @srcdir@ VPATH = .:@srcdir@ diff --git a/lib/termcap/grot/COPYING b/lib/termcap/grot/COPYING deleted file mode 100644 index 2b940a4..0000000 --- a/lib/termcap/grot/COPYING +++ /dev/null @@ -1,347 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -The Free Software Foundation has exempted Bash from the requirement of -Paragraph 2c of the General Public License. This is to say, there is -no requirement for Bash to print a notice when it is started -interactively in the usual way. We made this exception because users -and standards expect shells not to print such messages. This -exception applies to any program that serves as a shell and that is -based primarily on Bash as opposed to other GNU software. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) 19yy <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/lib/termcap/grot/ChangeLog b/lib/termcap/grot/ChangeLog deleted file mode 100644 index e8c4751..0000000 --- a/lib/termcap/grot/ChangeLog +++ /dev/null @@ -1,137 +0,0 @@ -Wed Aug 16 20:45:44 1995 David J. MacKenzie <djm@geech.gnu.ai.mit.edu> - - * version.c: Version 1.3. - - * termcap.c (tgetent): Use the user-supplied buffer even if we - don't find a matching terminal, so the program can set the buffer - if they want (`less' does this). From Bob Pegram - <pegram@emba.uvm.edu>. - -Wed Jul 26 11:44:51 1995 David J. MacKenzie <djm@geech.gnu.ai.mit.edu> - - * termcap.c: TERMCAP_NAME -> TERMCAP_FILE. - - * configure.in: Add --enable-install-termcap and --with-termcap - options. - - * Makefile.in: Add hooks for new configure options. - - * Makefile.in (DISTFILES): Add termcap.src. - (DEFS): Remove -DNO_ARG_ARRAY. - (install-data, uninstall-data): New targets. - - * tparam.c (tparam): Remove arg array version and the #ifdef. - - * termcap.c: Move #define of bcopy to after #include <string.h>. - - * termcap.h: Prototype the arg to the tputs outfun arg. - - * Makefile.in: realclean -> maintainer-clean. Use @prefix@ and - @exec_prefix@. - - * Makefile.in (DISTFILES): Add install-sh. - -Fri Apr 7 14:57:45 1995 Richard Stallman <rms@mole.gnu.ai.mit.edu> - - * termcap.c (tgetent): Don't try to return the allocated address. - Always return 1 if successful. - -Tue Feb 14 02:34:43 1995 Richard Stallman <rms@pogo.gnu.ai.mit.edu> - - * termcap.c (speeds): Make it ints. Add some higher speeds. - (tputs) [emacs]: If speed is high, convert to smaller units. - (tputs): Really use SPEED to calculate PADCOUNT. - -Sat Dec 17 07:20:24 1994 Richard Stallman <rms@mole.gnu.ai.mit.edu> - - * termcap.c (tgetst1): Let ^? stand for DEL character. - -Thu Jun 30 04:35:50 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * configure.in: Use AC_HAVE_HEADERS instead of AC_UNISTD_H. - Add AC_PROG_RANLIB. - * Makefile.in (AR, RANLIB): New variables. - (install, libtermcap.a): Use them instead of hard-wired commands. - -Sat Jun 4 12:21:41 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * termcap.c [HAVE_CONFIG_H]: Include <sys/file.h>, and include - <fcntl.h> #ifdef USG5, so we get O_* defns. - -Wed May 25 19:05:30 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * termcap.c (O_RDONLY): Define to 0 if not already defined. - (tgetent): Use O_RDONLY instead of explicit 0 in call to open. - -Wed Jan 5 22:20:15 1993 Morten Welinder (terra@diku.dk) - - * termcap.c (tgetent) [INTERNAL_TERMINAL]: Fake internal terminal - without reading any files. - (valid_file_name, tgetent) [MSDOS]: Drive letter support. - (tgetent) [MSDOS]: Use text mode for database. - -Fri Dec 17 00:22:43 1993 Mike Long (mike.long@analog.com) - - * termcap.c (tgetent): Replaced literal filenames for termcap - database with preprocessor symbol TERMCAP_NAME. - (TERMCAP_NAME): Define if not defined. - -Fri Sep 10 00:35:07 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Makefile.in (.c.o): Put -I. before -I$(srcdir). - * termcap.c: Include <config.h> instead of "config.h". - * tparam.c: Likewise. - -Thu Jul 29 20:53:30 1993 David J. MacKenzie (djm@wookumz.gnu.ai.mit.edu) - - * Makefile.in (config.status): Run config.status --recheck, not - configure, to get the right args passed. - -Thu Apr 15 12:45:10 1993 David J. MacKenzie (djm@kropotkin.gnu.ai.mit.edu) - - * Version 1.2. - - * tparam.c [!emacs] (xmalloc, xrealloc, memory_out): New functions. - (tparam1): Use them. - - * termcap.c, tparam.c: Use NULL or '\0' where appropriate - instead of 0. Rename some vars. - * termcap.c (tgetent): If EOF is reached on termcap file, - free allocated resources before returning. - - * termcap.c (tgetent): Use /etc/termcap if TERMCAP is an entry - for a term type other than TERM. - From pjr@jet.UK (Paul J Rippin). - -Sat Apr 10 23:55:12 1993 Richard Stallman (rms@mole.gnu.ai.mit.edu) - - * tparam.c (tparam1): Don't set the 0200 bit on a non-0 character code. - From junio@twinsun.COM (Junio Hamano). - -Tue Dec 8 22:02:15 1992 David J. MacKenzie (djm@kropotkin.gnu.ai.mit.edu) - - * termcap.c, tparam.c: Use HAVE_STRING_H instead of USG. - -Thu Dec 3 13:47:56 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu) - - * termcap.c, tparam.c [HAVE_CONFIG_H]: Include config.h. - -Fri Oct 23 12:35:29 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu) - - * termcap.h [__STDC__]: Add consts. From Franc,ois Pinard. - -Tue Oct 13 15:52:21 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu) - - * Version 1.1. - -Tue Sep 29 21:04:39 1992 David J. MacKenzie (djm@geech.gnu.ai.mit.edu) - - * termcap.[ch], tparam.c: Fix some lint. - - * version.c: New file. - -Local Variables: -mode: indented-text -left-margin: 8 -version-control: never -End: diff --git a/lib/termcap/grot/INSTALL b/lib/termcap/grot/INSTALL deleted file mode 100644 index 95d84c8..0000000 --- a/lib/termcap/grot/INSTALL +++ /dev/null @@ -1,176 +0,0 @@ -Basic Installation -================== - - These are generic installation instructions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, a file -`config.cache' that saves the results of its tests to speed up -reconfiguring, and a file `config.log' containing compiler output -(useful mainly for debugging `configure'). - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If at some point `config.cache' -contains results you don't want to keep, you may remove or edit it. - - The file `configure.in' is used to create `configure' by a program -called `autoconf'. You only need `configure.in' if you want to change -it or regenerate `configure' using a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. You can give `configure' -initial values for variables by setting them in the environment. Using -a Bourne-compatible shell, you can do that on the command line like -this: - CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure - -Or on systems that have the `env' program, you can do it like this: - env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not supports the `VPATH' -variable, you have to compile the package for one architecture at a time -in the source code directory. After you have installed the package for -one architecture, use `make distclean' before reconfiguring for another -architecture. - -Installation Names -================== - - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - - There may be some features `configure' can not figure out -automatically, but needs to determine by the type of host the package -will run on. Usually `configure' can figure that out, but if it prints -a message saying it can not guess the host type, give it the -`--host=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name with three fields: - CPU-COMPANY-SYSTEM - -See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the host type. - - If you are building compiler tools for cross-compiling, you can also -use the `--target=TYPE' option to select the type of system they will -produce code for and the `--build=TYPE' option to select the type of -system on which you are compiling the package. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Operation Controls -================== - - `configure' recognizes the following options to control how it -operates. - -`--cache-file=FILE' - Use and save the results of the tests in FILE instead of - `./config.cache'. Set FILE to `/dev/null' to disable caching, for - debugging `configure'. - -`--help' - Print a summary of the options to `configure', and exit. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`--version' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`configure' also accepts some other, not widely useful, options. - diff --git a/lib/termcap/grot/Makefile.in b/lib/termcap/grot/Makefile.in deleted file mode 100644 index e6f06ae..0000000 --- a/lib/termcap/grot/Makefile.in +++ /dev/null @@ -1,138 +0,0 @@ -# Makefile for GNU termcap library. -# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. - -#### Start of system configuration section. #### - -srcdir = @srcdir@ -VPATH = @srcdir@ - -CC = @CC@ -AR = ar -RANLIB = @RANLIB@ - -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ - -MAKEINFO = makeinfo - -DEFS = @DEFS@ -DTERMCAP_FILE=\"$(termcapfile)\" - -CFLAGS = -g - -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -# Directory in which to install libtermcap.a. -libdir = $(exec_prefix)/lib - -# Directory in which to install termcap.h. -includedir = $(prefix)/include - -# Directory in which to optionally also install termcap.h, -# so compilers besides gcc can find it by default. -# If it is empty or not defined, termcap.h will only be installed in -# includedir. -oldincludedir = /usr/include - -# Directory in which to install the documentation info files. -infodir = $(prefix)/info - -# File to which `install-data' should install the data file -# if --enable-install-termcap was given. -termcapfile = @termcapfile@ - -#### End of system configuration section. #### - -SHELL = /bin/sh - -SRCS = termcap.c tparam.c version.c -OBJS = termcap.o tparam.o version.o -HDRS = termcap.h -DISTFILES = $(SRCS) $(HDRS) ChangeLog COPYING README INSTALL NEWS \ -termcap.src termcap.texi termcap.info* \ -texinfo.tex Makefile.in configure configure.in mkinstalldirs install-sh - -all: libtermcap.a info - -.c.o: - $(CC) -c $(CPPFLAGS) $(DEFS) -I. -I$(srcdir) $(CFLAGS) $< - -install: all installdirs @installdata@ - $(INSTALL_DATA) libtermcap.a $(libdir)/libtermcap.a - -$(RANLIB) $(libdir)/libtermcap.a - cd $(srcdir); $(INSTALL_DATA) termcap.h $(includedir)/termcap.h - -cd $(srcdir); test -z "$(oldincludedir)" || \ - $(INSTALL_DATA) termcap.h $(oldincludedir)/termcap.h - cd $(srcdir); for f in termcap.info*; \ - do $(INSTALL_DATA) $$f $(infodir)/$$f; done - -uninstall: @uninstalldata@ - rm -f $(libdir)/libtermcap.a $(includedir)/termcap.h - test -z "$(oldincludedir)" || rm -f $(oldincludedir)/termcap.h - rm -f $(infodir)/termcap.info* - -# These are separate targets to avoid trashing the user's existing -# termcap file unexpectedly. -install-data: - $(INSTALL_DATA) ${srcdir}/termcap.src ${termcapfile} - -uninstall-data: - rm -f ${termcapfile} - -installdirs: - $(SHELL) ${srcdir}/mkinstalldirs $(bindir) $(libdir) \ - $(includedir) $(infodir) - -Makefile: Makefile.in config.status - $(SHELL) config.status -config.status: configure - $(SHELL) config.status --recheck -configure: configure.in - cd $(srcdir) && autoconf - -libtermcap.a: $(OBJS) - $(AR) rc $@ $(OBJS) - -$(RANLIB) $@ - -info: termcap.info - -termcap.info: termcap.texi - $(MAKEINFO) $(srcdir)/termcap.texi --output=$@ - -TAGS: $(SRCS) - etags $(SRCS) - -clean: - rm -f *.a *.o core - -mostlyclean: clean - -distclean: clean - rm -f Makefile config.status config.cache config.log - -maintainer-clean: distclean - @echo "This command is intended for maintainers to use;" - @echo "rebuilding the deleted files requires makeinfo." - rm -f TAGS *.info* - -dist: $(DISTFILES) - echo termcap-`sed -e '/version_string/!d' -e 's/[^0-9]*\([0-9a-z.]*\).*/\1/' -e q version.c` > .fname - rm -rf `cat .fname` - mkdir `cat .fname` - ln $(DISTFILES) `cat .fname` - tar chzf `cat .fname`.tar.gz `cat .fname` - rm -rf `cat .fname` .fname diff --git a/lib/termcap/grot/NEWS b/lib/termcap/grot/NEWS deleted file mode 100644 index e5d58b9..0000000 --- a/lib/termcap/grot/NEWS +++ /dev/null @@ -1,20 +0,0 @@ -Major changes in release 1.3: - -Termcap data file is now included in distribution and may optionally - be installed, or used in a non-default location. -Support for a fake internal terminal (no external files). -Higher tty speeds supported. -Portability tweaks. - -Major changes in release 1.2: - -For `%.', only set the high bit on NUL. -Fix a file descriptor and memory leak. -Add const in termcap.h prototypes. -Configuration improvements. - -Major changes in release 1.1: - -Fix portability problems. -Improve configuration and installation. -Fix compiler warnings. diff --git a/lib/termcap/grot/README b/lib/termcap/grot/README deleted file mode 100644 index ba1a19c..0000000 --- a/lib/termcap/grot/README +++ /dev/null @@ -1,34 +0,0 @@ -This is the GNU termcap library -- a library of C functions that -enable programs to send control strings to terminals in a way -independent of the terminal type. The GNU termcap library does not -place an arbitrary limit on the size of termcap entries, unlike most -other termcap libraries. - -Most of this package is also distributed with GNU Emacs, but it is -available in this separate distribution to make it easier to install -as -ltermcap. However, use of termcap is discouraged. Termcap is -being phased out in favor of the terminfo-based ncurses library, which -contains an emulation of the termcap library routines in addition to -an excellent curses implementation. ncurses is available from the -usual GNU archive sites. - -See the file INSTALL for compilation and installation instructions. -Additionally: - -This package contains termcap.src, the latest official termcap data -file. By default, it is not installed. The current version contains -some entries that are more than 1023 bytes long, which is the largest -value that is safe to use with the many historical applications that -only allocate a 1024 byte termcap buffer (telnet, for example). If -you make sure that all of your programs allocate buffers of at least -2500 bytes, or let the termcap library do it by passing a NULL -pointer, then it is safe to install the new termcap file, as described -below. - -You can give configure two special options: - --enable-install-termcap install the termcap data file - --with-termcap=FILE use data file FILE instead of /etc/termcap - -Please report any bugs in this library to bug-gnu-emacs@prep.ai.mit.edu. -You can check which version of the library you have by using the RCS -`ident' command on libtermcap.a. diff --git a/lib/termcap/grot/configure b/lib/termcap/grot/configure deleted file mode 100755 index 8a885fa..0000000 --- a/lib/termcap/grot/configure +++ /dev/null @@ -1,998 +0,0 @@ -#! /bin/sh - -# Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.4 -# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. - -# Defaults: -ac_help= -ac_default_prefix=/usr/local -# Any additions from configure.in: -ac_help="$ac_help - --enable-install-termcap install the termcap data file" -ac_help="$ac_help - --with-termcap=FILE use data file FILE instead of /etc/termcap" - -# Initialize some variables set by options. -# The variables have the same names as the options, with -# dashes changed to underlines. -build=NONE -cache_file=./config.cache -exec_prefix=NONE -host=NONE -no_create= -nonopt=NONE -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -target=NONE -verbose= -x_includes=NONE -x_libraries=NONE - -# Initialize some other variables. -subdirs= - -ac_prev= -for ac_option -do - - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" - ac_prev= - continue - fi - - case "$ac_option" in - -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) ac_optarg= ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case "$ac_option" in - - -build | --build | --buil | --bui | --bu | --b) - ac_prev=build ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=* | --b=*) - build="$ac_optarg" ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file="$ac_optarg" ;; - - -disable-* | --disable-*) - ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - eval "enable_${ac_feature}=no" ;; - - -enable-* | --enable-*) - ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "enable_${ac_feature}='$ac_optarg'" ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix="$ac_optarg" ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he) - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat << EOF -Usage: configure [options] [host] -Options: [defaults in brackets after descriptions] -Configuration: - --cache-file=FILE cache test results in FILE - --help print this message - --no-create do not create output files - --quiet, --silent do not print \`checking...' messages - --version print the version of autoconf that created configure -Directory and file names: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=PREFIX install architecture-dependent files in PREFIX - [same as prefix] - --srcdir=DIR find the sources in DIR [configure dir or ..] - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM run sed PROGRAM on installed program names -Host type: - --build=BUILD configure for building on BUILD [BUILD=HOST] - --host=HOST configure for HOST [guessed] - --target=TARGET configure for TARGET [TARGET=HOST] -Features and packages: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --x-includes=DIR X include files are in DIR - --x-libraries=DIR X library files are in DIR ---enable and --with options recognized:$ac_help -EOF - exit 0 ;; - - -host | --host | --hos | --ho) - ac_prev=host ;; - -host=* | --host=* | --hos=* | --ho=*) - host="$ac_optarg" ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix="$ac_optarg" ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix="$ac_optarg" ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix="$ac_optarg" ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name="$ac_optarg" ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site="$ac_optarg" ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir="$ac_optarg" ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target="$ac_optarg" ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.4" - exit 0 ;; - - -with-* | --with-*) - ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "with_${ac_package}='$ac_optarg'" ;; - - -without-* | --without-*) - ac_package=`echo $ac_option|sed -e 's/-*without-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - eval "with_${ac_package}=no" ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes="$ac_optarg" ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries="$ac_optarg" ;; - - -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } - ;; - - *) - if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then - echo "configure: warning: $ac_option: invalid host type" 1>&2 - fi - if test "x$nonopt" != xNONE; then - { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } - fi - nonopt="$ac_option" - ;; - - esac -done - -if test -n "$ac_prev"; then - { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } -fi - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -# File descriptor usage: -# 0 standard input -# 1 file creation -# 2 errors and warnings -# 3 some systems may open it to /dev/tty -# 4 used on the Kubota Titan -# 6 checking for... messages and results -# 5 compiler messages saved in config.log -if test "$silent" = yes; then - exec 6>/dev/null -else - exec 6>&1 -fi -exec 5>./config.log - -echo "\ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. -" 1>&5 - -# Strip out --no-create and --no-recursion so they do not pile up. -# Also quote any args containing shell metacharacters. -ac_configure_args= -for ac_arg -do - case "$ac_arg" in - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) ;; - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) - ac_configure_args="$ac_configure_args '$ac_arg'" ;; - *) ac_configure_args="$ac_configure_args $ac_arg" ;; - esac -done - -# NLS nuisances. -# Only set LANG and LC_ALL to C if already set. -# These must not be set unconditionally because not all systems understand -# e.g. LANG=C (notably SCO). -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi -if test "${LANG+set}" = set; then LANG=C; export LANG; fi - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo > confdefs.h - -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=termcap.h - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_prog=$0 - ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` - test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. - srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } - else - { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } - fi -fi -srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` - -# Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi -fi -for ac_site_file in $CONFIG_SITE; do - if test -r "$ac_site_file"; then - echo "loading site script $ac_site_file" - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - echo "loading cache $cache_file" - . $cache_file -else - echo "creating cache $cache_file" - > $cache_file -fi - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5 2>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5 2>&5' - -if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then - # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. - if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then - ac_n= ac_c=' -' ac_t=' ' - else - ac_n=-n ac_c= ac_t= - fi -else - ac_n= ac_c='\c' ac_t= -fi - - - -# Check whether --enable-install-termcap or --disable-install-termcap was given. -enableval="$enable_install_termcap" -if test -n "$enableval"; then - if test $enableval = yes; then - installdata=install-data uninstalldata=uninstall-data - fi -fi - - -# Check whether --with-termcap or --without-termcap was given. -withval="$with_termcap" -if test -n "$withval"; then - termcapfile=$withval -else - termcapfile=/etc/termcap -fi - - -# Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="gcc" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_CC" && ac_cv_prog_CC="cc" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - -echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.c <<EOF -#ifdef __GNUC__ - yes; -#endif -EOF -if ${CC-cc} -E conftest.c 2>&5 | egrep yes >/dev/null 2>&1; then - ac_cv_prog_gcc=yes -else - ac_cv_prog_gcc=no -fi -fi -echo "$ac_t""$ac_cv_prog_gcc" 1>&6 -if test $ac_cv_prog_gcc = yes; then - GCC=yes - if test "${CFLAGS+set}" != set; then - echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -if eval "test \"`echo '$''{'ac_cv_prog_gcc_g'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - echo 'void f(){}' > conftest.c -if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then - ac_cv_prog_gcc_g=yes -else - ac_cv_prog_gcc_g=no -fi -rm -f conftest* - -fi - echo "$ac_t""$ac_cv_prog_gcc_g" 1>&6 - if test $ac_cv_prog_gcc_g = yes; then - CFLAGS="-g -O" - else - CFLAGS="-O" - fi - fi -else - GCC= - test "${CFLAGS+set}" = set || CFLAGS="-g" -fi - -# Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_RANLIB="ranlib" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" -fi -fi -RANLIB="$ac_cv_prog_RANLIB" -if test -n "$RANLIB"; then - echo "$ac_t""$RANLIB" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -ac_aux_dir= -for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do - if test -f $ac_dir/install-sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f $ac_dir/install.sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - fi -done -if test -z "$ac_aux_dir"; then - { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } -fi -ac_config_guess=$ac_aux_dir/config.guess -ac_config_sub=$ac_aux_dir/config.sub -ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# ./install, which can be erroneously created by make from ./install.sh. -echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -if test -z "$INSTALL"; then -if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - # Account for people who put trailing slashes in PATH elements. - case "$ac_dir/" in - /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - for ac_prog in ginstall installbsd scoinst install; do - if test -f $ac_dir/$ac_prog; then - if test $ac_prog = install && - grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - # OSF/1 installbsd also uses dspmsg, but is usable. - : - else - ac_cv_path_install="$ac_dir/$ac_prog -c" - break 2 - fi - fi - done - ;; - esac - done - IFS="$ac_save_ifs" - # As a last resort, use the slow shell script. - test -z "$ac_cv_path_install" && ac_cv_path_install="$ac_install_sh" -fi - INSTALL="$ac_cv_path_install" -fi -echo "$ac_t""$INSTALL" 1>&6 - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then -if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - # This must be in double quotes, not single quotes, because CPP may get - # substituted into the Makefile and "${CC-cc}" will confuse make. - CPP="${CC-cc} -E" - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. - cat > conftest.$ac_ext <<EOF -#line 612 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - rm -rf conftest* - CPP="${CC-cc} -E -traditional-cpp" - cat > conftest.$ac_ext <<EOF -#line 626 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - rm -rf conftest* - CPP=/lib/cpp -fi -rm -f conftest* -fi -rm -f conftest* - ac_cv_prog_CPP="$CPP" -fi - CPP="$ac_cv_prog_CPP" -else - ac_cv_prog_CPP="$CPP" -fi -echo "$ac_t""$CPP" 1>&6 - -for ac_hdr in string.h unistd.h -do -ac_safe=`echo "$ac_hdr" | tr './\055' '___'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 659 "configure" -#include "confdefs.h" -#include <$ac_hdr> -EOF -eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./\055' '[A-Z]___'` - cat >> confdefs.h <<EOF -#define $ac_tr_hdr 1 -EOF - -else - echo "$ac_t""no" 1>&6 -fi -done - -# If we cannot run a trivial program, we must be cross compiling. -echo $ac_n "checking whether cross-compiling""... $ac_c" 1>&6 -if eval "test \"`echo '$''{'ac_cv_c_cross'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test "$cross_compiling" = yes; then - ac_cv_c_cross=yes -else -cat > conftest.$ac_ext <<EOF -#line 696 "configure" -#include "confdefs.h" -main(){return(0);} -EOF -eval $ac_link -if test -s conftest && (./conftest; exit) 2>/dev/null; then - ac_cv_c_cross=no -else - ac_cv_c_cross=yes -fi -fi -rm -fr conftest* -fi -cross_compiling=$ac_cv_c_cross -echo "$ac_t""$ac_cv_c_cross" 1>&6 - -echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 717 "configure" -#include "confdefs.h" -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> -#include <float.h> -EOF -eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - ac_cv_header_stdc=yes -else - echo "$ac_err" >&5 - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. -cat > conftest.$ac_ext <<EOF -#line 739 "configure" -#include "confdefs.h" -#include <string.h> -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "memchr" >/dev/null 2>&1; then - : -else - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. -cat > conftest.$ac_ext <<EOF -#line 757 "configure" -#include "confdefs.h" -#include <stdlib.h> -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "free" >/dev/null 2>&1; then - : -else - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. -if test "$cross_compiling" = yes; then - ac_cv_header_stdc=no -else -cat > conftest.$ac_ext <<EOF -#line 778 "configure" -#include "confdefs.h" -#include <ctype.h> -#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int main () { int i; for (i = 0; i < 256; i++) -if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); -exit (0); } - -EOF -eval $ac_link -if test -s conftest && (./conftest; exit) 2>/dev/null; then - : -else - ac_cv_header_stdc=no -fi -fi -rm -fr conftest* -fi -fi -echo "$ac_t""$ac_cv_header_stdc" 1>&6 -if test $ac_cv_header_stdc = yes; then - cat >> confdefs.h <<\EOF -#define STDC_HEADERS 1 -EOF - -fi - - -trap '' 1 2 15 -cat > confcache <<\EOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs. It is not useful on other systems. -# If it contains results you don't want to keep, you may remove or edit it. -# -# By default, configure uses ./config.cache as the cache file, -# creating it if it does not exist already. You can give configure -# the --cache-file=FILE option to use a different cache file; that is -# what configure does when it calls configure scripts in -# subdirectories, so they share the cache. -# Giving --cache-file=/dev/null disables caching, for debugging configure. -# config.status only pays attention to the cache file if you give it the -# --recheck option to rerun configure. -# -EOF -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -(set) 2>&1 | - sed -n "s/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=\${\1='\2'}/p" \ - >> confcache -if cmp -s $cache_file confcache; then - : -else - if test -w $cache_file; then - echo "updating cache $cache_file" - cat confcache > $cache_file - else - echo "not updating unwritable cache $cache_file" - fi -fi -rm -f confcache - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# Any assignment to VPATH causes Sun make to only execute -# the first set of double-colon rules, so remove it if not needed. -# If there is a colon in the path, we need to keep it. -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' -fi - -trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 - -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -cat > conftest.defs <<\EOF -s%#define \([A-Za-z_][A-Za-z0-9_]*\) \(.*\)%-D\1=\2%g -s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g -s%\[%\\&%g -s%\]%\\&%g -s%\$%$$%g -EOF -DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` -rm -f conftest.defs - - -# Without the "./", some shells look in PATH for config.status. -: ${CONFIG_STATUS=./config.status} - -echo creating $CONFIG_STATUS -rm -f $CONFIG_STATUS -cat > $CONFIG_STATUS <<EOF -#! /bin/sh -# Generated automatically by configure. -# Run this file to recreate the current configuration. -# This directory was configured as follows, -# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# -# $0 $ac_configure_args -# -# Compiler output produced by configure, useful for debugging -# configure, is in ./config.log if it exists. - -ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" -for ac_option -do - case "\$ac_option" in - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" - exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; - -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.4" - exit 0 ;; - -help | --help | --hel | --he | --h) - echo "\$ac_cs_usage"; exit 0 ;; - *) echo "\$ac_cs_usage"; exit 1 ;; - esac -done - -ac_given_srcdir=$srcdir -ac_given_INSTALL="$INSTALL" - -trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 - -# Protect against being on the right side of a sed subst in config.status. -sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\\\&%]/\\\\&/g; - s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF -$ac_vpsub -$extrasub -s%@CFLAGS@%$CFLAGS%g -s%@CPPFLAGS@%$CPPFLAGS%g -s%@CXXFLAGS@%$CXXFLAGS%g -s%@DEFS@%$DEFS%g -s%@LDFLAGS@%$LDFLAGS%g -s%@LIBS@%$LIBS%g -s%@exec_prefix@%$exec_prefix%g -s%@prefix@%$prefix%g -s%@program_transform_name@%$program_transform_name%g -s%@installdata@%$installdata%g -s%@uninstalldata@%$uninstalldata%g -s%@termcapfile@%$termcapfile%g -s%@CC@%$CC%g -s%@RANLIB@%$RANLIB%g -s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_DATA@%$INSTALL_DATA%g -s%@CPP@%$CPP%g - -CEOF -EOF -cat >> $CONFIG_STATUS <<EOF - -CONFIG_FILES=\${CONFIG_FILES-"Makefile"} -EOF -cat >> $CONFIG_STATUS <<\EOF -for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then - # Support "outfile[:infile]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - # Adjust relative srcdir, etc. for subdirectories. - - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" - # A "../" for each directory in $ac_dir_suffix. - ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` - else - ac_dir_suffix= ac_dots= - fi - - case "$ac_given_srcdir" in - .) srcdir=. - if test -z "$ac_dots"; then top_srcdir=. - else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; - /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; - *) # Relative path. - srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" - top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - - case "$ac_given_INSTALL" in - [/$]*) INSTALL="$ac_given_INSTALL" ;; - *) INSTALL="$ac_dots$ac_given_INSTALL" ;; - esac - echo creating "$ac_file" - rm -f "$ac_file" - configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." - case "$ac_file" in - *Makefile*) ac_comsub="1i\\ -# $configure_input" ;; - *) ac_comsub= ;; - esac - sed -e "$ac_comsub -s%@configure_input@%$configure_input%g -s%@srcdir@%$srcdir%g -s%@top_srcdir@%$top_srcdir%g -s%@INSTALL@%$INSTALL%g -" -f conftest.subs $ac_given_srcdir/$ac_file_in > $ac_file -fi; done -rm -f conftest.subs - - - -exit 0 -EOF -chmod +x $CONFIG_STATUS -rm -fr confdefs* $ac_clean_files -test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 - diff --git a/lib/termcap/grot/configure.in b/lib/termcap/grot/configure.in deleted file mode 100644 index f3f944f..0000000 --- a/lib/termcap/grot/configure.in +++ /dev/null @@ -1,23 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. -AC_INIT(termcap.h) - -AC_ARG_ENABLE(install-termcap, -[ --enable-install-termcap install the termcap data file], -[if test $enableval = yes; then - installdata=install-data uninstalldata=uninstall-data - fi]) -AC_SUBST(installdata)dnl -AC_SUBST(uninstalldata)dnl - -AC_ARG_WITH(termcap, -[ --with-termcap=FILE use data file FILE instead of /etc/termcap], -termcapfile=$withval, termcapfile=/etc/termcap) -AC_SUBST(termcapfile)dnl - -AC_PROG_CC -AC_PROG_RANLIB -AC_PROG_INSTALL -AC_HAVE_HEADERS(string.h unistd.h) -AC_STDC_HEADERS - -AC_OUTPUT(Makefile) diff --git a/lib/termcap/grot/termcap.info b/lib/termcap/grot/termcap.info deleted file mode 100644 index f663195..0000000 --- a/lib/termcap/grot/termcap.info +++ /dev/null @@ -1,80 +0,0 @@ -This is Info file ./termcap.info, produced by Makeinfo-1.55 from the -input file ./termcap.texi. - - This file documents the termcap library of the GNU system. - - Copyright (C) 1988 Free Software Foundation, Inc. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Foundation. - - -Indirect: -termcap.info-1: 874 -termcap.info-2: 47411 -termcap.info-3: 90390 -termcap.info-4: 138827 - -Tag Table: -(Indirect) -Node: Top874 -Node: Introduction4105 -Node: Library5832 -Node: Preparation6851 -Node: Find8034 -Node: Interrogate11492 -Node: Initialize16800 -Node: Padding18440 -Node: Why Pad19146 -Node: Not Enough20768 -Node: Describe Padding23336 -Node: Output Padding24826 -Node: Parameters28441 -Node: Encode Parameters30101 -Node: Using Parameters36185 -Node: tparam36780 -Node: tgoto38806 -Node: Data Base41361 -Node: Format42257 -Node: Capability Format44346 -Node: Naming47411 -Node: Inheriting51980 -Node: Changing54224 -Node: Capabilities55388 -Node: Basic58127 -Node: Screen Size62180 -Node: Cursor Motion63920 -Node: Wrapping74062 -Node: Scrolling77091 -Node: Windows82980 -Node: Clearing83714 -Node: Insdel Line85478 -Node: Insdel Char90390 -Node: Standout100375 -Node: Underlining109433 -Node: Cursor Visibility111852 -Node: Bell112600 -Node: Keypad113149 -Node: Meta Key117864 -Node: Initialization118818 -Node: Pad Specs121369 -Node: Status Line123422 -Node: Half-Line125306 -Node: Printer126108 -Node: Summary127787 -Node: Var Index138114 -Node: Cap Index138827 -Node: Index145991 - -End Tag Table diff --git a/lib/termcap/grot/termcap.info-1 b/lib/termcap/grot/termcap.info-1 deleted file mode 100644 index a5b5da0..0000000 --- a/lib/termcap/grot/termcap.info-1 +++ /dev/null @@ -1,1114 +0,0 @@ -This is Info file ./termcap.info, produced by Makeinfo-1.55 from the -input file ./termcap.texi. - - This file documents the termcap library of the GNU system. - - Copyright (C) 1988 Free Software Foundation, Inc. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Foundation. - - -File: termcap.info, Node: Top, Next: Introduction, Prev: (dir), Up: (dir) - -* Menu: - -* Introduction:: What is termcap? Why this manual? -* Library:: The termcap library functions. -* Data Base:: What terminal descriptions in `/etc/termcap' look like. -* Capabilities:: Definitions of the individual terminal capabilities: - how to write them in descriptions, and how to use - their values to do display updating. -* Summary:: Brief table of capability names and their meanings. -* Var Index:: Index of C functions and variables. -* Cap Index:: Index of termcap capabilities. -* Index:: Concept index. - - -- The Detailed Node Listing -- - -The Termcap Library - -* Preparation:: Preparing to use the termcap library. -* Find:: Finding the description of the terminal being used. -* Interrogate:: Interrogating the description for particular capabilities. -* Initialize:: Initialization for output using termcap. -* Padding:: Outputting padding. -* Parameters:: Encoding parameters such as cursor positions. - -Padding - -* Why Pad:: Explanation of padding. -* Not Enough:: When there is not enough padding. -* Describe Padding:: The data base says how much padding a terminal needs. -* Output Padding:: Using `tputs' to output the needed padding. - -Filling In Parameters - -* Encode Parameters:: The language for encoding parameters. -* Using Parameters:: Outputting a string command with parameters. - -Sending Display Commands with Parameters - -* tparam:: The general case, for GNU termcap only. -* tgoto:: The special case of cursor motion. - -The Format of the Data Base - -* Format:: Overall format of a terminal description. -* Capability Format:: Format of capabilities within a description. -* Naming:: Naming conventions for terminal types. -* Inheriting:: Inheriting part of a description from -a related terminal type. -* Changing:: When changes in the data base take effect. - -Definitions of the Terminal Capabilities - -* Basic:: Basic characteristics. -* Screen Size:: Screen size, and what happens when it changes. -* Cursor Motion:: Various ways to move the cursor. -* Wrapping:: What happens if you write a character in the last column. -* Scrolling:: Pushing text up and down on the screen. -* Windows:: Limiting the part of the window that output affects. -* Clearing:: Erasing one or many lines. -* Insdel Line:: Making new blank lines in mid-screen; deleting lines. -* Insdel Char:: Inserting and deleting characters within a line. -* Standout:: Highlighting some of the text. -* Underlining:: Underlining some of the text. -* Cursor Visibility:: Making the cursor more or less easy to spot. -* Bell:: Attracts user's attention; not localized on the screen. -* Keypad:: Recognizing when function keys or arrows are typed. -* Meta Key:: META acts like an extra shift key. -* Initialization:: Commands used to initialize or reset the terminal. -* Pad Specs:: Info for the kernel on how much padding is needed. -* Status Line:: A status line displays "background" information. -* Half-Line:: Moving by half-lines, for superscripts and subscripts. -* Printer:: Controlling auxiliary printers of display terminals. - - -File: termcap.info, Node: Introduction, Next: Library, Prev: Top, Up: Top - -Introduction -************ - - "Termcap" is a library and data base that enables programs to use -display terminals in a terminal-independent manner. It originated in -Berkeley Unix. - - The termcap data base describes the capabilities of hundreds of -different display terminals in great detail. Some examples of the -information recorded for a terminal could include how many columns wide -it is, what string to send to move the cursor to an arbitrary position -(including how to encode the row and column numbers), how to scroll the -screen up one or several lines, and how much padding is needed for such -a scrolling operation. - - The termcap library is provided for easy access this data base in -programs that want to do terminal-independent character-based display -output. - - This manual describes the GNU version of the termcap library, which -has some extensions over the Unix version. All the extensions are -identified as such, so this manual also tells you how to use the Unix -termcap. - - The GNU version of the termcap library is available free as source -code, for use in free programs, and runs on Unix and VMS systems (at -least). You can find it in the GNU Emacs distribution in the files -`termcap.c' and `tparam.c'. - - This manual was written for the GNU project, whose goal is to -develop a complete free operating system upward-compatible with Unix -for user programs. The project is approximately two thirds complete. -For more information on the GNU project, including the GNU Emacs editor -and the mostly-portable optimizing C compiler, send one dollar to - - Free Software Foundation - 675 Mass Ave - Cambridge, MA 02139 - - -File: termcap.info, Node: Library, Next: Data Base, Prev: Introduction, Up: Top - -The Termcap Library -******************* - - The termcap library is the application programmer's interface to the -termcap data base. It contains functions for the following purposes: - - * Finding the description of the user's terminal type (`tgetent'). - - * Interrogating the description for information on various topics - (`tgetnum', `tgetflag', `tgetstr'). - - * Computing and performing padding (`tputs'). - - * Encoding numeric parameters such as cursor positions into the - terminal-specific form required for display commands (`tparam', - `tgoto'). - -* Menu: - -* Preparation:: Preparing to use the termcap library. -* Find:: Finding the description of the terminal being used. -* Interrogate:: Interrogating the description for particular capabilities. -* Initialize:: Initialization for output using termcap. -* Padding:: Outputting padding. -* Parameters:: Encoding parameters such as cursor positions. - - -File: termcap.info, Node: Preparation, Next: Find, Up: Library - -Preparing to Use the Termcap Library -==================================== - - To use the termcap library in a program, you need two kinds of -preparation: - - * The compiler needs declarations of the functions and variables in - the library. - - On GNU systems, it suffices to include the header file `termcap.h' - in each source file that uses these functions and variables. - - On Unix systems, there is often no such header file. Then you must - explictly declare the variables as external. You can do likewise - for the functions, or let them be implicitly declared and cast - their values from type `int' to the appropriate type. - - We illustrate the declarations of the individual termcap library - functions with ANSI C prototypes because they show how to pass the - arguments. If you are not using the GNU C compiler, you probably - cannot use function prototypes, so omit the argument types and - names from your declarations. - - * The linker needs to search the library. Usually either - `-ltermcap' or `-ltermlib' as an argument when linking will do - this. - - -File: termcap.info, Node: Find, Next: Interrogate, Prev: Preparation, Up: Library - -Finding a Terminal Description: `tgetent' -========================================= - - An application program that is going to use termcap must first look -up the description of the terminal type in use. This is done by calling -`tgetent', whose declaration in ANSI Standard C looks like: - - int tgetent (char *BUFFER, char *TERMTYPE); - -This function finds the description and remembers it internally so that -you can interrogate it about specific terminal capabilities (*note -Interrogate::.). - - The argument TERMTYPE is a string which is the name for the type of -terminal to look up. Usually you would obtain this from the environment -variable `TERM' using `getenv ("TERM")'. - - If you are using the GNU version of termcap, you can alternatively -ask `tgetent' to allocate enough space. Pass a null pointer for -BUFFER, and `tgetent' itself allocates the storage using `malloc'. -There is no way to get the address that was allocated, and you -shouldn't try to free the storage. - - With the Unix version of termcap, you must allocate space for the -description yourself and pass the address of the space as the argument -BUFFER. There is no way you can tell how much space is needed, so the -convention is to allocate a buffer 2048 characters long and assume that -is enough. (Formerly the convention was to allocate 1024 characters and -assume that was enough. But one day, for one kind of terminal, that was -not enough.) - - No matter how the space to store the description has been obtained, -termcap records its address internally for use when you later -interrogate the description with `tgetnum', `tgetstr' or `tgetflag'. If -the buffer was allocated by termcap, it will be freed by termcap too if -you call `tgetent' again. If the buffer was provided by you, you must -make sure that its contents remain unchanged for as long as you still -plan to interrogate the description. - - The return value of `tgetent' is -1 if there is some difficulty -accessing the data base of terminal types, 0 if the data base is -accessible but the specified type is not defined in it, and some other -value otherwise. - - Here is how you might use the function `tgetent': - - #ifdef unix - static char term_buffer[2048]; - #else - #define term_buffer 0 - #endif - - init_terminal_data () - { - char *termtype = getenv ("TERM"); - int success; - - if (termtype == 0) - fatal ("Specify a terminal type with `setenv TERM <yourtype>'.\n"); - - success = tgetent (term_buffer, termtype); - if (success < 0) - fatal ("Could not access the termcap data base.\n"); - if (success == 0) - fatal ("Terminal type `%s' is not defined.\n", termtype); - } - -Here we assume the function `fatal' prints an error message and exits. - - If the environment variable `TERMCAP' is defined, its value is used -to override the terminal type data base. The function `tgetent' checks -the value of `TERMCAP' automatically. If the value starts with `/' -then it is taken as a file name to use as the data base file, instead -of `/etc/termcap' which is the standard data base. If the value does -not start with `/' then it is itself used as the terminal description, -provided that the terminal type TERMTYPE is among the types it claims -to apply to. *Note Data Base::, for information on the format of a -terminal description. - - -File: termcap.info, Node: Interrogate, Next: Initialize, Prev: Find, Up: Library - -Interrogating the Terminal Description -====================================== - - Each piece of information recorded in a terminal description is -called a "capability". Each defined terminal capability has a -two-letter code name and a specific meaning. For example, the number -of columns is named `co'. *Note Capabilities::, for definitions of all -the standard capability names. - - Once you have found the proper terminal description with `tgetent' -(*note Find::.), your application program must "interrogate" it for -various terminal capabilities. You must specify the two-letter code of -the capability whose value you seek. - - Capability values can be numeric, boolean (capability is either -present or absent) or strings. Any particular capability always has -the same value type; for example, `co' always has a numeric value, -while `am' (automatic wrap at margin) is always a flag, and `cm' -(cursor motion command) always has a string value. The documentation -of each capability says which type of value it has. - - There are three functions to use to get the value of a capability, -depending on the type of value the capability has. Here are their -declarations in ANSI C: - - int tgetnum (char *NAME); - int tgetflag (char *NAME); - char *tgetstr (char *NAME, char **AREA); - -`tgetnum' - Use `tgetnum' to get a capability value that is numeric. The - argument NAME is the two-letter code name of the capability. If - the capability is present, `tgetnum' returns the numeric value - (which is nonnegative). If the capability is not mentioned in the - terminal description, `tgetnum' returns -1. - -`tgetflag' - Use `tgetflag' to get a boolean value. If the capability NAME is - present in the terminal description, `tgetflag' returns 1; - otherwise, it returns 0. - -`tgetstr' - Use `tgetstr' to get a string value. It returns a pointer to a - string which is the capability value, or a null pointer if the - capability is not present in the terminal description. - - There are two ways `tgetstr' can find space to store the string - value: - - * You can ask `tgetstr' to allocate the space. Pass a null - pointer for the argument AREA, and `tgetstr' will use - `malloc' to allocate storage big enough for the value. - Termcap will never free this storage or refer to it again; you - should free it when you are finished with it. - - This method is more robust, since there is no need to guess - how much space is needed. But it is supported only by the GNU - termcap library. - - * You can provide the space. Provide for the argument AREA the - address of a pointer variable of type `char *'. Before - calling `tgetstr', initialize the variable to point at - available space. Then `tgetstr' will store the string value - in that space and will increment the pointer variable to - point after the space that has been used. You can use the - same pointer variable for many calls to `tgetstr'. - - There is no way to determine how much space is needed for a - single string, and no way for you to prevent or handle - overflow of the area you have provided. However, you can be - sure that the total size of all the string values you will - obtain from the terminal description is no greater than the - size of the description (unless you get the same capability - twice). You can determine that size with `strlen' on the - buffer you provided to `tgetent'. See below for an example. - - Providing the space yourself is the only method supported by - the Unix version of termcap. - - Note that you do not have to specify a terminal type or terminal -description for the interrogation functions. They automatically use the -description found by the most recent call to `tgetent'. - - Here is an example of interrogating a terminal description for -various capabilities, with conditionals to select between the Unix and -GNU methods of providing buffer space. - - char *tgetstr (); - - char *cl_string, *cm_string; - int height; - int width; - int auto_wrap; - - char PC; /* For tputs. */ - char *BC; /* For tgoto. */ - char *UP; - - interrogate_terminal () - { - #ifdef UNIX - /* Here we assume that an explicit term_buffer - was provided to tgetent. */ - char *buffer - = (char *) malloc (strlen (term_buffer)); - #define BUFFADDR &buffer - #else - #define BUFFADDR 0 - #endif - - char *temp; - - /* Extract information we will use. */ - cl_string = tgetstr ("cl", BUFFADDR); - cm_string = tgetstr ("cm", BUFFADDR); - auto_wrap = tgetflag ("am"); - height = tgetnum ("li"); - width = tgetnum ("co"); - - /* Extract information that termcap functions use. */ - temp = tgetstr ("pc", BUFFADDR); - PC = temp ? *temp : 0; - BC = tgetstr ("le", BUFFADDR); - UP = tgetstr ("up", BUFFADDR); - } - -*Note Padding::, for information on the variable `PC'. *Note Using -Parameters::, for information on `UP' and `BC'. - - -File: termcap.info, Node: Initialize, Next: Padding, Prev: Interrogate, Up: Library - -Initialization for Use of Termcap -================================= - - Before starting to output commands to a terminal using termcap, an -application program should do two things: - - * Initialize various global variables which termcap library output - functions refer to. These include `PC' and `ospeed' for padding - (*note Output Padding::.) and `UP' and `BC' for cursor motion - (*note tgoto::.). - - * Tell the kernel to turn off alteration and padding of - horizontal-tab characters sent to the terminal. - - To turn off output processing in Berkeley Unix you would use `ioctl' -with code `TIOCLSET' to set the bit named `LLITOUT', and clear the bits -`ANYDELAY' using `TIOCSETN'. In POSIX or System V, you must clear the -bit named `OPOST'. Refer to the system documentation for details. - - If you do not set the terminal flags properly, some older terminals -will not work. This is because their commands may contain the -characters that normally signify newline, carriage return and -horizontal tab--characters which the kernel thinks it ought to modify -before output. - - When you change the kernel's terminal flags, you must arrange to -restore them to their normal state when your program exits. This -implies that the program must catch fatal signals such as `SIGQUIT' and -`SIGINT' and restore the old terminal flags before actually terminating. - - Modern terminals' commands do not use these special characters, so -if you do not care about problems with old terminals, you can leave the -kernel's terminal flags unaltered. - - -File: termcap.info, Node: Padding, Next: Parameters, Prev: Initialize, Up: Library - -Padding -======= - - "Padding" means outputting null characters following a terminal -display command that takes a long time to execute. The terminal -description says which commands require padding and how much; the -function `tputs', described below, outputs a terminal command while -extracting from it the padding information, and then outputs the -padding that is necessary. - -* Menu: - -* Why Pad:: Explanation of padding. -* Not Enough:: When there is not enough padding. -* Describe Padding:: The data base says how much padding a terminal needs. -* Output Padding:: Using `tputs' to output the needed padding. - - -File: termcap.info, Node: Why Pad, Next: Not Enough, Up: Padding - -Why Pad, and How ----------------- - - Most types of terminal have commands that take longer to execute -than they do to send over a high-speed line. For example, clearing the -screen may take 20msec once the entire command is received. During -that time, on a 9600 bps line, the terminal could receive about 20 -additional output characters while still busy clearing the screen. -Every terminal has a certain amount of buffering capacity to remember -output characters that cannot be processed yet, but too many slow -commands in a row can cause the buffer to fill up. Then any additional -output that cannot be processed immediately will be lost. - - To avoid this problem, we normally follow each display command with -enough useless charaters (usually null characters) to fill up the time -that the display command needs to execute. This does the job if the -terminal throws away null characters without using up space in the -buffer (which most terminals do). If enough padding is used, no output -can ever be lost. The right amount of padding avoids loss of output -without slowing down operation, since the time used to transmit padding -is time that nothing else could be done. - - The number of padding characters needed for an operation depends on -the line speed. In fact, it is proportional to the line speed. A 9600 -baud line transmits about one character per msec, so the clear screen -command in the example above would need about 20 characters of padding. -At 1200 baud, however, only about 3 characters of padding are needed -to fill up 20msec. - - -File: termcap.info, Node: Not Enough, Next: Describe Padding, Prev: Why Pad, Up: Padding - -When There Is Not Enough Padding --------------------------------- - - There are several common manifestations of insufficient padding. - - * Emacs displays `I-search: ^Q-' at the bottom of the screen. - - This means that the terminal thought its buffer was getting full of - display commands, so it tried to tell the computer to stop sending - any. - - * The screen is garbled intermittently, or the details of garbling - vary when you repeat the action. (A garbled screen could be due - to a command which is simply incorrect, or to user option in the - terminal which doesn't match the assumptions of the terminal - description, but this usually leads to reproducible failure.) - - This means that the buffer did get full, and some commands were - lost. Many changeable factors can change which ones are lost. - - * Screen is garbled at high output speeds but not at low speeds. - Padding problems nearly always go away at low speeds, usually even - at 1200 baud. - - This means that a high enough speed permits commands to arrive - faster than they can be executed. - - Although any obscure command on an obscure terminal might lack -padding, in practice problems arise most often from the clearing -commands `cl' and `cd' (*note Clearing::.), the scrolling commands `sf' -and `sr' (*note Scrolling::.), and the line insert/delete commands `al' -and `dl' (*note Insdel Line::.). - - Occasionally the terminal description fails to define `sf' and some -programs will use `do' instead, so you may get a problem with `do'. If -so, first define `sf' just like `do', then add some padding to `sf'. - - The best strategy is to add a lot of padding at first, perhaps 200 -msec. This is much more than enough; in fact, it should cause a -visible slowdown. (If you don't see a slowdown, the change has not -taken effect; *note Changing::..) If this makes the problem go away, -you have found the right place to add padding; now reduce the amount -until the problem comes back, then increase it again. If the problem -remains, either it is in some other capability or it is not a matter of -padding at all. - - Keep in mind that on many terminals the correct padding for -insert/delete line or for scrolling is cursor-position dependent. If -you get problems from scrolling a large region of the screen but not -from scrolling a small part (just a few lines moving), it may mean that -fixed padding should be replaced with position-dependent padding. - - -File: termcap.info, Node: Describe Padding, Next: Output Padding, Prev: Not Enough, Up: Padding - -Specifying Padding in a Terminal Description --------------------------------------------- - - In the terminal description, the amount of padding required by each -display command is recorded as a sequence of digits at the front of the -command. These digits specify the padding time in milliseconds (msec). -They can be followed optionally by a decimal point and one more digit, -which is a number of tenths of msec. - - Sometimes the padding needed by a command depends on the cursor -position. For example, the time taken by an "insert line" command is -usually proportional to the number of lines that need to be moved down -or cleared. An asterisk (`*') following the padding time says that the -time should be multiplied by the number of screen lines affected by the -command. - - :al=1.3*\E[L: - -is used to describe the "insert line" command for a certain terminal. -The padding required is 1.3 msec per line affected. The command itself -is `ESC [ L'. - - The padding time specified in this way tells `tputs' how many pad -characters to output. *Note Output Padding::. - - Two special capability values affect padding for all commands. -These are the `pc' and `pb'. The variable `pc' specifies the character -to pad with, and `pb' the speed below which no padding is needed. The -defaults for these variables, a null character and 0, are correct for -most terminals. *Note Pad Specs::. - - -File: termcap.info, Node: Output Padding, Prev: Describe Padding, Up: Padding - -Performing Padding with `tputs' -------------------------------- - - Use the termcap function `tputs' to output a string containing an -optional padding spec of the form described above (*note Describe -Padding::.). The function `tputs' strips off and decodes the padding -spec, outputs the rest of the string, and then outputs the appropriate -padding. Here is its declaration in ANSI C: - - char PC; - short ospeed; - - int tputs (char *STRING, int NLINES, int (*OUTFUN) ()); - - Here STRING is the string (including padding spec) to be output; -NLINES is the number of lines affected by the operation, which is used -to multiply the amount of padding if the padding spec ends with a `*'. -Finally, OUTFUN is a function (such as `fputchar') that is called to -output each character. When actually called, OUTFUN should expect one -argument, a character. - - The operation of `tputs' is controlled by two global variables, -`ospeed' and `PC'. The value of `ospeed' is supposed to be the -terminal output speed, encoded as in the `ioctl' system call which gets -the speed information. This is needed to compute the number of padding -characters. The value of `PC' is the character used for padding. - - You are responsible for storing suitable values into these variables -before using `tputs'. The value stored into the `PC' variable should be -taken from the `pc' capability in the terminal description (*note Pad -Specs::.). Store zero in `PC' if there is no `pc' capability. - - The argument NLINES requires some thought. Normally, it should be -the number of lines whose contents will be cleared or moved by the -command. For cursor motion commands, or commands that do editing -within one line, use the value 1. For most commands that affect -multiple lines, such as `al' (insert a line) and `cd' (clear from the -cursor to the end of the screen), NLINES should be the screen height -minus the current vertical position (origin 0). For multiple insert -and scroll commands such as `AL' (insert multiple lines), that same -value for NLINES is correct; the number of lines being inserted is not -correct. - - If a "scroll window" feature is used to reduce the number of lines -affected by a command, the value of NLINES should take this into -account. This is because the delay time required depends on how much -work the terminal has to do, and the scroll window feature reduces the -work. *Note Scrolling::. - - Commands such as `ic' and `dc' (insert or delete characters) are -problematical because the padding needed by these commands is -proportional to the number of characters affected, which is the number -of columns from the cursor to the end of the line. It would be nice to -have a way to specify such a dependence, and there is no need for -dependence on vertical position in these commands, so it is an obvious -idea to say that for these commands NLINES should really be the number -of columns affected. However, the definition of termcap clearly says -that NLINES is always the number of lines affected, even in this case, -where it is always 1. It is not easy to change this rule now, because -too many programs and terminal descriptions have been written to follow -it. - - Because NLINES is always 1 for the `ic' and `dc' strings, there is -no reason for them to use `*', but some of them do. These should be -corrected by deleting the `*'. If, some day, such entries have -disappeared, it may be possible to change to a more useful convention -for the NLINES argument for these operations without breaking any -programs. - - -File: termcap.info, Node: Parameters, Prev: Padding, Up: Library - -Filling In Parameters -===================== - - Some terminal control strings require numeric "parameters". For -example, when you move the cursor, you need to say what horizontal and -vertical positions to move it to. The value of the terminal's `cm' -capability, which says how to move the cursor, cannot simply be a -string of characters; it must say how to express the cursor position -numbers and where to put them within the command. - - The specifications of termcap include conventions as to which -string-valued capabilities require parameters, how many parameters, and -what the parameters mean; for example, it defines the `cm' string to -take two parameters, the vertical and horizontal positions, with 0,0 -being the upper left corner. These conventions are described where the -individual commands are documented. - - Termcap also defines a language used within the capability -definition for specifying how and where to encode the parameters for -output. This language uses character sequences starting with `%'. -(This is the same idea as `printf', but the details are different.) -The language for parameter encoding is described in this section. - - A program that is doing display output calls the functions `tparam' -or `tgoto' to encode parameters according to the specifications. These -functions produce a string containing the actual commands to be output -(as well a padding spec which must be processed with `tputs'; *note -Padding::.). - -* Menu: - -* Encode Parameters:: The language for encoding parameters. -* Using Parameters:: Outputting a string command with parameters. - - -File: termcap.info, Node: Encode Parameters, Next: Using Parameters, Up: Parameters - -Describing the Encoding ------------------------ - - A terminal command string that requires parameters contains special -character sequences starting with `%' to say how to encode the -parameters. These sequences control the actions of `tparam' and -`tgoto'. - - The parameters values passed to `tparam' or `tgoto' are considered -to form a vector. A pointer into this vector determines the next -parameter to be processed. Some of the `%'-sequences encode one -parameter and advance the pointer to the next parameter. Other -`%'-sequences alter the pointer or alter the parameter values without -generating output. - - For example, the `cm' string for a standard ANSI terminal is written -as `\E[%i%d;%dH'. (`\E' stands for ESC.) `cm' by convention always -requires two parameters, the vertical and horizontal goal positions, so -this string specifies the encoding of two parameters. Here `%i' -increments the two values supplied, and each `%d' encodes one of the -values in decimal. If the cursor position values 20,58 are encoded -with this string, the result is `\E[21;59H'. - - First, here are the `%'-sequences that generate output. Except for -`%%', each of them encodes one parameter and advances the pointer to -the following parameter. - -`%%' - Output a single `%'. This is the only way to represent a literal - `%' in a terminal command with parameters. `%%' does not use up a - parameter. - -`%d' - As in `printf', output the next parameter in decimal. - -`%2' - Like `%02d' in `printf': output the next parameter in decimal, and - always use at least two digits. - -`%3' - Like `%03d' in `printf': output the next parameter in decimal, and - always use at least three digits. Note that `%4' and so on are - *not* defined. - -`%.' - Output the next parameter as a single character whose ASCII code is - the parameter value. Like `%c' in `printf'. - -`%+CHAR' - Add the next parameter to the character CHAR, and output the - resulting character. For example, `%+ ' represents 0 as a space, - 1 as `!', etc. - - The following `%'-sequences specify alteration of the parameters -(their values, or their order) rather than encoding a parameter for -output. They generate no output; they are used only for their side -effects on the parameters. Also, they do not advance the "next -parameter" pointer except as explicitly stated. Only `%i', `%r' and -`%>' are defined in standard Unix termcap. The others are GNU -extensions. - -`%i' - Increment the next two parameters. This is used for terminals that - expect cursor positions in origin 1. For example, `%i%d,%d' would - output two parameters with `1' for 0, `2' for 1, etc. - -`%r' - Interchange the next two parameters. This is used for terminals - whose cursor positioning command expects the horizontal position - first. - -`%s' - Skip the next parameter. Do not output anything. - -`%b' - Back up one parameter. The last parameter used will become once - again the next parameter to be output, and the next output command - will use it. Using `%b' more than once, you can back up any - number of parameters, and you can refer to each parameter any - number of times. - -`%>C1C2' - Conditionally increment the next parameter. Here C1 and C2 are - characters which stand for their ASCII codes as numbers. If the - next parameter is greater than the ASCII code of C1, the ASCII - code of C2 is added to it. - -`%a OP TYPE POS' - Perform arithmetic on the next parameter, do not use it up, and do - not output anything. Here OP specifies the arithmetic operation, - while TYPE and POS together specify the other operand. - - Spaces are used above to separate the operands for clarity; the - spaces don't appear in the data base, where this sequence is - exactly five characters long. - - The character OP says what kind of arithmetic operation to - perform. It can be any of these characters: - - `=' - assign a value to the next parameter, ignoring its old value. - The new value comes from the other operand. - - `+' - add the other operand to the next parameter. - - `-' - subtract the other operand from the next parameter. - - `*' - multiply the next parameter by the other operand. - - `/' - divide the next parameter by the other operand. - - The "other operand" may be another parameter's value or a constant; - the character TYPE says which. It can be: - - `p' - Use another parameter. The character POS says which - parameter to use. Subtract 64 from its ASCII code to get the - position of the desired parameter relative to this one. Thus, - the character `A' as POS means the parameter after the next - one; the character `?' means the parameter before the next - one. - - `c' - Use a constant value. The character POS specifies the value - of the constant. The 0200 bit is cleared out, so that 0200 - can be used to represent zero. - - The following `%'-sequences are special purpose hacks to compensate -for the weird designs of obscure terminals. They modify the next -parameter or the next two parameters but do not generate output and do -not use up any parameters. `%m' is a GNU extension; the others are -defined in standard Unix termcap. - -`%n' - Exclusive-or the next parameter with 0140, and likewise the - parameter after next. - -`%m' - Complement all the bits of the next parameter and the parameter - after next. - -`%B' - Encode the next parameter in BCD. It alters the value of the - parameter by adding six times the quotient of the parameter by ten. - Here is a C statement that shows how the new value is computed: - - PARM = (PARM / 10) * 16 + PARM % 10; - -`%D' - Transform the next parameter as needed by Delta Data terminals. - This involves subtracting twice the remainder of the parameter by - 16. - - PARM -= 2 * (PARM % 16); - - -File: termcap.info, Node: Using Parameters, Prev: Encode Parameters, Up: Parameters - -Sending Display Commands with Parameters ----------------------------------------- - - The termcap library functions `tparam' and `tgoto' serve as the -analog of `printf' for terminal string parameters. The newer function -`tparam' is a GNU extension, more general but missing from Unix -termcap. The original parameter-encoding function is `tgoto', which is -preferable for cursor motion. - -* Menu: - -* tparam:: The general case, for GNU termcap only. -* tgoto:: The special case of cursor motion. - - -File: termcap.info, Node: tparam, Next: tgoto, Up: Using Parameters - -`tparam' -........ - - The function `tparam' can encode display commands with any number of -parameters and allows you to specify the buffer space. It is the -preferred function for encoding parameters for all but the `cm' -capability. Its ANSI C declaration is as follows: - - char *tparam (char *CTLSTRING, char *BUFFER, int SIZE, int PARM1,...) - - The arguments are a control string CTLSTRING (the value of a terminal -capability, presumably), an output buffer BUFFER and SIZE, and any -number of integer parameters to be encoded. The effect of `tparam' is -to copy the control string into the buffer, encoding parameters -according to the `%' sequences in the control string. - - You describe the output buffer by its address, BUFFER, and its size -in bytes, SIZE. If the buffer is not big enough for the data to be -stored in it, `tparam' calls `malloc' to get a larger buffer. In -either case, `tparam' returns the address of the buffer it ultimately -uses. If the value equals BUFFER, your original buffer was used. -Otherwise, a new buffer was allocated, and you must free it after you -are done with printing the results. If you pass zero for SIZE and -BUFFER, `tparam' always allocates the space with `malloc'. - - All capabilities that require parameters also have the ability to -specify padding, so you should use `tputs' to output the string -produced by `tparam'. *Note Padding::. Here is an example. - - { - char *buf; - char buffer[40]; - - buf = tparam (command, buffer, 40, parm); - tputs (buf, 1, fputchar); - if (buf != buffer) - free (buf); - } - - If a parameter whose value is zero is encoded with `%.'-style -encoding, the result is a null character, which will confuse `tputs'. -This would be a serious problem, but luckily `%.' encoding is used only -by a few old models of terminal, and only for the `cm' capability. To -solve the problem, use `tgoto' rather than `tparam' to encode the `cm' -capability. - - -File: termcap.info, Node: tgoto, Prev: tparam, Up: Using Parameters - -`tgoto' -....... - - The special case of cursor motion is handled by `tgoto'. There are -two reasons why you might choose to use `tgoto': - - * For Unix compatibility, because Unix termcap does not have - `tparam'. - - * For the `cm' capability, since `tgoto' has a special feature to - avoid problems with null characters, tabs and newlines on certain - old terminal types that use `%.' encoding for that capability. - - Here is how `tgoto' might be declared in ANSI C: - - char *tgoto (char *CSTRING, int HPOS, int VPOS) - - There are three arguments, the terminal description's `cm' string and -the two cursor position numbers; `tgoto' computes the parametrized -string in an internal static buffer and returns the address of that -buffer. The next time you use `tgoto' the same buffer will be reused. - - Parameters encoded with `%.' encoding can generate null characters, -tabs or newlines. These might cause trouble: the null character because -`tputs' would think that was the end of the string, the tab because the -kernel or other software might expand it into spaces, and the newline -becaue the kernel might add a carriage-return, or padding characters -normally used for a newline. To prevent such problems, `tgoto' is -careful to avoid these characters. Here is how this works: if the -target cursor position value is such as to cause a problem (that is to -say, zero, nine or ten), `tgoto' increments it by one, then compensates -by appending a string to move the cursor back or up one position. - - The compensation strings to use for moving back or up are found in -global variables named `BC' and `UP'. These are actual external C -variables with upper case names; they are declared `char *'. It is up -to you to store suitable values in them, normally obtained from the -`le' and `up' terminal capabilities in the terminal description with -`tgetstr'. Alternatively, if these two variables are both zero, the -feature of avoiding nulls, tabs and newlines is turned off. - - It is safe to use `tgoto' for commands other than `cm' only if you -have stored zero in `BC' and `UP'. - - Note that `tgoto' reverses the order of its operands: the horizontal -position comes before the vertical position in the arguments to -`tgoto', even though the vertical position comes before the horizontal -in the parameters of the `cm' string. If you use `tgoto' with a -command such as `AL' that takes one parameter, you must pass the -parameter to `tgoto' as the "vertical position". - - -File: termcap.info, Node: Data Base, Next: Capabilities, Prev: Library, Up: Top - -The Format of the Data Base -*************************** - - The termcap data base of terminal descriptions is stored in the file -`/etc/termcap'. It contains terminal descriptions, blank lines, and -comments. - - A terminal description starts with one or more names for the -terminal type. The information in the description is a series of -"capability names" and values. The capability names have standard -meanings (*note Capabilities::.) and their values describe the terminal. - -* Menu: - -* Format:: Overall format of a terminal description. -* Capability Format:: Format of capabilities within a description. -* Naming:: Naming conventions for terminal types. -* Inheriting:: Inheriting part of a description from -a related terminal type. -* Changing:: When changes in the data base take effect. - - -File: termcap.info, Node: Format, Next: Capability Format, Up: Data Base - -Terminal Description Format -=========================== - - Aside from comments (lines starting with `#', which are ignored), -each nonblank line in the termcap data base is a terminal description. -A terminal description is nominally a single line, but it can be split -into multiple lines by inserting the two characters `\ newline'. This -sequence is ignored wherever it appears in a description. - - The preferred way to split the description is between capabilities: -insert the four characters `: \ newline tab' immediately before any -colon. This allows each sub-line to start with some indentation. This -works because, after the `\ newline' are ignored, the result is `: tab -:'; the first colon ends the preceding capability and the second colon -starts the next capability. If you split with `\ newline' alone, you -may not add any indentation after them. - - Here is a real example of a terminal description: - - dw|vt52|DEC vt52:\ - :cr=^M:do=^J:nl=^J:bl=^G:\ - :le=^H:bs:cd=\EJ:ce=\EK:cl=\EH\EJ:\ - :cm=\EY%+ %+ :co#80:li#24:\ - :nd=\EC:ta=^I:pt:sr=\EI:up=\EA:\ - :ku=\EA:kd=\EB:kr=\EC:kl=\ED:kb=^H: - - Each terminal description begins with several names for the terminal -type. The names are separated by `|' characters, and a colon ends the -last name. The first name should be two characters long; it exists -only for the sake of very old Unix systems and is never used in modern -systems. The last name should be a fully verbose name such as "DEC -vt52" or "Ann Arbor Ambassador with 48 lines". The other names should -include whatever the user ought to be able to specify to get this -terminal type, such as `vt52' or `aaa-48'. *Note Naming::, for -information on how to choose terminal type names. - - After the terminal type names come the terminal capabilities, -separated by colons and with a colon after the last one. Each -capability has a two-letter name, such as `cm' for "cursor motion -string" or `li' for "number of display lines". - - -File: termcap.info, Node: Capability Format, Next: Naming, Prev: Format, Up: Data Base - -Writing the Capabilities -======================== - - There are three kinds of capabilities: flags, numbers, and strings. -Each kind has its own way of being written in the description. Each -defined capability has by convention a particular kind of value; for -example, `li' always has a numeric value and `cm' always a string value. - - A flag capability is thought of as having a boolean value: the value -is true if the capability is present, false if not. When the -capability is present, just write its name between two colons. - - A numeric capability has a value which is a nonnegative number. -Write the capability name, a `#', and the number, between two colons. -For example, `...:li#48:...' is how you specify the `li' capability for -48 lines. - - A string-valued capability has a value which is a sequence of -characters. Usually these are the characters used to perform some -display operation. Write the capability name, a `=', and the -characters of the value, between two colons. For example, -`...:cm=\E[%i%d;%dH:...' is how the cursor motion command for a -standard ANSI terminal would be specified. - - Special characters in the string value can be expressed using -`\'-escape sequences as in C; in addition, `\E' stands for ESC. `^' is -also a kind of escape character; `^' followed by CHAR stands for the -control-equivalent of CHAR. Thus, `^a' stands for the character -control-a, just like `\001'. `\' and `^' themselves can be represented -as `\\' and `\^'. - - To include a colon in the string, you must write `\072'. You might -ask, "Why can't `\:' be used to represent a colon?" The reason is that -the interrogation functions do not count slashes while looking for a -capability. Even if `:ce=ab\:cd:' were interpreted as giving the `ce' -capability the value `ab:cd', it would also appear to define `cd' as a -flag. - - The string value will often contain digits at the front to specify -padding (*note Padding::.) and/or `%'-sequences within to specify how -to encode parameters (*note Parameters::.). Although these things are -not to be output literally to the terminal, they are considered part of -the value of the capability. They are special only when the string -value is processed by `tputs', `tparam' or `tgoto'. By contrast, `\' -and `^' are considered part of the syntax for specifying the characters -in the string. - - Let's look at the VT52 example again: - - dw|vt52|DEC vt52:\ - :cr=^M:do=^J:nl=^J:bl=^G:\ - :le=^H:bs:cd=\EJ:ce=\EK:cl=\EH\EJ:\ - :cm=\EY%+ %+ :co#80:li#24:\ - :nd=\EC:ta=^I:pt:sr=\EI:up=\EA:\ - :ku=\EA:kd=\EB:kr=\EC:kl=\ED:kb=^H: - - Here we see the numeric-valued capabilities `co' and `li', the flags -`bs' and `pt', and many string-valued capabilities. Most of the -strings start with ESC represented as `\E'. The rest contain control -characters represented using `^'. The meanings of the individual -capabilities are defined elsewhere (*note Capabilities::.). - diff --git a/lib/termcap/grot/termcap.info-2 b/lib/termcap/grot/termcap.info-2 deleted file mode 100644 index 6098d62..0000000 --- a/lib/termcap/grot/termcap.info-2 +++ /dev/null @@ -1,974 +0,0 @@ -This is Info file ./termcap.info, produced by Makeinfo-1.55 from the -input file ./termcap.texi. - - This file documents the termcap library of the GNU system. - - Copyright (C) 1988 Free Software Foundation, Inc. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Foundation. - - -File: termcap.info, Node: Naming, Next: Inheriting, Prev: Capability Format, Up: Data Base - -Terminal Type Name Conventions -============================== - - There are conventions for choosing names of terminal types. For one -thing, all letters should be in lower case. The terminal type for a -terminal in its most usual or most fundamental mode of operation should -not have a hyphen in it. - - If the same terminal has other modes of operation which require -different terminal descriptions, these variant descriptions are given -names made by adding suffixes with hyphens. Such alternate descriptions -are used for two reasons: - - * When the terminal has a switch that changes its behavior. Since - the computer cannot tell how the switch is set, the user must tell - the computer by choosing the appropriate terminal type name. - - For example, the VT-100 has a setup flag that controls whether the - cursor wraps at the right margin. If this flag is set to "wrap", - you must use the terminal type `vt100-am'. Otherwise you must use - `vt100-nam'. Plain `vt100' is defined as a synonym for either - `vt100-am' or `vt100-nam' depending on the preferences of the - local site. - - The standard suffix `-am' stands for "automatic margins". - - * To give the user a choice in how to use the terminal. This is done - when the terminal has a switch that the computer normally controls. - - For example, the Ann Arbor Ambassador can be configured with many - screen sizes ranging from 20 to 60 lines. Fewer lines make bigger - characters but more lines let you see more of what you are editing. - As a result, users have different preferences. Therefore, termcap - provides terminal types for many screen sizes. If you choose type - `aaa-30', the terminal will be configured to use 30 lines; if you - choose `aaa-48', 48 lines will be used, and so on. - - Here is a list of standard suffixes and their conventional meanings: - -`-w' - Short for "wide". This is a mode that gives the terminal more - columns than usual. This is normally a user option. - -`-am' - "Automatic margins". This is an alternate description for use when - the terminal's margin-wrap switch is on; it contains the `am' - flag. The implication is that normally the switch is off and the - usual description for the terminal says that the switch is off. - -`-nam' - "No automatic margins". The opposite of `-am', this names an - alternative description which lacks the `am' flag. This implies - that the terminal is normally operated with the margin-wrap switch - turned on, and the normal description of the terminal says so. - -`-na' - "No arrows". This terminal description initializes the terminal to - keep its arrow keys in local mode. This is a user option. - -`-rv' - "Reverse video". This terminal description causes text output for - normal video to appear as reverse, and text output for reverse - video to come out as normal. Often this description differs from - the usual one by interchanging the two strings which turn reverse - video on and off. - - This is a user option; you can choose either the "reverse video" - variant terminal type or the normal terminal type, and termcap will - obey. - -`-s' - "Status". Says to enable use of a status line which ordinary - output does not touch (*note Status Line::.). - - Some terminals have a special line that is used only as a status - line. For these terminals, there is no need for an `-s' variant; - the status line commands should be defined by default. On other - terminals, enabling a status line means removing one screen line - from ordinary use and reducing the effective screen height. For - these terminals, the user can choose the `-s' variant type to - request use of a status line. - -`-NLINES' - Says to operate with NLINES lines on the screen, for terminals - such as the Ambassador which provide this as an option. Normally - this is a user option; by choosing the terminal type, you control - how many lines termcap will use. - -`-NPAGESp' - Says that the terminal has NPAGES pages worth of screen memory, - for terminals where this is a hardware option. - -`-unk' - Says that description is not for direct use, but only for - reference in `tc' capabilities. Such a description is a kind of - subroutine, because it describes the common characteristics of - several variant descriptions that would use other suffixes in - place of `-unk'. - - -File: termcap.info, Node: Inheriting, Next: Changing, Prev: Naming, Up: Data Base - -Inheriting from Related Descriptions -==================================== - - When two terminal descriptions are similar, their identical parts do -not need to be given twice. Instead, one of the two can be defined in -terms of the other, using the `tc' capability. We say that one -description "refers to" the other, or "inherits from" the other. - - The `tc' capability must be the last one in the terminal description, -and its value is a string which is the name of another terminal type -which is referred to. For example, - - N9|aaa|ambassador|aaa-30|ann arbor ambassador/30 lines:\ - :ti=\E[2J\E[30;0;0;30p:\ - :te=\E[60;0;0;30p\E[30;1H\E[J:\ - :li#30:tc=aaa-unk: - -defines the terminal type `aaa-30' (also known as plain `aaa') in terms -of `aaa-unk', which defines everything about the Ambassador that is -independent of screen height. The types `aaa-36', `aaa-48' and so on -for other screen heights are likewise defined to inherit from `aaa-unk'. - - The capabilities overridden by `aaa-30' include `li', which says how -many lines there are, and `ti' and `te', which configure the terminal -to use that many lines. - - The effective terminal description for type `aaa' consists of the -text shown above followed by the text of the description of `aaa-unk'. -The `tc' capability is handled automatically by `tgetent', which finds -the description thus referenced and combines the two descriptions -(*note Find::.). Therefore, only the implementor of the terminal -descriptions needs to think about using `tc'. Users and application -programmers do not need to be concerned with it. - - Since the reference terminal description is used last, capabilities -specified in the referring description override any specifications of -the same capabilities in the reference description. - - The referring description can cancel out a capability without -specifying any new value for it by means of a special trick. Write the -capability in the referring description, with the character `@' after -the capability name, as follows: - - NZ|aaa-30-nam|ann arbor ambassador/30 lines/no automatic-margins:\ - :am@:tc=aaa-30: - - -File: termcap.info, Node: Changing, Prev: Inheriting, Up: Data Base - -When Changes in the Data Base Take Effect -========================================= - - Each application program must read the terminal description from the -data base, so a change in the data base is effective for all jobs -started after the change is made. - - The change will usually have no effect on a job that have been in -existence since before the change. The program probably read the -terminal description once, when it was started, and is continuing to -use what it read then. If the program does not have a feature for -reexamining the data base, then you will need to run it again (probably -killing the old job). - - If the description in use is coming from the `TERMCAP' environment -variable, then the data base file is effectively overridden, and -changes in it will have no effect until you change the `TERMCAP' -variable as well. For example, some users' `.login' files -automatically copy the terminal description into `TERMCAP' to speed -startup of applications. If you have done this, you will need to -change the `TERMCAP' variable to make the changed data base take effect. - - -File: termcap.info, Node: Capabilities, Next: Summary, Prev: Data Base, Up: Top - -Definitions of the Terminal Capabilities -**************************************** - - This section is divided into many subsections, each for one aspect of -use of display terminals. For writing a display program, you usually -need only check the subsections for the operations you want to use. -For writing a terminal description, you must read each subsection and -fill in the capabilities described there. - - String capabilities that are display commands may require numeric -parameters (*note Parameters::.). Most such capabilities do not use -parameters. When a capability requires parameters, this is explicitly -stated at the beginning of its definition. In simple cases, the first -or second sentence of the definition mentions all the parameters, in -the order they should be given, using a name in upper case for each -one. For example, the `rp' capability is a command that requires two -parameters; its definition begins as follows: - - String of commands to output a graphic character C, repeated N - times. - - In complex cases or when there are many parameters, they are -described explicitly. - - When a capability is described as obsolete, this means that programs -should not be written to look for it, but terminal descriptions should -still be written to provide it. - - When a capability is described as very obsolete, this means that it -should be omitted from terminal descriptions as well. - -* Menu: - -* Basic:: Basic characteristics. -* Screen Size:: Screen size, and what happens when it changes. -* Cursor Motion:: Various ways to move the cursor. -* Wrapping:: What happens if you write a character in the last column. -* Scrolling:: Pushing text up and down on the screen. -* Windows:: Limiting the part of the window that output affects. -* Clearing:: Erasing one or many lines. -* Insdel Line:: Making new blank lines in mid-screen; deleting lines. -* Insdel Char:: Inserting and deleting characters within a line. -* Standout:: Highlighting some of the text. -* Underlining:: Underlining some of the text. -* Cursor Visibility:: Making the cursor more or less easy to spot. -* Bell:: Attracts user's attention; not localized on the screen. -* Keypad:: Recognizing when function keys or arrows are typed. -* Meta Key:: META acts like an extra shift key. -* Initialization:: Commands used to initialize or reset the terminal. -* Pad Specs:: Info for the kernel on how much padding is needed. -* Status Line:: A status line displays "background" information. -* Half-Line:: Moving by half-lines, for superscripts and subscripts. -* Printer:: Controlling auxiliary printers of display terminals. - - -File: termcap.info, Node: Basic, Next: Screen Size, Up: Capabilities - -Basic Characteristics -===================== - - This section documents the capabilities that describe the basic and -nature of the terminal, and also those that are relevant to the output -of graphic characters. - -`os' - Flag whose presence means that the terminal can overstrike. This - means that outputting a graphic character does not erase whatever - was present in the same character position before. The terminals - that can overstrike include printing terminals, storage tubes (all - obsolete nowadays), and many bit-map displays. - -`eo' - Flag whose presence means that outputting a space erases a - character position even if the terminal supports overstriking. If - this flag is not present and overstriking is supported, output of - a space has no effect except to move the cursor. - - (On terminals that do not support overstriking, you can always - assume that outputting a space at a position erases whatever - character was previously displayed there.) - -`gn' - Flag whose presence means that this terminal type is a generic type - which does not really describe any particular terminal. Generic - types are intended for use as the default type assigned when the - user connects to the system, with the intention that the user - should specify what type he really has. One example of a generic - type is the type `network'. - - Since the generic type cannot say how to do anything interesting - with the terminal, termcap-using programs will always find that the - terminal is too weak to be supported if the user has failed to - specify a real terminal type in place of the generic one. The - `gn' flag directs these programs to use a different error message: - "You have not specified your real terminal type", rather than - "Your terminal is not powerful enough to be used". - -`hc' - Flag whose presence means this is a hardcopy terminal. - -`rp' - String of commands to output a graphic character C, repeated N - times. The first parameter value is the ASCII code for the desired - character, and the second parameter is the number of times to - repeat the character. Often this command requires padding - proportional to the number of times the character is repeated. - This effect can be had by using parameter arithmetic with - `%'-sequences to compute the amount of padding, then generating - the result as a number at the front of the string so that `tputs' - will treat it as padding. - -`hz' - Flag whose presence means that the ASCII character `~' cannot be - output on this terminal because it is used for display commands. - - Programs handle this flag by checking all text to be output and - replacing each `~' with some other character(s). If this is not - done, the screen will be thoroughly garbled. - - The old Hazeltine terminals that required such treatment are - probably very rare today, so you might as well not bother to - support this flag. - -`CC' - String whose presence means the terminal has a settable command - character. The value of the string is the default command - character (which is usually ESC). - - All the strings of commands in the terminal description should be - written to use the default command character. If you are writing - an application program that changes the command character, use the - `CC' capability to figure out how to translate all the display - commands to work with the new command character. - - Most programs have no reason to look at the `CC' capability. - -`xb' - Flag whose presence identifies Superbee terminals which are unable - to transmit the characters ESC and `Control-C'. Programs which - support this flag are supposed to check the input for the code - sequences sent by the F1 and F2 keys, and pretend that ESC or - `Control-C' (respectively) had been read. But this flag is - obsolete, and not worth supporting. - - -File: termcap.info, Node: Screen Size, Next: Cursor Motion, Prev: Basic, Up: Capabilities - -Screen Size -=========== - - A terminal description has two capabilities, `co' and `li', that -describe the screen size in columns and lines. But there is more to -the question of screen size than this. - - On some operating systems the "screen" is really a window and the -effective width can vary. On some of these systems, `tgetnum' uses the -actual width of the window to decide what value to return for the `co' -capability, overriding what is actually written in the terminal -description. On other systems, it is up to the application program to -check the actual window width using a system call. For example, on BSD -4.3 systems, the system call `ioctl' with code `TIOCGWINSZ' will tell -you the current screen size. - - On all window systems, termcap is powerless to advise the application -program if the user resizes the window. Application programs must deal -with this possibility in a system-dependent fashion. On some systems -the C shell handles part of the problem by detecting changes in window -size and setting the `TERMCAP' environment variable appropriately. -This takes care of application programs that are started subsequently. -It does not help application programs already running. - - On some systems, including BSD 4.3, all programs using a terminal get -a signal named `SIGWINCH' whenever the screen size changes. Programs -that use termcap should handle this signal by using `ioctl TIOCGWINSZ' -to learn the new screen size. - -`co' - Numeric value, the width of the screen in character positions. - Even hardcopy terminals normally have a `co' capability. - -`li' - Numeric value, the height of the screen in lines. - - -File: termcap.info, Node: Cursor Motion, Next: Wrapping, Prev: Screen Size, Up: Capabilities - -Cursor Motion -============= - - Termcap assumes that the terminal has a "cursor", a spot on the -screen where a visible mark is displayed, and that most display -commands take effect at the position of the cursor. It follows that -moving the cursor to a specified location is very important. - - There are many terminal capabilities for different cursor motion -operations. A terminal description should define as many as possible, -but most programs do not need to use most of them. One capability, -`cm', moves the cursor to an arbitrary place on the screen; this by -itself is sufficient for any application as long as there is no need to -support hardcopy terminals or certain old, weak displays that have only -relative motion commands. Use of other cursor motion capabilities is an -optimization, enabling the program to output fewer characters in some -common cases. - - If you plan to use the relative cursor motion commands in an -application program, you must know what the starting cursor position -is. To do this, you must keep track of the cursor position and update -the records each time anything is output to the terminal, including -graphic characters. In addition, it is necessary to know whether the -terminal wraps after writing in the rightmost column. *Note Wrapping::. - - One other motion capability needs special mention: `nw' moves the -cursor to the beginning of the following line, perhaps clearing all the -starting line after the cursor, or perhaps not clearing at all. This -capability is a least common denominator that is probably supported -even by terminals that cannot do most other things such as `cm' or `do'. -Even hardcopy terminals can support `nw'. - -`cm' - String of commands to position the cursor at line L, column C. - Both parameters are origin-zero, and are defined relative to the - screen, not relative to display memory. - - All display terminals except a few very obsolete ones support `cm', - so it is acceptable for an application program to refuse to - operate on terminals lacking `cm'. - -`ho' - String of commands to move the cursor to the upper left corner of - the screen (this position is called the "home position"). In - terminals where the upper left corner of the screen is not the - same as the beginning of display memory, this command must go to - the upper left corner of the screen, not the beginning of display - memory. - - Every display terminal supports this capability, and many - application programs refuse to operate if the `ho' capability is - missing. - -`ll' - String of commands to move the cursor to the lower left corner of - the screen. On some terminals, moving up from home position does - this, but programs should never assume that will work. Just - output the `ll' string (if it is provided); if moving to home - position and then moving up is the best way to get there, the `ll' - command will do that. - -`cr' - String of commands to move the cursor to the beginning of the line - it is on. If this capability is not specified, many programs - assume they can use the ASCII carriage return character for this. - -`le' - String of commands to move the cursor left one column. Unless the - `bw' flag capability is specified, the effect is undefined if the - cursor is at the left margin; do not use this command there. If - `bw' is present, this command may be used at the left margin, and - it wraps the cursor to the last column of the preceding line. - -`nd' - String of commands to move the cursor right one column. The - effect is undefined if the cursor is at the right margin; do not - use this command there, not even if `am' is present. - -`up' - String of commands to move the cursor vertically up one line. The - effect of sending this string when on the top line is undefined; - programs should never use it that way. - -`do' - String of commands to move the cursor vertically down one line. - The effect of sending this string when on the bottom line is - undefined; programs should never use it that way. - - Some programs do use `do' to scroll up one line if used at the - bottom line, if `sf' is not defined but `sr' is. This is only to - compensate for certain old, incorrect terminal descriptions. (In - principle this might actually lead to incorrect behavior on other - terminals, but that seems to happen rarely if ever.) But the - proper solution is that the terminal description should define - `sf' as well as `do' if the command is suitable for scrolling. - - The original idea was that this string would not contain a newline - character and therefore could be used without disabling the - kernel's usual habit of converting of newline into a - carriage-return newline sequence. But many terminal descriptions - do use newline in the `do' string, so this is not possible; a - program which sends the `do' string must disable output conversion - in the kernel (*note Initialize::.). - -`bw' - Flag whose presence says that `le' may be used in column zero to - move to the last column of the preceding line. If this flag is - not present, `le' should not be used in column zero. - -`nw' - String of commands to move the cursor to start of next line, - possibly clearing rest of line (following the cursor) before - moving. - -`DO', `UP', `LE', `RI' - Strings of commands to move the cursor N lines down vertically, up - vertically, or N columns left or right. Do not attempt to move - past any edge of the screen with these commands; the effect of - trying that is undefined. Only a few terminal descriptions provide - these commands, and most programs do not use them. - -`CM' - String of commands to position the cursor at line L, column C, - relative to display memory. Both parameters are origin-zero. - This capability is present only in terminals where there is a - difference between screen-relative and memory-relative addressing, - and not even in all such terminals. - -`ch' - String of commands to position the cursor at column C in the same - line it is on. This is a special case of `cm' in which the - vertical position is not changed. The `ch' capability is provided - only when it is faster to output than `cm' would be in this - special case. Programs should not assume most display terminals - have `ch'. - -`cv' - String of commands to position the cursor at line L in the same - column. This is a special case of `cm' in which the horizontal - position is not changed. The `cv' capability is provided only - when it is faster to output than `cm' would be in this special - case. Programs should not assume most display terminals have `cv'. - -`sc' - String of commands to make the terminal save the current cursor - position. Only the last saved position can be used. If this - capability is present, `rc' should be provided also. Most - terminals have neither. - -`rc' - String of commands to make the terminal restore the last saved - cursor position. If this capability is present, `sc' should be - provided also. Most terminals have neither. - -`ff' - String of commands to advance to the next page, for a hardcopy - terminal. - -`ta' - String of commands to move the cursor right to the next hardware - tab stop column. Missing if the terminal does not have any kind of - hardware tabs. Do not send this command if the kernel's terminal - modes say that the kernel is expanding tabs into spaces. - -`bt' - String of commands to move the cursor left to the previous hardware - tab stop column. Missing if the terminal has no such ability; many - terminals do not. Do not send this command if the kernel's - terminal modes say that the kernel is expanding tabs into spaces. - - The following obsolete capabilities should be included in terminal -descriptions when appropriate, but should not be looked at by new -programs. - -`nc' - Flag whose presence means the terminal does not support the ASCII - carriage return character as `cr'. This flag is needed because - old programs assume, when the `cr' capability is missing, that - ASCII carriage return can be used for the purpose. We use `nc' to - tell the old programs that carriage return may not be used. - - New programs should not assume any default for `cr', so they need - not look at `nc'. However, descriptions should contain `nc' - whenever they do not contain `cr'. - -`xt' - Flag whose presence means that the ASCII tab character may not be - used for cursor motion. This flag exists because old programs - assume, when the `ta' capability is missing, that ASCII tab can be - used for the purpose. We use `xt' to tell the old programs not to - use tab. - - New programs should not assume any default for `ta', so they need - not look at `xt' in connection with cursor motion. Note that `xt' - also has implications for standout mode (*note Standout::.). It - is obsolete in regard to cursor motion but not in regard to - standout. - - In fact, `xt' means that the terminal is a Teleray 1061. - -`bc' - Very obsolete alternative name for the `le' capability. - -`bs' - Flag whose presence means that the ASCII character backspace may be - used to move the cursor left. Obsolete; look at `le' instead. - -`nl' - Obsolete capability which is a string that can either be used to - move the cursor down or to scroll. The same string must scroll - when used on the bottom line and move the cursor when used on any - other line. New programs should use `do' or `sf', and ignore `nl'. - - If there is no `nl' capability, some old programs assume they can - use the newline character for this purpose. These programs follow - a bad practice, but because they exist, it is still desirable to - define the `nl' capability in a terminal description if the best - way to move down is *not* a newline. - - -File: termcap.info, Node: Wrapping, Next: Scrolling, Prev: Cursor Motion, Up: Capabilities - -Wrapping -======== - - "Wrapping" means moving the cursor from the right margin to the left -margin of the following line. Some terminals wrap automatically when a -graphic character is output in the last column, while others do not. -Most application programs that use termcap need to know whether the -terminal wraps. There are two special flag capabilities to describe -what the terminal does when a graphic character is output in the last -column. - -`am' - Flag whose presence means that writing a character in the last - column causes the cursor to wrap to the beginning of the next line. - - If `am' is not present, writing in the last column leaves the - cursor at the place where the character was written. - - Writing in the last column of the last line should be avoided on - terminals with `am', as it may or may not cause scrolling to occur - (*note Scrolling::.). Scrolling is surely not what you would - intend. - - If your program needs to check the `am' flag, then it also needs - to check the `xn' flag which indicates that wrapping happens in a - strange way. Many common terminals have the `xn' flag. - -`xn' - Flag whose presence means that the cursor wraps in a strange way. - At least two distinct kinds of strange behavior are known; the - termcap data base does not contain anything to distinguish the two. - - On Concept-100 terminals, output in the last column wraps the - cursor almost like an ordinary `am' terminal. But if the next - thing output is a newline, it is ignored. - - DEC VT-100 terminals (when the wrap switch is on) do a different - strange thing: the cursor wraps only if the next thing output is - another graphic character. In fact, the wrap occurs when the - following graphic character is received by the terminal, before the - character is placed on the screen. - - On both of these terminals, after writing in the last column a - following graphic character will be displayed in the first column - of the following line. But the effect of relative cursor motion - characters such as newline or backspace at such a time depends on - the terminal. The effect of erase or scrolling commands also - depends on the terminal. You can't assume anything about what - they will do on a terminal that has `xn'. So, to be safe, you - should never do these things at such a time on such a terminal. - - To be sure of reliable results on a terminal which has the `xn' - flag, output a `cm' absolute positioning command after writing in - the last column. Another safe thing to do is to output - carriage-return newline, which will leave the cursor at the - beginning of the following line. - -`LP' - Flag whose presence means that it is safe to write in the last - column of the last line without worrying about undesired - scrolling. `LP' indicates the DEC flavor of `xn' strangeness. - - -File: termcap.info, Node: Scrolling, Next: Windows, Prev: Wrapping, Up: Capabilities - -Scrolling -========= - - "Scrolling" means moving the contents of the screen up or down one or -more lines. Moving the contents up is "forward scrolling"; moving them -down is "reverse scrolling". - - Scrolling happens after each line of output during ordinary output -on most display terminals. But in an application program that uses -termcap for random-access output, scrolling happens only when -explicitly requested with the commands in this section. - - Some terminals have a "scroll region" feature. This lets you limit -the effect of scrolling to a specified range of lines. Lines outside -the range are unaffected when scrolling happens. The scroll region -feature is available if either `cs' or `cS' is present. - -`sf' - String of commands to scroll the screen one line up, assuming it is - output with the cursor at the beginning of the bottom line. - -`sr' - String of commands to scroll the screen one line down, assuming it - is output with the cursor at the beginning of the top line. - -`do' - A few programs will try to use `do' to do the work of `sf'. This - is not really correct--it is an attempt to compensate for the - absence of a `sf' command in some old terminal descriptions. - - Since these terminal descriptions do define `sr', perhaps at one - time the definition of `do' was different and it could be used for - scrolling as well. But it isn't desirable to combine these two - functions in one capability, since scrolling often requires more - padding than simply moving the cursor down. Defining `sf' and - `do' separately allows you to specify the padding properly. Also, - all sources agree that `do' should not be relied on to do - scrolling. - - So the best approach is to add `sf' capabilities to the - descriptions of these terminals, copying the definition of `do' if - that does scroll. - -`SF' - String of commands to scroll the screen N lines up, assuming it is - output with the cursor at the beginning of the bottom line. - -`SR' - String of commands to scroll the screen N lines down, assuming it - is output with the cursor at the beginning of the top line. - -`cs' - String of commands to set the scroll region. This command takes - two parameters, START and END, which are the line numbers - (origin-zero) of the first line to include in the scroll region - and of the last line to include in it. When a scroll region is - set, scrolling is limited to the specified range of lines; lines - outside the range are not affected by scroll commands. - - Do not try to move the cursor outside the scroll region. The - region remains set until explicitly removed. To remove the scroll - region, use another `cs' command specifying the full height of the - screen. - - The cursor position is undefined after the `cs' command is set, so - position the cursor with `cm' immediately afterward. - -`cS' - String of commands to set the scroll region using parameters in - different form. The effect is the same as if `cs' were used. - Four parameters are required: - - 1. Total number of lines on the screen. - - 2. Number of lines above desired scroll region. - - 3. Number of lines below (outside of) desired scroll region. - - 4. Total number of lines on the screen, the same as the first - parameter. - - This capability is a GNU extension that was invented to allow the - Ann Arbor Ambassador's scroll-region command to be described; it - could also be done by putting non-Unix `%'-sequences into a `cs' - string, but that would have confused Unix programs that used the - `cs' capability with the Unix termcap. Currently only GNU Emacs - uses the `cS' capability. - -`ns' - Flag which means that the terminal does not normally scroll for - ordinary sequential output. For modern terminals, this means that - outputting a newline in ordinary sequential output with the cursor - on the bottom line wraps to the top line. For some obsolete - terminals, other things may happen. - - The terminal may be able to scroll even if it does not normally do - so. If the `sf' capability is provided, it can be used for - scrolling regardless of `ns'. - -`da' - Flag whose presence means that lines scrolled up off the top of the - screen may come back if scrolling down is done subsequently. - - The `da' and `db' flags do not, strictly speaking, affect how to - scroll. But programs that scroll usually need to clear the lines - scrolled onto the screen, if these flags are present. - -`db' - Flag whose presence means that lines scrolled down off the bottom - of the screen may come back if scrolling up is done subsequently. - -`lm' - Numeric value, the number of lines of display memory that the - terminal has. A value of zero means that the terminal has more - display memory than can fit on the screen, but no fixed number of - lines. (The number of lines may depend on the amount of text in - each line.) - - Any terminal description that defines `SF' should also define `sf'; -likewise for `SR' and `sr'. However, many terminals can only scroll by -one line at a time, so it is common to find `sf' and not `SF', or `sr' -without `SR'. - - Therefore, all programs that use the scrolling facilities should be -prepared to work with `sf' in the case that `SF' is absent, and -likewise with `sr'. On the other hand, an application program that -uses only `sf' and not `SF' is acceptable, though slow on some -terminals. - - When outputting a scroll command with `tputs', the NLINES argument -should be the total number of lines in the portion of the screen being -scrolled. Very often these commands require padding proportional to -this number of lines. *Note Padding::. - - -File: termcap.info, Node: Windows, Next: Clearing, Prev: Scrolling, Up: Capabilities - -Windows -======= - - A "window", in termcap, is a rectangular portion of the screen to -which all display operations are restricted. Wrapping, clearing, -scrolling, insertion and deletion all operate as if the specified -window were all the screen there was. - -`wi' - String of commands to set the terminal output screen window. This - string requires four parameters, all origin-zero: - 1. The first line to include in the window. - - 2. The last line to include in the window. - - 3. The first column to include in the window. - - 4. The last column to include in the window. - - Most terminals do not support windows. - - -File: termcap.info, Node: Clearing, Next: Insdel Line, Prev: Windows, Up: Capabilities - -Clearing Parts of the Screen -============================ - - There are several terminal capabilities for clearing parts of the -screen to blank. All display terminals support the `cl' string, and -most display terminals support all of these capabilities. - -`cl' - String of commands to clear the entire screen and position the - cursor at the upper left corner. - -`cd' - String of commands to clear the line the cursor is on, and all the - lines below it, down to the bottom of the screen. This command - string should be used only with the cursor in column zero; their - effect is undefined if the cursor is elsewhere. - -`ce' - String of commands to clear from the cursor to the end of the - current line. - -`ec' - String of commands to clear N characters, starting with the - character that the cursor is on. This command string is expected - to leave the cursor position unchanged. The parameter N should - never be large enough to reach past the right margin; the effect - of such a large parameter would be undefined. - - Clear to end of line (`ce') is extremely important in programs that -maintain an updating display. Nearly all display terminals support this -operation, so it is acceptable for a an application program to refuse to -work if `ce' is not present. However, if you do not want this -limitation, you can accomplish clearing to end of line by outputting -spaces until you reach the right margin. In order to do this, you must -know the current horizontal position. Also, this technique assumes -that writing a space will erase. But this happens to be true on all -the display terminals that fail to support `ce'. - - -File: termcap.info, Node: Insdel Line, Next: Insdel Char, Prev: Clearing, Up: Capabilities - -Insert/Delete Line -================== - - "Inserting a line" means creating a blank line in the middle of the -screen, and pushing the existing lines of text apart. In fact, the -lines above the insertion point do not change, while the lines below -move down, and one is normally lost at the bottom of the screen. - - "Deleting a line" means causing the line to disappear from the -screen, closing up the gap by moving the lines below it upward. A new -line appears at the bottom of the screen. Usually this line is blank, -but on terminals with the `db' flag it may be a line previously moved -off the screen bottom by scrolling or line insertion. - - Insertion and deletion of lines is useful in programs that maintain -an updating display some parts of which may get longer or shorter. -They are also useful in editors for scrolling parts of the screen, and -for redisplaying after lines of text are killed or inserted. - - Many terminals provide commands to insert or delete a single line at -the cursor position. Some provide the ability to insert or delete -several lines with one command, using the number of lines to insert or -delete as a parameter. Always move the cursor to column zero before -using any of these commands. - -`al' - String of commands to insert a blank line before the line the - cursor is on. The existing line, and all lines below it, are - moved down. The last line in the screen (or in the scroll region, - if one is set) disappears and in most circumstances is discarded. - It may not be discarded if the `db' is present (*note - Scrolling::.). - - The cursor must be at the left margin before this command is used. - This command does not move the cursor. - -`dl' - String of commands to delete the line the cursor is on. The - following lines move up, and a blank line appears at the bottom of - the screen (or bottom of the scroll region). If the terminal has - the `db' flag, a nonblank line previously pushed off the screen - bottom may reappear at the bottom. - - The cursor must be at the left margin before this command is used. - This command does not move the cursor. - -`AL' - String of commands to insert N blank lines before the line that - the cursor is on. It is like `al' repeated N times, except that - it is as fast as one `al'. - -`DL' - String of commands to delete N lines starting with the line that - the cursor is on. It is like `dl' repeated N times, except that - it is as fast as one `dl'. - - Any terminal description that defines `AL' should also define `al'; -likewise for `DL' and `dl'. However, many terminals can only insert or -delete one line at a time, so it is common to find `al' and not `AL', -or `dl' without `DL'. - - Therefore, all programs that use the insert and delete facilities -should be prepared to work with `al' in the case that `AL' is absent, -and likewise with `dl'. On the other hand, it is acceptable to write -an application that uses only `al' and `dl' and does not look for `AL' -or `DL' at all. - - If a terminal does not support line insertion and deletion directly, -but does support a scroll region, the effect of insertion and deletion -can be obtained with scrolling. However, it is up to the individual -user program to check for this possibility and use the scrolling -commands to get the desired result. It is fairly important to implement -this alternate strategy, since it is the only way to get the effect of -line insertion and deletion on the popular VT100 terminal. - - Insertion and deletion of lines is affected by the scroll region on -terminals that have a settable scroll region. This is useful when it is -desirable to move any few consecutive lines up or down by a few lines. -*Note Scrolling::. - - The line pushed off the bottom of the screen is not lost if the -terminal has the `db' flag capability; instead, it is pushed into -display memory that does not appear on the screen. This is the same -thing that happens when scrolling pushes a line off the bottom of the -screen. Either reverse scrolling or deletion of a line can bring the -apparently lost line back onto the bottom of the screen. If the -terminal has the scroll region feature as well as `db', the pushed-out -line really is lost if a scroll region is in effect. - - When outputting an insert or delete command with `tputs', the NLINES -argument should be the total number of lines from the cursor to the -bottom of the screen (or scroll region). Very often these commands -require padding proportional to this number of lines. *Note Padding::. - - For `AL' and `DL' the NLINES argument should *not* depend on the -number of lines inserted or deleted; only the total number of lines -affected. This is because it is just as fast to insert two or N lines -with `AL' as to insert one line with `al'. - diff --git a/lib/termcap/grot/termcap.info-3 b/lib/termcap/grot/termcap.info-3 deleted file mode 100644 index d5b309f..0000000 --- a/lib/termcap/grot/termcap.info-3 +++ /dev/null @@ -1,1480 +0,0 @@ -This is Info file ./termcap.info, produced by Makeinfo-1.55 from the -input file ./termcap.texi. - - This file documents the termcap library of the GNU system. - - Copyright (C) 1988 Free Software Foundation, Inc. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Foundation. - - -File: termcap.info, Node: Insdel Char, Next: Standout, Prev: Insdel Line, Up: Capabilities - -Insert/Delete Character -======================= - - "Inserting a character" means creating a blank space in the middle -of a line, and pushing the rest of the line rightward. The character -in the rightmost column is lost. - - "Deleting a character" means causing the character to disappear from -the screen, closing up the gap by moving the rest of the line leftward. -A blank space appears in the rightmost column. - - Insertion and deletion of characters is useful in programs that -maintain an updating display some parts of which may get longer or -shorter. It is also useful in editors for redisplaying the results of -editing within a line. - - Many terminals provide commands to insert or delete a single -character at the cursor position. Some provide the ability to insert -or delete several characters with one command, using the number of -characters to insert or delete as a parameter. - - Many terminals provide an insert mode in which outputting a graphic -character has the added effect of inserting a position for that -character. A special command string is used to enter insert mode and -another is used to exit it. The reason for designing a terminal with -an insert mode rather than an insert command is that inserting -character positions is usually followed by writing characters into -them. With insert mode, this is as fast as simply writing the -characters, except for the fixed overhead of entering and leaving -insert mode. However, when the line speed is great enough, padding may -be required for the graphic characters output in insert mode. - - Some terminals require you to enter insert mode and then output a -special command for each position to be inserted. Or they may require -special commands to be output before or after each graphic character to -be inserted. - - Deletion of characters is usually accomplished by a straightforward -command to delete one or several positions; but on some terminals, it -is necessary to enter a special delete mode before using the delete -command, and leave delete mode afterward. Sometimes delete mode and -insert mode are the same mode. - - Some terminals make a distinction between character positions in -which a space character has been output and positions which have been -cleared. On these terminals, the effect of insert or delete character -runs to the first cleared position rather than to the end of the line. -In fact, the effect may run to more than one line if there is no -cleared position to stop the shift on the first line. These terminals -are identified by the `in' flag capability. - - On terminals with the `in' flag, the technique of skipping over -characters that you know were cleared, and then outputting text later -on in the same line, causes later insert and delete character -operations on that line to do nonstandard things. A program that has -any chance of doing this must check for the `in' flag and must be -careful to write explicit space characters into the intermediate -columns when `in' is present. - - A plethora of terminal capabilities are needed to describe all of -this complexity. Here is a list of them all. Following the list, we -present an algorithm for programs to use to take proper account of all -of these capabilities. - -`im' - String of commands to enter insert mode. - - If the terminal has no special insert mode, but it can insert - characters with a special command, `im' should be defined with a - null value, because the `vi' editor assumes that insertion of a - character is impossible if `im' is not provided. - - New programs should not act like `vi'. They should pay attention - to `im' only if it is defined. - -`ei' - String of commands to leave insert mode. This capability must be - present if `im' is. - - On a few old terminals the same string is used to enter and exit - insert mode. This string turns insert mode on if it was off, and - off it it was on. You can tell these terminals because the `ei' - string equals the `im' string. If you want to support these - terminals, you must always remember accurately whether insert mode - is in effect. However, these terminals are obsolete, and it is - reasonable to refuse to support them. On all modern terminals, you - can safely output `ei' at any time to ensure that insert mode is - turned off. - -`ic' - String of commands to insert one character position at the cursor. - The cursor does not move. - - If outputting a graphic character while in insert mode is - sufficient to insert the character, then the `ic' capability - should be defined with a null value. - - If your terminal offers a choice of ways to insert--either use - insert mode or use a special command--then define `im' and do not - define `ic', since this gives the most efficient operation when - several characters are to be inserted. *Do not* define both - strings, for that means that *both* must be used each time - insertion is done. - -`ip' - String of commands to output following an inserted graphic - character in insert mode. Often it is used just for a padding - spec, when padding is needed after an inserted character (*note - Padding::.). - -`IC' - String of commands to insert N character positions at and after - the cursor. It has the same effect as repeating the `ic' string - and a space, N times. - - If `IC' is provided, application programs may use it without first - entering insert mode. - -`mi' - Flag whose presence means it is safe to move the cursor while in - insert mode and assume the terminal remains in insert mode. - -`in' - Flag whose presence means that the terminal distinguishes between - character positions in which space characters have been output and - positions which have been cleared. - - An application program can assume that the terminal can do character -insertion if *any one of* the capabilities `IC', `im', `ic' or `ip' is -provided. - - To insert N blank character positions, move the cursor to the place -to insert them and follow this algorithm: - - 1. If an `IC' string is provided, output it with parameter N and you - are finished. Otherwise (or if you don't want to bother to look - for an `IC' string) follow the remaining steps. - - 2. Output the `im' string, if there is one, unless the terminal is - already in insert mode. - - 3. Repeat steps 4 through 6, N times. - - 4. Output the `ic' string if any. - - 5. Output a space. - - 6. Output the `ip' string if any. - - 7. Output the `ei' string, eventually, to exit insert mode. There is - no need to do this right away. If the `mi' flag is present, you - can move the cursor and the cursor will remain in insert mode; - then you can do more insertion elsewhere without reentering insert - mode. - - To insert N graphic characters, position the cursor and follow this -algorithm: - - 1. If an `IC' string is provided, output it with parameter N, then - output the graphic characters, and you are finished. Otherwise - (or if you don't want to bother to look for an `IC' string) follow - the remaining steps. - - 2. Output the `im' string, if there is one, unless the terminal is - already in insert mode. - - 3. For each character to be output, repeat steps 4 through 6. - - 4. Output the `ic' string if any. - - 5. Output the next graphic character. - - 6. Output the `ip' string if any. - - 7. Output the `ei' string, eventually, to exit insert mode. There is - no need to do this right away. If the `mi' flag is present, you - can move the cursor and the cursor will remain in insert mode; - then you can do more insertion elsewhere without reentering insert - mode. - - Note that this is not the same as the original Unix termcap -specifications in one respect: it assumes that the `IC' string can be -used without entering insert mode. This is true as far as I know, and -it allows you be able to avoid entering and leaving insert mode, and -also to be able to avoid the inserted-character padding after the -characters that go into the inserted positions. - - Deletion of characters is less complicated; deleting one column is -done by outputting the `dc' string. However, there may be a delete -mode that must be entered with `dm' in order to make `dc' work. - -`dc' - String of commands to delete one character position at the cursor. - If `dc' is not present, the terminal cannot delete characters. - -`DC' - String of commands to delete N characters starting at the cursor. - It has the same effect as repeating the `dc' string N times. Any - terminal description that has `DC' also has `dc'. - -`dm' - String of commands to enter delete mode. If not present, there is - no delete mode, and `dc' can be used at any time (assuming there is - a `dc'). - -`ed' - String of commands to exit delete mode. This must be present if - `dm' is. - - To delete N character positions, position the cursor and follow these -steps: - - 1. If the `DC' string is present, output it with parameter N and you - are finished. Otherwise, follow the remaining steps. - - 2. Output the `dm' string, unless you know the terminal is already in - delete mode. - - 3. Output the `dc' string N times. - - 4. Output the `ed' string eventually. If the flag capability `mi' is - present, you can move the cursor and do more deletion without - leaving and reentering delete mode. - - As with the `IC' string, we have departed from the original termcap -specifications by assuming that `DC' works without entering delete mode -even though `dc' would not. - - If the `dm' and `im' capabilities are both present and have the same -value, it means that the terminal has one mode for both insertion and -deletion. It is useful for a program to know this, because then it can -do insertions after deletions, or vice versa, without leaving -insert/delete mode and reentering it. - - -File: termcap.info, Node: Standout, Next: Underlining, Prev: Insdel Char, Up: Capabilities - -Standout and Appearance Modes -============================= - - "Appearance modes" are modifications to the ways characters are -displayed. Typical appearance modes include reverse video, dim, bright, -blinking, underlined, invisible, and alternate character set. Each -kind of terminal supports various among these, or perhaps none. - - For each type of terminal, one appearance mode or combination of -them that looks good for highlighted text is chosen as the "standout -mode". The capabilities `so' and `se' say how to enter and leave -standout mode. Programs that use appearance modes only to highlight -some text generally use the standout mode so that they can work on as -many terminals as possible. Use of specific appearance modes other -than "underlined" and "alternate character set" is rare. - - Terminals that implement appearance modes fall into two general -classes as to how they do it. - - In some terminals, the presence or absence of any appearance mode is -recorded separately for each character position. In these terminals, -each graphic character written is given the appearance modes current at -the time it is written, and keeps those modes until it is erased or -overwritten. There are special commands to turn the appearance modes -on or off for characters to be written in the future. - - In other terminals, the change of appearance modes is represented by -a marker that belongs to a certain screen position but affects all -following screen positions until the next marker. These markers are -traditionally called "magic cookies". - - The same capabilities (`so', `se', `mb' and so on) for turning -appearance modes on and off are used for both magic-cookie terminals -and per-character terminals. On magic cookie terminals, these give the -commands to write the magic cookies. On per-character terminals, they -change the current modes that affect future output and erasure. Some -simple applications can use these commands without knowing whether or -not they work by means of cookies. - - However, a program that maintains and updates a display needs to know -whether the terminal uses magic cookies, and exactly what their effect -is. This information comes from the `sg' capability. - - The `sg' capability is a numeric capability whose presence indicates -that the terminal uses magic cookies for appearance modes. Its value is -the number of character positions that a magic cookie occupies. Usually -the cookie occupies one or more character positions on the screen, and -these character positions are displayed as blank, but in some terminals -the cookie has zero width. - - The `sg' capability describes both the magic cookie to turn standout -on and the cookie to turn it off. This makes the assumption that both -kinds of cookie have the same width on the screen. If that is not true, -the narrower cookie must be "widened" with spaces until it has the same -width as the other. - - On some magic cookie terminals, each line always starts with normal -display; in other words, the scope of a magic cookie never extends over -more than one line. But on other terminals, one magic cookie affects -all the lines below it unless explicitly canceled. Termcap does not -define any way to distinguish these two ways magic cookies can work. -To be safe, it is best to put a cookie at the beginning of each line. - - On some per-character terminals, standout mode or other appearance -modes may be canceled by moving the cursor. On others, moving the -cursor has no effect on the state of the appearance modes. The latter -class of terminals are given the flag capability `ms' ("can move in -standout"). All programs that might have occasion to move the cursor -while appearance modes are turned on must check for this flag; if it is -not present, they should reset appearance modes to normal before doing -cursor motion. - - A program that has turned on only standout mode should use `se' to -reset the standout mode to normal. A program that has turned on only -alternate character set mode should use `ae' to return it to normal. -If it is possible that any other appearance modes are turned on, use the -`me' capability to return them to normal. - - Note that the commands to turn on one appearance mode, including `so' -and `mb' ... `mr', if used while some other appearance modes are turned -on, may combine the two modes on some terminals but may turn off the -mode previously enabled on other terminals. This is because some -terminals do not have a command to set or clear one appearance mode -without changing the others. Programs should not attempt to use -appearance modes in combination except with `sa', and when switching -from one single mode to another should always turn off the previously -enabled mode and then turn on the new desired mode. - - On some old terminals, the `so' and `se' commands may be the same -command, which has the effect of turning standout on if it is off, or -off it is on. It is therefore risky for a program to output extra `se' -commands for good measure. Fortunately, all these terminals are -obsolete. - - Programs that update displays in which standout-text may be replaced -with non-standout text must check for the `xs' flag. In a per-character -terminal, this flag says that the only way to remove standout once -written is to clear that portion of the line with the `ce' string or -something even more powerful (*note Clearing::.); just writing new -characters at those screen positions will not change the modes in -effect there. In a magic cookie terminal, `xs' says that the only way -to remove a cookie is to clear a portion of the line that includes the -cookie; writing a different cookie at the same position does not work. - - Such programs must also check for the `xt' flag, which means that the -terminal is a Teleray 1061. On this terminal it is impossible to -position the cursor at the front of a magic cookie, so the only two -ways to remove a cookie are (1) to delete the line it is on or (2) to -position the cursor at least one character before it (possibly on a -previous line) and output the `se' string, which on these terminals -finds and removes the next `so' magic cookie on the screen. (It may -also be possible to remove a cookie which is not at the beginning of a -line by clearing that line.) The `xt' capability also has implications -for the use of tab characters, but in that regard it is obsolete (*Note -Cursor Motion::). - -`so' - String of commands to enter standout mode. - -`se' - String of commands to leave standout mode. - -`sg' - Numeric capability, the width on the screen of the magic cookie. - This capability is absent in terminals that record appearance modes - character by character. - -`ms' - Flag whose presence means that it is safe to move the cursor while - the appearance modes are not in the normal state. If this flag is - absent, programs should always reset the appearance modes to - normal before moving the cursor. - -`xs' - Flag whose presence means that the only way to reset appearance - modes already on the screen is to clear to end of line. On a - per-character terminal, you must clear the area where the modes - are set. On a magic cookie terminal, you must clear an area - containing the cookie. See the discussion above. - -`xt' - Flag whose presence means that the cursor cannot be positioned - right in front of a magic cookie, and that `se' is a command to - delete the next magic cookie following the cursor. See discussion - above. - -`mb' - String of commands to enter blinking mode. - -`md' - String of commands to enter double-bright mode. - -`mh' - String of commands to enter half-bright mode. - -`mk' - String of commands to enter invisible mode. - -`mp' - String of commands to enter protected mode. - -`mr' - String of commands to enter reverse-video mode. - -`me' - String of commands to turn off all appearance modes, including - standout mode and underline mode. On some terminals it also turns - off alternate character set mode; on others, it may not. This - capability must be present if any of `mb' ... `mr' is present. - -`as' - String of commands to turn on alternate character set mode. This - mode assigns some or all graphic characters an alternate picture - on the screen. There is no standard as to what the alternate - pictures look like. - -`ae' - String of commands to turn off alternate character set mode. - -`sa' - String of commands to turn on an arbitrary combination of - appearance modes. It accepts 9 parameters, each of which controls - a particular kind of appearance mode. A parameter should be 1 to - turn its appearance mode on, or zero to turn that mode off. Most - terminals do not support the `sa' capability, even among those - that do have various appearance modes. - - The nine parameters are, in order, STANDOUT, UNDERLINE, REVERSE, - BLINK, HALF-BRIGHT, DOUBLE-BRIGHT, BLANK, PROTECT, ALT CHAR SET. - - -File: termcap.info, Node: Underlining, Next: Cursor Visibility, Prev: Standout, Up: Capabilities - -Underlining -=========== - - Underlining on most terminals is a kind of appearance mode, much like -standout mode. Therefore, it may be implemented using magic cookies or -as a flag in the terminal whose current state affects each character -that is output. *Note Standout::, for a full explanation. - - The `ug' capability is a numeric capability whose presence indicates -that the terminal uses magic cookies for underlining. Its value is the -number of character positions that a magic cookie for underlining -occupies; it is used for underlining just as `sg' is used for standout. -Aside from the simplest applications, it is impossible to use -underlining correctly without paying attention to the value of `ug'. - -`us' - String of commands to turn on underline mode or to output a magic - cookie to start underlining. - -`ue' - String of commands to turn off underline mode or to output a magic - cookie to stop underlining. - -`ug' - Width of magic cookie that represents a change of underline mode; - or missing, if the terminal does not use a magic cookie for this. - -`ms' - Flag whose presence means that it is safe to move the cursor while - the appearance modes are not in the normal state. Underlining is - an appearance mode. If this flag is absent, programs should - always turn off underlining before moving the cursor. - - There are two other, older ways of doing underlining: there can be a -command to underline a single character, or the output of `_', the -ASCII underscore character, as an overstrike could cause a character to -be underlined. New programs need not bother to handle these -capabilities unless the author cares strongly about the obscure -terminals which support them. However, terminal descriptions should -provide these capabilities when appropriate. - -`uc' - String of commands to underline the character under the cursor, and - move the cursor right. - -`ul' - Flag whose presence means that the terminal can underline by - overstriking an underscore character (`_'); some terminals can do - this even though they do not support overstriking in general. An - implication of this flag is that when outputting new text to - overwrite old text, underscore characters must be treated - specially lest they underline the old text instead. - - -File: termcap.info, Node: Cursor Visibility, Next: Bell, Prev: Underlining, Up: Capabilities - -Cursor Visibility -================= - - Some terminals have the ability to make the cursor invisible, or to -enhance it. Enhancing the cursor is often done by programs that plan -to use the cursor to indicate to the user a position of interest that -may be anywhere on the screen--for example, the Emacs editor enhances -the cursor on entry. Such programs should always restore the cursor to -normal on exit. - -`vs' - String of commands to enhance the cursor. - -`vi' - String of commands to make the cursor invisible. - -`ve' - String of commands to return the cursor to normal. - - If you define either `vs' or `vi', you must also define `ve'. - - -File: termcap.info, Node: Bell, Next: Keypad, Prev: Cursor Visibility, Up: Capabilities - -Bell -==== - - Here we describe commands to make the terminal ask for the user to -pay attention to it. - -`bl' - String of commands to cause the terminal to make an audible sound. - If this capability is absent, the terminal has no way to make a - suitable sound. - -`vb' - String of commands to cause the screen to flash to attract - attention ("visible bell"). If this capability is absent, the - terminal has no way to do such a thing. - - -File: termcap.info, Node: Keypad, Next: Meta Key, Prev: Bell, Up: Capabilities - -Keypad and Function Keys -======================== - - Many terminals have arrow and function keys that transmit specific -character sequences to the computer. Since the precise sequences used -depend on the terminal, termcap defines capabilities used to say what -the sequences are. Unlike most termcap string-valued capabilities, -these are not strings of commands to be sent to the terminal, rather -strings that are received from the terminal. - - Programs that expect to use keypad keys should check, initially, for -a `ks' capability and send it, to make the keypad actually transmit. -Such programs should also send the `ke' string when exiting. - -`ks' - String of commands to make the keypad keys transmit. If this - capability is not provided, but the others in this section are, - programs may assume that the keypad keys always transmit. - -`ke' - String of commands to make the keypad keys work locally. This - capability is provided only if `ks' is. - -`kl' - String of input characters sent by typing the left-arrow key. If - this capability is missing, you cannot expect the terminal to have - a left-arrow key that transmits anything to the computer. - -`kr' - String of input characters sent by typing the right-arrow key. - -`ku' - String of input characters sent by typing the up-arrow key. - -`kd' - String of input characters sent by typing the down-arrow key. - -`kh' - String of input characters sent by typing the "home-position" key. - -`K1' ... `K5' - Strings of input characters sent by the five other keys in a 3-by-3 - array that includes the arrow keys, if the keyboard has such a - 3-by-3 array. Note that one of these keys may be the - "home-position" key, in which case one of these capabilities will - have the same value as the `kh' key. - -`k0' - String of input characters sent by function key 10 (or 0, if the - terminal has one labeled 0). - -`k1' ... `k9' - Strings of input characters sent by function keys 1 through 9, - provided for those function keys that exist. - -`kn' - Number: the number of numbered function keys, if there are more - than 10. - -`l0' ... `l9' - Strings which are the labels appearing on the keyboard on the keys - described by the capabilities `k0' ... `l9'. These capabilities - should be left undefined if the labels are `f0' or `f10' and `f1' - ... `f9'. - -`kH' - String of input characters sent by the "home down" key, if there is - one. - -`kb' - String of input characters sent by the "backspace" key, if there is - one. - -`ka' - String of input characters sent by the "clear all tabs" key, if - there is one. - -`kt' - String of input characters sent by the "clear tab stop this column" - key, if there is one. - -`kC' - String of input characters sent by the "clear screen" key, if - there is one. - -`kD' - String of input characters sent by the "delete character" key, if - there is one. - -`kL' - String of input characters sent by the "delete line" key, if there - is one. - -`kM' - String of input characters sent by the "exit insert mode" key, if - there is one. - -`kE' - String of input characters sent by the "clear to end of line" key, - if there is one. - -`kS' - String of input characters sent by the "clear to end of screen" - key, if there is one. - -`kI' - String of input characters sent by the "insert character" or "enter - insert mode" key, if there is one. - -`kA' - String of input characters sent by the "insert line" key, if there - is one. - -`kN' - String of input characters sent by the "next page" key, if there is - one. - -`kP' - String of input characters sent by the "previous page" key, if - there is one. - -`kF' - String of input characters sent by the "scroll forward" key, if - there is one. - -`kR' - String of input characters sent by the "scroll reverse" key, if - there is one. - -`kT' - String of input characters sent by the "set tab stop in this - column" key, if there is one. - -`ko' - String listing the other function keys the terminal has. This is a - very obsolete way of describing the same information found in the - `kH' ... `kT' keys. The string contains a list of two-character - termcap capability names, separated by commas. The meaning is - that for each capability name listed, the terminal has a key which - sends the string which is the value of that capability. For - example, the value `:ko=cl,ll,sf,sr:' says that the terminal has - four function keys which mean "clear screen", "home down", "scroll - forward" and "scroll reverse". - - -File: termcap.info, Node: Meta Key, Next: Initialization, Prev: Keypad, Up: Capabilities - -Meta Key -======== - - A Meta key is a key on the keyboard that modifies each character you -type by controlling the 0200 bit. This bit is on if and only if the -Meta key is held down when the character is typed. Characters typed -using the Meta key are called Meta characters. Emacs uses Meta -characters as editing commands. - -`km' - Flag whose presence means that the terminal has a Meta key. - -`mm' - String of commands to enable the functioning of the Meta key. - -`mo' - String of commands to disable the functioning of the Meta key. - - If the terminal has `km' but does not have `mm' and `mo', it means -that the Meta key always functions. If it has `mm' and `mo', it means -that the Meta key can be turned on or off. Send the `mm' string to -turn it on, and the `mo' string to turn it off. I do not know why one -would ever not want it to be on. - - -File: termcap.info, Node: Initialization, Next: Pad Specs, Prev: Meta Key, Up: Capabilities - -Initialization -============== - -`ti' - String of commands to put the terminal into whatever special modes - are needed or appropriate for programs that move the cursor - nonsequentially around the screen. Programs that use termcap to do - full-screen display should output this string when they start up. - -`te' - String of commands to undo what is done by the `ti' string. - Programs that output the `ti' string on entry should output this - string when they exit. - -`is' - String of commands to initialize the terminal for each login - session. - -`if' - String which is the name of a file containing the string of - commands to initialize the terminal for each session of use. - Normally `is' and `if' are not both used. - -`i1' -`i3' - Two more strings of commands to initialize the terminal for each - login session. The `i1' string (if defined) is output before `is' - or `if', and the `i3' string (if defined) is output after. - - The reason for having three separate initialization strings is to - make it easier to define a group of related terminal types with - slightly different initializations. Define two or three of the - strings in the basic type; then the other types can override one - or two of the strings. - -`rs' - String of commands to reset the terminal from any strange mode it - may be in. Normally this includes the `is' string (or other - commands with the same effects) and more. What would go in the - `rs' string but not in the `is' string are annoying or slow - commands to bring the terminal back from strange modes that nobody - would normally use. - -`it' - Numeric value, the initial spacing between hardware tab stop - columns when the terminal is powered up. Programs to initialize - the terminal can use this to decide whether there is a need to set - the tab stops. If the initial width is 8, well and good; if it is - not 8, then the tab stops should be set; if they cannot be set, - the kernel is told to convert tabs to spaces, and other programs - will observe this and do likewise. - -`ct' - String of commands to clear all tab stops. - -`st' - String of commands to set tab stop at current cursor column on all - lines. - -`NF' - Flag whose presence means that the terminal does not support - XON/XOFF flow control. Programs should not send XON (`C-q') or - XOFF (`C-s') characters to the terminal. - - -File: termcap.info, Node: Pad Specs, Next: Status Line, Prev: Initialization, Up: Capabilities - -Padding Capabilities -==================== - - There are two terminal capabilities that exist just to explain the -proper way to obey the padding specifications in all the command string -capabilities. One, `pc', must be obeyed by all termcap-using programs. - -`pb' - Numeric value, the lowest baud rate at which padding is actually - needed. Programs may check this and refrain from doing any - padding at lower speeds. - -`pc' - String of commands for padding. The first character of this - string is to be used as the pad character, instead of using null - characters for padding. If `pc' is not provided, use null - characters. Every program that uses termcap must look up this - capability and use it to set the variable `PC' that is used by - `tputs'. *Note Padding::. - - Some termcap capabilities exist just to specify the amount of -padding that the kernel should give to cursor motion commands used in -ordinary sequential output. - -`dC' - Numeric value, the number of msec of padding needed for the - carriage-return character. - -`dN' - Numeric value, the number of msec of padding needed for the newline - (linefeed) character. - -`dB' - Numeric value, the number of msec of padding needed for the - backspace character. - -`dF' - Numeric value, the number of msec of padding needed for the - formfeed character. - -`dT' - Numeric value, the number of msec of padding needed for the tab - character. - - In some systems, the kernel uses the above capabilities; in other -systems, the kernel uses the paddings specified in the string -capabilities `cr', `sf', `le', `ff' and `ta'. Descriptions of -terminals which require such padding should contain the `dC' ... `dT' -capabilities and also specify the appropriate padding in the -corresponding string capabilities. Since no modern terminals require -padding for ordinary sequential output, you probably won't need to do -either of these things. - - -File: termcap.info, Node: Status Line, Next: Half-Line, Prev: Pad Specs, Up: Capabilities - -Status Line -=========== - - A "status line" is a line on the terminal that is not used for -ordinary display output but instead used for a special message. The -intended use is for a continuously updated description of what the -user's program is doing, and that is where the name "status line" comes -from, but in fact it could be used for anything. The distinguishing -characteristic of a status line is that ordinary output to the terminal -does not affect it; it changes only if the special status line commands -of this section are used. - -`hs' - Flag whose presence means that the terminal has a status line. If - a terminal description specifies that there is a status line, it - must provide the `ts' and `fs' capabilities. - -`ts' - String of commands to move the terminal cursor into the status - line. Usually these commands must specifically record the old - cursor position for the sake of the `fs' string. - -`fs' - String of commands to move the cursor back from the status line to - its previous position (outside the status line). - -`es' - Flag whose presence means that other display commands work while - writing the status line. In other words, one can clear parts of - it, insert or delete characters, move the cursor within it using - `ch' if there is a `ch' capability, enter and leave standout mode, - and so on. - -`ds' - String of commands to disable the display of the status line. This - may be absent, if there is no way to disable the status line - display. - -`ws' - Numeric value, the width of the status line. If this capability is - absent in a terminal that has a status line, it means the status - line is the same width as the other lines. - - Note that the value of `ws' is sometimes as small as 8. - - -File: termcap.info, Node: Half-Line, Next: Printer, Prev: Status Line, Up: Capabilities - -Half-Line Motion -================ - - Some terminals have commands for moving the cursor vertically by -half-lines, useful for outputting subscripts and superscripts. Mostly -it is hardcopy terminals that have such features. - -`hu' - String of commands to move the cursor up half a line. If the - terminal is a display, it is your responsibility to avoid moving - up past the top line; however, most likely the terminal that - supports this is a hardcopy terminal and there is nothing to be - concerned about. - -`hd' - String of commands to move the cursor down half a line. If the - terminal is a display, it is your responsibility to avoid moving - down past the bottom line, etc. - - -File: termcap.info, Node: Printer, Prev: Half-Line, Up: Capabilities - -Controlling Printers Attached to Terminals -========================================== - - Some terminals have attached hardcopy printer ports. They may be -able to copy the screen contents to the printer; they may also be able -to redirect output to the printer. Termcap does not have anything to -tell the program whether the redirected output appears also on the -screen; it does on some terminals but not all. - -`ps' - String of commands to cause the contents of the screen to be - printed. If it is absent, the screen contents cannot be printed. - -`po' - String of commands to redirect further output to the printer. - -`pf' - String of commands to terminate redirection of output to the - printer. This capability must be present in the description if - `po' is. - -`pO' - String of commands to redirect output to the printer for next N - characters of output, regardless of what they are. Redirection - will end automatically after N characters of further output. Until - then, nothing that is output can end redirection, not even the - `pf' string if there is one. The number N should not be more than - 255. - - One use of this capability is to send non-text byte sequences - (such as bit-maps) to the printer. - - Most terminals with printers do not support all of `ps', `po' and -`pO'; any one or two of them may be supported. To make a program that -can send output to all kinds of printers, it is necessary to check for -all three of these capabilities, choose the most convenient of the ones -that are provided, and use it in its own appropriate fashion. - - -File: termcap.info, Node: Summary, Next: Var Index, Prev: Capabilities, Up: Top - -Summary of Capability Names -*************************** - - Here are all the terminal capability names in alphabetical order -with a brief description of each. For cross references to their -definitions, see the index of capability names (*note Cap Index::.). - -`ae' - String to turn off alternate character set mode. - -`al' - String to insert a blank line before the cursor. - -`AL' - String to insert N blank lines before the cursor. - -`am' - Flag: output to last column wraps cursor to next line. - -`as' - String to turn on alternate character set mode.like. - -`bc' - Very obsolete alternative name for the `le' capability. - -`bl' - String to sound the bell. - -`bs' - Obsolete flag: ASCII backspace may be used for leftward motion. - -`bt' - String to move the cursor left to the previous hardware tab stop - column. - -`bw' - Flag: `le' at left margin wraps to end of previous line. - -`CC' - String to change terminal's command character. - -`cd' - String to clear the line the cursor is on, and following lines. - -`ce' - String to clear from the cursor to the end of the line. - -`ch' - String to position the cursor at column C in the same line. - -`cl' - String to clear the entire screen and put cursor at upper left - corner. - -`cm' - String to position the cursor at line L, column C. - -`CM' - String to position the cursor at line L, column C, relative to - display memory. - -`co' - Number: width of the screen. - -`cr' - String to move cursor sideways to left margin. - -`cs' - String to set the scroll region. - -`cS' - Alternate form of string to set the scroll region. - -`ct' - String to clear all tab stops. - -`cv' - String to position the cursor at line L in the same column. - -`da' - Flag: data scrolled off top of screen may be scrolled back. - -`db' - Flag: data scrolled off bottom of screen may be scrolled back. - -`dB' - Obsolete number: msec of padding needed for the backspace - character. - -`dc' - String to delete one character position at the cursor. - -`dC' - Obsolete number: msec of padding needed for the carriage-return - character. - -`DC' - String to delete N characters starting at the cursor. - -`dF' - Obsolete number: msec of padding needed for the formfeed character. - -`dl' - String to delete the line the cursor is on. - -`DL' - String to delete N lines starting with the cursor's line. - -`dm' - String to enter delete mode. - -`dN' - Obsolete number: msec of padding needed for the newline character. - -`do' - String to move the cursor vertically down one line. - -`DO' - String to move cursor vertically down N lines. - -`ds' - String to disable the display of the status line. - -`dT' - Obsolete number: msec of padding needed for the tab character. - -`ec' - String of commands to clear N characters at cursor. - -`ed' - String to exit delete mode. - -`ei' - String to leave insert mode. - -`eo' - Flag: output of a space can erase an overstrike. - -`es' - Flag: other display commands work while writing the status line. - -`ff' - String to advance to the next page, for a hardcopy terminal. - -`fs' - String to move the cursor back from the status line to its - previous position (outside the status line). - -`gn' - Flag: this terminal type is generic, not real. - -`hc' - Flag: hardcopy terminal. - -`hd' - String to move the cursor down half a line. - -`ho' - String to position cursor at upper left corner. - -`hs' - Flag: the terminal has a status line. - -`hu' - String to move the cursor up half a line. - -`hz' - Flag: terminal cannot accept `~' as output. - -`i1' - String to initialize the terminal for each login session. - -`i3' - String to initialize the terminal for each login session. - -`ic' - String to insert one character position at the cursor. - -`IC' - String to insert N character positions at the cursor. - -`if' - String naming a file of commands to initialize the terminal. - -`im' - String to enter insert mode. - -`in' - Flag: outputting a space is different from moving over empty - positions. - -`ip' - String to output following an inserted character in insert mode. - -`is' - String to initialize the terminal for each login session. - -`it' - Number: initial spacing between hardware tab stop columns. - -`k0' - String of input sent by function key 0 or 10. - -`k1 ... k9' - Strings of input sent by function keys 1 through 9. - -`K1 ... K5' - Strings sent by the five other keys in 3-by-3 array with arrows. - -`ka' - String of input sent by the "clear all tabs" key. - -`kA' - String of input sent by the "insert line" key. - -`kb' - String of input sent by the "backspace" key. - -`kC' - String of input sent by the "clear screen" key. - -`kd' - String of input sent by typing the down-arrow key. - -`kD' - String of input sent by the "delete character" key. - -`ke' - String to make the function keys work locally. - -`kE' - String of input sent by the "clear to end of line" key. - -`kF' - String of input sent by the "scroll forward" key. - -`kh' - String of input sent by typing the "home-position" key. - -`kH' - String of input sent by the "home down" key. - -`kI' - String of input sent by the "insert character" or "enter insert - mode" key. - -`kl' - String of input sent by typing the left-arrow key. - -`kL' - String of input sent by the "delete line" key. - -`km' - Flag: the terminal has a Meta key. - -`kM' - String of input sent by the "exit insert mode" key. - -`kn' - Numeric value, the number of numbered function keys. - -`kN' - String of input sent by the "next page" key. - -`ko' - Very obsolete string listing the terminal's named function keys. - -`kP' - String of input sent by the "previous page" key. - -`kr' - String of input sent by typing the right-arrow key. - -`kR' - String of input sent by the "scroll reverse" key. - -`ks' - String to make the function keys transmit. - -`kS' - String of input sent by the "clear to end of screen" key. - -`kt' - String of input sent by the "clear tab stop this column" key. - -`kT' - String of input sent by the "set tab stop in this column" key. - -`ku' - String of input sent by typing the up-arrow key. - -`l0' - String on keyboard labelling function key 0 or 10. - -`l1 ... l9' - Strings on keyboard labelling function keys 1 through 9. - -`le' - String to move the cursor left one column. - -`LE' - String to move cursor left N columns. - -`li' - Number: height of the screen. - -`ll' - String to position cursor at lower left corner. - -`lm' - Number: lines of display memory. - -`LP' - Flag: writing to last column of last line will not scroll. - -`mb' - String to enter blinking mode. - -`md' - String to enter double-bright mode. - -`me' - String to turn off all appearance modes - -`mh' - String to enter half-bright mode. - -`mi' - Flag: cursor motion in insert mode is safe. - -`mk' - String to enter invisible mode. - -`mm' - String to enable the functioning of the Meta key. - -`mo' - String to disable the functioning of the Meta key. - -`mp' - String to enter protected mode. - -`mr' - String to enter reverse-video mode. - -`ms' - Flag: cursor motion in standout mode is safe. - -`nc' - Obsolete flag: do not use ASCII carriage-return on this terminal. - -`nd' - String to move the cursor right one column. - -`NF' - Flag: do not use XON/XOFF flow control. - -`nl' - Obsolete alternative name for the `do' and `sf' capabilities. - -`ns' - Flag: the terminal does not normally scroll for sequential output. - -`nw' - String to move to start of next line, possibly clearing rest of - old line. - -`os' - Flag: terminal can overstrike. - -`pb' - Number: the lowest baud rate at which padding is actually needed. - -`pc' - String containing character for padding. - -`pf' - String to terminate redirection of output to the printer. - -`po' - String to redirect further output to the printer. - -`pO' - String to redirect N characters ofoutput to the printer. - -`ps' - String to print the screen on the attached printer. - -`rc' - String to move to last saved cursor position. - -`RI' - String to move cursor right N columns. - -`rp' - String to output character C repeated N times. - -`rs' - String to reset the terminal from any strange modes. - -`sa' - String to turn on an arbitrary combination of appearance modes. - -`sc' - String to save the current cursor position. - -`se' - String to leave standout mode. - -`sf' - String to scroll the screen one line up. - -`SF' - String to scroll the screen N lines up. - -`sg' - Number: width of magic standout cookie. Absent if magic cookies - are not used. - -`so' - String to enter standout mode. - -`sr' - String to scroll the screen one line down. - -`SR' - String to scroll the screen N line down. - -`st' - String to set tab stop at current cursor column on all lines. - programs. - -`ta' - String to move the cursor right to the next hardware tab stop - column. - -`te' - String to return terminal to settings for sequential output. - -`ti' - String to initialize terminal for random cursor motion. - -`ts' - String to move the terminal cursor into the status line. - -`uc' - String to underline one character and move cursor right. - -`ue' - String to turn off underline mode - -`ug' - Number: width of underlining magic cookie. Absent if underlining - doesn't use magic cookies. - -`ul' - Flag: underline by overstriking with an underscore. - -`up' - String to move the cursor vertically up one line. - -`UP' - String to move cursor vertically up N lines. - -`us' - String to turn on underline mode - -`vb' - String to make the screen flash. - -`ve' - String to return the cursor to normal. - -`vi' - String to make the cursor invisible. - -`vs' - String to enhance the cursor. - -`wi' - String to set the terminal output screen window. - -`ws' - Number: the width of the status line. - -`xb' - Flag: superbee terminal. - -`xn' - Flag: cursor wraps in a strange way. - -`xs' - Flag: clearing a line is the only way to clear the appearance - modes of positions in that line (or, only way to remove magic - cookies on that line). - -`xt' - Flag: Teleray 1061; several strange characteristics. - - -File: termcap.info, Node: Var Index, Next: Cap Index, Prev: Summary, Up: Top - -Variable and Function Index -*************************** - -* Menu: - -* BC: tgoto. -* ospeed: Output Padding. -* PC: Output Padding. -* tgetent: Find. -* tgetflag: Interrogate. -* tgetnum: Interrogate. -* tgetstr: Interrogate. -* tgoto: tgoto. -* tparam: tparam. -* tputs: Output Padding. -* UP: tgoto. - diff --git a/lib/termcap/grot/termcap.info-4 b/lib/termcap/grot/termcap.info-4 deleted file mode 100644 index 4b8bf79..0000000 --- a/lib/termcap/grot/termcap.info-4 +++ /dev/null @@ -1,220 +0,0 @@ -This is Info file ./termcap.info, produced by Makeinfo-1.55 from the -input file ./termcap.texi. - - This file documents the termcap library of the GNU system. - - Copyright (C) 1988 Free Software Foundation, Inc. - - Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be stated in a -translation approved by the Foundation. - - -File: termcap.info, Node: Cap Index, Next: Index, Prev: Var Index, Up: Top - -Capability Index -**************** - -* Menu: - -* ae: Standout. -* al: Insdel Line. -* AL: Insdel Line. -* am: Wrapping. -* as: Standout. -* bc: Cursor Motion. -* bl: Bell. -* bs: Cursor Motion. -* bt: Cursor Motion. -* bw: Cursor Motion. -* CC: Basic. -* cd: Clearing. -* ce: Clearing. -* ch: Cursor Motion. -* cl: Clearing. -* cm: Cursor Motion. -* CM: Cursor Motion. -* co: Screen Size. -* cr: Cursor Motion. -* cS: Scrolling. -* cs: Scrolling. -* ct: Initialization. -* cv: Cursor Motion. -* da: Scrolling. -* dB: Pad Specs. -* db: Scrolling. -* dC: Pad Specs. -* DC: Insdel Char. -* dc: Insdel Char. -* dF: Pad Specs. -* dl: Insdel Line. -* DL: Insdel Line. -* dm: Insdel Char. -* dN: Pad Specs. -* do: Cursor Motion. -* DO: Cursor Motion. -* ds: Status Line. -* dT: Pad Specs. -* ec: Clearing. -* ed: Insdel Char. -* ei: Insdel Char. -* eo: Basic. -* es: Status Line. -* ff: Cursor Motion. -* fs: Status Line. -* gn: Basic. -* hc: Basic. -* hd: Half-Line. -* ho: Cursor Motion. -* hs: Status Line. -* hu: Half-Line. -* hz: Basic. -* i1: Initialization. -* i3: Initialization. -* IC: Insdel Char. -* ic: Insdel Char. -* if: Initialization. -* im: Insdel Char. -* in: Insdel Char. -* ip: Insdel Char. -* is: Initialization. -* it: Initialization. -* K1...K5: Keypad. -* k1...k9: Keypad. -* kA...kT: Keypad. -* ka...ku: Keypad. -* km: Meta Key. -* l0...l9: Keypad. -* le: Cursor Motion. -* LE: Cursor Motion. -* li: Screen Size. -* ll: Cursor Motion. -* lm: Scrolling. -* LP: Wrapping. -* mb: Standout. -* md: Standout. -* me: Standout. -* mh: Standout. -* mi: Insdel Char. -* mk: Standout. -* mm: Meta Key. -* mo: Meta Key. -* mp: Standout. -* mr: Standout. -* ms: Standout. -* ms: Underlining. -* nc: Cursor Motion. -* nd: Cursor Motion. -* NF: Initialization. -* nl: Cursor Motion. -* ns: Scrolling. -* nw: Cursor Motion. -* os: Basic. -* pb: Pad Specs. -* pc: Pad Specs. -* pf: Printer. -* pO: Printer. -* po: Printer. -* ps: Printer. -* rc: Cursor Motion. -* RI: Cursor Motion. -* rp: Basic. -* rs: Initialization. -* sa: Standout. -* sc: Cursor Motion. -* se: Standout. -* SF: Scrolling. -* sf: Scrolling. -* sg: Standout. -* so: Standout. -* SR: Scrolling. -* sr: Scrolling. -* st: Initialization. -* ta: Cursor Motion. -* te: Initialization. -* ti: Initialization. -* ts: Status Line. -* uc: Underlining. -* ue: Underlining. -* ug: Underlining. -* ul: Underlining. -* up: Cursor Motion. -* UP: Cursor Motion. -* us: Underlining. -* vb: Bell. -* ve: Cursor Visibility. -* vi: Cursor Visibility. -* vs: Cursor Visibility. -* wi: Windows. -* ws: Status Line. -* xb: Basic. -* xn: Wrapping. -* xs: Standout. -* xt: Cursor Motion. -* xt: Standout. - - -File: termcap.info, Node: Index, Prev: Cap Index, Up: Top - -Concept Index -************* - -* Menu: - -* %: Encode Parameters. -* appearance modes: Standout. -* bell: Bell. -* clearing the screen: Clearing. -* command character: Basic. -* cursor motion: Cursor Motion. -* delete character: Insdel Char. -* delete line: Insdel Line. -* delete mode: Insdel Char. -* description format: Format. -* erasing: Clearing. -* generic terminal type: Basic. -* home position: Cursor Motion. -* inheritance: Inheriting. -* initialization: Initialization. -* insert character: Insdel Char. -* insert line: Insdel Line. -* insert mode: Insdel Char. -* line speed: Output Padding. -* magic cookie: Standout. -* meta key: Meta Key. -* names of terminal types: Naming. -* overstrike: Basic. -* padding: Pad Specs. -* padding: Padding. -* parameters: Parameters. -* printer: Printer. -* repeat output: Basic. -* reset: Initialization. -* screen size: Screen Size. -* screen size: Naming. -* screen size: Screen Size. -* scrolling: Scrolling. -* standout: Standout. -* status line: Status Line. -* Superbee: Basic. -* tab stops: Initialization. -* termcap: Introduction. -* terminal flags (kernel): Initialize. -* underlining: Underlining. -* visibility: Cursor Visibility. -* visible bell: Bell. -* window: Windows. -* wrapping: Wrapping. -* wrapping: Naming. - - diff --git a/lib/termcap/grot/termcap.texi b/lib/termcap/grot/termcap.texi deleted file mode 100644 index eab49e8..0000000 --- a/lib/termcap/grot/termcap.texi +++ /dev/null @@ -1,3617 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@setfilename termcap.info -@settitle The Termcap Library -@smallbook - -@ifinfo -This file documents the termcap library of the GNU system. - -Copyright (C) 1988 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation approved -by the Foundation. -@end ifinfo - -@setchapternewpage odd - -@c @shorttitlepage The Termcap Manual - -@titlepage -@ignore -@sp 6 -@center @titlefont{Termcap} -@sp 1 -@center The Termcap Library and Data Base -@sp 4 -@center Second Edition -@sp 1 -@center December 1992 -@sp 5 -@center Richard M. Stallman -@sp 1 -@center Free Software Foundation -@end ignore - -@c Real title page -@title The Termcap Manual -@subtitle The Termcap Library and Data Base -@subtitle Second Edition -@subtitle December 1992 -@author Richard M. Stallman -@page -@vskip 0pt plus 1filll -Copyright @copyright{} 1988 Free Software Foundation, Inc. - -Published by the Free Software Foundation -(59 Temple Place, Suite 330, Boston, MA 02111 USA). -Printed copies are available for $10 each. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation approved -by the Foundation. -@sp 2 -Cover art by Etienne Suvasa. -@end titlepage -@page - -@synindex vr fn - -@node Top, Introduction, (dir), (dir) - -@menu -* Introduction:: What is termcap? Why this manual? -* Library:: The termcap library functions. -* Data Base:: What terminal descriptions in @file{/etc/termcap} look like. -* Capabilities:: Definitions of the individual terminal capabilities: - how to write them in descriptions, and how to use - their values to do display updating. -* Summary:: Brief table of capability names and their meanings. -* Var Index:: Index of C functions and variables. -* Cap Index:: Index of termcap capabilities. -* Index:: Concept index. - - --- The Detailed Node Listing --- - -The Termcap Library - -* Preparation:: Preparing to use the termcap library. -* Find:: Finding the description of the terminal being used. -* Interrogate:: Interrogating the description for particular capabilities. -* Initialize:: Initialization for output using termcap. -* Padding:: Outputting padding. -* Parameters:: Encoding parameters such as cursor positions. - -Padding - -* Why Pad:: Explanation of padding. -* Not Enough:: When there is not enough padding. -* Describe Padding:: The data base says how much padding a terminal needs. -* Output Padding:: Using @code{tputs} to output the needed padding. - -Filling In Parameters - -* Encode Parameters:: The language for encoding parameters. -* Using Parameters:: Outputting a string command with parameters. - -Sending Display Commands with Parameters - -* tparam:: The general case, for GNU termcap only. -* tgoto:: The special case of cursor motion. - -The Format of the Data Base - -* Format:: Overall format of a terminal description. -* Capability Format:: Format of capabilities within a description. -* Naming:: Naming conventions for terminal types. -* Inheriting:: Inheriting part of a description from -a related terminal type. -* Changing:: When changes in the data base take effect. - -Definitions of the Terminal Capabilities - -* Basic:: Basic characteristics. -* Screen Size:: Screen size, and what happens when it changes. -* Cursor Motion:: Various ways to move the cursor. -* Wrapping:: What happens if you write a character in the last column. -* Scrolling:: Pushing text up and down on the screen. -* Windows:: Limiting the part of the window that output affects. -* Clearing:: Erasing one or many lines. -* Insdel Line:: Making new blank lines in mid-screen; deleting lines. -* Insdel Char:: Inserting and deleting characters within a line. -* Standout:: Highlighting some of the text. -* Underlining:: Underlining some of the text. -* Cursor Visibility:: Making the cursor more or less easy to spot. -* Bell:: Attracts user's attention; not localized on the screen. -* Keypad:: Recognizing when function keys or arrows are typed. -* Meta Key:: @key{META} acts like an extra shift key. -* Initialization:: Commands used to initialize or reset the terminal. -* Pad Specs:: Info for the kernel on how much padding is needed. -* Status Line:: A status line displays ``background'' information. -* Half-Line:: Moving by half-lines, for superscripts and subscripts. -* Printer:: Controlling auxiliary printers of display terminals. -@end menu - -@node Introduction, Library, Top, Top -@unnumbered Introduction - -@cindex termcap -@dfn{Termcap} is a library and data base that enables programs to use -display terminals in a terminal-independent manner. It originated in -Berkeley Unix. - -The termcap data base describes the capabilities of hundreds of different -display terminals in great detail. Some examples of the information -recorded for a terminal could include how many columns wide it is, what -string to send to move the cursor to an arbitrary position (including how -to encode the row and column numbers), how to scroll the screen up one or -several lines, and how much padding is needed for such a scrolling -operation. - -The termcap library is provided for easy access this data base in programs -that want to do terminal-independent character-based display output. - -This manual describes the GNU version of the termcap library, which has -some extensions over the Unix version. All the extensions are identified -as such, so this manual also tells you how to use the Unix termcap. - -The GNU version of the termcap library is available free as source code, -for use in free programs, and runs on Unix and VMS systems (at least). You -can find it in the GNU Emacs distribution in the files @file{termcap.c} and -@file{tparam.c}. - -This manual was written for the GNU project, whose goal is to develop a -complete free operating system upward-compatible with Unix for user -programs. The project is approximately two thirds complete. For more -information on the GNU project, including the GNU Emacs editor and the -mostly-portable optimizing C compiler, send one dollar to - -@display -Free Software Foundation -675 Mass Ave -Cambridge, MA 02139 -@end display - -@node Library, Data Base, Introduction, Top -@chapter The Termcap Library - -The termcap library is the application programmer's interface to the -termcap data base. It contains functions for the following purposes: - -@itemize @bullet -@item -Finding the description of the user's terminal type (@code{tgetent}). - -@item -Interrogating the description for information on various topics -(@code{tgetnum}, @code{tgetflag}, @code{tgetstr}). - -@item -Computing and performing padding (@code{tputs}). - -@item -Encoding numeric parameters such as cursor positions into the -terminal-specific form required for display commands (@code{tparam}, -@code{tgoto}). -@end itemize - -@menu -* Preparation:: Preparing to use the termcap library. -* Find:: Finding the description of the terminal being used. -* Interrogate:: Interrogating the description for particular capabilities. -* Initialize:: Initialization for output using termcap. -* Padding:: Outputting padding. -* Parameters:: Encoding parameters such as cursor positions. -@end menu - -@node Preparation, Find, , Library -@section Preparing to Use the Termcap Library - -To use the termcap library in a program, you need two kinds of preparation: - -@itemize @bullet -@item -The compiler needs declarations of the functions and variables in the -library. - -On GNU systems, it suffices to include the header file -@file{termcap.h} in each source file that uses these functions and -variables.@refill - -On Unix systems, there is often no such header file. Then you must -explictly declare the variables as external. You can do likewise for -the functions, or let them be implicitly declared and cast their -values from type @code{int} to the appropriate type. - -We illustrate the declarations of the individual termcap library -functions with ANSI C prototypes because they show how to pass the -arguments. If you are not using the GNU C compiler, you probably -cannot use function prototypes, so omit the argument types and names -from your declarations. - -@item -The linker needs to search the library. Usually either -@samp{-ltermcap} or @samp{-ltermlib} as an argument when linking will -do this.@refill -@end itemize - -@node Find, Interrogate, Preparation, Library -@section Finding a Terminal Description: @code{tgetent} - -@findex tgetent -An application program that is going to use termcap must first look up the -description of the terminal type in use. This is done by calling -@code{tgetent}, whose declaration in ANSI Standard C looks like: - -@example -int tgetent (char *@var{buffer}, char *@var{termtype}); -@end example - -@noindent -This function finds the description and remembers it internally so that -you can interrogate it about specific terminal capabilities -(@pxref{Interrogate}). - -The argument @var{termtype} is a string which is the name for the type of -terminal to look up. Usually you would obtain this from the environment -variable @code{TERM} using @code{getenv ("TERM")}. - -If you are using the GNU version of termcap, you can alternatively ask -@code{tgetent} to allocate enough space. Pass a null pointer for -@var{buffer}, and @code{tgetent} itself allocates the storage using -@code{malloc}. There is no way to get the address that was allocated, -and you shouldn't try to free the storage.@refill - -With the Unix version of termcap, you must allocate space for the -description yourself and pass the address of the space as the argument -@var{buffer}. There is no way you can tell how much space is needed, so -the convention is to allocate a buffer 2048 characters long and assume that -is enough. (Formerly the convention was to allocate 1024 characters and -assume that was enough. But one day, for one kind of terminal, that was -not enough.) - -No matter how the space to store the description has been obtained, -termcap records its address internally for use when you later interrogate -the description with @code{tgetnum}, @code{tgetstr} or @code{tgetflag}. If -the buffer was allocated by termcap, it will be freed by termcap too if you -call @code{tgetent} again. If the buffer was provided by you, you must -make sure that its contents remain unchanged for as long as you still plan -to interrogate the description.@refill - -The return value of @code{tgetent} is @minus{}1 if there is some difficulty -accessing the data base of terminal types, 0 if the data base is accessible -but the specified type is not defined in it, and some other value -otherwise. - -Here is how you might use the function @code{tgetent}: - -@smallexample -#ifdef unix -static char term_buffer[2048]; -#else -#define term_buffer 0 -#endif - -init_terminal_data () -@{ - char *termtype = getenv ("TERM"); - int success; - - if (termtype == 0) - fatal ("Specify a terminal type with `setenv TERM <yourtype>'.\n"); - - success = tgetent (term_buffer, termtype); - if (success < 0) - fatal ("Could not access the termcap data base.\n"); - if (success == 0) - fatal ("Terminal type `%s' is not defined.\n", termtype); -@} -@end smallexample - -@noindent -Here we assume the function @code{fatal} prints an error message and exits. - -If the environment variable @code{TERMCAP} is defined, its value is used to -override the terminal type data base. The function @code{tgetent} checks -the value of @code{TERMCAP} automatically. If the value starts with -@samp{/} then it is taken as a file name to use as the data base file, -instead of @file{/etc/termcap} which is the standard data base. If the -value does not start with @samp{/} then it is itself used as the terminal -description, provided that the terminal type @var{termtype} is among the -types it claims to apply to. @xref{Data Base}, for information on the -format of a terminal description.@refill - -@node Interrogate, Initialize, Find, Library -@section Interrogating the Terminal Description - -Each piece of information recorded in a terminal description is called a -@dfn{capability}. Each defined terminal capability has a two-letter code -name and a specific meaning. For example, the number of columns is named -@samp{co}. @xref{Capabilities}, for definitions of all the standard -capability names. - -Once you have found the proper terminal description with @code{tgetent} -(@pxref{Find}), your application program must @dfn{interrogate} it for -various terminal capabilities. You must specify the two-letter code of -the capability whose value you seek. - -Capability values can be numeric, boolean (capability is either present or -absent) or strings. Any particular capability always has the same value -type; for example, @samp{co} always has a numeric value, while @samp{am} -(automatic wrap at margin) is always a flag, and @samp{cm} (cursor motion -command) always has a string value. The documentation of each capability -says which type of value it has.@refill - -There are three functions to use to get the value of a capability, -depending on the type of value the capability has. Here are their -declarations in ANSI C: - -@findex tgetnum -@findex tgetflag -@findex tgetstr -@example -int tgetnum (char *@var{name}); -int tgetflag (char *@var{name}); -char *tgetstr (char *@var{name}, char **@var{area}); -@end example - -@table @code -@item tgetnum -Use @code{tgetnum} to get a capability value that is numeric. The -argument @var{name} is the two-letter code name of the capability. If -the capability is present, @code{tgetnum} returns the numeric value -(which is nonnegative). If the capability is not mentioned in the -terminal description, @code{tgetnum} returns @minus{}1. - -@item tgetflag -Use @code{tgetflag} to get a boolean value. If the capability -@var{name} is present in the terminal description, @code{tgetflag} -returns 1; otherwise, it returns 0. - -@item tgetstr -Use @code{tgetstr} to get a string value. It returns a pointer to a -string which is the capability value, or a null pointer if the -capability is not present in the terminal description. - -There are two ways @code{tgetstr} can find space to store the string value: - -@itemize @bullet -@item -You can ask @code{tgetstr} to allocate the space. Pass a null -pointer for the argument @var{area}, and @code{tgetstr} will use -@code{malloc} to allocate storage big enough for the value. -Termcap will never free this storage or refer to it again; you -should free it when you are finished with it. - -This method is more robust, since there is no need to guess how -much space is needed. But it is supported only by the GNU -termcap library. - -@item -You can provide the space. Provide for the argument @var{area} the -address of a pointer variable of type @code{char *}. Before calling -@code{tgetstr}, initialize the variable to point at available space. -Then @code{tgetstr} will store the string value in that space and will -increment the pointer variable to point after the space that has been -used. You can use the same pointer variable for many calls to -@code{tgetstr}. - -There is no way to determine how much space is needed for a single -string, and no way for you to prevent or handle overflow of the area -you have provided. However, you can be sure that the total size of -all the string values you will obtain from the terminal description is -no greater than the size of the description (unless you get the same -capability twice). You can determine that size with @code{strlen} on -the buffer you provided to @code{tgetent}. See below for an example. - -Providing the space yourself is the only method supported by the Unix -version of termcap. -@end itemize -@end table - -Note that you do not have to specify a terminal type or terminal -description for the interrogation functions. They automatically use the -description found by the most recent call to @code{tgetent}. - -Here is an example of interrogating a terminal description for various -capabilities, with conditionals to select between the Unix and GNU methods -of providing buffer space. - -@example -char *tgetstr (); - -char *cl_string, *cm_string; -int height; -int width; -int auto_wrap; - -char PC; /* For tputs. */ -char *BC; /* For tgoto. */ -char *UP; - -interrogate_terminal () -@{ -#ifdef UNIX - /* Here we assume that an explicit term_buffer - was provided to tgetent. */ - char *buffer - = (char *) malloc (strlen (term_buffer)); -#define BUFFADDR &buffer -#else -#define BUFFADDR 0 -#endif - - char *temp; - - /* Extract information we will use. */ - cl_string = tgetstr ("cl", BUFFADDR); - cm_string = tgetstr ("cm", BUFFADDR); - auto_wrap = tgetflag ("am"); - height = tgetnum ("li"); - width = tgetnum ("co"); - - /* Extract information that termcap functions use. */ - temp = tgetstr ("pc", BUFFADDR); - PC = temp ? *temp : 0; - BC = tgetstr ("le", BUFFADDR); - UP = tgetstr ("up", BUFFADDR); -@} -@end example - -@noindent -@xref{Padding}, for information on the variable @code{PC}. @xref{Using -Parameters}, for information on @code{UP} and @code{BC}. - -@node Initialize, Padding, Interrogate, Library -@section Initialization for Use of Termcap -@cindex terminal flags (kernel) - -Before starting to output commands to a terminal using termcap, -an application program should do two things: - -@itemize @bullet -@item -Initialize various global variables which termcap library output -functions refer to. These include @code{PC} and @code{ospeed} for -padding (@pxref{Output Padding}) and @code{UP} and @code{BC} for -cursor motion (@pxref{tgoto}).@refill - -@item -Tell the kernel to turn off alteration and padding of horizontal-tab -characters sent to the terminal. -@end itemize - -To turn off output processing in Berkeley Unix you would use @code{ioctl} -with code @code{TIOCLSET} to set the bit named @code{LLITOUT}, and clear -the bits @code{ANYDELAY} using @code{TIOCSETN}. In POSIX or System V, you -must clear the bit named @code{OPOST}. Refer to the system documentation -for details.@refill - -If you do not set the terminal flags properly, some older terminals will -not work. This is because their commands may contain the characters that -normally signify newline, carriage return and horizontal tab---characters -which the kernel thinks it ought to modify before output. - -When you change the kernel's terminal flags, you must arrange to restore -them to their normal state when your program exits. This implies that the -program must catch fatal signals such as @code{SIGQUIT} and @code{SIGINT} -and restore the old terminal flags before actually terminating. - -Modern terminals' commands do not use these special characters, so if you -do not care about problems with old terminals, you can leave the kernel's -terminal flags unaltered. - -@node Padding, Parameters, Initialize, Library -@section Padding -@cindex padding - -@dfn{Padding} means outputting null characters following a terminal display -command that takes a long time to execute. The terminal description says -which commands require padding and how much; the function @code{tputs}, -described below, outputs a terminal command while extracting from it the -padding information, and then outputs the padding that is necessary. - -@menu -* Why Pad:: Explanation of padding. -* Not Enough:: When there is not enough padding. -* Describe Padding:: The data base says how much padding a terminal needs. -* Output Padding:: Using @code{tputs} to output the needed padding. -@end menu - -@node Why Pad, Not Enough, , Padding -@subsection Why Pad, and How - -Most types of terminal have commands that take longer to execute than they -do to send over a high-speed line. For example, clearing the screen may -take 20msec once the entire command is received. During that time, on a -9600 bps line, the terminal could receive about 20 additional output -characters while still busy clearing the screen. Every terminal has a -certain amount of buffering capacity to remember output characters that -cannot be processed yet, but too many slow commands in a row can cause the -buffer to fill up. Then any additional output that cannot be processed -immediately will be lost. - -To avoid this problem, we normally follow each display command with enough -useless charaters (usually null characters) to fill up the time that the -display command needs to execute. This does the job if the terminal throws -away null characters without using up space in the buffer (which most -terminals do). If enough padding is used, no output can ever be lost. The -right amount of padding avoids loss of output without slowing down -operation, since the time used to transmit padding is time that nothing -else could be done. - -The number of padding characters needed for an operation depends on the -line speed. In fact, it is proportional to the line speed. A 9600 baud -line transmits about one character per msec, so the clear screen command in -the example above would need about 20 characters of padding. At 1200 baud, -however, only about 3 characters of padding are needed to fill up 20msec. - -@node Not Enough, Describe Padding, Why Pad, Padding -@subsection When There Is Not Enough Padding - -There are several common manifestations of insufficient padding. - -@itemize @bullet -@item -Emacs displays @samp{I-search: ^Q-} at the bottom of the screen. - -This means that the terminal thought its buffer was getting full of -display commands, so it tried to tell the computer to stop sending -any. - -@item -The screen is garbled intermittently, or the details of garbling vary -when you repeat the action. (A garbled screen could be due to a -command which is simply incorrect, or to user option in the terminal -which doesn't match the assumptions of the terminal description, but -this usually leads to reproducible failure.) - -This means that the buffer did get full, and some commands were lost. -Many changeable factors can change which ones are lost. - -@item -Screen is garbled at high output speeds but not at low speeds. -Padding problems nearly always go away at low speeds, usually even at -1200 baud. - -This means that a high enough speed permits commands to arrive faster -than they can be executed. -@end itemize - -Although any obscure command on an obscure terminal might lack padding, -in practice problems arise most often from the clearing commands -@samp{cl} and @samp{cd} (@pxref{Clearing}), the scrolling commands -@samp{sf} and @samp{sr} (@pxref{Scrolling}), and the line insert/delete -commands @samp{al} and @samp{dl} (@pxref{Insdel Line}). - -Occasionally the terminal description fails to define @samp{sf} and some -programs will use @samp{do} instead, so you may get a problem with -@samp{do}. If so, first define @samp{sf} just like @samp{do}, then -add some padding to @samp{sf}. - -The best strategy is to add a lot of padding at first, perhaps 200 msec. -This is much more than enough; in fact, it should cause a visible slowdown. -(If you don't see a slowdown, the change has not taken effect; -@pxref{Changing}.) If this makes the problem go away, you have found the -right place to add padding; now reduce the amount until the problem comes -back, then increase it again. If the problem remains, either it is in some -other capability or it is not a matter of padding at all. - -Keep in mind that on many terminals the correct padding for insert/delete -line or for scrolling is cursor-position dependent. If you get problems -from scrolling a large region of the screen but not from scrolling a small -part (just a few lines moving), it may mean that fixed padding should be -replaced with position-dependent padding. - -@node Describe Padding, Output Padding, Not Enough, Padding -@subsection Specifying Padding in a Terminal Description - -In the terminal description, the amount of padding required by each display -command is recorded as a sequence of digits at the front of the command. -These digits specify the padding time in milliseconds (msec). They can be -followed optionally by a decimal point and one more digit, which is a -number of tenths of msec. - -Sometimes the padding needed by a command depends on the cursor position. -For example, the time taken by an ``insert line'' command is usually -proportional to the number of lines that need to be moved down or cleared. -An asterisk (@samp{*}) following the padding time says that the time -should be multiplied by the number of screen lines affected by the command. - -@example -:al=1.3*\E[L: -@end example - -@noindent -is used to describe the ``insert line'' command for a certain terminal. -The padding required is 1.3 msec per line affected. The command itself is -@samp{@key{ESC} [ L}. - -The padding time specified in this way tells @code{tputs} how many pad -characters to output. @xref{Output Padding}. - -Two special capability values affect padding for all commands. These are -the @samp{pc} and @samp{pb}. The variable @samp{pc} specifies the -character to pad with, and @samp{pb} the speed below which no padding is -needed. The defaults for these variables, a null character and 0, -are correct for most terminals. @xref{Pad Specs}. - -@node Output Padding, , Describe Padding, Padding -@subsection Performing Padding with @code{tputs} -@cindex line speed - -@findex tputs -Use the termcap function @code{tputs} to output a string containing an -optional padding spec of the form described above (@pxref{Describe -Padding}). The function @code{tputs} strips off and decodes the padding -spec, outputs the rest of the string, and then outputs the appropriate -padding. Here is its declaration in ANSI C: - -@example -char PC; -short ospeed; - -int tputs (char *@var{string}, int @var{nlines}, int (*@var{outfun}) ()); -@end example - -Here @var{string} is the string (including padding spec) to be output; -@var{nlines} is the number of lines affected by the operation, which is -used to multiply the amount of padding if the padding spec ends with a -@samp{*}. Finally, @var{outfun} is a function (such as @code{fputchar}) -that is called to output each character. When actually called, -@var{outfun} should expect one argument, a character. - -@vindex ospeed -@vindex PC -The operation of @code{tputs} is controlled by two global variables, -@code{ospeed} and @code{PC}. The value of @code{ospeed} is supposed to be -the terminal output speed, encoded as in the @code{ioctl} system call which -gets the speed information. This is needed to compute the number of -padding characters. The value of @code{PC} is the character used for -padding. - -You are responsible for storing suitable values into these variables before -using @code{tputs}. The value stored into the @code{PC} variable should be -taken from the @samp{pc} capability in the terminal description (@pxref{Pad -Specs}). Store zero in @code{PC} if there is no @samp{pc} -capability.@refill - -The argument @var{nlines} requires some thought. Normally, it should be -the number of lines whose contents will be cleared or moved by the command. -For cursor motion commands, or commands that do editing within one line, -use the value 1. For most commands that affect multiple lines, such as -@samp{al} (insert a line) and @samp{cd} (clear from the cursor to the end -of the screen), @var{nlines} should be the screen height minus the current -vertical position (origin 0). For multiple insert and scroll commands such -as @samp{AL} (insert multiple lines), that same value for @var{nlines} is -correct; the number of lines being inserted is @i{not} correct.@refill - -If a ``scroll window'' feature is used to reduce the number of lines -affected by a command, the value of @var{nlines} should take this into -account. This is because the delay time required depends on how much work -the terminal has to do, and the scroll window feature reduces the work. -@xref{Scrolling}. - -Commands such as @samp{ic} and @samp{dc} (insert or delete characters) are -problematical because the padding needed by these commands is proportional -to the number of characters affected, which is the number of columns from -the cursor to the end of the line. It would be nice to have a way to -specify such a dependence, and there is no need for dependence on vertical -position in these commands, so it is an obvious idea to say that for these -commands @var{nlines} should really be the number of columns affected. -However, the definition of termcap clearly says that @var{nlines} is always -the number of lines affected, even in this case, where it is always 1. It -is not easy to change this rule now, because too many programs and terminal -descriptions have been written to follow it. - -Because @var{nlines} is always 1 for the @samp{ic} and @samp{dc} strings, -there is no reason for them to use @samp{*}, but some of them do. These -should be corrected by deleting the @samp{*}. If, some day, such entries -have disappeared, it may be possible to change to a more useful convention -for the @var{nlines} argument for these operations without breaking any -programs. - -@node Parameters, , Padding, Library -@section Filling In Parameters -@cindex parameters - -Some terminal control strings require numeric @dfn{parameters}. For -example, when you move the cursor, you need to say what horizontal and -vertical positions to move it to. The value of the terminal's @samp{cm} -capability, which says how to move the cursor, cannot simply be a string of -characters; it must say how to express the cursor position numbers and -where to put them within the command. - -The specifications of termcap include conventions as to which string-valued -capabilities require parameters, how many parameters, and what the -parameters mean; for example, it defines the @samp{cm} string to take -two parameters, the vertical and horizontal positions, with 0,0 being the -upper left corner. These conventions are described where the individual -commands are documented. - -Termcap also defines a language used within the capability definition for -specifying how and where to encode the parameters for output. This language -uses character sequences starting with @samp{%}. (This is the same idea as -@code{printf}, but the details are different.) The language for parameter -encoding is described in this section. - -A program that is doing display output calls the functions @code{tparam} or -@code{tgoto} to encode parameters according to the specifications. These -functions produce a string containing the actual commands to be output (as -well a padding spec which must be processed with @code{tputs}; -@pxref{Padding}). - -@menu -* Encode Parameters:: The language for encoding parameters. -* Using Parameters:: Outputting a string command with parameters. -@end menu - -@node Encode Parameters, Using Parameters, , Parameters -@subsection Describing the Encoding -@cindex % - -A terminal command string that requires parameters contains special -character sequences starting with @samp{%} to say how to encode the -parameters. These sequences control the actions of @code{tparam} and -@code{tgoto}. - -The parameters values passed to @code{tparam} or @code{tgoto} are -considered to form a vector. A pointer into this vector determines -the next parameter to be processed. Some of the @samp{%}-sequences -encode one parameter and advance the pointer to the next parameter. -Other @samp{%}-sequences alter the pointer or alter the parameter -values without generating output. - -For example, the @samp{cm} string for a standard ANSI terminal is written -as @samp{\E[%i%d;%dH}. (@samp{\E} stands for @key{ESC}.) @samp{cm} by -convention always requires two parameters, the vertical and horizontal goal -positions, so this string specifies the encoding of two parameters. Here -@samp{%i} increments the two values supplied, and each @samp{%d} encodes -one of the values in decimal. If the cursor position values 20,58 are -encoded with this string, the result is @samp{\E[21;59H}. - -First, here are the @samp{%}-sequences that generate output. Except for -@samp{%%}, each of them encodes one parameter and advances the pointer -to the following parameter. - -@table @samp -@item %% -Output a single @samp{%}. This is the only way to represent a literal -@samp{%} in a terminal command with parameters. @samp{%%} does not -use up a parameter. - -@item %d -As in @code{printf}, output the next parameter in decimal. - -@item %2 -Like @samp{%02d} in @code{printf}: output the next parameter in -decimal, and always use at least two digits. - -@item %3 -Like @samp{%03d} in @code{printf}: output the next parameter in -decimal, and always use at least three digits. Note that @samp{%4} -and so on are @emph{not} defined. - -@item %. -Output the next parameter as a single character whose ASCII code is -the parameter value. Like @samp{%c} in @code{printf}. - -@item %+@var{char} -Add the next parameter to the character @var{char}, and output the -resulting character. For example, @samp{%+ } represents 0 as a space, -1 as @samp{!}, etc. -@end table - -The following @samp{%}-sequences specify alteration of the parameters -(their values, or their order) rather than encoding a parameter for output. -They generate no output; they are used only for their side effects -on the parameters. Also, they do not advance the ``next parameter'' pointer -except as explicitly stated. Only @samp{%i}, @samp{%r} and @samp{%>} are -defined in standard Unix termcap. The others are GNU extensions.@refill - -@table @samp -@item %i -Increment the next two parameters. This is used for terminals that -expect cursor positions in origin 1. For example, @samp{%i%d,%d} would -output two parameters with @samp{1} for 0, @samp{2} for 1, etc. - -@item %r -Interchange the next two parameters. This is used for terminals whose -cursor positioning command expects the horizontal position first. - -@item %s -Skip the next parameter. Do not output anything. - -@item %b -Back up one parameter. The last parameter used will become once again -the next parameter to be output, and the next output command will use -it. Using @samp{%b} more than once, you can back up any number of -parameters, and you can refer to each parameter any number of times. - -@item %>@var{c1}@var{c2} -Conditionally increment the next parameter. Here @var{c1} and -@var{c2} are characters which stand for their ASCII codes as numbers. -If the next parameter is greater than the ASCII code of @var{c1}, the -ASCII code of @var{c2} is added to it.@refill - -@item %a @var{op} @var{type} @var{pos} -Perform arithmetic on the next parameter, do not use it up, and do not -output anything. Here @var{op} specifies the arithmetic operation, -while @var{type} and @var{pos} together specify the other operand. - -Spaces are used above to separate the operands for clarity; the spaces -don't appear in the data base, where this sequence is exactly five -characters long. - -The character @var{op} says what kind of arithmetic operation to -perform. It can be any of these characters: - -@table @samp -@item = -assign a value to the next parameter, ignoring its old value. -The new value comes from the other operand. - -@item + -add the other operand to the next parameter. - -@item - -subtract the other operand from the next parameter. - -@item * -multiply the next parameter by the other operand. - -@item / -divide the next parameter by the other operand. -@end table - -The ``other operand'' may be another parameter's value or a constant; -the character @var{type} says which. It can be: - -@table @samp -@item p -Use another parameter. The character @var{pos} says which -parameter to use. Subtract 64 from its ASCII code to get the -position of the desired parameter relative to this one. Thus, -the character @samp{A} as @var{pos} means the parameter after the -next one; the character @samp{?} means the parameter before the -next one. - -@item c -Use a constant value. The character @var{pos} specifies the -value of the constant. The 0200 bit is cleared out, so that 0200 -can be used to represent zero. -@end table -@end table - -The following @samp{%}-sequences are special purpose hacks to compensate -for the weird designs of obscure terminals. They modify the next parameter -or the next two parameters but do not generate output and do not use up any -parameters. @samp{%m} is a GNU extension; the others are defined in -standard Unix termcap. - -@table @samp -@item %n -Exclusive-or the next parameter with 0140, and likewise the parameter -after next. - -@item %m -Complement all the bits of the next parameter and the parameter after next. - -@item %B -Encode the next parameter in BCD. It alters the value of the -parameter by adding six times the quotient of the parameter by ten. -Here is a C statement that shows how the new value is computed: - -@example -@var{parm} = (@var{parm} / 10) * 16 + @var{parm} % 10; -@end example - -@item %D -Transform the next parameter as needed by Delta Data terminals. -This involves subtracting twice the remainder of the parameter by 16. - -@example -@var{parm} -= 2 * (@var{parm} % 16); -@end example -@end table - -@node Using Parameters, , Encode Parameters, Parameters -@subsection Sending Display Commands with Parameters - -The termcap library functions @code{tparam} and @code{tgoto} serve as the -analog of @code{printf} for terminal string parameters. The newer function -@code{tparam} is a GNU extension, more general but missing from Unix -termcap. The original parameter-encoding function is @code{tgoto}, which -is preferable for cursor motion. - -@menu -* tparam:: The general case, for GNU termcap only. -* tgoto:: The special case of cursor motion. -@end menu - -@node tparam, tgoto, , Using Parameters -@subsubsection @code{tparam} - -@findex tparam -The function @code{tparam} can encode display commands with any number of -parameters and allows you to specify the buffer space. It is the preferred -function for encoding parameters for all but the @samp{cm} capability. Its -ANSI C declaration is as follows: - -@smallexample -char *tparam (char *@var{ctlstring}, char *@var{buffer}, int @var{size}, int @var{parm1},...) -@end smallexample - -The arguments are a control string @var{ctlstring} (the value of a terminal -capability, presumably), an output buffer @var{buffer} and @var{size}, and -any number of integer parameters to be encoded. The effect of -@code{tparam} is to copy the control string into the buffer, encoding -parameters according to the @samp{%} sequences in the control string. - -You describe the output buffer by its address, @var{buffer}, and its size -in bytes, @var{size}. If the buffer is not big enough for the data to be -stored in it, @code{tparam} calls @code{malloc} to get a larger buffer. In -either case, @code{tparam} returns the address of the buffer it ultimately -uses. If the value equals @var{buffer}, your original buffer was used. -Otherwise, a new buffer was allocated, and you must free it after you are -done with printing the results. If you pass zero for @var{size} and -@var{buffer}, @code{tparam} always allocates the space with @code{malloc}. - -All capabilities that require parameters also have the ability to specify -padding, so you should use @code{tputs} to output the string produced by -@code{tparam}. @xref{Padding}. Here is an example. - -@example -@{ -char *buf; -char buffer[40]; - -buf = tparam (command, buffer, 40, parm); -tputs (buf, 1, fputchar); -if (buf != buffer) -free (buf); -@} -@end example - -If a parameter whose value is zero is encoded with @samp{%.}-style -encoding, the result is a null character, which will confuse @code{tputs}. -This would be a serious problem, but luckily @samp{%.} encoding is used -only by a few old models of terminal, and only for the @samp{cm} -capability. To solve the problem, use @code{tgoto} rather than -@code{tparam} to encode the @samp{cm} capability.@refill - -@node tgoto, , tparam, Using Parameters -@subsubsection @code{tgoto} - -@findex tgoto -The special case of cursor motion is handled by @code{tgoto}. There -are two reasons why you might choose to use @code{tgoto}: - -@itemize @bullet -@item -For Unix compatibility, because Unix termcap does not have @code{tparam}. - -@item -For the @samp{cm} capability, since @code{tgoto} has a special feature -to avoid problems with null characters, tabs and newlines on certain old -terminal types that use @samp{%.} encoding for that capability. -@end itemize - -Here is how @code{tgoto} might be declared in ANSI C: - -@example -char *tgoto (char *@var{cstring}, int @var{hpos}, int @var{vpos}) -@end example - -There are three arguments, the terminal description's @samp{cm} string and -the two cursor position numbers; @code{tgoto} computes the parametrized -string in an internal static buffer and returns the address of that buffer. -The next time you use @code{tgoto} the same buffer will be reused. - -@vindex UP -@vindex BC -Parameters encoded with @samp{%.} encoding can generate null characters, -tabs or newlines. These might cause trouble: the null character because -@code{tputs} would think that was the end of the string, the tab because -the kernel or other software might expand it into spaces, and the newline -becaue the kernel might add a carriage-return, or padding characters -normally used for a newline. To prevent such problems, @code{tgoto} is -careful to avoid these characters. Here is how this works: if the target -cursor position value is such as to cause a problem (that is to say, zero, -nine or ten), @code{tgoto} increments it by one, then compensates by -appending a string to move the cursor back or up one position. - -The compensation strings to use for moving back or up are found in global -variables named @code{BC} and @code{UP}. These are actual external C -variables with upper case names; they are declared @code{char *}. It is up -to you to store suitable values in them, normally obtained from the -@samp{le} and @samp{up} terminal capabilities in the terminal description -with @code{tgetstr}. Alternatively, if these two variables are both zero, -the feature of avoiding nulls, tabs and newlines is turned off. - -It is safe to use @code{tgoto} for commands other than @samp{cm} only if -you have stored zero in @code{BC} and @code{UP}. - -Note that @code{tgoto} reverses the order of its operands: the horizontal -position comes before the vertical position in the arguments to -@code{tgoto}, even though the vertical position comes before the horizontal -in the parameters of the @samp{cm} string. If you use @code{tgoto} with a -command such as @samp{AL} that takes one parameter, you must pass the -parameter to @code{tgoto} as the ``vertical position''.@refill - -@node Data Base, Capabilities, Library, Top -@chapter The Format of the Data Base - -The termcap data base of terminal descriptions is stored in the file -@file{/etc/termcap}. It contains terminal descriptions, blank lines, and -comments. - -A terminal description starts with one or more names for the terminal type. -The information in the description is a series of @dfn{capability names} -and values. The capability names have standard meanings -(@pxref{Capabilities}) and their values describe the terminal. - -@menu -* Format:: Overall format of a terminal description. -* Capability Format:: Format of capabilities within a description. -* Naming:: Naming conventions for terminal types. -* Inheriting:: Inheriting part of a description from -a related terminal type. -* Changing:: When changes in the data base take effect. -@end menu - -@node Format, Capability Format, , Data Base -@section Terminal Description Format -@cindex description format - -Aside from comments (lines starting with @samp{#}, which are ignored), each -nonblank line in the termcap data base is a terminal description. -A terminal description is nominally a single line, but it can be split -into multiple lines by inserting the two characters @samp{\ newline}. -This sequence is ignored wherever it appears in a description. - -The preferred way to split the description is between capabilities: insert -the four characters @samp{: \ newline tab} immediately before any colon. -This allows each sub-line to start with some indentation. This works -because, after the @samp{\ newline} are ignored, the result is @samp{: tab -:}; the first colon ends the preceding capability and the second colon -starts the next capability. If you split with @samp{\ newline} alone, you -may not add any indentation after them. - -Here is a real example of a terminal description: - -@example -dw|vt52|DEC vt52:\ - :cr=^M:do=^J:nl=^J:bl=^G:\ - :le=^H:bs:cd=\EJ:ce=\EK:cl=\EH\EJ:\ - :cm=\EY%+ %+ :co#80:li#24:\ - :nd=\EC:ta=^I:pt:sr=\EI:up=\EA:\ - :ku=\EA:kd=\EB:kr=\EC:kl=\ED:kb=^H: -@end example - -Each terminal description begins with several names for the terminal type. -The names are separated by @samp{|} characters, and a colon ends the last -name. The first name should be two characters long; it exists only for the -sake of very old Unix systems and is never used in modern systems. The -last name should be a fully verbose name such as ``DEC vt52'' or ``Ann -Arbor Ambassador with 48 lines''. The other names should include whatever -the user ought to be able to specify to get this terminal type, such as -@samp{vt52} or @samp{aaa-48}. @xref{Naming}, for information on how to -choose terminal type names. - -After the terminal type names come the terminal capabilities, separated by -colons and with a colon after the last one. Each capability has a -two-letter name, such as @samp{cm} for ``cursor motion string'' or @samp{li} -for ``number of display lines''. - -@node Capability Format, Naming, Format, Data Base -@section Writing the Capabilities - -There are three kinds of capabilities: flags, numbers, and strings. Each -kind has its own way of being written in the description. Each defined -capability has by convention a particular kind of value; for example, -@samp{li} always has a numeric value and @samp{cm} always a string value. - -A flag capability is thought of as having a boolean value: the value is -true if the capability is present, false if not. When the capability is -present, just write its name between two colons. - -A numeric capability has a value which is a nonnegative number. Write the -capability name, a @samp{#}, and the number, between two colons. For -example, @samp{@dots{}:li#48:@dots{}} is how you specify the @samp{li} -capability for 48 lines.@refill - -A string-valued capability has a value which is a sequence of characters. -Usually these are the characters used to perform some display operation. -Write the capability name, a @samp{=}, and the characters of the value, -between two colons. For example, @samp{@dots{}:cm=\E[%i%d;%dH:@dots{}} is -how the cursor motion command for a standard ANSI terminal would be -specified.@refill - -Special characters in the string value can be expressed using -@samp{\}-escape sequences as in C; in addition, @samp{\E} stands for -@key{ESC}. @samp{^} is also a kind of escape character; @samp{^} followed -by @var{char} stands for the control-equivalent of @var{char}. Thus, -@samp{^a} stands for the character control-a, just like @samp{\001}. -@samp{\} and @samp{^} themselves can be represented as @samp{\\} and -@samp{\^}.@refill - -To include a colon in the string, you must write @samp{\072}. You might -ask, ``Why can't @samp{\:} be used to represent a colon?'' The reason is -that the interrogation functions do not count slashes while looking for a -capability. Even if @samp{:ce=ab\:cd:} were interpreted as giving the -@samp{ce} capability the value @samp{ab:cd}, it would also appear to define -@samp{cd} as a flag. - -The string value will often contain digits at the front to specify padding -(@pxref{Padding}) and/or @samp{%}-sequences within to specify how to encode -parameters (@pxref{Parameters}). Although these things are not to be -output literally to the terminal, they are considered part of the value of -the capability. They are special only when the string value is processed -by @code{tputs}, @code{tparam} or @code{tgoto}. By contrast, @samp{\} and -@samp{^} are considered part of the syntax for specifying the characters -in the string. - -Let's look at the VT52 example again: - -@example -dw|vt52|DEC vt52:\ - :cr=^M:do=^J:nl=^J:bl=^G:\ - :le=^H:bs:cd=\EJ:ce=\EK:cl=\EH\EJ:\ - :cm=\EY%+ %+ :co#80:li#24:\ - :nd=\EC:ta=^I:pt:sr=\EI:up=\EA:\ - :ku=\EA:kd=\EB:kr=\EC:kl=\ED:kb=^H: -@end example - -Here we see the numeric-valued capabilities @samp{co} and @samp{li}, the -flags @samp{bs} and @samp{pt}, and many string-valued capabilities. Most -of the strings start with @key{ESC} represented as @samp{\E}. The rest -contain control characters represented using @samp{^}. The meanings of the -individual capabilities are defined elsewhere (@pxref{Capabilities}). - -@node Naming, Inheriting, Capability Format, Data Base -@section Terminal Type Name Conventions -@cindex names of terminal types - -There are conventions for choosing names of terminal types. For one thing, -all letters should be in lower case. The terminal type for a terminal in -its most usual or most fundamental mode of operation should not have a -hyphen in it. - -If the same terminal has other modes of operation which require -different terminal descriptions, these variant descriptions are given -names made by adding suffixes with hyphens. Such alternate descriptions -are used for two reasons: - -@itemize @bullet -@item -When the terminal has a switch that changes its behavior. Since the -computer cannot tell how the switch is set, the user must tell the -computer by choosing the appropriate terminal type name. - -@cindex wrapping -For example, the VT-100 has a setup flag that controls whether the -cursor wraps at the right margin. If this flag is set to ``wrap'', -you must use the terminal type @samp{vt100-am}. Otherwise you must -use @samp{vt100-nam}. Plain @samp{vt100} is defined as a synonym for -either @samp{vt100-am} or @samp{vt100-nam} depending on the -preferences of the local site.@refill - -The standard suffix @samp{-am} stands for ``automatic margins''. - -@item -To give the user a choice in how to use the terminal. This is done -when the terminal has a switch that the computer normally controls. - -@cindex screen size -For example, the Ann Arbor Ambassador can be configured with many -screen sizes ranging from 20 to 60 lines. Fewer lines make bigger -characters but more lines let you see more of what you are editing. -As a result, users have different preferences. Therefore, termcap -provides terminal types for many screen sizes. If you choose type -@samp{aaa-30}, the terminal will be configured to use 30 lines; if you -choose @samp{aaa-48}, 48 lines will be used, and so on. -@end itemize - -Here is a list of standard suffixes and their conventional meanings: - -@table @samp -@item -w -Short for ``wide''. This is a mode that gives the terminal more -columns than usual. This is normally a user option. - -@item -am -``Automatic margins''. This is an alternate description for use when -the terminal's margin-wrap switch is on; it contains the @samp{am} -flag. The implication is that normally the switch is off and the -usual description for the terminal says that the switch is off. - -@item -nam -``No automatic margins''. The opposite of @samp{-am}, this names an -alternative description which lacks the @samp{am} flag. This implies -that the terminal is normally operated with the margin-wrap switch -turned on, and the normal description of the terminal says so. - -@item -na -``No arrows''. This terminal description initializes the terminal to -keep its arrow keys in local mode. This is a user option. - -@item -rv -``Reverse video''. This terminal description causes text output for -normal video to appear as reverse, and text output for reverse video -to come out as normal. Often this description differs from the usual -one by interchanging the two strings which turn reverse video on and -off.@refill - -This is a user option; you can choose either the ``reverse video'' -variant terminal type or the normal terminal type, and termcap will -obey. - -@item -s -``Status''. Says to enable use of a status line which ordinary output -does not touch (@pxref{Status Line}). - -Some terminals have a special line that is used only as a status line. -For these terminals, there is no need for an @samp{-s} variant; the -status line commands should be defined by default. On other -terminals, enabling a status line means removing one screen line from -ordinary use and reducing the effective screen height. For these -terminals, the user can choose the @samp{-s} variant type to request -use of a status line. - -@item -@var{nlines} -Says to operate with @var{nlines} lines on the screen, for terminals -such as the Ambassador which provide this as an option. Normally this -is a user option; by choosing the terminal type, you control how many -lines termcap will use. - -@item -@var{npages}p -Says that the terminal has @var{npages} pages worth of screen memory, -for terminals where this is a hardware option. - -@item -unk -Says that description is not for direct use, but only for reference in -@samp{tc} capabilities. Such a description is a kind of subroutine, -because it describes the common characteristics of several variant -descriptions that would use other suffixes in place of @samp{-unk}. -@end table - -@node Inheriting, Changing, Naming, Data Base -@section Inheriting from Related Descriptions - -@cindex inheritance -When two terminal descriptions are similar, their identical parts do not -need to be given twice. Instead, one of the two can be defined in terms of -the other, using the @samp{tc} capability. We say that one description -@dfn{refers to} the other, or @dfn{inherits from} the other. - -The @samp{tc} capability must be the last one in the terminal description, -and its value is a string which is the name of another terminal type which -is referred to. For example, - -@example -N9|aaa|ambassador|aaa-30|ann arbor ambassador/30 lines:\ - :ti=\E[2J\E[30;0;0;30p:\ - :te=\E[60;0;0;30p\E[30;1H\E[J:\ - :li#30:tc=aaa-unk: -@end example - -@noindent -defines the terminal type @samp{aaa-30} (also known as plain @samp{aaa}) in -terms of @samp{aaa-unk}, which defines everything about the Ambassador that -is independent of screen height. The types @samp{aaa-36}, @samp{aaa-48} -and so on for other screen heights are likewise defined to inherit from -@samp{aaa-unk}. - -The capabilities overridden by @samp{aaa-30} include @samp{li}, which says -how many lines there are, and @samp{ti} and @samp{te}, which configure the -terminal to use that many lines. - -The effective terminal description for type @samp{aaa} consists of the text -shown above followed by the text of the description of @samp{aaa-unk}. The -@samp{tc} capability is handled automatically by @code{tgetent}, which -finds the description thus referenced and combines the two descriptions -(@pxref{Find}). Therefore, only the implementor of the terminal -descriptions needs to think about using @samp{tc}. Users and application -programmers do not need to be concerned with it. - -Since the reference terminal description is used last, capabilities -specified in the referring description override any specifications of the -same capabilities in the reference description. - -The referring description can cancel out a capability without specifying -any new value for it by means of a special trick. Write the capability in -the referring description, with the character @samp{@@} after the capability -name, as follows: - -@smallexample -NZ|aaa-30-nam|ann arbor ambassador/30 lines/no automatic-margins:\ - :am@@:tc=aaa-30: -@end smallexample - -@node Changing, , Inheriting, Data Base -@section When Changes in the Data Base Take Effect - -Each application program must read the terminal description from the -data base, so a change in the data base is effective for all jobs started -after the change is made. - -The change will usually have no effect on a job that have been in existence -since before the change. The program probably read the terminal description -once, when it was started, and is continuing to use what it read then. -If the program does not have a feature for reexamining the data base, then -you will need to run it again (probably killing the old job). - -If the description in use is coming from the @code{TERMCAP} environment -variable, then the data base file is effectively overridden, and changes in -it will have no effect until you change the @code{TERMCAP} variable as -well. For example, some users' @file{.login} files automatically copy the -terminal description into @code{TERMCAP} to speed startup of applications. -If you have done this, you will need to change the @code{TERMCAP} variable -to make the changed data base take effect. - -@node Capabilities, Summary, Data Base, Top -@chapter Definitions of the Terminal Capabilities - -This section is divided into many subsections, each for one aspect of -use of display terminals. For writing a display program, you usually need -only check the subsections for the operations you want to use. For writing -a terminal description, you must read each subsection and fill in the -capabilities described there. - -String capabilities that are display commands may require numeric -parameters (@pxref{Parameters}). Most such capabilities do not use -parameters. When a capability requires parameters, this is explicitly -stated at the beginning of its definition. In simple cases, the first or -second sentence of the definition mentions all the parameters, in the order -they should be given, using a name -@iftex -in italics -@end iftex -@ifinfo -in upper case -@end ifinfo -for each one. For example, the @samp{rp} capability is a command that -requires two parameters; its definition begins as follows: - -@quotation -String of commands to output a graphic character @var{c}, repeated @var{n} -times. -@end quotation - -In complex cases or when there are many parameters, they are described -explicitly. - -When a capability is described as obsolete, this means that programs should -not be written to look for it, but terminal descriptions should still be -written to provide it. - -When a capability is described as very obsolete, this means that it should -be omitted from terminal descriptions as well. - -@menu -* Basic:: Basic characteristics. -* Screen Size:: Screen size, and what happens when it changes. -* Cursor Motion:: Various ways to move the cursor. -* Wrapping:: What happens if you write a character in the last column. -* Scrolling:: Pushing text up and down on the screen. -* Windows:: Limiting the part of the window that output affects. -* Clearing:: Erasing one or many lines. -* Insdel Line:: Making new blank lines in mid-screen; deleting lines. -* Insdel Char:: Inserting and deleting characters within a line. -* Standout:: Highlighting some of the text. -* Underlining:: Underlining some of the text. -* Cursor Visibility:: Making the cursor more or less easy to spot. -* Bell:: Attracts user's attention; not localized on the screen. -* Keypad:: Recognizing when function keys or arrows are typed. -* Meta Key:: @key{META} acts like an extra shift key. -* Initialization:: Commands used to initialize or reset the terminal. -* Pad Specs:: Info for the kernel on how much padding is needed. -* Status Line:: A status line displays ``background'' information. -* Half-Line:: Moving by half-lines, for superscripts and subscripts. -* Printer:: Controlling auxiliary printers of display terminals. -@end menu - -@node Basic, Screen Size, , Capabilities -@section Basic Characteristics - -This section documents the capabilities that describe the basic and -nature of the terminal, and also those that are relevant to the output -of graphic characters. - -@table @samp -@item os -@kindex os -@cindex overstrike -Flag whose presence means that the terminal can overstrike. This -means that outputting a graphic character does not erase whatever was -present in the same character position before. The terminals that can -overstrike include printing terminals, storage tubes (all obsolete -nowadays), and many bit-map displays. - -@item eo -@kindex eo -Flag whose presence means that outputting a space erases a character -position even if the terminal supports overstriking. If this flag is -not present and overstriking is supported, output of a space has no -effect except to move the cursor. - -(On terminals that do not support overstriking, you can always assume -that outputting a space at a position erases whatever character was -previously displayed there.) - -@item gn -@kindex gn -@cindex generic terminal type -Flag whose presence means that this terminal type is a generic type -which does not really describe any particular terminal. Generic types -are intended for use as the default type assigned when the user -connects to the system, with the intention that the user should -specify what type he really has. One example of a generic type -is the type @samp{network}. - -Since the generic type cannot say how to do anything interesting with -the terminal, termcap-using programs will always find that the -terminal is too weak to be supported if the user has failed to specify -a real terminal type in place of the generic one. The @samp{gn} flag -directs these programs to use a different error message: ``You have -not specified your real terminal type'', rather than ``Your terminal -is not powerful enough to be used''. - -@item hc -@kindex hc -Flag whose presence means this is a hardcopy terminal. - -@item rp -@kindex rp -@cindex repeat output -String of commands to output a graphic character @var{c}, repeated @var{n} -times. The first parameter value is the ASCII code for the desired -character, and the second parameter is the number of times to repeat the -character. Often this command requires padding proportional to the -number of times the character is repeated. This effect can be had by -using parameter arithmetic with @samp{%}-sequences to compute the -amount of padding, then generating the result as a number at the front -of the string so that @code{tputs} will treat it as padding. - -@item hz -@kindex hz -Flag whose presence means that the ASCII character @samp{~} cannot be -output on this terminal because it is used for display commands. - -Programs handle this flag by checking all text to be output and -replacing each @samp{~} with some other character(s). If this is not -done, the screen will be thoroughly garbled. - -The old Hazeltine terminals that required such treatment are probably -very rare today, so you might as well not bother to support this flag. - -@item CC -@kindex CC -@cindex command character -String whose presence means the terminal has a settable command -character. The value of the string is the default command character -(which is usually @key{ESC}). - -All the strings of commands in the terminal description should be -written to use the default command character. If you are writing an -application program that changes the command character, use the -@samp{CC} capability to figure out how to translate all the display -commands to work with the new command character. - -Most programs have no reason to look at the @samp{CC} capability. - -@item xb -@kindex xb -@cindex Superbee -Flag whose presence identifies Superbee terminals which are unable to -transmit the characters @key{ESC} and @kbd{Control-C}. Programs which -support this flag are supposed to check the input for the code sequences -sent by the @key{F1} and @key{F2} keys, and pretend that @key{ESC} -or @kbd{Control-C} (respectively) had been read. But this flag is -obsolete, and not worth supporting. -@end table - -@node Screen Size, Cursor Motion, Basic, Capabilities -@section Screen Size -@cindex screen size - -A terminal description has two capabilities, @samp{co} and @samp{li}, -that describe the screen size in columns and lines. But there is more -to the question of screen size than this. - -On some operating systems the ``screen'' is really a window and the -effective width can vary. On some of these systems, @code{tgetnum} -uses the actual width of the window to decide what value to return for -the @samp{co} capability, overriding what is actually written in the -terminal description. On other systems, it is up to the application -program to check the actual window width using a system call. For -example, on BSD 4.3 systems, the system call @code{ioctl} with code -@code{TIOCGWINSZ} will tell you the current screen size. - -On all window systems, termcap is powerless to advise the application -program if the user resizes the window. Application programs must -deal with this possibility in a system-dependent fashion. On some -systems the C shell handles part of the problem by detecting changes -in window size and setting the @code{TERMCAP} environment variable -appropriately. This takes care of application programs that are -started subsequently. It does not help application programs already -running. - -On some systems, including BSD 4.3, all programs using a terminal get -a signal named @code{SIGWINCH} whenever the screen size changes. -Programs that use termcap should handle this signal by using -@code{ioctl TIOCGWINSZ} to learn the new screen size. - -@table @samp -@item co -@kindex co -@cindex screen size -Numeric value, the width of the screen in character positions. Even -hardcopy terminals normally have a @samp{co} capability. - -@item li -@kindex li -Numeric value, the height of the screen in lines. -@end table - -@node Cursor Motion, Wrapping, Screen Size, Capabilities -@section Cursor Motion -@cindex cursor motion - -Termcap assumes that the terminal has a @dfn{cursor}, a spot on the screen -where a visible mark is displayed, and that most display commands take -effect at the position of the cursor. It follows that moving the cursor -to a specified location is very important. - -There are many terminal capabilities for different cursor motion -operations. A terminal description should define as many as possible, but -most programs do not need to use most of them. One capability, @samp{cm}, -moves the cursor to an arbitrary place on the screen; this by itself is -sufficient for any application as long as there is no need to support -hardcopy terminals or certain old, weak displays that have only relative -motion commands. Use of other cursor motion capabilities is an -optimization, enabling the program to output fewer characters in some -common cases. - -If you plan to use the relative cursor motion commands in an application -program, you must know what the starting cursor position is. To do this, -you must keep track of the cursor position and update the records each -time anything is output to the terminal, including graphic characters. -In addition, it is necessary to know whether the terminal wraps after -writing in the rightmost column. @xref{Wrapping}. - -One other motion capability needs special mention: @samp{nw} moves the -cursor to the beginning of the following line, perhaps clearing all the -starting line after the cursor, or perhaps not clearing at all. This -capability is a least common denominator that is probably supported even by -terminals that cannot do most other things such as @samp{cm} or @samp{do}. -Even hardcopy terminals can support @samp{nw}. - -@table @asis -@item @samp{cm} -@kindex cm -String of commands to position the cursor at line @var{l}, column @var{c}. -Both parameters are origin-zero, and are defined relative to the -screen, not relative to display memory. - -All display terminals except a few very obsolete ones support @samp{cm}, -so it is acceptable for an application program to refuse to operate on -terminals lacking @samp{cm}. - -@item @samp{ho} -@kindex ho -@cindex home position -String of commands to move the cursor to the upper left corner of the -screen (this position is called the @dfn{home position}). In -terminals where the upper left corner of the screen is not the same as -the beginning of display memory, this command must go to the upper -left corner of the screen, not the beginning of display memory. - -Every display terminal supports this capability, and many application -programs refuse to operate if the @samp{ho} capability is missing. - -@item @samp{ll} -@kindex ll -String of commands to move the cursor to the lower left corner of the -screen. On some terminals, moving up from home position does this, -but programs should never assume that will work. Just output the -@samp{ll} string (if it is provided); if moving to home position and -then moving up is the best way to get there, the @samp{ll} command -will do that. - -@item @samp{cr} -@kindex cr -String of commands to move the cursor to the beginning of the line it -is on. If this capability is not specified, many programs assume -they can use the ASCII carriage return character for this. - -@item @samp{le} -@kindex le -String of commands to move the cursor left one column. Unless the -@samp{bw} flag capability is specified, the effect is undefined if the -cursor is at the left margin; do not use this command there. If -@samp{bw} is present, this command may be used at the left margin, and -it wraps the cursor to the last column of the preceding line. - -@item @samp{nd} -@kindex nd -String of commands to move the cursor right one column. The effect is -undefined if the cursor is at the right margin; do not use this -command there, not even if @samp{am} is present. - -@item @samp{up} -@kindex up -String of commands to move the cursor vertically up one line. The -effect of sending this string when on the top line is undefined; -programs should never use it that way. - -@item @samp{do} -@kindex do -String of commands to move the cursor vertically down one line. The -effect of sending this string when on the bottom line is undefined; -programs should never use it that way. - -Some programs do use @samp{do} to scroll up one line if used at the -bottom line, if @samp{sf} is not defined but @samp{sr} is. This is -only to compensate for certain old, incorrect terminal descriptions. -(In principle this might actually lead to incorrect behavior on other -terminals, but that seems to happen rarely if ever.) But the proper -solution is that the terminal description should define @samp{sf} as -well as @samp{do} if the command is suitable for scrolling. - -The original idea was that this string would not contain a newline -character and therefore could be used without disabling the kernel's -usual habit of converting of newline into a carriage-return newline -sequence. But many terminal descriptions do use newline in the -@samp{do} string, so this is not possible; a program which sends the -@samp{do} string must disable output conversion in the kernel -(@pxref{Initialize}). - -@item @samp{bw} -@kindex bw -Flag whose presence says that @samp{le} may be used in column zero -to move to the last column of the preceding line. If this flag -is not present, @samp{le} should not be used in column zero. - -@item @samp{nw} -@kindex nw -String of commands to move the cursor to start of next line, possibly -clearing rest of line (following the cursor) before moving. - -@item @samp{DO}, @samp{UP}, @samp{LE}, @samp{RI} -@kindex DO -@kindex LE -@kindex RI -@kindex UP -Strings of commands to move the cursor @var{n} lines down vertically, -up vertically, or @var{n} columns left or right. Do not attempt to -move past any edge of the screen with these commands; the effect of -trying that is undefined. Only a few terminal descriptions provide -these commands, and most programs do not use them. - -@item @samp{CM} -@kindex CM -String of commands to position the cursor at line @var{l}, column -@var{c}, relative to display memory. Both parameters are origin-zero. -This capability is present only in terminals where there is a -difference between screen-relative and memory-relative addressing, and -not even in all such terminals. - -@item @samp{ch} -@kindex ch -String of commands to position the cursor at column @var{c} in the -same line it is on. This is a special case of @samp{cm} in which the -vertical position is not changed. The @samp{ch} capability is -provided only when it is faster to output than @samp{cm} would be in -this special case. Programs should not assume most display terminals -have @samp{ch}. - -@item @samp{cv} -@kindex cv -String of commands to position the cursor at line @var{l} in the same -column. This is a special case of @samp{cm} in which the horizontal -position is not changed. The @samp{cv} capability is provided only -when it is faster to output than @samp{cm} would be in this special -case. Programs should not assume most display terminals have -@samp{cv}. - -@item @samp{sc} -@kindex sc -String of commands to make the terminal save the current cursor -position. Only the last saved position can be used. If this -capability is present, @samp{rc} should be provided also. Most -terminals have neither. - -@item @samp{rc} -@kindex rc -String of commands to make the terminal restore the last saved cursor -position. If this capability is present, @samp{sc} should be provided -also. Most terminals have neither. - -@item @samp{ff} -@kindex ff -String of commands to advance to the next page, for a hardcopy -terminal. - -@item @samp{ta} -@kindex ta -String of commands to move the cursor right to the next hardware tab -stop column. Missing if the terminal does not have any kind of -hardware tabs. Do not send this command if the kernel's terminal -modes say that the kernel is expanding tabs into spaces. - -@item @samp{bt} -@kindex bt -String of commands to move the cursor left to the previous hardware -tab stop column. Missing if the terminal has no such ability; many -terminals do not. Do not send this command if the kernel's terminal -modes say that the kernel is expanding tabs into spaces. -@end table - -The following obsolete capabilities should be included in terminal -descriptions when appropriate, but should not be looked at by new programs. - -@table @samp -@item nc -@kindex nc -Flag whose presence means the terminal does not support the ASCII -carriage return character as @samp{cr}. This flag is needed because -old programs assume, when the @samp{cr} capability is missing, that -ASCII carriage return can be used for the purpose. We use @samp{nc} -to tell the old programs that carriage return may not be used. - -New programs should not assume any default for @samp{cr}, so they need -not look at @samp{nc}. However, descriptions should contain @samp{nc} -whenever they do not contain @samp{cr}. - -@item xt -@kindex xt -Flag whose presence means that the ASCII tab character may not be used -for cursor motion. This flag exists because old programs assume, when -the @samp{ta} capability is missing, that ASCII tab can be used for -the purpose. We use @samp{xt} to tell the old programs not to use tab. - -New programs should not assume any default for @samp{ta}, so they need -not look at @samp{xt} in connection with cursor motion. Note that -@samp{xt} also has implications for standout mode (@pxref{Standout}). -It is obsolete in regard to cursor motion but not in regard to -standout. - -In fact, @samp{xt} means that the terminal is a Teleray 1061. - -@item bc -@kindex bc -Very obsolete alternative name for the @samp{le} capability. - -@item bs -@kindex bs -Flag whose presence means that the ASCII character backspace may be -used to move the cursor left. Obsolete; look at @samp{le} instead. - -@item nl -@kindex nl -Obsolete capability which is a string that can either be used to move -the cursor down or to scroll. The same string must scroll when used -on the bottom line and move the cursor when used on any other line. -New programs should use @samp{do} or @samp{sf}, and ignore @samp{nl}. - -If there is no @samp{nl} capability, some old programs assume they can -use the newline character for this purpose. These programs follow a -bad practice, but because they exist, it is still desirable to define -the @samp{nl} capability in a terminal description if the best way to -move down is @emph{not} a newline. -@end table - -@node Wrapping, Scrolling, Cursor Motion, Capabilities -@section Wrapping -@cindex wrapping - -@dfn{Wrapping} means moving the cursor from the right margin to the left -margin of the following line. Some terminals wrap automatically when a -graphic character is output in the last column, while others do not. Most -application programs that use termcap need to know whether the terminal -wraps. There are two special flag capabilities to describe what the -terminal does when a graphic character is output in the last column. - -@table @samp -@item am -@kindex am -Flag whose presence means that writing a character in the last column -causes the cursor to wrap to the beginning of the next line. - -If @samp{am} is not present, writing in the last column leaves the -cursor at the place where the character was written. - -Writing in the last column of the last line should be avoided on -terminals with @samp{am}, as it may or may not cause scrolling to -occur (@pxref{Scrolling}). Scrolling is surely not what you would -intend. - -If your program needs to check the @samp{am} flag, then it also needs -to check the @samp{xn} flag which indicates that wrapping happens in a -strange way. Many common terminals have the @samp{xn} flag. - -@item xn -@kindex xn -Flag whose presence means that the cursor wraps in a strange way. At -least two distinct kinds of strange behavior are known; the termcap -data base does not contain anything to distinguish the two. - -On Concept-100 terminals, output in the last column wraps the cursor -almost like an ordinary @samp{am} terminal. But if the next thing -output is a newline, it is ignored. - -DEC VT-100 terminals (when the wrap switch is on) do a different -strange thing: the cursor wraps only if the next thing output is -another graphic character. In fact, the wrap occurs when the -following graphic character is received by the terminal, before the -character is placed on the screen. - -On both of these terminals, after writing in the last column a -following graphic character will be displayed in the first column of -the following line. But the effect of relative cursor motion -characters such as newline or backspace at such a time depends on the -terminal. The effect of erase or scrolling commands also depends on -the terminal. You can't assume anything about what they will do on a -terminal that has @samp{xn}. So, to be safe, you should never do -these things at such a time on such a terminal. - -To be sure of reliable results on a terminal which has the @samp{xn} -flag, output a @samp{cm} absolute positioning command after writing in -the last column. Another safe thing to do is to output carriage-return -newline, which will leave the cursor at the beginning of the following -line. - -@item LP -@kindex LP -Flag whose presence means that it is safe to write in the last column of -the last line without worrying about undesired scrolling. @samp{LP} -indicates the DEC flavor of @samp{xn} strangeness. -@end table - -@node Scrolling, Windows, Wrapping, Capabilities -@section Scrolling -@cindex scrolling - -@dfn{Scrolling} means moving the contents of the screen up or down one or -more lines. Moving the contents up is @dfn{forward scrolling}; moving them -down is @dfn{reverse scrolling}. - -Scrolling happens after each line of output during ordinary output on most -display terminals. But in an application program that uses termcap for -random-access output, scrolling happens only when explicitly requested with -the commands in this section. - -Some terminals have a @dfn{scroll region} feature. This lets you limit -the effect of scrolling to a specified range of lines. Lines outside the -range are unaffected when scrolling happens. The scroll region feature -is available if either @samp{cs} or @samp{cS} is present. - -@table @samp -@item sf -@kindex sf -String of commands to scroll the screen one line up, assuming it is -output with the cursor at the beginning of the bottom line. - -@item sr -@kindex sr -String of commands to scroll the screen one line down, assuming it is -output with the cursor at the beginning of the top line. - -@item do -A few programs will try to use @samp{do} to do the work of @samp{sf}. -This is not really correct---it is an attempt to compensate for the -absence of a @samp{sf} command in some old terminal descriptions. - -Since these terminal descriptions do define @samp{sr}, perhaps at one -time the definition of @samp{do} was different and it could be used -for scrolling as well. But it isn't desirable to combine these two -functions in one capability, since scrolling often requires more -padding than simply moving the cursor down. Defining @samp{sf} and -@samp{do} separately allows you to specify the padding properly. -Also, all sources agree that @samp{do} should not be relied on to do -scrolling. - -So the best approach is to add @samp{sf} capabilities to the -descriptions of these terminals, copying the definition of @samp{do} -if that does scroll. - -@item SF -@kindex SF -String of commands to scroll the screen @var{n} lines up, assuming it -is output with the cursor at the beginning of the bottom line. - -@item SR -@kindex SR -String of commands to scroll the screen @var{n} lines down, assuming it -is output with the cursor at the beginning of the top line. - -@item cs -@kindex cs -String of commands to set the scroll region. This command takes two -parameters, @var{start} and @var{end}, which are the line numbers -(origin-zero) of the first line to include in the scroll region and of -the last line to include in it. When a scroll region is set, -scrolling is limited to the specified range of lines; lines outside -the range are not affected by scroll commands. - -Do not try to move the cursor outside the scroll region. The region -remains set until explicitly removed. To remove the scroll region, -use another @samp{cs} command specifying the full height of the -screen. - -The cursor position is undefined after the @samp{cs} command is set, -so position the cursor with @samp{cm} immediately afterward. - -@item cS -@kindex cS -String of commands to set the scroll region using parameters in -different form. The effect is the same as if @samp{cs} were used. -Four parameters are required: - -@enumerate -@item -Total number of lines on the screen. -@item -Number of lines above desired scroll region. -@item -Number of lines below (outside of) desired scroll region. -@item -Total number of lines on the screen, the same as the first parameter. -@end enumerate - -This capability is a GNU extension that was invented to allow the Ann -Arbor Ambassador's scroll-region command to be described; it could -also be done by putting non-Unix @samp{%}-sequences into a @samp{cs} -string, but that would have confused Unix programs that used the -@samp{cs} capability with the Unix termcap. Currently only GNU Emacs -uses the @samp{cS} capability. - -@item ns -@kindex ns -Flag which means that the terminal does not normally scroll for -ordinary sequential output. For modern terminals, this means that -outputting a newline in ordinary sequential output with the cursor on -the bottom line wraps to the top line. For some obsolete terminals, -other things may happen. - -The terminal may be able to scroll even if it does not normally do so. -If the @samp{sf} capability is provided, it can be used for scrolling -regardless of @samp{ns}. - -@item da -@kindex da -Flag whose presence means that lines scrolled up off the top of the -screen may come back if scrolling down is done subsequently. - -The @samp{da} and @samp{db} flags do not, strictly speaking, affect -how to scroll. But programs that scroll usually need to clear the -lines scrolled onto the screen, if these flags are present. - -@item db -@kindex db -Flag whose presence means that lines scrolled down off the bottom of -the screen may come back if scrolling up is done subsequently. - -@item lm -@kindex lm -Numeric value, the number of lines of display memory that the terminal -has. A value of zero means that the terminal has more display memory -than can fit on the screen, but no fixed number of lines. (The number -of lines may depend on the amount of text in each line.) -@end table - -Any terminal description that defines @samp{SF} should also define @samp{sf}; -likewise for @samp{SR} and @samp{sr}. However, many terminals can only -scroll by one line at a time, so it is common to find @samp{sf} and not -@samp{SF}, or @samp{sr} without @samp{SR}.@refill - -Therefore, all programs that use the scrolling facilities should be -prepared to work with @samp{sf} in the case that @samp{SF} is absent, and -likewise with @samp{sr}. On the other hand, an application program that -uses only @samp{sf} and not @samp{SF} is acceptable, though slow on some -terminals.@refill - -When outputting a scroll command with @code{tputs}, the @var{nlines} -argument should be the total number of lines in the portion of the screen -being scrolled. Very often these commands require padding proportional to -this number of lines. @xref{Padding}. - -@node Windows, Clearing, Scrolling, Capabilities -@section Windows -@cindex window - -A @dfn{window}, in termcap, is a rectangular portion of the screen to which -all display operations are restricted. Wrapping, clearing, scrolling, -insertion and deletion all operate as if the specified window were all the -screen there was. - -@table @samp -@item wi -@kindex wi -String of commands to set the terminal output screen window. -This string requires four parameters, all origin-zero: -@enumerate -@item -The first line to include in the window. -@item -The last line to include in the window. -@item -The first column to include in the window. -@item -The last column to include in the window. -@end enumerate -@end table - -Most terminals do not support windows. - -@node Clearing, Insdel Line, Windows, Capabilities -@section Clearing Parts of the Screen -@cindex erasing -@cindex clearing the screen - -There are several terminal capabilities for clearing parts of the screen -to blank. All display terminals support the @samp{cl} string, and most -display terminals support all of these capabilities. - -@table @samp -@item cl -@kindex cl -String of commands to clear the entire screen and position the cursor -at the upper left corner. - -@item cd -@kindex cd -String of commands to clear the line the cursor is on, and all the -lines below it, down to the bottom of the screen. This command string -should be used only with the cursor in column zero; their effect is -undefined if the cursor is elsewhere. - -@item ce -@kindex ce -String of commands to clear from the cursor to the end of the current -line. - -@item ec -@kindex ec -String of commands to clear @var{n} characters, starting with the -character that the cursor is on. This command string is expected to -leave the cursor position unchanged. The parameter @var{n} should never -be large enough to reach past the right margin; the effect of such a -large parameter would be undefined. -@end table - -Clear to end of line (@samp{ce}) is extremely important in programs that -maintain an updating display. Nearly all display terminals support this -operation, so it is acceptable for a an application program to refuse to -work if @samp{ce} is not present. However, if you do not want this -limitation, you can accomplish clearing to end of line by outputting spaces -until you reach the right margin. In order to do this, you must know the -current horizontal position. Also, this technique assumes that writing a -space will erase. But this happens to be true on all the display terminals -that fail to support @samp{ce}. - -@node Insdel Line, Insdel Char, Clearing, Capabilities -@section Insert/Delete Line - -@cindex insert line -@cindex delete line -@dfn{Inserting a line} means creating a blank line in the middle -of the screen, and pushing the existing lines of text apart. In fact, -the lines above the insertion point do not change, while the lines below -move down, and one is normally lost at the bottom of the screen. - -@dfn{Deleting a line} means causing the line to disappear from the screen, -closing up the gap by moving the lines below it upward. A new line -appears at the bottom of the screen. Usually this line is blank, but -on terminals with the @samp{db} flag it may be a line previously moved -off the screen bottom by scrolling or line insertion. - -Insertion and deletion of lines is useful in programs that maintain an -updating display some parts of which may get longer or shorter. They are -also useful in editors for scrolling parts of the screen, and for -redisplaying after lines of text are killed or inserted. - -Many terminals provide commands to insert or delete a single line at the -cursor position. Some provide the ability to insert or delete several -lines with one command, using the number of lines to insert or delete as a -parameter. Always move the cursor to column zero before using any of -these commands. - -@table @samp -@item al -@kindex al -String of commands to insert a blank line before the line the cursor -is on. The existing line, and all lines below it, are moved down. -The last line in the screen (or in the scroll region, if one is set) -disappears and in most circumstances is discarded. It may not be -discarded if the @samp{db} is present (@pxref{Scrolling}). - -The cursor must be at the left margin before this command is used. -This command does not move the cursor. - -@item dl -@kindex dl -String of commands to delete the line the cursor is on. The following -lines move up, and a blank line appears at the bottom of the screen -(or bottom of the scroll region). If the terminal has the @samp{db} -flag, a nonblank line previously pushed off the screen bottom may -reappear at the bottom. - -The cursor must be at the left margin before this command is used. -This command does not move the cursor. - -@item AL -@kindex AL -String of commands to insert @var{n} blank lines before the line that -the cursor is on. It is like @samp{al} repeated @var{n} times, except -that it is as fast as one @samp{al}. - -@item DL -@kindex DL -String of commands to delete @var{n} lines starting with the line that -the cursor is on. It is like @samp{dl} repeated @var{n} times, except -that it is as fast as one @samp{dl}. -@end table - -Any terminal description that defines @samp{AL} should also define -@samp{al}; likewise for @samp{DL} and @samp{dl}. However, many terminals -can only insert or delete one line at a time, so it is common to find -@samp{al} and not @samp{AL}, or @samp{dl} without @samp{DL}.@refill - -Therefore, all programs that use the insert and delete facilities should be -prepared to work with @samp{al} in the case that @samp{AL} is absent, and -likewise with @samp{dl}. On the other hand, it is acceptable to write -an application that uses only @samp{al} and @samp{dl} and does not look -for @samp{AL} or @samp{DL} at all.@refill - -If a terminal does not support line insertion and deletion directly, -but does support a scroll region, the effect of insertion and deletion -can be obtained with scrolling. However, it is up to the individual -user program to check for this possibility and use the scrolling -commands to get the desired result. It is fairly important to implement -this alternate strategy, since it is the only way to get the effect of -line insertion and deletion on the popular VT100 terminal. - -Insertion and deletion of lines is affected by the scroll region on -terminals that have a settable scroll region. This is useful when it is -desirable to move any few consecutive lines up or down by a few lines. -@xref{Scrolling}. - -The line pushed off the bottom of the screen is not lost if the terminal -has the @samp{db} flag capability; instead, it is pushed into display -memory that does not appear on the screen. This is the same thing that -happens when scrolling pushes a line off the bottom of the screen. -Either reverse scrolling or deletion of a line can bring the apparently -lost line back onto the bottom of the screen. If the terminal has the -scroll region feature as well as @samp{db}, the pushed-out line really -is lost if a scroll region is in effect. - -When outputting an insert or delete command with @code{tputs}, the -@var{nlines} argument should be the total number of lines from the cursor -to the bottom of the screen (or scroll region). Very often these commands -require padding proportional to this number of lines. @xref{Padding}. - -For @samp{AL} and @samp{DL} the @var{nlines} argument should @emph{not} -depend on the number of lines inserted or deleted; only the total number of -lines affected. This is because it is just as fast to insert two or -@var{n} lines with @samp{AL} as to insert one line with @samp{al}. - -@node Insdel Char, Standout, Insdel Line, Capabilities -@section Insert/Delete Character -@cindex insert character -@cindex delete character - -@dfn{Inserting a character} means creating a blank space in the middle of a -line, and pushing the rest of the line rightward. The character in the -rightmost column is lost. - -@dfn{Deleting a character} means causing the character to disappear from -the screen, closing up the gap by moving the rest of the line leftward. A -blank space appears in the rightmost column. - -Insertion and deletion of characters is useful in programs that maintain an -updating display some parts of which may get longer or shorter. It is also -useful in editors for redisplaying the results of editing within a line. - -Many terminals provide commands to insert or delete a single character at -the cursor position. Some provide the ability to insert or delete several -characters with one command, using the number of characters to insert or -delete as a parameter. - -@cindex insert mode -Many terminals provide an insert mode in which outputting a graphic -character has the added effect of inserting a position for that character. -A special command string is used to enter insert mode and another is used -to exit it. The reason for designing a terminal with an insert mode rather -than an insert command is that inserting character positions is usually -followed by writing characters into them. With insert mode, this is as -fast as simply writing the characters, except for the fixed overhead of -entering and leaving insert mode. However, when the line speed is great -enough, padding may be required for the graphic characters output in insert -mode. - -Some terminals require you to enter insert mode and then output a special -command for each position to be inserted. Or they may require special -commands to be output before or after each graphic character to be -inserted. - -@cindex delete mode -Deletion of characters is usually accomplished by a straightforward command -to delete one or several positions; but on some terminals, it is necessary -to enter a special delete mode before using the delete command, and leave -delete mode afterward. Sometimes delete mode and insert mode are the same -mode. - -Some terminals make a distinction between character positions in which a -space character has been output and positions which have been cleared. On -these terminals, the effect of insert or delete character runs to the first -cleared position rather than to the end of the line. In fact, the effect -may run to more than one line if there is no cleared position to stop the -shift on the first line. These terminals are identified by the @samp{in} -flag capability. - -On terminals with the @samp{in} flag, the technique of skipping over -characters that you know were cleared, and then outputting text later on in -the same line, causes later insert and delete character operations on that -line to do nonstandard things. A program that has any chance of doing this -must check for the @samp{in} flag and must be careful to write explicit -space characters into the intermediate columns when @samp{in} is present. - -A plethora of terminal capabilities are needed to describe all of this -complexity. Here is a list of them all. Following the list, we present -an algorithm for programs to use to take proper account of all of these -capabilities. - -@table @samp -@item im -@kindex im -String of commands to enter insert mode. - -If the terminal has no special insert mode, but it can insert -characters with a special command, @samp{im} should be defined with a -null value, because the @samp{vi} editor assumes that insertion of a -character is impossible if @samp{im} is not provided. - -New programs should not act like @samp{vi}. They should pay attention -to @samp{im} only if it is defined. - -@item ei -@kindex ei -String of commands to leave insert mode. This capability must be -present if @samp{im} is. - -On a few old terminals the same string is used to enter and exit -insert mode. This string turns insert mode on if it was off, and off -it it was on. You can tell these terminals because the @samp{ei} -string equals the @samp{im} string. If you want to support these -terminals, you must always remember accurately whether insert mode is -in effect. However, these terminals are obsolete, and it is -reasonable to refuse to support them. On all modern terminals, you -can safely output @samp{ei} at any time to ensure that insert mode is -turned off. - -@item ic -@kindex ic -String of commands to insert one character position at the cursor. -The cursor does not move. - -If outputting a graphic character while in insert mode is sufficient -to insert the character, then the @samp{ic} capability should be -defined with a null value. - -If your terminal offers a choice of ways to insert---either use insert -mode or use a special command---then define @samp{im} and do not define -@samp{ic}, since this gives the most efficient operation when several -characters are to be inserted. @emph{Do not} define both strings, for -that means that @emph{both} must be used each time insertion is done. - -@item ip -@kindex ip -String of commands to output following an inserted graphic character -in insert mode. Often it is used just for a padding spec, when padding -is needed after an inserted character (@pxref{Padding}). - -@item IC -@kindex IC -String of commands to insert @var{n} character positions at and after -the cursor. It has the same effect as repeating the @samp{ic} string -and a space, @var{n} times. - -If @samp{IC} is provided, application programs may use it without first -entering insert mode. - -@item mi -@kindex mi -Flag whose presence means it is safe to move the cursor while in insert -mode and assume the terminal remains in insert mode. - -@item in -@kindex in -Flag whose presence means that the terminal distinguishes between -character positions in which space characters have been output and -positions which have been cleared. -@end table - -An application program can assume that the terminal can do character -insertion if @emph{any one of} the capabilities @samp{IC}, @samp{im}, -@samp{ic} or @samp{ip} is provided. - -To insert @var{n} blank character positions, move the cursor to the place -to insert them and follow this algorithm: - -@enumerate -@item -If an @samp{IC} string is provided, output it with parameter @var{n} -and you are finished. Otherwise (or if you don't want to bother to -look for an @samp{IC} string) follow the remaining steps. - -@item -Output the @samp{im} string, if there is one, unless the terminal is -already in insert mode. - -@item -Repeat steps 4 through 6, @var{n} times. - -@item -Output the @samp{ic} string if any. - -@item -Output a space. - -@item -Output the @samp{ip} string if any. - -@item -Output the @samp{ei} string, eventually, to exit insert mode. There -is no need to do this right away. If the @samp{mi} flag is present, -you can move the cursor and the cursor will remain in insert mode; -then you can do more insertion elsewhere without reentering insert -mode. -@end enumerate - -To insert @var{n} graphic characters, position the cursor and follow this -algorithm: - -@enumerate -@item -If an @samp{IC} string is provided, output it with parameter @var{n}, -then output the graphic characters, and you are finished. Otherwise -(or if you don't want to bother to look for an @samp{IC} string) -follow the remaining steps. - -@item -Output the @samp{im} string, if there is one, unless the terminal is -already in insert mode. - -@item -For each character to be output, repeat steps 4 through 6. - -@item -Output the @samp{ic} string if any. - -@item -Output the next graphic character. - -@item -Output the @samp{ip} string if any. - -@item -Output the @samp{ei} string, eventually, to exit insert mode. There -is no need to do this right away. If the @samp{mi} flag is present, -you can move the cursor and the cursor will remain in insert mode; -then you can do more insertion elsewhere without reentering insert -mode. -@end enumerate - -Note that this is not the same as the original Unix termcap specifications -in one respect: it assumes that the @samp{IC} string can be used without -entering insert mode. This is true as far as I know, and it allows you be -able to avoid entering and leaving insert mode, and also to be able to -avoid the inserted-character padding after the characters that go into the -inserted positions. - -Deletion of characters is less complicated; deleting one column is done by -outputting the @samp{dc} string. However, there may be a delete mode that -must be entered with @samp{dm} in order to make @samp{dc} work. - -@table @samp -@item dc -@kindex dc -String of commands to delete one character position at the cursor. If -@samp{dc} is not present, the terminal cannot delete characters. - -@item DC -@kindex DC -String of commands to delete @var{n} characters starting at the cursor. -It has the same effect as repeating the @samp{dc} string @var{n} times. -Any terminal description that has @samp{DC} also has @samp{dc}. - -@item dm -@kindex dm -String of commands to enter delete mode. If not present, there is no -delete mode, and @samp{dc} can be used at any time (assuming there is -a @samp{dc}). - -@item ed -@kindex ed -String of commands to exit delete mode. This must be present if -@samp{dm} is. -@end table - -To delete @var{n} character positions, position the cursor and follow these -steps: - -@enumerate -@item -If the @samp{DC} string is present, output it with parameter @var{n} -and you are finished. Otherwise, follow the remaining steps. - -@item -Output the @samp{dm} string, unless you know the terminal is already -in delete mode. - -@item -Output the @samp{dc} string @var{n} times. - -@item -Output the @samp{ed} string eventually. If the flag capability -@samp{mi} is present, you can move the cursor and do more deletion -without leaving and reentering delete mode. -@end enumerate - -As with the @samp{IC} string, we have departed from the original termcap -specifications by assuming that @samp{DC} works without entering delete -mode even though @samp{dc} would not. - -If the @samp{dm} and @samp{im} capabilities are both present and have the -same value, it means that the terminal has one mode for both insertion and -deletion. It is useful for a program to know this, because then it can do -insertions after deletions, or vice versa, without leaving insert/delete -mode and reentering it. - -@node Standout, Underlining, Insdel Char, Capabilities -@section Standout and Appearance Modes -@cindex appearance modes -@cindex standout -@cindex magic cookie - -@dfn{Appearance modes} are modifications to the ways characters are -displayed. Typical appearance modes include reverse video, dim, bright, -blinking, underlined, invisible, and alternate character set. Each kind of -terminal supports various among these, or perhaps none. - -For each type of terminal, one appearance mode or combination of them that -looks good for highlighted text is chosen as the @dfn{standout mode}. The -capabilities @samp{so} and @samp{se} say how to enter and leave standout -mode. Programs that use appearance modes only to highlight some text -generally use the standout mode so that they can work on as many terminals -as possible. Use of specific appearance modes other than ``underlined'' -and ``alternate character set'' is rare. - -Terminals that implement appearance modes fall into two general classes as -to how they do it. - -In some terminals, the presence or absence of any appearance mode is -recorded separately for each character position. In these terminals, each -graphic character written is given the appearance modes current at the time -it is written, and keeps those modes until it is erased or overwritten. -There are special commands to turn the appearance modes on or off for -characters to be written in the future. - -In other terminals, the change of appearance modes is represented by a -marker that belongs to a certain screen position but affects all following -screen positions until the next marker. These markers are traditionally -called @dfn{magic cookies}. - -The same capabilities (@samp{so}, @samp{se}, @samp{mb} and so on) for -turning appearance modes on and off are used for both magic-cookie -terminals and per-character terminals. On magic cookie terminals, these -give the commands to write the magic cookies. On per-character terminals, -they change the current modes that affect future output and erasure. Some -simple applications can use these commands without knowing whether or not -they work by means of cookies. - -However, a program that maintains and updates a display needs to know -whether the terminal uses magic cookies, and exactly what their effect is. -This information comes from the @samp{sg} capability. - -The @samp{sg} capability is a numeric capability whose presence indicates -that the terminal uses magic cookies for appearance modes. Its value is -the number of character positions that a magic cookie occupies. Usually -the cookie occupies one or more character positions on the screen, and these -character positions are displayed as blank, but in some terminals the -cookie has zero width. - -The @samp{sg} capability describes both the magic cookie to turn standout -on and the cookie to turn it off. This makes the assumption that both -kinds of cookie have the same width on the screen. If that is not true, -the narrower cookie must be ``widened'' with spaces until it has the same -width as the other. - -On some magic cookie terminals, each line always starts with normal -display; in other words, the scope of a magic cookie never extends over -more than one line. But on other terminals, one magic cookie affects all -the lines below it unless explicitly canceled. Termcap does not define any -way to distinguish these two ways magic cookies can work. To be safe, it -is best to put a cookie at the beginning of each line. - -On some per-character terminals, standout mode or other appearance modes -may be canceled by moving the cursor. On others, moving the cursor has no -effect on the state of the appearance modes. The latter class of terminals -are given the flag capability @samp{ms} (``can move in standout''). All -programs that might have occasion to move the cursor while appearance modes -are turned on must check for this flag; if it is not present, they should -reset appearance modes to normal before doing cursor motion. - -A program that has turned on only standout mode should use @samp{se} to -reset the standout mode to normal. A program that has turned on only -alternate character set mode should use @samp{ae} to return it to normal. -If it is possible that any other appearance modes are turned on, use the -@samp{me} capability to return them to normal. - -Note that the commands to turn on one appearance mode, including @samp{so} -and @samp{mb} @dots{} @samp{mr}, if used while some other appearance modes -are turned on, may combine the two modes on some terminals but may turn off -the mode previously enabled on other terminals. This is because some -terminals do not have a command to set or clear one appearance mode without -changing the others. Programs should not attempt to use appearance modes -in combination except with @samp{sa}, and when switching from one single -mode to another should always turn off the previously enabled mode and then -turn on the new desired mode. - -On some old terminals, the @samp{so} and @samp{se} commands may be the same -command, which has the effect of turning standout on if it is off, or off -it is on. It is therefore risky for a program to output extra @samp{se} -commands for good measure. Fortunately, all these terminals are obsolete. - -Programs that update displays in which standout-text may be replaced with -non-standout text must check for the @samp{xs} flag. In a per-character -terminal, this flag says that the only way to remove standout once written is -to clear that portion of the line with the @samp{ce} string or something -even more powerful (@pxref{Clearing}); just writing new characters at those -screen positions will not change the modes in effect there. In a magic -cookie terminal, @samp{xs} says that the only way to remove a cookie is to -clear a portion of the line that includes the cookie; writing a different -cookie at the same position does not work. - -Such programs must also check for the @samp{xt} flag, which means that the -terminal is a Teleray 1061. On this terminal it is impossible to position -the cursor at the front of a magic cookie, so the only two ways to remove a -cookie are (1) to delete the line it is on or (2) to position the cursor at -least one character before it (possibly on a previous line) and output the -@samp{se} string, which on these terminals finds and removes the next -@samp{so} magic cookie on the screen. (It may also be possible to remove a -cookie which is not at the beginning of a line by clearing that line.) The -@samp{xt} capability also has implications for the use of tab characters, -but in that regard it is obsolete (@xref{Cursor Motion}). - -@table @samp -@item so -@kindex so -String of commands to enter standout mode. - -@item se -@kindex se -String of commands to leave standout mode. - -@item sg -@kindex sg -Numeric capability, the width on the screen of the magic cookie. This -capability is absent in terminals that record appearance modes -character by character. - -@item ms -@kindex ms -Flag whose presence means that it is safe to move the cursor while the -appearance modes are not in the normal state. If this flag is absent, -programs should always reset the appearance modes to normal before -moving the cursor. - -@item xs -@kindex xs -Flag whose presence means that the only way to reset appearance modes -already on the screen is to clear to end of line. On a per-character -terminal, you must clear the area where the modes are set. On a magic -cookie terminal, you must clear an area containing the cookie. -See the discussion above. - -@item xt -@kindex xt -Flag whose presence means that the cursor cannot be positioned right -in front of a magic cookie, and that @samp{se} is a command to delete -the next magic cookie following the cursor. See discussion above. - -@item mb -@kindex mb -String of commands to enter blinking mode. - -@item md -@kindex md -String of commands to enter double-bright mode. - -@item mh -@kindex mh -String of commands to enter half-bright mode. - -@item mk -@kindex mk -String of commands to enter invisible mode. - -@item mp -@kindex mp -String of commands to enter protected mode. - -@item mr -@kindex mr -String of commands to enter reverse-video mode. - -@item me -@kindex me -String of commands to turn off all appearance modes, including -standout mode and underline mode. On some terminals it also turns off -alternate character set mode; on others, it may not. This capability -must be present if any of @samp{mb} @dots{} @samp{mr} is present. - -@item as -@kindex as -String of commands to turn on alternate character set mode. This mode -assigns some or all graphic characters an alternate picture on the -screen. There is no standard as to what the alternate pictures look -like. - -@item ae -@kindex ae -String of commands to turn off alternate character set mode. - -@item sa -@kindex sa -String of commands to turn on an arbitrary combination of appearance -modes. It accepts 9 parameters, each of which controls a particular -kind of appearance mode. A parameter should be 1 to turn its appearance -mode on, or zero to turn that mode off. Most terminals do not support -the @samp{sa} capability, even among those that do have various -appearance modes. - -The nine parameters are, in order, @var{standout}, @var{underline}, -@var{reverse}, @var{blink}, @var{half-bright}, @var{double-bright}, -@var{blank}, @var{protect}, @var{alt char set}. -@end table - -@node Underlining, Cursor Visibility, Standout, Capabilities -@section Underlining -@cindex underlining - -Underlining on most terminals is a kind of appearance mode, much like -standout mode. Therefore, it may be implemented using magic cookies or as -a flag in the terminal whose current state affects each character that is -output. @xref{Standout}, for a full explanation. - -The @samp{ug} capability is a numeric capability whose presence indicates -that the terminal uses magic cookies for underlining. Its value is the -number of character positions that a magic cookie for underlining occupies; -it is used for underlining just as @samp{sg} is used for standout. Aside -from the simplest applications, it is impossible to use underlining -correctly without paying attention to the value of @samp{ug}. - -@table @samp -@item us -@kindex us -String of commands to turn on underline mode or to output a magic cookie -to start underlining. - -@item ue -@kindex ue -String of commands to turn off underline mode or to output a magic -cookie to stop underlining. - -@item ug -@kindex ug -Width of magic cookie that represents a change of underline mode; -or missing, if the terminal does not use a magic cookie for this. - -@item ms -@kindex ms -Flag whose presence means that it is safe to move the cursor while the -appearance modes are not in the normal state. Underlining is an -appearance mode. If this flag is absent, programs should always turn -off underlining before moving the cursor. -@end table - -There are two other, older ways of doing underlining: there can be a -command to underline a single character, or the output of @samp{_}, the -ASCII underscore character, as an overstrike could cause a character to be -underlined. New programs need not bother to handle these capabilities -unless the author cares strongly about the obscure terminals which support -them. However, terminal descriptions should provide these capabilities -when appropriate. - -@table @samp -@item uc -@kindex uc -String of commands to underline the character under the cursor, and -move the cursor right. - -@item ul -@kindex ul -Flag whose presence means that the terminal can underline by -overstriking an underscore character (@samp{_}); some terminals can do -this even though they do not support overstriking in general. An -implication of this flag is that when outputting new text to overwrite -old text, underscore characters must be treated specially lest they -underline the old text instead. -@end table - -@node Cursor Visibility, Bell, Underlining, Capabilities -@section Cursor Visibility -@cindex visibility - -Some terminals have the ability to make the cursor invisible, or to enhance -it. Enhancing the cursor is often done by programs that plan to use the -cursor to indicate to the user a position of interest that may be anywhere -on the screen---for example, the Emacs editor enhances the cursor on entry. -Such programs should always restore the cursor to normal on exit. - -@table @samp -@item vs -@kindex vs -String of commands to enhance the cursor. - -@item vi -@kindex vi -String of commands to make the cursor invisible. - -@item ve -@kindex ve -String of commands to return the cursor to normal. -@end table - -If you define either @samp{vs} or @samp{vi}, you must also define @samp{ve}. - -@node Bell, Keypad, Cursor Visibility, Capabilities -@section Bell -@cindex bell -@cindex visible bell - -Here we describe commands to make the terminal ask for the user to pay -attention to it. - -@table @samp -@item bl -@kindex bl -String of commands to cause the terminal to make an audible sound. If -this capability is absent, the terminal has no way to make a suitable -sound. - -@item vb -@kindex vb -String of commands to cause the screen to flash to attract attention -(``visible bell''). If this capability is absent, the terminal has no -way to do such a thing. -@end table - -@node Keypad, Meta Key, Bell, Capabilities -@section Keypad and Function Keys - -Many terminals have arrow and function keys that transmit specific -character sequences to the computer. Since the precise sequences used -depend on the terminal, termcap defines capabilities used to say what the -sequences are. Unlike most termcap string-valued capabilities, these are -not strings of commands to be sent to the terminal, rather strings that -are received from the terminal. - -Programs that expect to use keypad keys should check, initially, for a -@samp{ks} capability and send it, to make the keypad actually transmit. -Such programs should also send the @samp{ke} string when exiting. - -@table @asis -@item @samp{ks} -@kindex ka@dots{}ku -String of commands to make the keypad keys transmit. If this -capability is not provided, but the others in this section are, -programs may assume that the keypad keys always transmit. - -@item @samp{ke} -String of commands to make the keypad keys work locally. This -capability is provided only if @samp{ks} is. - -@item @samp{kl} -String of input characters sent by typing the left-arrow key. If this -capability is missing, you cannot expect the terminal to have a -left-arrow key that transmits anything to the computer. - -@item @samp{kr} -String of input characters sent by typing the right-arrow key. - -@item @samp{ku} -String of input characters sent by typing the up-arrow key. - -@item @samp{kd} -String of input characters sent by typing the down-arrow key. - -@item @samp{kh} -String of input characters sent by typing the ``home-position'' key. - -@item @samp{K1} @dots{} @samp{K5} -@kindex K1@dots{}K5 -Strings of input characters sent by the five other keys in a 3-by-3 -array that includes the arrow keys, if the keyboard has such a 3-by-3 -array. Note that one of these keys may be the ``home-position'' key, -in which case one of these capabilities will have the same value as -the @samp{kh} key. - -@item @samp{k0} -String of input characters sent by function key 10 (or 0, if the terminal -has one labeled 0). - -@item @samp{k1} @dots{} @samp{k9} -@kindex k1@dots{}k9 -Strings of input characters sent by function keys 1 through 9, -provided for those function keys that exist. - -@item @samp{kn} -Number: the number of numbered function keys, if there are more than -10. - -@item @samp{l0} @dots{} @samp{l9} -@kindex l0@dots{}l9 -Strings which are the labels appearing on the keyboard on the keys -described by the capabilities @samp{k0} @dots{} @samp{l9}. These -capabilities should be left undefined if the labels are @samp{f0} or -@samp{f10} and @samp{f1} @dots{} @samp{f9}.@refill - -@item @samp{kH} -@kindex kA@dots{}kT -String of input characters sent by the ``home down'' key, if there is -one. - -@item @samp{kb} -String of input characters sent by the ``backspace'' key, if there is -one. - -@item @samp{ka} -String of input characters sent by the ``clear all tabs'' key, if there -is one. - -@item @samp{kt} -String of input characters sent by the ``clear tab stop this column'' -key, if there is one. - -@item @samp{kC} -String of input characters sent by the ``clear screen'' key, if there is -one. - -@item @samp{kD} -String of input characters sent by the ``delete character'' key, if -there is one. - -@item @samp{kL} -String of input characters sent by the ``delete line'' key, if there is -one. - -@item @samp{kM} -String of input characters sent by the ``exit insert mode'' key, if -there is one. - -@item @samp{kE} -String of input characters sent by the ``clear to end of line'' key, if -there is one. - -@item @samp{kS} -String of input characters sent by the ``clear to end of screen'' key, -if there is one. - -@item @samp{kI} -String of input characters sent by the ``insert character'' or ``enter -insert mode'' key, if there is one. - -@item @samp{kA} -String of input characters sent by the ``insert line'' key, if there is -one. - -@item @samp{kN} -String of input characters sent by the ``next page'' key, if there is -one. - -@item @samp{kP} -String of input characters sent by the ``previous page'' key, if there is -one. - -@item @samp{kF} -String of input characters sent by the ``scroll forward'' key, if there -is one. - -@item @samp{kR} -String of input characters sent by the ``scroll reverse'' key, if there -is one. - -@item @samp{kT} -String of input characters sent by the ``set tab stop in this column'' -key, if there is one. - -@item @samp{ko} -String listing the other function keys the terminal has. This is a -very obsolete way of describing the same information found in the -@samp{kH} @dots{} @samp{kT} keys. The string contains a list of -two-character termcap capability names, separated by commas. The -meaning is that for each capability name listed, the terminal has a -key which sends the string which is the value of that capability. For -example, the value @samp{:ko=cl,ll,sf,sr:} says that the terminal has -four function keys which mean ``clear screen'', ``home down'', -``scroll forward'' and ``scroll reverse''.@refill -@end table - -@node Meta Key, Initialization, Keypad, Capabilities -@section Meta Key - -@cindex meta key -A Meta key is a key on the keyboard that modifies each character you type -by controlling the 0200 bit. This bit is on if and only if the Meta key is -held down when the character is typed. Characters typed using the Meta key -are called Meta characters. Emacs uses Meta characters as editing -commands. - -@table @samp -@item km -@kindex km -Flag whose presence means that the terminal has a Meta key. - -@item mm -@kindex mm -String of commands to enable the functioning of the Meta key. - -@item mo -@kindex mo -String of commands to disable the functioning of the Meta key. -@end table - -If the terminal has @samp{km} but does not have @samp{mm} and @samp{mo}, it -means that the Meta key always functions. If it has @samp{mm} and -@samp{mo}, it means that the Meta key can be turned on or off. Send the -@samp{mm} string to turn it on, and the @samp{mo} string to turn it off. -I do not know why one would ever not want it to be on. - -@node Initialization, Pad Specs, Meta Key, Capabilities -@section Initialization -@cindex reset -@cindex initialization -@cindex tab stops - -@table @samp -@item ti -@kindex ti -String of commands to put the terminal into whatever special modes are -needed or appropriate for programs that move the cursor -nonsequentially around the screen. Programs that use termcap to do -full-screen display should output this string when they start up. - -@item te -@kindex te -String of commands to undo what is done by the @samp{ti} string. -Programs that output the @samp{ti} string on entry should output this -string when they exit. - -@item is -@kindex is -String of commands to initialize the terminal for each login session. - -@item if -@kindex if -String which is the name of a file containing the string of commands -to initialize the terminal for each session of use. Normally @samp{is} -and @samp{if} are not both used. - -@item i1 -@itemx i3 -@kindex i1 -@kindex i3 -Two more strings of commands to initialize the terminal for each login -session. The @samp{i1} string (if defined) is output before @samp{is} -or @samp{if}, and the @samp{i3} string (if defined) is output after. - -The reason for having three separate initialization strings is to make -it easier to define a group of related terminal types with slightly -different initializations. Define two or three of the strings in the -basic type; then the other types can override one or two of the -strings. - -@item rs -@kindex rs -String of commands to reset the terminal from any strange mode it may -be in. Normally this includes the @samp{is} string (or other commands -with the same effects) and more. What would go in the @samp{rs} -string but not in the @samp{is} string are annoying or slow commands -to bring the terminal back from strange modes that nobody would -normally use. - -@item it -@kindex it -Numeric value, the initial spacing between hardware tab stop columns -when the terminal is powered up. Programs to initialize the terminal -can use this to decide whether there is a need to set the tab stops. -If the initial width is 8, well and good; if it is not 8, then the -tab stops should be set; if they cannot be set, the kernel is told -to convert tabs to spaces, and other programs will observe this and do -likewise. - -@item ct -@kindex ct -String of commands to clear all tab stops. - -@item st -@kindex st -String of commands to set tab stop at current cursor column on all -lines. - -@item NF -@kindex NF -Flag whose presence means that the terminal does not support XON/XOFF -flow control. Programs should not send XON (@kbd{C-q}) or XOFF -(@kbd{C-s}) characters to the terminal. -@end table - -@node Pad Specs, Status Line, Initialization, Capabilities -@section Padding Capabilities -@cindex padding - -There are two terminal capabilities that exist just to explain the proper -way to obey the padding specifications in all the command string -capabilities. One, @samp{pc}, must be obeyed by all termcap-using -programs. - -@table @samp -@item pb -@kindex pb -Numeric value, the lowest baud rate at which padding is actually -needed. Programs may check this and refrain from doing any padding at -lower speeds. - -@item pc -@kindex pc -String of commands for padding. The first character of this string is -to be used as the pad character, instead of using null characters for -padding. If @samp{pc} is not provided, use null characters. Every -program that uses termcap must look up this capability and use it to -set the variable @code{PC} that is used by @code{tputs}. -@xref{Padding}. -@end table - -Some termcap capabilities exist just to specify the amount of padding that -the kernel should give to cursor motion commands used in ordinary -sequential output. - -@table @samp -@item dC -@kindex dC -Numeric value, the number of msec of padding needed for the -carriage-return character. - -@item dN -@kindex dN -Numeric value, the number of msec of padding needed for the newline -(linefeed) character. - -@item dB -@kindex dB -Numeric value, the number of msec of padding needed for the backspace -character. - -@item dF -@kindex dF -Numeric value, the number of msec of padding needed for the formfeed -character. - -@item dT -@kindex dT -Numeric value, the number of msec of padding needed for the tab -character. -@end table - -In some systems, the kernel uses the above capabilities; in other systems, -the kernel uses the paddings specified in the string capabilities -@samp{cr}, @samp{sf}, @samp{le}, @samp{ff} and @samp{ta}. Descriptions of -terminals which require such padding should contain the @samp{dC} @dots{} -@samp{dT} capabilities and also specify the appropriate padding in the -corresponding string capabilities. Since no modern terminals require -padding for ordinary sequential output, you probably won't need to do -either of these things. - -@node Status Line, Half-Line, Pad Specs, Capabilities -@section Status Line - -@cindex status line -A @dfn{status line} is a line on the terminal that is not used for ordinary -display output but instead used for a special message. The intended use is -for a continuously updated description of what the user's program is doing, -and that is where the name ``status line'' comes from, but in fact it could -be used for anything. The distinguishing characteristic of a status line -is that ordinary output to the terminal does not affect it; it changes only -if the special status line commands of this section are used. - -@table @samp -@item hs -@kindex hs -Flag whose presence means that the terminal has a status line. If a -terminal description specifies that there is a status line, it must -provide the @samp{ts} and @samp{fs} capabilities. - -@item ts -@kindex ts -String of commands to move the terminal cursor into the status line. -Usually these commands must specifically record the old cursor -position for the sake of the @samp{fs} string. - -@item fs -@kindex fs -String of commands to move the cursor back from the status line to its -previous position (outside the status line). - -@item es -@kindex es -Flag whose presence means that other display commands work while -writing the status line. In other words, one can clear parts of it, -insert or delete characters, move the cursor within it using @samp{ch} -if there is a @samp{ch} capability, enter and leave standout mode, and -so on. - -@item ds -@kindex ds -String of commands to disable the display of the status line. This -may be absent, if there is no way to disable the status line display. - -@item ws -@kindex ws -Numeric value, the width of the status line. If this capability is -absent in a terminal that has a status line, it means the status line -is the same width as the other lines. - -Note that the value of @samp{ws} is sometimes as small as 8. -@end table - -@node Half-Line, Printer, Status Line, Capabilities -@section Half-Line Motion - -Some terminals have commands for moving the cursor vertically by half-lines, -useful for outputting subscripts and superscripts. Mostly it is hardcopy -terminals that have such features. - -@table @samp -@item hu -@kindex hu -String of commands to move the cursor up half a line. If the terminal -is a display, it is your responsibility to avoid moving up past the -top line; however, most likely the terminal that supports this is a -hardcopy terminal and there is nothing to be concerned about. - -@item hd -@kindex hd -String of commands to move the cursor down half a line. If the -terminal is a display, it is your responsibility to avoid moving down -past the bottom line, etc. -@end table - -@node Printer, , Half-Line, Capabilities -@section Controlling Printers Attached to Terminals -@cindex printer - -Some terminals have attached hardcopy printer ports. They may be able to -copy the screen contents to the printer; they may also be able to redirect -output to the printer. Termcap does not have anything to tell the program -whether the redirected output appears also on the screen; it does on some -terminals but not all. - -@table @samp -@item ps -@kindex ps -String of commands to cause the contents of the screen to be printed. -If it is absent, the screen contents cannot be printed. - -@item po -@kindex po -String of commands to redirect further output to the printer. - -@item pf -@kindex pf -String of commands to terminate redirection of output to the printer. -This capability must be present in the description if @samp{po} is. - -@item pO -@kindex pO -String of commands to redirect output to the printer for next @var{n} -characters of output, regardless of what they are. Redirection will -end automatically after @var{n} characters of further output. Until -then, nothing that is output can end redirection, not even the -@samp{pf} string if there is one. The number @var{n} should not be -more than 255. - -One use of this capability is to send non-text byte sequences (such as -bit-maps) to the printer. -@end table - -Most terminals with printers do not support all of @samp{ps}, @samp{po} and -@samp{pO}; any one or two of them may be supported. To make a program that -can send output to all kinds of printers, it is necessary to check for all -three of these capabilities, choose the most convenient of the ones that -are provided, and use it in its own appropriate fashion. - -@node Summary, Var Index, Capabilities, Top -@chapter Summary of Capability Names - -Here are all the terminal capability names in alphabetical order -with a brief description of each. For cross references to their definitions, -see the index of capability names (@pxref{Cap Index}). - -@table @samp -@item ae -String to turn off alternate character set mode. -@item al -String to insert a blank line before the cursor. -@item AL -String to insert @var{n} blank lines before the cursor. -@item am -Flag: output to last column wraps cursor to next line. -@item as -String to turn on alternate character set mode.like. -@item bc -Very obsolete alternative name for the @samp{le} capability. -@item bl -String to sound the bell. -@item bs -Obsolete flag: ASCII backspace may be used for leftward motion. -@item bt -String to move the cursor left to the previous hardware tab stop column. -@item bw -Flag: @samp{le} at left margin wraps to end of previous line. -@item CC -String to change terminal's command character. -@item cd -String to clear the line the cursor is on, and following lines. -@item ce -String to clear from the cursor to the end of the line. -@item ch -String to position the cursor at column @var{c} in the same line. -@item cl -String to clear the entire screen and put cursor at upper left corner. -@item cm -String to position the cursor at line @var{l}, column @var{c}. -@item CM -String to position the cursor at line @var{l}, column -@var{c}, relative to display memory. -@item co -Number: width of the screen. -@item cr -String to move cursor sideways to left margin. -@item cs -String to set the scroll region. -@item cS -Alternate form of string to set the scroll region. -@item ct -String to clear all tab stops. -@item cv -String to position the cursor at line @var{l} in the same column. -@item da -Flag: data scrolled off top of screen may be scrolled back. -@item db -Flag: data scrolled off bottom of screen may be scrolled back. -@item dB -Obsolete number: msec of padding needed for the backspace character. -@item dc -String to delete one character position at the cursor. -@item dC -Obsolete number: msec of padding needed for the carriage-return character. -@item DC -String to delete @var{n} characters starting at the cursor. -@item dF -Obsolete number: msec of padding needed for the formfeed character. -@item dl -String to delete the line the cursor is on. -@item DL -String to delete @var{n} lines starting with the cursor's line. -@item dm -String to enter delete mode. -@item dN -Obsolete number: msec of padding needed for the newline character. -@item do -String to move the cursor vertically down one line. -@item DO -String to move cursor vertically down @var{n} lines. -@item ds -String to disable the display of the status line. -@item dT -Obsolete number: msec of padding needed for the tab character. -@item ec -String of commands to clear @var{n} characters at cursor. -@item ed -String to exit delete mode. -@item ei -String to leave insert mode. -@item eo -Flag: output of a space can erase an overstrike. -@item es -Flag: other display commands work while writing the status line. -@item ff -String to advance to the next page, for a hardcopy terminal. -@item fs -String to move the cursor back from the status line to its -previous position (outside the status line). -@item gn -Flag: this terminal type is generic, not real. -@item hc -Flag: hardcopy terminal. -@item hd -String to move the cursor down half a line. -@item ho -String to position cursor at upper left corner. -@item hs -Flag: the terminal has a status line. -@item hu -String to move the cursor up half a line. -@item hz -Flag: terminal cannot accept @samp{~} as output. -@item i1 -String to initialize the terminal for each login session. -@item i3 -String to initialize the terminal for each login session. -@item ic -String to insert one character position at the cursor. -@item IC -String to insert @var{n} character positions at the cursor. -@item if -String naming a file of commands to initialize the terminal. -@item im -String to enter insert mode. -@item in -Flag: outputting a space is different from moving over empty positions. -@item ip -String to output following an inserted character in insert mode. -@item is -String to initialize the terminal for each login session. -@item it -Number: initial spacing between hardware tab stop columns. -@item k0 -String of input sent by function key 0 or 10. -@item k1 @dots{} k9 -Strings of input sent by function keys 1 through 9. -@item K1 @dots{} K5 -Strings sent by the five other keys in 3-by-3 array with arrows. -@item ka -String of input sent by the ``clear all tabs'' key. -@item kA -String of input sent by the ``insert line'' key. -@item kb -String of input sent by the ``backspace'' key. -@item kC -String of input sent by the ``clear screen'' key. -@item kd -String of input sent by typing the down-arrow key. -@item kD -String of input sent by the ``delete character'' key. -@item ke -String to make the function keys work locally. -@item kE -String of input sent by the ``clear to end of line'' key. -@item kF -String of input sent by the ``scroll forward'' key. -@item kh -String of input sent by typing the ``home-position'' key. -@item kH -String of input sent by the ``home down'' key. -@item kI -String of input sent by the ``insert character'' or ``enter -insert mode'' key. -@item kl -String of input sent by typing the left-arrow key. -@item kL -String of input sent by the ``delete line'' key. -@item km -Flag: the terminal has a Meta key. -@item kM -String of input sent by the ``exit insert mode'' key. -@item kn -Numeric value, the number of numbered function keys. -@item kN -String of input sent by the ``next page'' key. -@item ko -Very obsolete string listing the terminal's named function keys. -@item kP -String of input sent by the ``previous page'' key. -@item kr -String of input sent by typing the right-arrow key. -@item kR -String of input sent by the ``scroll reverse'' key. -@item ks -String to make the function keys transmit. -@item kS -String of input sent by the ``clear to end of screen'' key. -@item kt -String of input sent by the ``clear tab stop this column'' key. -@item kT -String of input sent by the ``set tab stop in this column'' key. -@item ku -String of input sent by typing the up-arrow key. -@item l0 -String on keyboard labelling function key 0 or 10. -@item l1 @dots{} l9 -Strings on keyboard labelling function keys 1 through 9. -@item le -String to move the cursor left one column. -@item LE -String to move cursor left @var{n} columns. -@item li -Number: height of the screen. -@item ll -String to position cursor at lower left corner. -@item lm -Number: lines of display memory. -@item LP -Flag: writing to last column of last line will not scroll. -@item mb -String to enter blinking mode. -@item md -String to enter double-bright mode. -@item me -String to turn off all appearance modes -@item mh -String to enter half-bright mode. -@item mi -Flag: cursor motion in insert mode is safe. -@item mk -String to enter invisible mode. -@item mm -String to enable the functioning of the Meta key. -@item mo -String to disable the functioning of the Meta key. -@item mp -String to enter protected mode. -@item mr -String to enter reverse-video mode. -@item ms -Flag: cursor motion in standout mode is safe. -@item nc -Obsolete flag: do not use ASCII carriage-return on this terminal. -@item nd -String to move the cursor right one column. -@item NF -Flag: do not use XON/XOFF flow control. -@item nl -Obsolete alternative name for the @samp{do} and @samp{sf} capabilities. -@item ns -Flag: the terminal does not normally scroll for sequential output. -@item nw -String to move to start of next line, possibly clearing rest of old line. -@item os -Flag: terminal can overstrike. -@item pb -Number: the lowest baud rate at which padding is actually needed. -@item pc -String containing character for padding. -@item pf -String to terminate redirection of output to the printer. -@item po -String to redirect further output to the printer. -@item pO -String to redirect @var{n} characters ofoutput to the printer. -@item ps -String to print the screen on the attached printer. -@item rc -String to move to last saved cursor position. -@item RI -String to move cursor right @var{n} columns. -@item rp -String to output character @var{c} repeated @var{n} times. -@item rs -String to reset the terminal from any strange modes. -@item sa -String to turn on an arbitrary combination of appearance modes. -@item sc -String to save the current cursor position. -@item se -String to leave standout mode. -@item sf -String to scroll the screen one line up. -@item SF -String to scroll the screen @var{n} lines up. -@item sg -Number: width of magic standout cookie. Absent if magic cookies are -not used. -@item so -String to enter standout mode. -@item sr -String to scroll the screen one line down. -@item SR -String to scroll the screen @var{n} line down. -@item st -String to set tab stop at current cursor column on all lines. -programs. -@item ta -String to move the cursor right to the next hardware tab stop column. -@item te -String to return terminal to settings for sequential output. -@item ti -String to initialize terminal for random cursor motion. -@item ts -String to move the terminal cursor into the status line. -@item uc -String to underline one character and move cursor right. -@item ue -String to turn off underline mode -@item ug -Number: width of underlining magic cookie. Absent if underlining -doesn't use magic cookies. -@item ul -Flag: underline by overstriking with an underscore. -@item up -String to move the cursor vertically up one line. -@item UP -String to move cursor vertically up @var{n} lines. -@item us -String to turn on underline mode -@item vb -String to make the screen flash. -@item ve -String to return the cursor to normal. -@item vi -String to make the cursor invisible. -@item vs -String to enhance the cursor. -@item wi -String to set the terminal output screen window. -@item ws -Number: the width of the status line. -@item xb -Flag: superbee terminal. -@item xn -Flag: cursor wraps in a strange way. -@item xs -Flag: clearing a line is the only way to clear the appearance modes of -positions in that line (or, only way to remove magic cookies on that -line). -@item xt -Flag: Teleray 1061; several strange characteristics. -@end table - -@node Var Index, Cap Index, Summary, Top -@unnumbered Variable and Function Index - -@printindex fn - -@node Cap Index, Index, Var Index, Top -@unnumbered Capability Index - -@printindex ky - -@node Index, , Cap Index, Top -@unnumbered Concept Index - -@printindex cp - -@contents -@bye diff --git a/lib/termcap/grot/texinfo.tex b/lib/termcap/grot/texinfo.tex deleted file mode 100644 index f62e9f5..0000000 --- a/lib/termcap/grot/texinfo.tex +++ /dev/null @@ -1,4422 +0,0 @@ -%% TeX macros to handle texinfo files - -% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 1994 Free Software Foundation, Inc. - -%This texinfo.tex file is free software; you can redistribute it and/or -%modify it under the terms of the GNU General Public License as -%published by the Free Software Foundation; either version 2, or (at -%your option) any later version. - -%This texinfo.tex file is distributed in the hope that it will be -%useful, but WITHOUT ANY WARRANTY; without even the implied warranty -%of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -%General Public License for more details. - -%You should have received a copy of the GNU General Public License -%along with this texinfo.tex file; see the file COPYING. If not, write -%to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, -%USA. - - -%In other words, you are welcome to use, share and improve this program. -%You are forbidden to forbid anyone else to use, share and improve -%what you give them. Help stamp out software-hoarding! - - -% Send bug reports to bug-texinfo@prep.ai.mit.edu. -% Please include a *precise* test case in each bug report. - - -% Make it possible to create a .fmt file just by loading this file: -% if the underlying format is not loaded, start by loading it now. -% Added by gildea November 1993. -\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi - -% This automatically updates the version number based on RCS. -\def\deftexinfoversion$#1: #2 ${\def\texinfoversion{#2}} -\deftexinfoversion$Revision: 2.146 $ -\message{Loading texinfo package [Version \texinfoversion]:} - -% If in a .fmt file, print the version number -% and turn on active characters that we couldn't do earlier because -% they might have appeared in the input file name. -\everyjob{\message{[Texinfo version \texinfoversion]}\message{} - \catcode`+=\active \catcode`\_=\active} - -% Save some parts of plain tex whose names we will redefine. - -\let\ptextilde=\~ -\let\ptexlbrace=\{ -\let\ptexrbrace=\} -\let\ptexdots=\dots -\let\ptexdot=\. -\let\ptexstar=\* -\let\ptexend=\end -\let\ptexbullet=\bullet -\let\ptexb=\b -\let\ptexc=\c -\let\ptexi=\i -\let\ptext=\t -\let\ptexl=\l -\let\ptexL=\L - -% Be sure we're in horizontal mode when doing a tie, since we make space -% equivalent to this in @example-like environments. Otherwise, a space -% at the beginning of a line will start with \penalty -- and -% since \penalty is valid in vertical mode, we'd end up putting the -% penalty on the vertical list instead of in the new paragraph. -{\catcode`@ = 11 - \gdef\tie{\leavevmode\penalty\@M\ } -} -\let\~ = \tie % And make it available as @~. - -\message{Basics,} -\chardef\other=12 - -% If this character appears in an error message or help string, it -% starts a new line in the output. -\newlinechar = `^^J - -% Set up fixed words for English. -\ifx\putwordChapter\undefined{\gdef\putwordChapter{Chapter}}\fi% -\def\putwordInfo{Info}% -\ifx\putwordSee\undefined{\gdef\putwordSee{See}}\fi% -\ifx\putwordsee\undefined{\gdef\putwordsee{see}}\fi% -\ifx\putwordfile\undefined{\gdef\putwordfile{file}}\fi% -\ifx\putwordpage\undefined{\gdef\putwordpage{page}}\fi% -\ifx\putwordsection\undefined{\gdef\putwordsection{section}}\fi% -\ifx\putwordSection\undefined{\gdef\putwordSection{Section}}\fi% -\ifx\putwordTableofContents\undefined{\gdef\putwordTableofContents{Table of Contents}}\fi% -\ifx\putwordShortContents\undefined{\gdef\putwordShortContents{Short Contents}}\fi% -\ifx\putwordAppendix\undefined{\gdef\putwordAppendix{Appendix}}\fi% - -% Ignore a token. -% -\def\gobble#1{} - -\hyphenation{ap-pen-dix} -\hyphenation{mini-buf-fer mini-buf-fers} -\hyphenation{eshell} - -% Margin to add to right of even pages, to left of odd pages. -\newdimen \bindingoffset \bindingoffset=0pt -\newdimen \normaloffset \normaloffset=\hoffset -\newdimen\pagewidth \newdimen\pageheight -\pagewidth=\hsize \pageheight=\vsize - -% Sometimes it is convenient to have everything in the transcript file -% and nothing on the terminal. We don't just call \tracingall here, -% since that produces some useless output on the terminal. -% -\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% -\def\loggingall{\tracingcommands2 \tracingstats2 - \tracingpages1 \tracingoutput1 \tracinglostchars1 - \tracingmacros2 \tracingparagraphs1 \tracingrestores1 - \showboxbreadth\maxdimen\showboxdepth\maxdimen -}% - -%---------------------Begin change----------------------- -% -%%%% For @cropmarks command. -% Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986 -% -\newdimen\cornerlong \newdimen\cornerthick -\newdimen \topandbottommargin -\newdimen \outerhsize \newdimen \outervsize -\cornerlong=1pc\cornerthick=.3pt % These set size of cropmarks -\outerhsize=7in -%\outervsize=9.5in -% Alternative @smallbook page size is 9.25in -\outervsize=9.25in -\topandbottommargin=.75in -% -%---------------------End change----------------------- - -% \onepageout takes a vbox as an argument. Note that \pagecontents -% does insertions itself, but you have to call it yourself. -\chardef\PAGE=255 \output={\onepageout{\pagecontents\PAGE}} -\def\onepageout#1{\hoffset=\normaloffset -\ifodd\pageno \advance\hoffset by \bindingoffset -\else \advance\hoffset by -\bindingoffset\fi -{\escapechar=`\\\relax % makes sure backslash is used in output files. -\shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}% -{\let\hsize=\pagewidth \makefootline}}}% -\advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi} - -%%%% For @cropmarks command %%%% - -% Here is a modification of the main output routine for Near East Publications -% This provides right-angle cropmarks at all four corners. -% The contents of the page are centerlined into the cropmarks, -% and any desired binding offset is added as an \hskip on either -% site of the centerlined box. (P. A. MacKay, 12 November, 1986) -% -\def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up -{\escapechar=`\\\relax % makes sure backslash is used in output files. - \shipout - \vbox to \outervsize{\hsize=\outerhsize - \vbox{\line{\ewtop\hfill\ewtop}} - \nointerlineskip - \line{\vbox{\moveleft\cornerthick\nstop} - \hfill - \vbox{\moveright\cornerthick\nstop}} - \vskip \topandbottommargin - \centerline{\ifodd\pageno\hskip\bindingoffset\fi - \vbox{ - {\let\hsize=\pagewidth \makeheadline} - \pagebody{#1} - {\let\hsize=\pagewidth \makefootline}} - \ifodd\pageno\else\hskip\bindingoffset\fi} - \vskip \topandbottommargin plus1fill minus1fill - \boxmaxdepth\cornerthick - \line{\vbox{\moveleft\cornerthick\nsbot} - \hfill - \vbox{\moveright\cornerthick\nsbot}} - \nointerlineskip - \vbox{\line{\ewbot\hfill\ewbot}} - }} - \advancepageno - \ifnum\outputpenalty>-20000 \else\dosupereject\fi} -% -% Do @cropmarks to get crop marks -\def\cropmarks{\let\onepageout=\croppageout } - -\newinsert\margin \dimen\margin=\maxdimen - -\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} -{\catcode`\@ =11 -\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi -% marginal hacks, juha@viisa.uucp (Juha Takala) -\ifvoid\margin\else % marginal info is present - \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi -\dimen@=\dp#1 \unvbox#1 -\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi -\ifr@ggedbottom \kern-\dimen@ \vfil \fi} -} - -% -% Here are the rules for the cropmarks. Note that they are -% offset so that the space between them is truly \outerhsize or \outervsize -% (P. A. MacKay, 12 November, 1986) -% -\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} -\def\nstop{\vbox - {\hrule height\cornerthick depth\cornerlong width\cornerthick}} -\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} -\def\nsbot{\vbox - {\hrule height\cornerlong depth\cornerthick width\cornerthick}} - -% Parse an argument, then pass it to #1. The argument is the rest of -% the input line (except we remove a trailing comment). #1 should be a -% macro which expects an ordinary undelimited TeX argument. -% -\def\parsearg#1{% - \let\next = #1% - \begingroup - \obeylines - \futurelet\temp\parseargx -} - -% If the next token is an obeyed space (from an @example environment or -% the like), remove it and recurse. Otherwise, we're done. -\def\parseargx{% - % \obeyedspace is defined far below, after the definition of \sepspaces. - \ifx\obeyedspace\temp - \expandafter\parseargdiscardspace - \else - \expandafter\parseargline - \fi -} - -% Remove a single space (as the delimiter token to the macro call). -{\obeyspaces % - \gdef\parseargdiscardspace {\futurelet\temp\parseargx}} - -{\obeylines % - \gdef\parseargline#1^^M{% - \endgroup % End of the group started in \parsearg. - % - % First remove any @c comment, then any @comment. - % Result of each macro is put in \toks0. - \argremovec #1\c\relax % - \expandafter\argremovecomment \the\toks0 \comment\relax % - % - % Call the caller's macro, saved as \next in \parsearg. - \expandafter\next\expandafter{\the\toks0}% - }% -} - -% Since all \c{,omment} does is throw away the argument, we can let TeX -% do that for us. The \relax here is matched by the \relax in the call -% in \parseargline; it could be more or less anything, its purpose is -% just to delimit the argument to the \c. -\def\argremovec#1\c#2\relax{\toks0 = {#1}} -\def\argremovecomment#1\comment#2\relax{\toks0 = {#1}} - -% \argremovec{,omment} might leave us with trailing spaces, though; e.g., -% @end itemize @c foo -% will have two active spaces as part of the argument with the -% `itemize'. Here we remove all active spaces from #1, and assign the -% result to \toks0. -% -% This loses if there are any *other* active characters besides spaces -% in the argument -- _ ^ +, for example -- since they get expanded. -% Fortunately, Texinfo does not define any such commands. (If it ever -% does, the catcode of the characters in questionwill have to be changed -% here.) But this means we cannot call \removeactivespaces as part of -% \argremovec{,omment}, since @c uses \parsearg, and thus the argument -% that \parsearg gets might well have any character at all in it. -% -\def\removeactivespaces#1{% - \begingroup - \ignoreactivespaces - \edef\temp{#1}% - \global\toks0 = \expandafter{\temp}% - \endgroup -} - -% Change the active space to expand to nothing. -% -\begingroup - \obeyspaces - \gdef\ignoreactivespaces{\obeyspaces\let =\empty} -\endgroup - - -\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} - -%% These are used to keep @begin/@end levels from running away -%% Call \inENV within environments (after a \begingroup) -\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi} -\def\ENVcheck{% -\ifENV\errmessage{Still within an environment. Type Return to continue.} -\endgroup\fi} % This is not perfect, but it should reduce lossage - -% @begin foo is the same as @foo, for now. -\newhelp\EMsimple{Type <Return> to continue.} - -\outer\def\begin{\parsearg\beginxxx} - -\def\beginxxx #1{% -\expandafter\ifx\csname #1\endcsname\relax -{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else -\csname #1\endcsname\fi} - -% @end foo executes the definition of \Efoo. -% -\def\end{\parsearg\endxxx} -\def\endxxx #1{% - \removeactivespaces{#1}% - \edef\endthing{\the\toks0}% - % - \expandafter\ifx\csname E\endthing\endcsname\relax - \expandafter\ifx\csname \endthing\endcsname\relax - % There's no \foo, i.e., no ``environment'' foo. - \errhelp = \EMsimple - \errmessage{Undefined command `@end \endthing'}% - \else - \unmatchedenderror\endthing - \fi - \else - % Everything's ok; the right environment has been started. - \csname E\endthing\endcsname - \fi -} - -% There is an environment #1, but it hasn't been started. Give an error. -% -\def\unmatchedenderror#1{% - \errhelp = \EMsimple - \errmessage{This `@end #1' doesn't have a matching `@#1'}% -} - -% Define the control sequence \E#1 to give an unmatched @end error. -% -\def\defineunmatchedend#1{% - \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}% -} - - -% Single-spacing is done by various environments (specifically, in -% \nonfillstart and \quotations). -\newskip\singlespaceskip \singlespaceskip = 12.5pt -\def\singlespace{% - % Why was this kern here? It messes up equalizing space above and below - % environments. --karl, 6may93 - %{\advance \baselineskip by -\singlespaceskip - %\kern \baselineskip}% - \setleading \singlespaceskip -} - -%% Simple single-character @ commands - -% @@ prints an @ -% Kludge this until the fonts are right (grr). -\def\@{{\tt \char '100}} - -% This is turned off because it was never documented -% and you can use @w{...} around a quote to suppress ligatures. -%% Define @` and @' to be the same as ` and ' -%% but suppressing ligatures. -%\def\`{{`}} -%\def\'{{'}} - -% Used to generate quoted braces. - -\def\mylbrace {{\tt \char '173}} -\def\myrbrace {{\tt \char '175}} -\let\{=\mylbrace -\let\}=\myrbrace - -% @: forces normal size whitespace following. -\def\:{\spacefactor=1000 } - -% @* forces a line break. -\def\*{\hfil\break\hbox{}\ignorespaces} - -% @. is an end-of-sentence period. -\def\.{.\spacefactor=3000 } - -% @enddots{} is an end-of-sentence ellipsis. -\gdef\enddots{$\mathinner{\ldotp\ldotp\ldotp\ldotp}$\spacefactor=3000} - -% @! is an end-of-sentence bang. -\gdef\!{!\spacefactor=3000 } - -% @? is an end-of-sentence query. -\gdef\?{?\spacefactor=3000 } - -% @w prevents a word break. Without the \leavevmode, @w at the -% beginning of a paragraph, when TeX is still in vertical mode, would -% produce a whole line of output instead of starting the paragraph. -\def\w#1{\leavevmode\hbox{#1}} - -% @group ... @end group forces ... to be all on one page, by enclosing -% it in a TeX vbox. We use \vtop instead of \vbox to construct the box -% to keep its height that of a normal line. According to the rules for -% \topskip (p.114 of the TeXbook), the glue inserted is -% max (\topskip - \ht (first item), 0). If that height is large, -% therefore, no glue is inserted, and the space between the headline and -% the text is small, which looks bad. -% -\def\group{\begingroup - \ifnum\catcode13=\active \else - \errhelp = \groupinvalidhelp - \errmessage{@group invalid in context where filling is enabled}% - \fi - % - % The \vtop we start below produces a box with normal height and large - % depth; thus, TeX puts \baselineskip glue before it, and (when the - % next line of text is done) \lineskip glue after it. (See p.82 of - % the TeXbook.) Thus, space below is not quite equal to space - % above. But it's pretty close. - \def\Egroup{% - \egroup % End the \vtop. - \endgroup % End the \group. - }% - % - \vtop\bgroup - % We have to put a strut on the last line in case the @group is in - % the midst of an example, rather than completely enclosing it. - % Otherwise, the interline space between the last line of the group - % and the first line afterwards is too small. But we can't put the - % strut in \Egroup, since there it would be on a line by itself. - % Hence this just inserts a strut at the beginning of each line. - \everypar = {\strut}% - % - % Since we have a strut on every line, we don't need any of TeX's - % normal interline spacing. - \offinterlineskip - % - % OK, but now we have to do something about blank - % lines in the input in @example-like environments, which normally - % just turn into \lisppar, which will insert no space now that we've - % turned off the interline space. Simplest is to make them be an - % empty paragraph. - \ifx\par\lisppar - \edef\par{\leavevmode \par}% - % - % Reset ^^M's definition to new definition of \par. - \obeylines - \fi - % - % Do @comment since we are called inside an environment such as - % @example, where each end-of-line in the input causes an - % end-of-line in the output. We don't want the end-of-line after - % the `@group' to put extra space in the output. Since @group - % should appear on a line by itself (according to the Texinfo - % manual), we don't worry about eating any user text. - \comment -} -% -% TeX puts in an \escapechar (i.e., `@') at the beginning of the help -% message, so this ends up printing `@group can only ...'. -% -\newhelp\groupinvalidhelp{% -group can only be used in environments such as @example,^^J% -where each line of input produces a line of output.} - -% @need space-in-mils -% forces a page break if there is not space-in-mils remaining. - -\newdimen\mil \mil=0.001in - -\def\need{\parsearg\needx} - -% Old definition--didn't work. -%\def\needx #1{\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\penalty 10000 -%\prevdepth=-1000pt -%}} - -\def\needx#1{% - % Go into vertical mode, so we don't make a big box in the middle of a - % paragraph. - \par - % - % Don't add any leading before our big empty box, but allow a page - % break, since the best break might be right here. - \allowbreak - \nointerlineskip - \vtop to #1\mil{\vfil}% - % - % TeX does not even consider page breaks if a penalty added to the - % main vertical list is 10000 or more. But in order to see if the - % empty box we just added fits on the page, we must make it consider - % page breaks. On the other hand, we don't want to actually break the - % page after the empty box. So we use a penalty of 9999. - % - % There is an extremely small chance that TeX will actually break the - % page at this \penalty, if there are no other feasible breakpoints in - % sight. (If the user is using lots of big @group commands, which - % almost-but-not-quite fill up a page, TeX will have a hard time doing - % good page breaking, for example.) However, I could not construct an - % example where a page broke at this \penalty; if it happens in a real - % document, then we can reconsider our strategy. - \penalty9999 - % - % Back up by the size of the box, whether we did a page break or not. - \kern -#1\mil - % - % Do not allow a page break right after this kern. - \nobreak -} - -% @br forces paragraph break - -\let\br = \par - -% @dots{} output some dots - -\def\dots{$\ldots$} - -% @page forces the start of a new page - -\def\page{\par\vfill\supereject} - -% @exdent text.... -% outputs text on separate line in roman font, starting at standard page margin - -% This records the amount of indent in the innermost environment. -% That's how much \exdent should take out. -\newskip\exdentamount - -% This defn is used inside fill environments such as @defun. -\def\exdent{\parsearg\exdentyyy} -\def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}} - -% This defn is used inside nofill environments such as @example. -\def\nofillexdent{\parsearg\nofillexdentyyy} -\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount -\leftline{\hskip\leftskip{\rm#1}}}} - -%\hbox{{\rm#1}}\hfil\break}} - -% @include file insert text of that file as input. - -\def\include{\parsearg\includezzz} -%Use \input\thisfile to avoid blank after \input, which may be an active -%char (in which case the blank would become the \input argument). -%The grouping keeps the value of \thisfile correct even when @include -%is nested. -\def\includezzz #1{\begingroup -\def\thisfile{#1}\input\thisfile -\endgroup} - -\def\thisfile{} - -% @center line outputs that line, centered - -\def\center{\parsearg\centerzzz} -\def\centerzzz #1{{\advance\hsize by -\leftskip -\advance\hsize by -\rightskip -\centerline{#1}}} - -% @sp n outputs n lines of vertical space - -\def\sp{\parsearg\spxxx} -\def\spxxx #1{\par \vskip #1\baselineskip} - -% @comment ...line which is ignored... -% @c is the same as @comment -% @ignore ... @end ignore is another way to write a comment - -\def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other% -\parsearg \commentxxx} - -\def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 } - -\let\c=\comment - -% Prevent errors for section commands. -% Used in @ignore and in failing conditionals. -\def\ignoresections{% -\let\chapter=\relax -\let\unnumbered=\relax -\let\top=\relax -\let\unnumberedsec=\relax -\let\unnumberedsection=\relax -\let\unnumberedsubsec=\relax -\let\unnumberedsubsection=\relax -\let\unnumberedsubsubsec=\relax -\let\unnumberedsubsubsection=\relax -\let\section=\relax -\let\subsec=\relax -\let\subsubsec=\relax -\let\subsection=\relax -\let\subsubsection=\relax -\let\appendix=\relax -\let\appendixsec=\relax -\let\appendixsection=\relax -\let\appendixsubsec=\relax -\let\appendixsubsection=\relax -\let\appendixsubsubsec=\relax -\let\appendixsubsubsection=\relax -\let\contents=\relax -\let\smallbook=\relax -\let\titlepage=\relax -} - -% Used in nested conditionals, where we have to parse the Texinfo source -% and so want to turn off most commands, in case they are used -% incorrectly. -% -\def\ignoremorecommands{% - \let\defcv = \relax - \let\deffn = \relax - \let\deffnx = \relax - \let\defindex = \relax - \let\defivar = \relax - \let\defmac = \relax - \let\defmethod = \relax - \let\defop = \relax - \let\defopt = \relax - \let\defspec = \relax - \let\deftp = \relax - \let\deftypefn = \relax - \let\deftypefun = \relax - \let\deftypevar = \relax - \let\deftypevr = \relax - \let\defun = \relax - \let\defvar = \relax - \let\defvr = \relax - \let\ref = \relax - \let\xref = \relax - \let\printindex = \relax - \let\pxref = \relax - \let\settitle = \relax - \let\include = \relax - \let\lowersections = \relax - \let\down = \relax - \let\raisesections = \relax - \let\up = \relax - \let\set = \relax - \let\clear = \relax - \let\item = \relax - \let\message = \relax -} - -% Ignore @ignore ... @end ignore. -% -\def\ignore{\doignore{ignore}} - -% Also ignore @ifinfo, @ifhtml, @html, @menu, and @direntry text. -% -\def\ifinfo{\doignore{ifinfo}} -\def\ifhtml{\doignore{ifhtml}} -\def\html{\doignore{html}} -\def\menu{\doignore{menu}} -\def\direntry{\doignore{direntry}} - -% Ignore text until a line `@end #1'. -% -\def\doignore#1{\begingroup - % Don't complain about control sequences we have declared \outer. - \ignoresections - % - % Define a command to swallow text until we reach `@end #1'. - \long\def\doignoretext##1\end #1{\enddoignore}% - % - % Make sure that spaces turn into tokens that match what \doignoretext wants. - \catcode32 = 10 - % - % And now expand that command. - \doignoretext -} - -% What we do to finish off ignored text. -% -\def\enddoignore{\endgroup\ignorespaces}% - -\newif\ifwarnedobs\warnedobsfalse -\def\obstexwarn{% - \ifwarnedobs\relax\else - % We need to warn folks that they may have trouble with TeX 3.0. - % This uses \immediate\write16 rather than \message to get newlines. - \immediate\write16{} - \immediate\write16{***WARNING*** for users of Unix TeX 3.0!} - \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).} - \immediate\write16{If you are running another version of TeX, relax.} - \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.} - \immediate\write16{ Then upgrade your TeX installation if you can.} - \immediate\write16{If you are stuck with version 3.0, run the} - \immediate\write16{ script ``tex3patch'' from the Texinfo distribution} - \immediate\write16{ to use a workaround.} - \immediate\write16{} - \warnedobstrue - \fi -} - -% **In TeX 3.0, setting text in \nullfont hangs tex. For a -% workaround (which requires the file ``dummy.tfm'' to be installed), -% uncomment the following line: -%%%%%\font\nullfont=dummy\let\obstexwarn=\relax - -% Ignore text, except that we keep track of conditional commands for -% purposes of nesting, up to an `@end #1' command. -% -\def\nestedignore#1{% - \obstexwarn - % We must actually expand the ignored text to look for the @end - % command, so that nested ignore constructs work. Thus, we put the - % text into a \vbox and then do nothing with the result. To minimize - % the change of memory overflow, we follow the approach outlined on - % page 401 of the TeXbook: make the current font be a dummy font. - % - \setbox0 = \vbox\bgroup - % Don't complain about control sequences we have declared \outer. - \ignoresections - % - % Define `@end #1' to end the box, which will in turn undefine the - % @end command again. - \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}% - % - % We are going to be parsing Texinfo commands. Most cause no - % trouble when they are used incorrectly, but some commands do - % complicated argument parsing or otherwise get confused, so we - % undefine them. - % - % We can't do anything about stray @-signs, unfortunately; - % they'll produce `undefined control sequence' errors. - \ignoremorecommands - % - % Set the current font to be \nullfont, a TeX primitive, and define - % all the font commands to also use \nullfont. We don't use - % dummy.tfm, as suggested in the TeXbook, because not all sites - % might have that installed. Therefore, math mode will still - % produce output, but that should be an extremely small amount of - % stuff compared to the main input. - % - \nullfont - \let\tenrm = \nullfont \let\tenit = \nullfont \let\tensl = \nullfont - \let\tenbf = \nullfont \let\tentt = \nullfont \let\smallcaps = \nullfont - \let\tensf = \nullfont - % Similarly for index fonts (mostly for their use in - % smallexample) - \let\indrm = \nullfont \let\indit = \nullfont \let\indsl = \nullfont - \let\indbf = \nullfont \let\indtt = \nullfont \let\indsc = \nullfont - \let\indsf = \nullfont - % - % Don't complain when characters are missing from the fonts. - \tracinglostchars = 0 - % - % Don't bother to do space factor calculations. - \frenchspacing - % - % Don't report underfull hboxes. - \hbadness = 10000 - % - % Do minimal line-breaking. - \pretolerance = 10000 - % - % Do not execute instructions in @tex - \def\tex{\doignore{tex}} -} - -% @set VAR sets the variable VAR to an empty value. -% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. -% -% Since we want to separate VAR from REST-OF-LINE (which might be -% empty), we can't just use \parsearg; we have to insert a space of our -% own to delimit the rest of the line, and then take it out again if we -% didn't need it. -% -\def\set{\parsearg\setxxx} -\def\setxxx#1{\setyyy#1 \endsetyyy} -\def\setyyy#1 #2\endsetyyy{% - \def\temp{#2}% - \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty - \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted. - \fi -} -% Can't use \xdef to pre-expand #2 and save some time, since \temp or -% \next or other control sequences that we've defined might get us into -% an infinite loop. Consider `@set foo @cite{bar}'. -\def\setzzz#1#2 \endsetzzz{\expandafter\gdef\csname SET#1\endcsname{#2}} - -% @clear VAR clears (i.e., unsets) the variable VAR. -% -\def\clear{\parsearg\clearxxx} -\def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax} - -% @value{foo} gets the text saved in variable foo. -% -\def\value#1{\expandafter - \ifx\csname SET#1\endcsname\relax - {\{No value for ``#1''\}} - \else \csname SET#1\endcsname \fi} - -% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined -% with @set. -% -\def\ifset{\parsearg\ifsetxxx} -\def\ifsetxxx #1{% - \expandafter\ifx\csname SET#1\endcsname\relax - \expandafter\ifsetfail - \else - \expandafter\ifsetsucceed - \fi -} -\def\ifsetsucceed{\conditionalsucceed{ifset}} -\def\ifsetfail{\nestedignore{ifset}} -\defineunmatchedend{ifset} - -% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been -% defined with @set, or has been undefined with @clear. -% -\def\ifclear{\parsearg\ifclearxxx} -\def\ifclearxxx #1{% - \expandafter\ifx\csname SET#1\endcsname\relax - \expandafter\ifclearsucceed - \else - \expandafter\ifclearfail - \fi -} -\def\ifclearsucceed{\conditionalsucceed{ifclear}} -\def\ifclearfail{\nestedignore{ifclear}} -\defineunmatchedend{ifclear} - -% @iftex always succeeds; we read the text following, through @end -% iftex). But `@end iftex' should be valid only after an @iftex. -% -\def\iftex{\conditionalsucceed{iftex}} -\defineunmatchedend{iftex} - -% We can't just want to start a group at @iftex (for example) and end it -% at @end iftex, since then @set commands inside the conditional have no -% effect (they'd get reverted at the end of the group). So we must -% define \Eiftex to redefine itself to be its previous value. (We can't -% just define it to fail again with an ``unmatched end'' error, since -% the @ifset might be nested.) -% -\def\conditionalsucceed#1{% - \edef\temp{% - % Remember the current value of \E#1. - \let\nece{prevE#1} = \nece{E#1}% - % - % At the `@end #1', redefine \E#1 to be its previous value. - \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}% - }% - \temp -} - -% We need to expand lots of \csname's, but we don't want to expand the -% control sequences after we've constructed them. -% -\def\nece#1{\expandafter\noexpand\csname#1\endcsname} - -% @asis just yields its argument. Used with @table, for example. -% -\def\asis#1{#1} - -% @math means output in math mode. -% We don't use $'s directly in the definition of \math because control -% sequences like \math are expanded when the toc file is written. Then, -% we read the toc file back, the $'s will be normal characters (as they -% should be, according to the definition of Texinfo). So we must use a -% control sequence to switch into and out of math mode. -% -% This isn't quite enough for @math to work properly in indices, but it -% seems unlikely it will ever be needed there. -% -\let\implicitmath = $ -\def\math#1{\implicitmath #1\implicitmath} - -% @bullet and @minus need the same treatment as @math, just above. -\def\bullet{\implicitmath\ptexbullet\implicitmath} -\def\minus{\implicitmath-\implicitmath} - -\def\node{\ENVcheck\parsearg\nodezzz} -\def\nodezzz#1{\nodexxx [#1,]} -\def\nodexxx[#1,#2]{\gdef\lastnode{#1}} -\let\nwnode=\node -\let\lastnode=\relax - -\def\donoderef{\ifx\lastnode\relax\else -\expandafter\expandafter\expandafter\setref{\lastnode}\fi -\global\let\lastnode=\relax} - -\def\unnumbnoderef{\ifx\lastnode\relax\else -\expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi -\global\let\lastnode=\relax} - -\def\appendixnoderef{\ifx\lastnode\relax\else -\expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi -\global\let\lastnode=\relax} - -\let\refill=\relax - -% @setfilename is done at the beginning of every texinfo file. -% So open here the files we need to have open while reading the input. -% This makes it possible to make a .fmt file for texinfo. -\def\setfilename{% - \readauxfile - \opencontents - \openindices - \fixbackslash % Turn off hack to swallow `\input texinfo'. - \global\let\setfilename=\comment % Ignore extra @setfilename cmds. - \comment % Ignore the actual filename. -} - -\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} - -\def\inforef #1{\inforefzzz #1,,,,**} -\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, - node \samp{\ignorespaces#1{}}} - -\message{fonts,} - -% Font-change commands. - -% Texinfo supports the sans serif font style, which plain TeX does not. -% So we set up a \sf analogous to plain's \rm, etc. -\newfam\sffam -\def\sf{\fam=\sffam \tensf} -\let\li = \sf % Sometimes we call it \li, not \sf. - -%% Try out Computer Modern fonts at \magstephalf -\let\mainmagstep=\magstephalf - -% Set the font macro #1 to the font named #2, adding on the -% specified font prefix (normally `cm'). -\def\setfont#1#2{\font#1=\fontprefix#2} - -% Use cm as the default font prefix. -% To specify the font prefix, you must define \fontprefix -% before you read in texinfo.tex. -\ifx\fontprefix\undefined -\def\fontprefix{cm} -\fi - -\ifx\bigger\relax -\let\mainmagstep=\magstep1 -\setfont\textrm{r12} -\setfont\texttt{tt12} -\else -\setfont\textrm{r10 scaled \mainmagstep} -\setfont\texttt{tt10 scaled \mainmagstep} -\fi -% Instead of cmb10, you many want to use cmbx10. -% cmbx10 is a prettier font on its own, but cmb10 -% looks better when embedded in a line with cmr10. -\setfont\textbf{b10 scaled \mainmagstep} -\setfont\textit{ti10 scaled \mainmagstep} -\setfont\textsl{sl10 scaled \mainmagstep} -\setfont\textsf{ss10 scaled \mainmagstep} -\setfont\textsc{csc10 scaled \mainmagstep} -\font\texti=cmmi10 scaled \mainmagstep -\font\textsy=cmsy10 scaled \mainmagstep - -% A few fonts for @defun, etc. -\setfont\defbf{bx10 scaled \magstep1} %was 1314 -\setfont\deftt{tt10 scaled \magstep1} -\def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf} - -% Fonts for indices and small examples. -% We actually use the slanted font rather than the italic, -% because texinfo normally uses the slanted fonts for that. -% Do not make many font distinctions in general in the index, since they -% aren't very useful. -\setfont\ninett{tt9} -\setfont\indrm{r9} -\setfont\indit{sl9} -\let\indsl=\indit -\let\indtt=\ninett -\let\indsf=\indrm -\let\indbf=\indrm -\setfont\indsc{csc10 at 9pt} -\font\indi=cmmi9 -\font\indsy=cmsy9 - -% Fonts for headings -\setfont\chaprm{bx12 scaled \magstep2} -\setfont\chapit{ti12 scaled \magstep2} -\setfont\chapsl{sl12 scaled \magstep2} -\setfont\chaptt{tt12 scaled \magstep2} -\setfont\chapsf{ss12 scaled \magstep2} -\let\chapbf=\chaprm -\setfont\chapsc{csc10 scaled\magstep3} -\font\chapi=cmmi12 scaled \magstep2 -\font\chapsy=cmsy10 scaled \magstep3 - -\setfont\secrm{bx12 scaled \magstep1} -\setfont\secit{ti12 scaled \magstep1} -\setfont\secsl{sl12 scaled \magstep1} -\setfont\sectt{tt12 scaled \magstep1} -\setfont\secsf{ss12 scaled \magstep1} -\setfont\secbf{bx12 scaled \magstep1} -\setfont\secsc{csc10 scaled\magstep2} -\font\seci=cmmi12 scaled \magstep1 -\font\secsy=cmsy10 scaled \magstep2 - -% \setfont\ssecrm{bx10 scaled \magstep1} % This size an font looked bad. -% \setfont\ssecit{cmti10 scaled \magstep1} % The letters were too crowded. -% \setfont\ssecsl{sl10 scaled \magstep1} -% \setfont\ssectt{tt10 scaled \magstep1} -% \setfont\ssecsf{ss10 scaled \magstep1} - -%\setfont\ssecrm{b10 scaled 1315} % Note the use of cmb rather than cmbx. -%\setfont\ssecit{ti10 scaled 1315} % Also, the size is a little larger than -%\setfont\ssecsl{sl10 scaled 1315} % being scaled magstep1. -%\setfont\ssectt{tt10 scaled 1315} -%\setfont\ssecsf{ss10 scaled 1315} - -%\let\ssecbf=\ssecrm - -\setfont\ssecrm{bx12 scaled \magstephalf} -\setfont\ssecit{ti12 scaled \magstephalf} -\setfont\ssecsl{sl12 scaled \magstephalf} -\setfont\ssectt{tt12 scaled \magstephalf} -\setfont\ssecsf{ss12 scaled \magstephalf} -\setfont\ssecbf{bx12 scaled \magstephalf} -\setfont\ssecsc{csc10 scaled \magstep1} -\font\sseci=cmmi12 scaled \magstephalf -\font\ssecsy=cmsy10 scaled \magstep1 -% The smallcaps and symbol fonts should actually be scaled \magstep1.5, -% but that is not a standard magnification. - -% Fonts for title page: -\setfont\titlerm{bx12 scaled \magstep3} -\let\authorrm = \secrm - -% In order for the font changes to affect most math symbols and letters, -% we have to define the \textfont of the standard families. Since -% texinfo doesn't allow for producing subscripts and superscripts, we -% don't bother to reset \scriptfont and \scriptscriptfont (which would -% also require loading a lot more fonts). -% -\def\resetmathfonts{% - \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy - \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf - \textfont\ttfam = \tentt \textfont\sffam = \tensf -} - - -% The font-changing commands redefine the meanings of \tenSTYLE, instead -% of just \STYLE. We do this so that font changes will continue to work -% in math mode, where it is the current \fam that is relevant in most -% cases, not the current. Plain TeX does, for example, -% \def\bf{\fam=\bffam \tenbf} By redefining \tenbf, we obviate the need -% to redefine \bf itself. -\def\textfonts{% - \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl - \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc - \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy - \resetmathfonts} -\def\chapfonts{% - \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl - \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc - \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy - \resetmathfonts} -\def\secfonts{% - \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl - \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc - \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy - \resetmathfonts} -\def\subsecfonts{% - \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl - \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc - \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy - \resetmathfonts} -\def\indexfonts{% - \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl - \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc - \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy - \resetmathfonts} - -% Set up the default fonts, so we can use them for creating boxes. -% -\textfonts - -% Count depth in font-changes, for error checks -\newcount\fontdepth \fontdepth=0 - -% Fonts for short table of contents. -\setfont\shortcontrm{r12} -\setfont\shortcontbf{bx12} -\setfont\shortcontsl{sl12} - -%% Add scribe-like font environments, plus @l for inline lisp (usually sans -%% serif) and @ii for TeX italic - -% \smartitalic{ARG} outputs arg in italics, followed by an italic correction -% unless the following character is such as not to need one. -\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi} -\def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx} - -\let\i=\smartitalic -\let\var=\smartitalic -\let\dfn=\smartitalic -\let\emph=\smartitalic -\let\cite=\smartitalic - -\def\b#1{{\bf #1}} -\let\strong=\b - -% We can't just use \exhyphenpenalty, because that only has effect at -% the end of a paragraph. Restore normal hyphenation at the end of the -% group within which \nohyphenation is presumably called. -% -\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} -\def\restorehyphenation{\hyphenchar\font = `- } - -\def\t#1{% - {\tt \rawbackslash \frenchspacing #1}% - \null -} -\let\ttfont=\t -\def\samp #1{`\tclose{#1}'\null} -\def\key #1{{\tt \nohyphenation \uppercase{#1}}\null} -\def\ctrl #1{{\tt \rawbackslash \hat}#1} - -\let\file=\samp - -% @code is a modification of @t, -% which makes spaces the same size as normal in the surrounding text. -\def\tclose#1{% - {% - % Change normal interword space to be same as for the current font. - \spaceskip = \fontdimen2\font - % - % Switch to typewriter. - \tt - % - % But `\ ' produces the large typewriter interword space. - \def\ {{\spaceskip = 0pt{} }}% - % - % Turn off hyphenation. - \nohyphenation - % - \rawbackslash - \frenchspacing - #1% - }% - \null -} - -% We *must* turn on hyphenation at `-' and `_' in \code. -% Otherwise, it is too hard to avoid overful hboxes -% in the Emacs manual, the Library manual, etc. - -% Unfortunately, TeX uses one parameter (\hyphenchar) to control -% both hyphenation at - and hyphenation within words. -% We must therefore turn them both off (\tclose does that) -% and arrange explicitly to hyphenate an a dash. -% -- rms. -{ -\catcode`\-=\active -\catcode`\_=\active -\global\def\code{\begingroup \catcode`\-=\active \let-\codedash \catcode`\_=\active \let_\codeunder \codex} -% The following is used by \doprintindex to insure that long function names -% wrap around. It is necessary for - and _ to be active before the index is -% read from the file, as \entry parses the arguments long before \code is -% ever called. -- mycroft -\global\def\indexbreaks{\catcode`\-=\active \let-\realdash \catcode`\_=\active \let_\realunder} -} - -\def\realdash{-} -\def\realunder{_} -\def\codedash{-\discretionary{}{}{}} -\def\codeunder{\normalunderscore\discretionary{}{}{}} -\def\codex #1{\tclose{#1}\endgroup} - -%\let\exp=\tclose %Was temporary - -% @kbd is like @code, except that if the argument is just one @key command, -% then @kbd has no effect. - -\def\xkey{\key} -\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% -\ifx\one\xkey\ifx\threex\three \key{#2}% -\else\tclose{\look}\fi -\else\tclose{\look}\fi} - -% Typeset a dimension, e.g., `in' or `pt'. The only reason for the -% argument is to make the input look right: @dmn{pt} instead of -% @dmn{}pt. -% -\def\dmn#1{\thinspace #1} - -\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par} - -\def\l#1{{\li #1}\null} % - -\def\r#1{{\rm #1}} % roman font -% Use of \lowercase was suggested. -\def\sc#1{{\smallcaps#1}} % smallcaps font -\def\ii#1{{\it #1}} % italic font - -\message{page headings,} - -\newskip\titlepagetopglue \titlepagetopglue = 1.5in -\newskip\titlepagebottomglue \titlepagebottomglue = 2pc - -% First the title page. Must do @settitle before @titlepage. -\def\titlefont#1{{\titlerm #1}} - -\newif\ifseenauthor -\newif\iffinishedtitlepage - -\def\shorttitlepage{\parsearg\shorttitlepagezzz} -\def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}% - \endgroup\page\hbox{}\page} - -\def\titlepage{\begingroup \parindent=0pt \textfonts - \let\subtitlerm=\tenrm -% I deinstalled the following change because \cmr12 is undefined. -% This change was not in the ChangeLog anyway. --rms. -% \let\subtitlerm=\cmr12 - \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}% - % - \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}% - % - % Leave some space at the very top of the page. - \vglue\titlepagetopglue - % - % Now you can print the title using @title. - \def\title{\parsearg\titlezzz}% - \def\titlezzz##1{\leftline{\titlefont{##1}} - % print a rule at the page bottom also. - \finishedtitlepagefalse - \vskip4pt \hrule height 4pt width \hsize \vskip4pt}% - % No rule at page bottom unless we print one at the top with @title. - \finishedtitlepagetrue - % - % Now you can put text using @subtitle. - \def\subtitle{\parsearg\subtitlezzz}% - \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}% - % - % @author should come last, but may come many times. - \def\author{\parsearg\authorzzz}% - \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi - {\authorfont \leftline{##1}}}% - % - % Most title ``pages'' are actually two pages long, with space - % at the top of the second. We don't want the ragged left on the second. - \let\oldpage = \page - \def\page{% - \iffinishedtitlepage\else - \finishtitlepage - \fi - \oldpage - \let\page = \oldpage - \hbox{}}% -% \def\page{\oldpage \hbox{}} -} - -\def\Etitlepage{% - \iffinishedtitlepage\else - \finishtitlepage - \fi - % It is important to do the page break before ending the group, - % because the headline and footline are only empty inside the group. - % If we use the new definition of \page, we always get a blank page - % after the title page, which we certainly don't want. - \oldpage - \endgroup - \HEADINGSon -} - -\def\finishtitlepage{% - \vskip4pt \hrule height 2pt width \hsize - \vskip\titlepagebottomglue - \finishedtitlepagetrue -} - -%%% Set up page headings and footings. - -\let\thispage=\folio - -\newtoks \evenheadline % Token sequence for heading line of even pages -\newtoks \oddheadline % Token sequence for heading line of odd pages -\newtoks \evenfootline % Token sequence for footing line of even pages -\newtoks \oddfootline % Token sequence for footing line of odd pages - -% Now make Tex use those variables -\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline - \else \the\evenheadline \fi}} -\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline - \else \the\evenfootline \fi}\HEADINGShook} -\let\HEADINGShook=\relax - -% Commands to set those variables. -% For example, this is what @headings on does -% @evenheading @thistitle|@thispage|@thischapter -% @oddheading @thischapter|@thispage|@thistitle -% @evenfooting @thisfile|| -% @oddfooting ||@thisfile - -\def\evenheading{\parsearg\evenheadingxxx} -\def\oddheading{\parsearg\oddheadingxxx} -\def\everyheading{\parsearg\everyheadingxxx} - -\def\evenfooting{\parsearg\evenfootingxxx} -\def\oddfooting{\parsearg\oddfootingxxx} -\def\everyfooting{\parsearg\everyfootingxxx} - -{\catcode`\@=0 % - -\gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish} -\gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{% -\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish} -\gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{% -\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish} -\gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{% -\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}} -\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish} -\gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{% -\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish} -\gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{% -\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish} -\gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{% -\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}} -\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} -% -}% unbind the catcode of @. - -% @headings double turns headings on for double-sided printing. -% @headings single turns headings on for single-sided printing. -% @headings off turns them off. -% @headings on same as @headings double, retained for compatibility. -% @headings after turns on double-sided headings after this page. -% @headings doubleafter turns on double-sided headings after this page. -% @headings singleafter turns on single-sided headings after this page. -% By default, they are off. - -\def\headings #1 {\csname HEADINGS#1\endcsname} - -\def\HEADINGSoff{ -\global\evenheadline={\hfil} \global\evenfootline={\hfil} -\global\oddheadline={\hfil} \global\oddfootline={\hfil}} -\HEADINGSoff -% When we turn headings on, set the page number to 1. -% For double-sided printing, put current file name in lower left corner, -% chapter name on inside top of right hand pages, document -% title on inside top of left hand pages, and page numbers on outside top -% edge of all pages. -\def\HEADINGSdouble{ -%\pagealignmacro -\global\pageno=1 -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\folio\hfil\thistitle}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -} -% For single-sided printing, chapter title goes across top left of page, -% page number on top right. -\def\HEADINGSsingle{ -%\pagealignmacro -\global\pageno=1 -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\thischapter\hfil\folio}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -} -\def\HEADINGSon{\HEADINGSdouble} - -\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} -\let\HEADINGSdoubleafter=\HEADINGSafter -\def\HEADINGSdoublex{% -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\folio\hfil\thistitle}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -} - -\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} -\def\HEADINGSsinglex{% -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\thischapter\hfil\folio}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -} - -% Subroutines used in generating headings -% Produces Day Month Year style of output. -\def\today{\number\day\space -\ifcase\month\or -January\or February\or March\or April\or May\or June\or -July\or August\or September\or October\or November\or December\fi -\space\number\year} - -% Use this if you want the Month Day, Year style of output. -%\def\today{\ifcase\month\or -%January\or February\or March\or April\or May\or June\or -%July\or August\or September\or October\or November\or December\fi -%\space\number\day, \number\year} - -% @settitle line... specifies the title of the document, for headings -% It generates no output of its own - -\def\thistitle{No Title} -\def\settitle{\parsearg\settitlezzz} -\def\settitlezzz #1{\gdef\thistitle{#1}} - -\message{tables,} - -% @tabs -- simple alignment - -% These don't work. For one thing, \+ is defined as outer. -% So these macros cannot even be defined. - -%\def\tabs{\parsearg\tabszzz} -%\def\tabszzz #1{\settabs\+#1\cr} -%\def\tabline{\parsearg\tablinezzz} -%\def\tablinezzz #1{\+#1\cr} -%\def\&{&} - -% Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x). - -% default indentation of table text -\newdimen\tableindent \tableindent=.8in -% default indentation of @itemize and @enumerate text -\newdimen\itemindent \itemindent=.3in -% margin between end of table item and start of table text. -\newdimen\itemmargin \itemmargin=.1in - -% used internally for \itemindent minus \itemmargin -\newdimen\itemmax - -% Note @table, @vtable, and @vtable define @item, @itemx, etc., with -% these defs. -% They also define \itemindex -% to index the item name in whatever manner is desired (perhaps none). - -\newif\ifitemxneedsnegativevskip - -\def\itemxpar{\par\ifitemxneedsnegativevskip\vskip-\parskip\nobreak\fi} - -\def\internalBitem{\smallbreak \parsearg\itemzzz} -\def\internalBitemx{\itemxpar \parsearg\itemzzz} - -\def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz} -\def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz} - -\def\internalBkitem{\smallbreak \parsearg\kitemzzz} -\def\internalBkitemx{\itemxpar \parsearg\kitemzzz} - -\def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}% - \itemzzz {#1}} - -\def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}% - \itemzzz {#1}} - -\def\itemzzz #1{\begingroup % - \advance\hsize by -\rightskip - \advance\hsize by -\tableindent - \setbox0=\hbox{\itemfont{#1}}% - \itemindex{#1}% - \nobreak % This prevents a break before @itemx. - % - % Be sure we are not still in the middle of a paragraph. - %{\parskip = 0in - %\par - %}% - % - % If the item text does not fit in the space we have, put it on a line - % by itself, and do not allow a page break either before or after that - % line. We do not start a paragraph here because then if the next - % command is, e.g., @kindex, the whatsit would get put into the - % horizontal list on a line by itself, resulting in extra blank space. - \ifdim \wd0>\itemmax - % - % Make this a paragraph so we get the \parskip glue and wrapping, - % but leave it ragged-right. - \begingroup - \advance\leftskip by-\tableindent - \advance\hsize by\tableindent - \advance\rightskip by0pt plus1fil - \leavevmode\unhbox0\par - \endgroup - % - % We're going to be starting a paragraph, but we don't want the - % \parskip glue -- logically it's part of the @item we just started. - \nobreak \vskip-\parskip - % - % Stop a page break at the \parskip glue coming up. Unfortunately - % we can't prevent a possible page break at the following - % \baselineskip glue. - \nobreak - \endgroup - \itemxneedsnegativevskipfalse - \else - % The item text fits into the space. Start a paragraph, so that the - % following text (if any) will end up on the same line. Since that - % text will be indented by \tableindent, we make the item text be in - % a zero-width box. - \noindent - \rlap{\hskip -\tableindent\box0}\ignorespaces% - \endgroup% - \itemxneedsnegativevskiptrue% - \fi -} - -\def\item{\errmessage{@item while not in a table}} -\def\itemx{\errmessage{@itemx while not in a table}} -\def\kitem{\errmessage{@kitem while not in a table}} -\def\kitemx{\errmessage{@kitemx while not in a table}} -\def\xitem{\errmessage{@xitem while not in a table}} -\def\xitemx{\errmessage{@xitemx while not in a table}} - -%% Contains a kludge to get @end[description] to work -\def\description{\tablez{\dontindex}{1}{}{}{}{}} - -\def\table{\begingroup\inENV\obeylines\obeyspaces\tablex} -{\obeylines\obeyspaces% -\gdef\tablex #1^^M{% -\tabley\dontindex#1 \endtabley}} - -\def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex} -{\obeylines\obeyspaces% -\gdef\ftablex #1^^M{% -\tabley\fnitemindex#1 \endtabley -\def\Eftable{\endgraf\afterenvbreak\endgroup}% -\let\Etable=\relax}} - -\def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex} -{\obeylines\obeyspaces% -\gdef\vtablex #1^^M{% -\tabley\vritemindex#1 \endtabley -\def\Evtable{\endgraf\afterenvbreak\endgroup}% -\let\Etable=\relax}} - -\def\dontindex #1{} -\def\fnitemindex #1{\doind {fn}{\code{#1}}}% -\def\vritemindex #1{\doind {vr}{\code{#1}}}% - -{\obeyspaces % -\gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup% -\tablez{#1}{#2}{#3}{#4}{#5}{#6}}} - -\def\tablez #1#2#3#4#5#6{% -\aboveenvbreak % -\begingroup % -\def\Edescription{\Etable}% Neccessary kludge. -\let\itemindex=#1% -\ifnum 0#3>0 \advance \leftskip by #3\mil \fi % -\ifnum 0#4>0 \tableindent=#4\mil \fi % -\ifnum 0#5>0 \advance \rightskip by #5\mil \fi % -\def\itemfont{#2}% -\itemmax=\tableindent % -\advance \itemmax by -\itemmargin % -\advance \leftskip by \tableindent % -\exdentamount=\tableindent -\parindent = 0pt -\parskip = \smallskipamount -\ifdim \parskip=0pt \parskip=2pt \fi% -\def\Etable{\endgraf\afterenvbreak\endgroup}% -\let\item = \internalBitem % -\let\itemx = \internalBitemx % -\let\kitem = \internalBkitem % -\let\kitemx = \internalBkitemx % -\let\xitem = \internalBxitem % -\let\xitemx = \internalBxitemx % -} - -% This is the counter used by @enumerate, which is really @itemize - -\newcount \itemno - -\def\itemize{\parsearg\itemizezzz} - -\def\itemizezzz #1{% - \begingroup % ended by the @end itemsize - \itemizey {#1}{\Eitemize} -} - -\def\itemizey #1#2{% -\aboveenvbreak % -\itemmax=\itemindent % -\advance \itemmax by -\itemmargin % -\advance \leftskip by \itemindent % -\exdentamount=\itemindent -\parindent = 0pt % -\parskip = \smallskipamount % -\ifdim \parskip=0pt \parskip=2pt \fi% -\def#2{\endgraf\afterenvbreak\endgroup}% -\def\itemcontents{#1}% -\let\item=\itemizeitem} - -% Set sfcode to normal for the chars that usually have another value. -% These are `.?!:;,' -\def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000 - \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 } - -% \splitoff TOKENS\endmark defines \first to be the first token in -% TOKENS, and \rest to be the remainder. -% -\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% - -% Allow an optional argument of an uppercase letter, lowercase letter, -% or number, to specify the first label in the enumerated list. No -% argument is the same as `1'. -% -\def\enumerate{\parsearg\enumeratezzz} -\def\enumeratezzz #1{\enumeratey #1 \endenumeratey} -\def\enumeratey #1 #2\endenumeratey{% - \begingroup % ended by the @end enumerate - % - % If we were given no argument, pretend we were given `1'. - \def\thearg{#1}% - \ifx\thearg\empty \def\thearg{1}\fi - % - % Detect if the argument is a single token. If so, it might be a - % letter. Otherwise, the only valid thing it can be is a number. - % (We will always have one token, because of the test we just made. - % This is a good thing, since \splitoff doesn't work given nothing at - % all -- the first parameter is undelimited.) - \expandafter\splitoff\thearg\endmark - \ifx\rest\empty - % Only one token in the argument. It could still be anything. - % A ``lowercase letter'' is one whose \lccode is nonzero. - % An ``uppercase letter'' is one whose \lccode is both nonzero, and - % not equal to itself. - % Otherwise, we assume it's a number. - % - % We need the \relax at the end of the \ifnum lines to stop TeX from - % continuing to look for a <number>. - % - \ifnum\lccode\expandafter`\thearg=0\relax - \numericenumerate % a number (we hope) - \else - % It's a letter. - \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax - \lowercaseenumerate % lowercase letter - \else - \uppercaseenumerate % uppercase letter - \fi - \fi - \else - % Multiple tokens in the argument. We hope it's a number. - \numericenumerate - \fi -} - -% An @enumerate whose labels are integers. The starting integer is -% given in \thearg. -% -\def\numericenumerate{% - \itemno = \thearg - \startenumeration{\the\itemno}% -} - -% The starting (lowercase) letter is in \thearg. -\def\lowercaseenumerate{% - \itemno = \expandafter`\thearg - \startenumeration{% - % Be sure we're not beyond the end of the alphabet. - \ifnum\itemno=0 - \errmessage{No more lowercase letters in @enumerate; get a bigger - alphabet}% - \fi - \char\lccode\itemno - }% -} - -% The starting (uppercase) letter is in \thearg. -\def\uppercaseenumerate{% - \itemno = \expandafter`\thearg - \startenumeration{% - % Be sure we're not beyond the end of the alphabet. - \ifnum\itemno=0 - \errmessage{No more uppercase letters in @enumerate; get a bigger - alphabet} - \fi - \char\uccode\itemno - }% -} - -% Call itemizey, adding a period to the first argument and supplying the -% common last two arguments. Also subtract one from the initial value in -% \itemno, since @item increments \itemno. -% -\def\startenumeration#1{% - \advance\itemno by -1 - \itemizey{#1.}\Eenumerate\flushcr -} - -% @alphaenumerate and @capsenumerate are abbreviations for giving an arg -% to @enumerate. -% -\def\alphaenumerate{\enumerate{a}} -\def\capsenumerate{\enumerate{A}} -\def\Ealphaenumerate{\Eenumerate} -\def\Ecapsenumerate{\Eenumerate} - -% Definition of @item while inside @itemize. - -\def\itemizeitem{% -\advance\itemno by 1 -{\let\par=\endgraf \smallbreak}% -\ifhmode \errmessage{\in hmode at itemizeitem}\fi -{\parskip=0in \hskip 0pt -\hbox to 0pt{\hss \itemcontents\hskip \itemmargin}% -\vadjust{\penalty 1200}}% -\flushcr} - -% @multitable macros -% Amy Hendrickson, 8/18/94 -% -% @multitable ... @endmultitable will make as many columns as desired. -% Contents of each column will wrap at width given in preamble. Width -% can be specified either with sample text given in a template line, -% or in percent of \hsize, the current width of text on page. - -% Table can continue over pages but will only break between lines. - -% To make preamble: -% -% Either define widths of columns in terms of percent of \hsize: -% @multitable @percentofhsize .2 .3 .5 -% @item ... -% -% Numbers following @percentofhsize are the percent of the total -% current hsize to be used for each column. You may use as many -% columns as desired. - -% Or use a template: -% @multitable {Column 1 template} {Column 2 template} {Column 3 template} -% @item ... -% using the widest term desired in each column. - - -% Each new table line starts with @item, each subsequent new column -% starts with @tab. Empty columns may be produced by supplying @tab's -% with nothing between them for as many times as empty columns are needed, -% ie, @tab@tab@tab will produce two empty columns. - -% @item, @tab, @multicolumn or @endmulticolumn do not need to be on their -% own lines, but it will not hurt if they are. - -% Sample multitable: - -% @multitable {Column 1 template} {Column 2 template} {Column 3 template} -% @item first col stuff @tab second col stuff @tab third col -% @item -% first col stuff -% @tab -% second col stuff -% @tab -% third col -% @item first col stuff @tab second col stuff -% @tab Many paragraphs of text may be used in any column. -% -% They will wrap at the width determined by the template. -% @item@tab@tab This will be in third column. -% @endmultitable - -% Default dimensions may be reset by user. -% @intableparskip will set vertical space between paragraphs in table. -% @intableparindent will set paragraph indent in table. -% @spacebetweencols will set horizontal space to be left between columns. -% @spacebetweenlines will set vertical space to be left between lines. - -%%%% -% Dimensions - -\newdimen\intableparskip -\newdimen\intableparindent -\newdimen\spacebetweencols -\newdimen\spacebetweenlines -\intableparskip=0pt -\intableparindent=6pt -\spacebetweencols=12pt -\spacebetweenlines=12pt - -%%%% -% Macros used to set up halign preamble: -\let\endsetuptable\relax -\def\xendsetuptable{\endsetuptable} -\let\percentofhsize\relax -\def\xpercentofhsize{\percentofhsize} -\newif\ifsetpercent - -\newcount\colcount -\def\setuptable#1{\def\firstarg{#1}% -\ifx\firstarg\xendsetuptable\let\go\relax% -\else - \ifx\firstarg\xpercentofhsize\global\setpercenttrue% - \else - \ifsetpercent - \if#1.\else% - \global\advance\colcount by1 % - \expandafter\xdef\csname col\the\colcount\endcsname{.#1\hsize}% - \fi - \else - \global\advance\colcount by1 - \setbox0=\hbox{#1}% - \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% - \fi% - \fi% - \let\go\setuptable% -\fi\go} -%%%% -% multitable syntax -\def\tab{&} - -%%%% -% @multitable ... @endmultitable definitions: - -\def\multitable#1\item{\bgroup -\let\item\cr -\tolerance=9500 -\hbadness=9500 -\parskip=\intableparskip -\parindent=\intableparindent -\overfullrule=0pt -\global\colcount=0\relax% -\def\Emultitable{\global\setpercentfalse\global\everycr{}\cr\egroup\egroup}% - % To parse everything between @multitable and @item : -\def\one{#1}\expandafter\setuptable\one\endsetuptable - % Need to reset this to 0 after \setuptable. -\global\colcount=0\relax% - % - % This preamble sets up a generic column definition, which will - % be used as many times as user calls for columns. - % \vtop will set a single line and will also let text wrap and - % continue for many paragraphs if desired. -\halign\bgroup&\global\advance\colcount by 1\relax% -\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname - % In order to keep entries from bumping into each other - % we will add a \leftskip of \spacebetweencols to all columns after - % the first one. - % If a template has been used, we will add \spacebetweencols - % to the width of each template entry. - % If user has set preamble in terms of percent of \hsize - % we will use that dimension as the width of the column, and - % the \leftskip will keep entries from bumping into each other. - % Table will start at left margin and final column will justify at - % right margin. -\ifnum\colcount=1 -\else - \ifsetpercent - \else - % If user has <not> set preamble in terms of percent of \hsize - % we will advance \hsize by \spacebetweencols - \advance\hsize by \spacebetweencols - \fi - % In either case we will make \leftskip=\spacebetweencols: -\leftskip=\spacebetweencols -\fi -\noindent##}\cr% - % \everycr will reset column counter, \colcount, at the end of - % each line. Every column entry will cause \colcount to advance by one. - % The table preamble - % looks at the current \colcount to find the correct column width. -\global\everycr{\noalign{\nointerlineskip\vskip\spacebetweenlines -\filbreak%% keeps underfull box messages off when table breaks over pages. -\global\colcount=0\relax}}} - -\message{indexing,} -% Index generation facilities - -% Define \newwrite to be identical to plain tex's \newwrite -% except not \outer, so it can be used within \newindex. -{\catcode`\@=11 -\gdef\newwrite{\alloc@7\write\chardef\sixt@@n}} - -% \newindex {foo} defines an index named foo. -% It automatically defines \fooindex such that -% \fooindex ...rest of line... puts an entry in the index foo. -% It also defines \fooindfile to be the number of the output channel for -% the file that accumulates this index. The file's extension is foo. -% The name of an index should be no more than 2 characters long -% for the sake of vms. - -\def\newindex #1{ -\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file -\openout \csname#1indfile\endcsname \jobname.#1 % Open the file -\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex -\noexpand\doindex {#1}} -} - -% @defindex foo == \newindex{foo} - -\def\defindex{\parsearg\newindex} - -% Define @defcodeindex, like @defindex except put all entries in @code. - -\def\newcodeindex #1{ -\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file -\openout \csname#1indfile\endcsname \jobname.#1 % Open the file -\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex -\noexpand\docodeindex {#1}} -} - -\def\defcodeindex{\parsearg\newcodeindex} - -% @synindex foo bar makes index foo feed into index bar. -% Do this instead of @defindex foo if you don't want it as a separate index. -\def\synindex #1 #2 {% -\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname -\expandafter\let\csname#1indfile\endcsname=\synindexfoo -\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex -\noexpand\doindex {#2}}% -} - -% @syncodeindex foo bar similar, but put all entries made for index foo -% inside @code. -\def\syncodeindex #1 #2 {% -\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname -\expandafter\let\csname#1indfile\endcsname=\synindexfoo -\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex -\noexpand\docodeindex {#2}}% -} - -% Define \doindex, the driver for all \fooindex macros. -% Argument #1 is generated by the calling \fooindex macro, -% and it is "foo", the name of the index. - -% \doindex just uses \parsearg; it calls \doind for the actual work. -% This is because \doind is more useful to call from other macros. - -% There is also \dosubind {index}{topic}{subtopic} -% which makes an entry in a two-level index such as the operation index. - -\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} -\def\singleindexer #1{\doind{\indexname}{#1}} - -% like the previous two, but they put @code around the argument. -\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} -\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} - -\def\indexdummies{% -% Take care of the plain tex accent commands. -\def\"{\realbackslash "}% -\def\`{\realbackslash `}% -\def\'{\realbackslash '}% -\def\^{\realbackslash ^}% -\def\~{\realbackslash ~}% -\def\={\realbackslash =}% -\def\b{\realbackslash b}% -\def\c{\realbackslash c}% -\def\d{\realbackslash d}% -\def\u{\realbackslash u}% -\def\v{\realbackslash v}% -\def\H{\realbackslash H}% -% Take care of the plain tex special European modified letters. -\def\oe{\realbackslash oe}% -\def\ae{\realbackslash ae}% -\def\aa{\realbackslash aa}% -\def\OE{\realbackslash OE}% -\def\AE{\realbackslash AE}% -\def\AA{\realbackslash AA}% -\def\o{\realbackslash o}% -\def\O{\realbackslash O}% -\def\l{\realbackslash l}% -\def\L{\realbackslash L}% -\def\ss{\realbackslash ss}% -% Take care of texinfo commands likely to appear in an index entry. -\def\_{{\realbackslash _}}% -\def\w{\realbackslash w }% -\def\bf{\realbackslash bf }% -\def\rm{\realbackslash rm }% -\def\sl{\realbackslash sl }% -\def\sf{\realbackslash sf}% -\def\tt{\realbackslash tt}% -\def\gtr{\realbackslash gtr}% -\def\less{\realbackslash less}% -\def\hat{\realbackslash hat}% -\def\char{\realbackslash char}% -\def\TeX{\realbackslash TeX}% -\def\dots{\realbackslash dots }% -\def\copyright{\realbackslash copyright }% -\def\tclose##1{\realbackslash tclose {##1}}% -\def\code##1{\realbackslash code {##1}}% -\def\samp##1{\realbackslash samp {##1}}% -\def\t##1{\realbackslash r {##1}}% -\def\r##1{\realbackslash r {##1}}% -\def\i##1{\realbackslash i {##1}}% -\def\b##1{\realbackslash b {##1}}% -\def\cite##1{\realbackslash cite {##1}}% -\def\key##1{\realbackslash key {##1}}% -\def\file##1{\realbackslash file {##1}}% -\def\var##1{\realbackslash var {##1}}% -\def\kbd##1{\realbackslash kbd {##1}}% -\def\dfn##1{\realbackslash dfn {##1}}% -\def\emph##1{\realbackslash emph {##1}}% -} - -% \indexnofonts no-ops all font-change commands. -% This is used when outputting the strings to sort the index by. -\def\indexdummyfont#1{#1} -\def\indexdummytex{TeX} -\def\indexdummydots{...} - -\def\indexnofonts{% -% Just ignore accents. -\let\"=\indexdummyfont -\let\`=\indexdummyfont -\let\'=\indexdummyfont -\let\^=\indexdummyfont -\let\~=\indexdummyfont -\let\==\indexdummyfont -\let\b=\indexdummyfont -\let\c=\indexdummyfont -\let\d=\indexdummyfont -\let\u=\indexdummyfont -\let\v=\indexdummyfont -\let\H=\indexdummyfont -% Take care of the plain tex special European modified letters. -\def\oe{oe}% -\def\ae{ae}% -\def\aa{aa}% -\def\OE{OE}% -\def\AE{AE}% -\def\AA{AA}% -\def\o{o}% -\def\O{O}% -\def\l{l}% -\def\L{L}% -\def\ss{ss}% -\let\w=\indexdummyfont -\let\t=\indexdummyfont -\let\r=\indexdummyfont -\let\i=\indexdummyfont -\let\b=\indexdummyfont -\let\emph=\indexdummyfont -\let\strong=\indexdummyfont -\let\cite=\indexdummyfont -\let\sc=\indexdummyfont -%Don't no-op \tt, since it isn't a user-level command -% and is used in the definitions of the active chars like <, >, |... -%\let\tt=\indexdummyfont -\let\tclose=\indexdummyfont -\let\code=\indexdummyfont -\let\file=\indexdummyfont -\let\samp=\indexdummyfont -\let\kbd=\indexdummyfont -\let\key=\indexdummyfont -\let\var=\indexdummyfont -\let\TeX=\indexdummytex -\let\dots=\indexdummydots -} - -% To define \realbackslash, we must make \ not be an escape. -% We must first make another character (@) an escape -% so we do not become unable to do a definition. - -{\catcode`\@=0 \catcode`\\=\other -@gdef@realbackslash{\}} - -\let\indexbackslash=0 %overridden during \printindex. - -\let\SETmarginindex=\relax %initialize! -% workhorse for all \fooindexes -% #1 is name of index, #2 is stuff to put there -\def\doind #1#2{% -% Put the index entry in the margin if desired. -\ifx\SETmarginindex\relax\else% -\insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}% -\fi% -{\count10=\lastpenalty % -{\indexdummies % Must do this here, since \bf, etc expand at this stage -\escapechar=`\\% -{\let\folio=0% Expand all macros now EXCEPT \folio -\def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now -% so it will be output as is; and it will print as backslash in the indx. -% -% Now process the index-string once, with all font commands turned off, -% to get the string to sort the index by. -{\indexnofonts -\xdef\temp1{#2}% -}% -% Now produce the complete index entry. We process the index-string again, -% this time with font commands expanded, to get what to print in the index. -\edef\temp{% -\write \csname#1indfile\endcsname{% -\realbackslash entry {\temp1}{\folio}{#2}}}% -\temp }% -}\penalty\count10}} - -\def\dosubind #1#2#3{% -{\count10=\lastpenalty % -{\indexdummies % Must do this here, since \bf, etc expand at this stage -\escapechar=`\\% -{\let\folio=0% -\def\rawbackslashxx{\indexbackslash}% -% -% Now process the index-string once, with all font commands turned off, -% to get the string to sort the index by. -{\indexnofonts -\xdef\temp1{#2 #3}% -}% -% Now produce the complete index entry. We process the index-string again, -% this time with font commands expanded, to get what to print in the index. -\edef\temp{% -\write \csname#1indfile\endcsname{% -\realbackslash entry {\temp1}{\folio}{#2}{#3}}}% -\temp }% -}\penalty\count10}} - -% The index entry written in the file actually looks like -% \entry {sortstring}{page}{topic} -% or -% \entry {sortstring}{page}{topic}{subtopic} -% The texindex program reads in these files and writes files -% containing these kinds of lines: -% \initial {c} -% before the first topic whose initial is c -% \entry {topic}{pagelist} -% for a topic that is used without subtopics -% \primary {topic} -% for the beginning of a topic that is used with subtopics -% \secondary {subtopic}{pagelist} -% for each subtopic. - -% Define the user-accessible indexing commands -% @findex, @vindex, @kindex, @cindex. - -\def\findex {\fnindex} -\def\kindex {\kyindex} -\def\cindex {\cpindex} -\def\vindex {\vrindex} -\def\tindex {\tpindex} -\def\pindex {\pgindex} - -\def\cindexsub {\begingroup\obeylines\cindexsub} -{\obeylines % -\gdef\cindexsub "#1" #2^^M{\endgroup % -\dosubind{cp}{#2}{#1}}} - -% Define the macros used in formatting output of the sorted index material. - -% This is what you call to cause a particular index to get printed. -% Write -% @unnumbered Function Index -% @printindex fn - -\def\printindex{\parsearg\doprintindex} - -\def\doprintindex#1{% - \tex - \dobreak \chapheadingskip {10000} - \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other - \catcode`\$=\other - \catcode`\~=\other - \indexbreaks - % - % The following don't help, since the chars were translated - % when the raw index was written, and their fonts were discarded - % due to \indexnofonts. - %\catcode`\"=\active - %\catcode`\^=\active - %\catcode`\_=\active - %\catcode`\|=\active - %\catcode`\<=\active - %\catcode`\>=\active - % % - \def\indexbackslash{\rawbackslashxx} - \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt - \begindoublecolumns - % - % See if the index file exists and is nonempty. - \openin 1 \jobname.#1s - \ifeof 1 - % \enddoublecolumns gets confused if there is no text in the index, - % and it loses the chapter title and the aux file entries for the - % index. The easiest way to prevent this problem is to make sure - % there is some text. - (Index is nonexistent) - \else - % - % If the index file exists but is empty, then \openin leaves \ifeof - % false. We have to make TeX try to read something from the file, so - % it can discover if there is anything in it. - \read 1 to \temp - \ifeof 1 - (Index is empty) - \else - \input \jobname.#1s - \fi - \fi - \closein 1 - \enddoublecolumns - \Etex -} - -% These macros are used by the sorted index file itself. -% Change them to control the appearance of the index. - -% Same as \bigskipamount except no shrink. -% \balancecolumns gets confused if there is any shrink. -\newskip\initialskipamount \initialskipamount 12pt plus4pt - -\def\initial #1{% -{\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt -\ifdim\lastskip<\initialskipamount -\removelastskip \penalty-200 \vskip \initialskipamount\fi -\line{\secbf#1\hfill}\kern 2pt\penalty10000}} - -% This typesets a paragraph consisting of #1, dot leaders, and then #2 -% flush to the right margin. It is used for index and table of contents -% entries. The paragraph is indented by \leftskip. -% -\def\entry #1#2{\begingroup - % - % Start a new paragraph if necessary, so our assignments below can't - % affect previous text. - \par - % - % Do not fill out the last line with white space. - \parfillskip = 0in - % - % No extra space above this paragraph. - \parskip = 0in - % - % Do not prefer a separate line ending with a hyphen to fewer lines. - \finalhyphendemerits = 0 - % - % \hangindent is only relevant when the entry text and page number - % don't both fit on one line. In that case, bob suggests starting the - % dots pretty far over on the line. Unfortunately, a large - % indentation looks wrong when the entry text itself is broken across - % lines. So we use a small indentation and put up with long leaders. - % - % \hangafter is reset to 1 (which is the value we want) at the start - % of each paragraph, so we need not do anything with that. - \hangindent=2em - % - % When the entry text needs to be broken, just fill out the first line - % with blank space. - \rightskip = 0pt plus1fil - % - % Start a ``paragraph'' for the index entry so the line breaking - % parameters we've set above will have an effect. - \noindent - % - % Insert the text of the index entry. TeX will do line-breaking on it. - #1% - % The following is kluged to not output a line of dots in the index if - % there are no page numbers. The next person who breaks this will be - % cursed by a Unix daemon. - \def\tempa{{\rm }}% - \def\tempb{#2}% - \edef\tempc{\tempa}% - \edef\tempd{\tempb}% - \ifx\tempc\tempd\ \else% - % - % If we must, put the page number on a line of its own, and fill out - % this line with blank space. (The \hfil is overwhelmed with the - % fill leaders glue in \indexdotfill if the page number does fit.) - \hfil\penalty50 - \null\nobreak\indexdotfill % Have leaders before the page number. - % - % The `\ ' here is removed by the implicit \unskip that TeX does as - % part of (the primitive) \par. Without it, a spurious underfull - % \hbox ensues. - \ #2% The page number ends the paragraph. - \fi% - \par -\endgroup} - -% Like \dotfill except takes at least 1 em. -\def\indexdotfill{\cleaders - \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill} - -\def\primary #1{\line{#1\hfil}} - -\newskip\secondaryindent \secondaryindent=0.5cm - -\def\secondary #1#2{ -{\parfillskip=0in \parskip=0in -\hangindent =1in \hangafter=1 -\noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par -}} - -%% Define two-column mode, which is used in indexes. -%% Adapted from the TeXbook, page 416. -\catcode `\@=11 - -\newbox\partialpage - -\newdimen\doublecolumnhsize - -\def\begindoublecolumns{\begingroup - % Grab any single-column material above us. - \output = {\global\setbox\partialpage - =\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}% - \eject - % - % Now switch to the double-column output routine. - \output={\doublecolumnout}% - % - % Change the page size parameters. We could do this once outside this - % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 - % format, but then we repeat the same computation. Repeating a couple - % of assignments once per index is clearly meaningless for the - % execution time, so we may as well do it once. - % - % First we halve the line length, less a little for the gutter between - % the columns. We compute the gutter based on the line length, so it - % changes automatically with the paper format. The magic constant - % below is chosen so that the gutter has the same value (well, +- < - % 1pt) as it did when we hard-coded it. - % - % We put the result in a separate register, \doublecolumhsize, so we - % can restore it in \pagesofar, after \hsize itself has (potentially) - % been clobbered. - % - \doublecolumnhsize = \hsize - \advance\doublecolumnhsize by -.04154\hsize - \divide\doublecolumnhsize by 2 - \hsize = \doublecolumnhsize - % - % Double the \vsize as well. (We don't need a separate register here, - % since nobody clobbers \vsize.) - \vsize = 2\vsize - \doublecolumnpagegoal -} - -\def\enddoublecolumns{\eject \endgroup \pagegoal=\vsize \unvbox\partialpage} - -\def\doublecolumnsplit{\splittopskip=\topskip \splitmaxdepth=\maxdepth - \global\dimen@=\pageheight \global\advance\dimen@ by-\ht\partialpage - \global\setbox1=\vsplit255 to\dimen@ \global\setbox0=\vbox{\unvbox1} - \global\setbox3=\vsplit255 to\dimen@ \global\setbox2=\vbox{\unvbox3} - \ifdim\ht0>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi - \ifdim\ht2>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi -} -\def\doublecolumnpagegoal{% - \dimen@=\vsize \advance\dimen@ by-2\ht\partialpage \global\pagegoal=\dimen@ -} -\def\pagesofar{\unvbox\partialpage % - \hsize=\doublecolumnhsize % have to restore this since output routine - \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}} -\def\doublecolumnout{% - \setbox5=\copy255 - {\vbadness=10000 \doublecolumnsplit} - \ifvbox255 - \setbox0=\vtop to\dimen@{\unvbox0} - \setbox2=\vtop to\dimen@{\unvbox2} - \onepageout\pagesofar \unvbox255 \penalty\outputpenalty - \else - \setbox0=\vbox{\unvbox5} - \ifvbox0 - \dimen@=\ht0 \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip - \divide\dimen@ by2 \splittopskip=\topskip \splitmaxdepth=\maxdepth - {\vbadness=10000 - \loop \global\setbox5=\copy0 - \setbox1=\vsplit5 to\dimen@ - \setbox3=\vsplit5 to\dimen@ - \ifvbox5 \global\advance\dimen@ by1pt \repeat - \setbox0=\vbox to\dimen@{\unvbox1} - \setbox2=\vbox to\dimen@{\unvbox3} - \global\setbox\partialpage=\vbox{\pagesofar} - \doublecolumnpagegoal - } - \fi - \fi -} - -\catcode `\@=\other -\message{sectioning,} -% Define chapters, sections, etc. - -\newcount \chapno -\newcount \secno \secno=0 -\newcount \subsecno \subsecno=0 -\newcount \subsubsecno \subsubsecno=0 - -% This counter is funny since it counts through charcodes of letters A, B, ... -\newcount \appendixno \appendixno = `\@ -\def\appendixletter{\char\the\appendixno} - -\newwrite \contentsfile -% This is called from \setfilename. -\def\opencontents{\openout \contentsfile = \jobname.toc} - -% Each @chapter defines this as the name of the chapter. -% page headings and footings can use it. @section does likewise - -\def\thischapter{} \def\thissection{} -\def\seccheck#1{\if \pageno<0 % -\errmessage{@#1 not allowed after generating table of contents}\fi -% -} - -\def\chapternofonts{% -\let\rawbackslash=\relax% -\let\frenchspacing=\relax% -\def\result{\realbackslash result} -\def\equiv{\realbackslash equiv} -\def\expansion{\realbackslash expansion} -\def\print{\realbackslash print} -\def\TeX{\realbackslash TeX} -\def\dots{\realbackslash dots} -\def\copyright{\realbackslash copyright} -\def\tt{\realbackslash tt} -\def\bf{\realbackslash bf } -\def\w{\realbackslash w} -\def\less{\realbackslash less} -\def\gtr{\realbackslash gtr} -\def\hat{\realbackslash hat} -\def\char{\realbackslash char} -\def\tclose##1{\realbackslash tclose {##1}} -\def\code##1{\realbackslash code {##1}} -\def\samp##1{\realbackslash samp {##1}} -\def\r##1{\realbackslash r {##1}} -\def\b##1{\realbackslash b {##1}} -\def\key##1{\realbackslash key {##1}} -\def\file##1{\realbackslash file {##1}} -\def\kbd##1{\realbackslash kbd {##1}} -% These are redefined because @smartitalic wouldn't work inside xdef. -\def\i##1{\realbackslash i {##1}} -\def\cite##1{\realbackslash cite {##1}} -\def\var##1{\realbackslash var {##1}} -\def\emph##1{\realbackslash emph {##1}} -\def\dfn##1{\realbackslash dfn {##1}} -} - -\newcount\absseclevel % used to calculate proper heading level -\newcount\secbase\secbase=0 % @raise/lowersections modify this count - -% @raisesections: treat @section as chapter, @subsection as section, etc. -\def\raisesections{\global\advance\secbase by -1} -\let\up=\raisesections % original BFox name - -% @lowersections: treat @chapter as section, @section as subsection, etc. -\def\lowersections{\global\advance\secbase by 1} -\let\down=\lowersections % original BFox name - -% Choose a numbered-heading macro -% #1 is heading level if unmodified by @raisesections or @lowersections -% #2 is text for heading -\def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 -\ifcase\absseclevel - \chapterzzz{#2} -\or - \seczzz{#2} -\or - \numberedsubseczzz{#2} -\or - \numberedsubsubseczzz{#2} -\else - \ifnum \absseclevel<0 - \chapterzzz{#2} - \else - \numberedsubsubseczzz{#2} - \fi -\fi -} - -% like \numhead, but chooses appendix heading levels -\def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 -\ifcase\absseclevel - \appendixzzz{#2} -\or - \appendixsectionzzz{#2} -\or - \appendixsubseczzz{#2} -\or - \appendixsubsubseczzz{#2} -\else - \ifnum \absseclevel<0 - \appendixzzz{#2} - \else - \appendixsubsubseczzz{#2} - \fi -\fi -} - -% like \numhead, but chooses numberless heading levels -\def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 -\ifcase\absseclevel - \unnumberedzzz{#2} -\or - \unnumberedseczzz{#2} -\or - \unnumberedsubseczzz{#2} -\or - \unnumberedsubsubseczzz{#2} -\else - \ifnum \absseclevel<0 - \unnumberedzzz{#2} - \else - \unnumberedsubsubseczzz{#2} - \fi -\fi -} - - -\def\thischaptername{No Chapter Title} -\outer\def\chapter{\parsearg\chapteryyy} -\def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz -\def\chapterzzz #1{\seccheck{chapter}% -\secno=0 \subsecno=0 \subsubsecno=0 -\global\advance \chapno by 1 \message{\putwordChapter \the\chapno}% -\chapmacro {#1}{\the\chapno}% -\gdef\thissection{#1}% -\gdef\thischaptername{#1}% -% We don't substitute the actual chapter name into \thischapter -% because we don't want its macros evaluated now. -\xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}% -{\chapternofonts% -\edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\donoderef % -\global\let\section = \numberedsec -\global\let\subsection = \numberedsubsec -\global\let\subsubsection = \numberedsubsubsec -}} - -\outer\def\appendix{\parsearg\appendixyyy} -\def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz -\def\appendixzzz #1{\seccheck{appendix}% -\secno=0 \subsecno=0 \subsubsecno=0 -\global\advance \appendixno by 1 \message{Appendix \appendixletter}% -\chapmacro {#1}{\putwordAppendix{} \appendixletter}% -\gdef\thissection{#1}% -\gdef\thischaptername{#1}% -\xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}% -{\chapternofonts% -\edef\temp{{\realbackslash chapentry - {#1}{\putwordAppendix{} \appendixletter}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\appendixnoderef % -\global\let\section = \appendixsec -\global\let\subsection = \appendixsubsec -\global\let\subsubsection = \appendixsubsubsec -}} - -\outer\def\top{\parsearg\unnumberedyyy} -\outer\def\unnumbered{\parsearg\unnumberedyyy} -\def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz -\def\unnumberedzzz #1{\seccheck{unnumbered}% -\secno=0 \subsecno=0 \subsubsecno=0 -% -% This used to be simply \message{#1}, but TeX fully expands the -% argument to \message. Therefore, if #1 contained @-commands, TeX -% expanded them. For example, in `@unnumbered The @cite{Book}', TeX -% expanded @cite (which turns out to cause errors because \cite is meant -% to be executed, not expanded). -% -% Anyway, we don't want the fully-expanded definition of @cite to appear -% as a result of the \message, we just want `@cite' itself. We use -% \the<toks register> to achieve this: TeX expands \the<toks> only once, -% simply yielding the contents of the <toks register>. -\toks0 = {#1}\message{(\the\toks0)}% -% -\unnumbchapmacro {#1}% -\gdef\thischapter{#1}\gdef\thissection{#1}% -{\chapternofonts% -\edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\unnumbnoderef % -\global\let\section = \unnumberedsec -\global\let\subsection = \unnumberedsubsec -\global\let\subsubsection = \unnumberedsubsubsec -}} - -\outer\def\numberedsec{\parsearg\secyyy} -\def\secyyy #1{\numhead1{#1}} % normally calls seczzz -\def\seczzz #1{\seccheck{section}% -\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % -\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}% -{\chapternofonts% -\edef\temp{{\realbackslash secentry % -{#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\donoderef % -\penalty 10000 % -}} - -\outer\def\appenixsection{\parsearg\appendixsecyyy} -\outer\def\appendixsec{\parsearg\appendixsecyyy} -\def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz -\def\appendixsectionzzz #1{\seccheck{appendixsection}% -\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % -\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}% -{\chapternofonts% -\edef\temp{{\realbackslash secentry % -{#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\appendixnoderef % -\penalty 10000 % -}} - -\outer\def\unnumberedsec{\parsearg\unnumberedsecyyy} -\def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz -\def\unnumberedseczzz #1{\seccheck{unnumberedsec}% -\plainsecheading {#1}\gdef\thissection{#1}% -{\chapternofonts% -\edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\unnumbnoderef % -\penalty 10000 % -}} - -\outer\def\numberedsubsec{\parsearg\numberedsubsecyyy} -\def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz -\def\numberedsubseczzz #1{\seccheck{subsection}% -\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % -\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}% -{\chapternofonts% -\edef\temp{{\realbackslash subsecentry % -{#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\donoderef % -\penalty 10000 % -}} - -\outer\def\appendixsubsec{\parsearg\appendixsubsecyyy} -\def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz -\def\appendixsubseczzz #1{\seccheck{appendixsubsec}% -\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % -\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}% -{\chapternofonts% -\edef\temp{{\realbackslash subsecentry % -{#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\appendixnoderef % -\penalty 10000 % -}} - -\outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy} -\def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz -\def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}% -\plainsecheading {#1}\gdef\thissection{#1}% -{\chapternofonts% -\edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\unnumbnoderef % -\penalty 10000 % -}} - -\outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy} -\def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz -\def\numberedsubsubseczzz #1{\seccheck{subsubsection}% -\gdef\thissection{#1}\global\advance \subsubsecno by 1 % -\subsubsecheading {#1} - {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}% -{\chapternofonts% -\edef\temp{{\realbackslash subsubsecentry % - {#1} - {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno} - {\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\donoderef % -\penalty 10000 % -}} - -\outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy} -\def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz -\def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}% -\gdef\thissection{#1}\global\advance \subsubsecno by 1 % -\subsubsecheading {#1} - {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}% -{\chapternofonts% -\edef\temp{{\realbackslash subsubsecentry{#1}% - {\appendixletter} - {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\appendixnoderef % -\penalty 10000 % -}} - -\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy} -\def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz -\def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}% -\plainsecheading {#1}\gdef\thissection{#1}% -{\chapternofonts% -\edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\unnumbnoderef % -\penalty 10000 % -}} - -% These are variants which are not "outer", so they can appear in @ifinfo. -% Actually, they should now be obsolete; ordinary section commands should work. -\def\infotop{\parsearg\unnumberedzzz} -\def\infounnumbered{\parsearg\unnumberedzzz} -\def\infounnumberedsec{\parsearg\unnumberedseczzz} -\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz} -\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz} - -\def\infoappendix{\parsearg\appendixzzz} -\def\infoappendixsec{\parsearg\appendixseczzz} -\def\infoappendixsubsec{\parsearg\appendixsubseczzz} -\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz} - -\def\infochapter{\parsearg\chapterzzz} -\def\infosection{\parsearg\sectionzzz} -\def\infosubsection{\parsearg\subsectionzzz} -\def\infosubsubsection{\parsearg\subsubsectionzzz} - -% These macros control what the section commands do, according -% to what kind of chapter we are in (ordinary, appendix, or unnumbered). -% Define them by default for a numbered chapter. -\global\let\section = \numberedsec -\global\let\subsection = \numberedsubsec -\global\let\subsubsection = \numberedsubsubsec - -% Define @majorheading, @heading and @subheading - -% NOTE on use of \vbox for chapter headings, section headings, and -% such: -% 1) We use \vbox rather than the earlier \line to permit -% overlong headings to fold. -% 2) \hyphenpenalty is set to 10000 because hyphenation in a -% heading is obnoxious; this forbids it. -% 3) Likewise, headings look best if no \parindent is used, and -% if justification is not attempted. Hence \raggedright. - - -\def\majorheading{\parsearg\majorheadingzzz} -\def\majorheadingzzz #1{% -{\advance\chapheadingskip by 10pt \chapbreak }% -{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\penalty 200} - -\def\chapheading{\parsearg\chapheadingzzz} -\def\chapheadingzzz #1{\chapbreak % -{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\penalty 200} - -\def\heading{\parsearg\secheadingi} - -\def\subheading{\parsearg\subsecheadingi} - -\def\subsubheading{\parsearg\subsubsecheadingi} - -% These macros generate a chapter, section, etc. heading only -% (including whitespace, linebreaking, etc. around it), -% given all the information in convenient, parsed form. - -%%% Args are the skip and penalty (usually negative) -\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} - -\def\setchapterstyle #1 {\csname CHAPF#1\endcsname} - -%%% Define plain chapter starts, and page on/off switching for it -% Parameter controlling skip before chapter headings (if needed) - -\newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt - -\def\chapbreak{\dobreak \chapheadingskip {-4000}} -\def\chappager{\par\vfill\supereject} -\def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi} - -\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} - -\def\CHAPPAGoff{ -\global\let\pchapsepmacro=\chapbreak -\global\let\pagealignmacro=\chappager} - -\def\CHAPPAGon{ -\global\let\pchapsepmacro=\chappager -\global\let\pagealignmacro=\chappager -\global\def\HEADINGSon{\HEADINGSsingle}} - -\def\CHAPPAGodd{ -\global\let\pchapsepmacro=\chapoddpage -\global\let\pagealignmacro=\chapoddpage -\global\def\HEADINGSon{\HEADINGSdouble}} - -\CHAPPAGon - -\def\CHAPFplain{ -\global\let\chapmacro=\chfplain -\global\let\unnumbchapmacro=\unnchfplain} - -\def\chfplain #1#2{% - \pchapsepmacro - {% - \chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #2\enspace #1}% - }% - \bigskip - \penalty5000 -} - -\def\unnchfplain #1{% -\pchapsepmacro % -{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\penalty 10000 % -} -\CHAPFplain % The default - -\def\unnchfopen #1{% -\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\penalty 10000 % -} - -\def\chfopen #1#2{\chapoddpage {\chapfonts -\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% -\par\penalty 5000 % -} - -\def\CHAPFopen{ -\global\let\chapmacro=\chfopen -\global\let\unnumbchapmacro=\unnchfopen} - -% Parameter controlling skip before section headings. - -\newskip \subsecheadingskip \subsecheadingskip = 17pt plus 8pt minus 4pt -\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}} - -\newskip \secheadingskip \secheadingskip = 21pt plus 8pt minus 4pt -\def\secheadingbreak{\dobreak \secheadingskip {-1000}} - -% @paragraphindent is defined for the Info formatting commands only. -\let\paragraphindent=\comment - -% Section fonts are the base font at magstep2, which produces -% a size a bit more than 14 points in the default situation. - -\def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}} -\def\plainsecheading #1{\secheadingi {#1}} -\def\secheadingi #1{{\advance \secheadingskip by \parskip % -\secheadingbreak}% -{\secfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}% -\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 } - - -% Subsection fonts are the base font at magstep1, -% which produces a size of 12 points. - -\def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}} -\def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip % -\subsecheadingbreak}% -{\subsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}% -\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 } - -\def\subsubsecfonts{\subsecfonts} % Maybe this should change: - % Perhaps make sssec fonts scaled - % magstep half -\def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}} -\def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip % -\subsecheadingbreak}% -{\subsubsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}% -\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000} - - -\message{toc printing,} - -% Finish up the main text and prepare to read what we've written -% to \contentsfile. - -\newskip\contentsrightmargin \contentsrightmargin=1in -\def\startcontents#1{% - \pagealignmacro - \immediate\closeout \contentsfile - \ifnum \pageno>0 - \pageno = -1 % Request roman numbered pages. - \fi - % Don't need to put `Contents' or `Short Contents' in the headline. - % It is abundantly clear what they are. - \unnumbchapmacro{#1}\def\thischapter{}% - \begingroup % Set up to handle contents files properly. - \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 - \catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi - \raggedbottom % Worry more about breakpoints than the bottom. - \advance\hsize by -\contentsrightmargin % Don't use the full line length. -} - - -% Normal (long) toc. -\outer\def\contents{% - \startcontents{\putwordTableofContents}% - \input \jobname.toc - \endgroup - \vfill \eject -} - -% And just the chapters. -\outer\def\summarycontents{% - \startcontents{\putwordShortContents}% - % - \let\chapentry = \shortchapentry - \let\unnumbchapentry = \shortunnumberedentry - % We want a true roman here for the page numbers. - \secfonts - \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl - \rm - \advance\baselineskip by 1pt % Open it up a little. - \def\secentry ##1##2##3##4{} - \def\unnumbsecentry ##1##2{} - \def\subsecentry ##1##2##3##4##5{} - \def\unnumbsubsecentry ##1##2{} - \def\subsubsecentry ##1##2##3##4##5##6{} - \def\unnumbsubsubsecentry ##1##2{} - \input \jobname.toc - \endgroup - \vfill \eject -} -\let\shortcontents = \summarycontents - -% These macros generate individual entries in the table of contents. -% The first argument is the chapter or section name. -% The last argument is the page number. -% The arguments in between are the chapter number, section number, ... - -% Chapter-level things, for both the long and short contents. -\def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}} - -% See comments in \dochapentry re vbox and related settings -\def\shortchapentry#1#2#3{% - \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}% -} - -% Typeset the label for a chapter or appendix for the short contents. -% The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter. -% We could simplify the code here by writing out an \appendixentry -% command in the toc file for appendices, instead of using \chapentry -% for both, but it doesn't seem worth it. -\setbox0 = \hbox{\shortcontrm \putwordAppendix } -\newdimen\shortappendixwidth \shortappendixwidth = \wd0 - -\def\shortchaplabel#1{% - % We typeset #1 in a box of constant width, regardless of the text of - % #1, so the chapter titles will come out aligned. - \setbox0 = \hbox{#1}% - \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi - % - % This space should be plenty, since a single number is .5em, and the - % widest letter (M) is 1em, at least in the Computer Modern fonts. - % (This space doesn't include the extra space that gets added after - % the label; that gets put in in \shortchapentry above.) - \advance\dimen0 by 1.1em - \hbox to \dimen0{#1\hfil}% -} - -\def\unnumbchapentry#1#2{\dochapentry{#1}{#2}} -\def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}} - -% Sections. -\def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}} -\def\unnumbsecentry#1#2{\dosecentry{#1}{#2}} - -% Subsections. -\def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}} -\def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}} - -% And subsubsections. -\def\subsubsecentry#1#2#3#4#5#6{% - \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}} -\def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}} - - -% This parameter controls the indentation of the various levels. -\newdimen\tocindent \tocindent = 3pc - -% Now for the actual typesetting. In all these, #1 is the text and #2 is the -% page number. -% -% If the toc has to be broken over pages, we would want to be at chapters -% if at all possible; hence the \penalty. -\def\dochapentry#1#2{% - \penalty-300 \vskip\baselineskip - \begingroup - \chapentryfonts - \tocentry{#1}{\dopageno{#2}}% - \endgroup - \nobreak\vskip .25\baselineskip -} - -\def\dosecentry#1#2{\begingroup - \secentryfonts \leftskip=\tocindent - \tocentry{#1}{\dopageno{#2}}% -\endgroup} - -\def\dosubsecentry#1#2{\begingroup - \subsecentryfonts \leftskip=2\tocindent - \tocentry{#1}{\dopageno{#2}}% -\endgroup} - -\def\dosubsubsecentry#1#2{\begingroup - \subsubsecentryfonts \leftskip=3\tocindent - \tocentry{#1}{\dopageno{#2}}% -\endgroup} - -% Final typesetting of a toc entry; we use the same \entry macro as for -% the index entries, but we want to suppress hyphenation here. (We -% can't do that in the \entry macro, since index entries might consist -% of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.) -% -% \turnoffactive is for the sake of @" used for umlauts. -\def\tocentry#1#2{\begingroup - \hyphenpenalty = 10000 - \entry{\turnoffactive #1}{\turnoffactive #2}% -\endgroup} - -% Space between chapter (or whatever) number and the title. -\def\labelspace{\hskip1em \relax} - -\def\dopageno#1{{\rm #1}} -\def\doshortpageno#1{{\rm #1}} - -\def\chapentryfonts{\secfonts \rm} -\def\secentryfonts{\textfonts} -\let\subsecentryfonts = \textfonts -\let\subsubsecentryfonts = \textfonts - - -\message{environments,} - -% Since these characters are used in examples, it should be an even number of -% \tt widths. Each \tt character is 1en, so two makes it 1em. -% Furthermore, these definitions must come after we define our fonts. -\newbox\dblarrowbox \newbox\longdblarrowbox -\newbox\pushcharbox \newbox\bullbox -\newbox\equivbox \newbox\errorbox - -\let\ptexequiv = \equiv - -%{\tentt -%\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil} -%\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil} -%\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil} -%\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil} -% Adapted from the manmac format (p.420 of TeXbook) -%\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex -% depth .1ex\hfil} -%} - -\def\point{$\star$} - -\def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} -\def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}} -\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} - -\def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}} - -% Adapted from the TeXbook's \boxit. -{\tentt \global\dimen0 = 3em}% Width of the box. -\dimen2 = .55pt % Thickness of rules -% The text. (`r' is open on the right, `e' somewhat less so on the left.) -\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt} - -\global\setbox\errorbox=\hbox to \dimen0{\hfil - \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. - \advance\hsize by -2\dimen2 % Rules. - \vbox{ - \hrule height\dimen2 - \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. - \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. - \kern3pt\vrule width\dimen2}% Space to right. - \hrule height\dimen2} - \hfil} - -% The @error{} command. -\def\error{\leavevmode\lower.7ex\copy\errorbox} - -% @tex ... @end tex escapes into raw Tex temporarily. -% One exception: @ is still an escape character, so that @end tex works. -% But \@ or @@ will get a plain tex @ character. - -\def\tex{\begingroup -\catcode `\\=0 \catcode `\{=1 \catcode `\}=2 -\catcode `\$=3 \catcode `\&=4 \catcode `\#=6 -\catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie -\catcode `\%=14 -\catcode 43=12 -\catcode`\"=12 -\catcode`\==12 -\catcode`\|=12 -\catcode`\<=12 -\catcode`\>=12 -\escapechar=`\\ -% -\let\~=\ptextilde -\let\{=\ptexlbrace -\let\}=\ptexrbrace -\let\.=\ptexdot -\let\*=\ptexstar -\let\dots=\ptexdots -\def\@{@}% -\let\bullet=\ptexbullet -\let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl -\let\L=\ptexL -% -\let\Etex=\endgroup} - -% Define @lisp ... @endlisp. -% @lisp does a \begingroup so it can rebind things, -% including the definition of @endlisp (which normally is erroneous). - -% Amount to narrow the margins by for @lisp. -\newskip\lispnarrowing \lispnarrowing=0.4in - -% This is the definition that ^^M gets inside @lisp, @example, and other -% such environments. \null is better than a space, since it doesn't -% have any width. -\def\lisppar{\null\endgraf} - -% Make each space character in the input produce a normal interword -% space in the output. Don't allow a line break at this space, as this -% is used only in environments like @example, where each line of input -% should produce a line of output anyway. -% -{\obeyspaces % -\gdef\sepspaces{\obeyspaces\let =\tie}} - -% Define \obeyedspace to be our active space, whatever it is. This is -% for use in \parsearg. -{\sepspaces% -\global\let\obeyedspace= } - -% This space is always present above and below environments. -\newskip\envskipamount \envskipamount = 0pt - -% Make spacing and below environment symmetrical. We use \parskip here -% to help in doing that, since in @example-like environments \parskip -% is reset to zero; thus the \afterenvbreak inserts no space -- but the -% start of the next paragraph will insert \parskip -% -\def\aboveenvbreak{{\advance\envskipamount by \parskip -\endgraf \ifdim\lastskip<\envskipamount -\removelastskip \penalty-50 \vskip\envskipamount \fi}} - -\let\afterenvbreak = \aboveenvbreak - -% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins. -\let\nonarrowing=\relax - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% \cartouche: draw rectangle w/rounded corners around argument -\font\circle=lcircle10 -\newdimen\circthick -\newdimen\cartouter\newdimen\cartinner -\newskip\normbskip\newskip\normpskip\newskip\normlskip -\circthick=\fontdimen8\circle -% -\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth -\def\ctr{{\hskip 6pt\circle\char'010}} -\def\cbl{{\circle\char'012\hskip -6pt}} -\def\cbr{{\hskip 6pt\circle\char'011}} -\def\carttop{\hbox to \cartouter{\hskip\lskip - \ctl\leaders\hrule height\circthick\hfil\ctr - \hskip\rskip}} -\def\cartbot{\hbox to \cartouter{\hskip\lskip - \cbl\leaders\hrule height\circthick\hfil\cbr - \hskip\rskip}} -% -\newskip\lskip\newskip\rskip - -\long\def\cartouche{% -\begingroup - \lskip=\leftskip \rskip=\rightskip - \leftskip=0pt\rightskip=0pt %we want these *outside*. - \cartinner=\hsize \advance\cartinner by-\lskip - \advance\cartinner by-\rskip - \cartouter=\hsize - \advance\cartouter by 18pt % allow for 3pt kerns on either -% side, and for 6pt waste from -% each corner char - \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip - % Flag to tell @lisp, etc., not to narrow margin. - \let\nonarrowing=\comment - \vbox\bgroup - \baselineskip=0pt\parskip=0pt\lineskip=0pt - \carttop - \hbox\bgroup - \hskip\lskip - \vrule\kern3pt - \vbox\bgroup - \hsize=\cartinner - \kern3pt - \begingroup - \baselineskip=\normbskip - \lineskip=\normlskip - \parskip=\normpskip - \vskip -\parskip -\def\Ecartouche{% - \endgroup - \kern3pt - \egroup - \kern3pt\vrule - \hskip\rskip - \egroup - \cartbot - \egroup -\endgroup -}} - - -% This macro is called at the beginning of all the @example variants, -% inside a group. -\def\nonfillstart{% - \aboveenvbreak - \inENV % This group ends at the end of the body - \hfuzz = 12pt % Don't be fussy - \sepspaces % Make spaces be word-separators rather than space tokens. - \singlespace - \let\par = \lisppar % don't ignore blank lines - \obeylines % each line of input is a line of output - \parskip = 0pt - \parindent = 0pt - \emergencystretch = 0pt % don't try to avoid overfull boxes - % @cartouche defines \nonarrowing to inhibit narrowing - % at next level down. - \ifx\nonarrowing\relax - \advance \leftskip by \lispnarrowing - \exdentamount=\lispnarrowing - \let\exdent=\nofillexdent - \let\nonarrowing=\relax - \fi -} - -% To ending an @example-like environment, we first end the paragraph -% (via \afterenvbreak's vertical glue), and then the group. That way we -% keep the zero \parskip that the environments set -- \parskip glue -% will be inserted at the beginning of the next paragraph in the -% document, after the environment. -% -\def\nonfillfinish{\afterenvbreak\endgroup}% - -% This macro is -\def\lisp{\begingroup - \nonfillstart - \let\Elisp = \nonfillfinish - \tt - \rawbackslash % have \ input char produce \ char from current font - \gobble -} - -% Define the \E... control sequence only if we are inside the -% environment, so the error checking in \end will work. -% -% We must call \lisp last in the definition, since it reads the -% return following the @example (or whatever) command. -% -\def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp} -\def\smallexample{\begingroup \def\Esmallexample{\nonfillfinish\endgroup}\lisp} -\def\smalllisp{\begingroup \def\Esmalllisp{\nonfillfinish\endgroup}\lisp} - -% @smallexample and @smalllisp. This is not used unless the @smallbook -% command is given. Originally contributed by Pavel@xerox. -% -\def\smalllispx{\begingroup - \nonfillstart - \let\Esmalllisp = \nonfillfinish - \let\Esmallexample = \nonfillfinish - % - % Smaller interline space and fonts for small examples. - \setleading{10pt}% - \indexfonts \tt - \rawbackslash % make \ output the \ character from the current font (tt) - \gobble -} - -% This is @display; same as @lisp except use roman font. -% -\def\display{\begingroup - \nonfillstart - \let\Edisplay = \nonfillfinish - \gobble -} - -% This is @format; same as @display except don't narrow margins. -% -\def\format{\begingroup - \let\nonarrowing = t - \nonfillstart - \let\Eformat = \nonfillfinish - \gobble -} - -% @flushleft (same as @format) and @flushright. -% -\def\flushleft{\begingroup - \let\nonarrowing = t - \nonfillstart - \let\Eflushleft = \nonfillfinish - \gobble -} -\def\flushright{\begingroup - \let\nonarrowing = t - \nonfillstart - \let\Eflushright = \nonfillfinish - \advance\leftskip by 0pt plus 1fill - \gobble} - -% @quotation does normal linebreaking (hence we can't use \nonfillstart) -% and narrows the margins. -% -\def\quotation{% - \begingroup\inENV %This group ends at the end of the @quotation body - {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip - \singlespace - \parindent=0pt - % We have retained a nonzero parskip for the environment, since we're - % doing normal filling. So to avoid extra space below the environment... - \def\Equotation{\parskip = 0pt \nonfillfinish}% - % - % @cartouche defines \nonarrowing to inhibit narrowing at next level down. - \ifx\nonarrowing\relax - \advance\leftskip by \lispnarrowing - \advance\rightskip by \lispnarrowing - \exdentamount = \lispnarrowing - \let\nonarrowing = \relax - \fi -} - -\message{defuns,} -% Define formatter for defuns -% First, allow user to change definition object font (\df) internally -\def\setdeffont #1 {\csname DEF#1\endcsname} - -\newskip\defbodyindent \defbodyindent=.4in -\newskip\defargsindent \defargsindent=50pt -\newskip\deftypemargin \deftypemargin=12pt -\newskip\deflastargmargin \deflastargmargin=18pt - -\newcount\parencount -% define \functionparens, which makes ( and ) and & do special things. -% \functionparens affects the group it is contained in. -\def\activeparens{% -\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active -\catcode`\[=\active \catcode`\]=\active} - -% Make control sequences which act like normal parenthesis chars. -\let\lparen = ( \let\rparen = ) - -{\activeparens % Now, smart parens don't turn on until &foo (see \amprm) - -% Be sure that we always have a definition for `(', etc. For example, -% if the fn name has parens in it, \boldbrax will not be in effect yet, -% so TeX would otherwise complain about undefined control sequence. -\global\let(=\lparen \global\let)=\rparen -\global\let[=\lbrack \global\let]=\rbrack - -\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 } -\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} -% This is used to turn on special parens -% but make & act ordinary (given that it's active). -\gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr} - -% Definitions of (, ) and & used in args for functions. -% This is the definition of ( outside of all parentheses. -\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested % -\global\advance\parencount by 1 } -% -% This is the definition of ( when already inside a level of parens. -\gdef\opnested{\char`\(\global\advance\parencount by 1 } -% -\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0. -% also in that case restore the outer-level definition of (. -\ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi -\global\advance \parencount by -1 } -% If we encounter &foo, then turn on ()-hacking afterwards -\gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ } -% -\gdef\normalparens{\boldbrax\let&=\ampnr} -} % End of definition inside \activeparens -%% These parens (in \boldbrax) actually are a little bolder than the -%% contained text. This is especially needed for [ and ] -\def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&} -\def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}} - -% First, defname, which formats the header line itself. -% #1 should be the function name. -% #2 should be the type of definition, such as "Function". - -\def\defname #1#2{% -% Get the values of \leftskip and \rightskip as they were -% outside the @def... -\dimen2=\leftskip -\advance\dimen2 by -\defbodyindent -\dimen3=\rightskip -\advance\dimen3 by -\defbodyindent -\noindent % -\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}% -\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line -\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations -\parshape 2 0in \dimen0 \defargsindent \dimen1 % -% Now output arg 2 ("Function" or some such) -% ending at \deftypemargin from the right margin, -% but stuck inside a box of width 0 so it does not interfere with linebreaking -{% Adjust \hsize to exclude the ambient margins, -% so that \rightline will obey them. -\advance \hsize by -\dimen2 \advance \hsize by -\dimen3 -\rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}% -% Make all lines underfull and no complaints: -\tolerance=10000 \hbadness=10000 -\advance\leftskip by -\defbodyindent -\exdentamount=\defbodyindent -{\df #1}\enskip % Generate function name -} - -% Actually process the body of a definition -% #1 should be the terminating control sequence, such as \Edefun. -% #2 should be the "another name" control sequence, such as \defunx. -% #3 should be the control sequence that actually processes the header, -% such as \defunheader. - -\def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2{\begingroup\obeylines\activeparens\spacesplit#3}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup % -\catcode 61=\active % 61 is `=' -\obeylines\activeparens\spacesplit#3} - -\def\defmethparsebody #1#2#3#4 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\activeparens\spacesplit{#3{#4}}} - -\def\defopparsebody #1#2#3#4#5 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 ##2 {\def#4{##1}% -\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\activeparens\spacesplit{#3{#5}}} - -% These parsing functions are similar to the preceding ones -% except that they do not make parens into active characters. -% These are used for "variables" since they have no arguments. - -\def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2{\begingroup\obeylines\spacesplit#3}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup % -\catcode 61=\active % -\obeylines\spacesplit#3} - -% This is used for \def{tp,vr}parsebody. It could probably be used for -% some of the others, too, with some judicious conditionals. -% -\def\parsebodycommon#1#2#3{% - \begingroup\inENV % - \medbreak % - % Define the end token that this defining construct specifies - % so that it will exit this group. - \def#1{\endgraf\endgroup\medbreak}% - \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}% - \parindent=0in - \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent - \exdentamount=\defbodyindent - \begingroup\obeylines -} - -\def\defvrparsebody#1#2#3#4 {% - \parsebodycommon{#1}{#2}{#3}% - \spacesplit{#3{#4}}% -} - -% This loses on `@deftp {Data Type} {struct termios}' -- it thinks the -% type is just `struct', because we lose the braces in `{struct -% termios}' when \spacesplit reads its undelimited argument. Sigh. -% \let\deftpparsebody=\defvrparsebody -% -% So, to get around this, we put \empty in with the type name. That -% way, TeX won't find exactly `{...}' as an undelimited argument, and -% won't strip off the braces. -% -\def\deftpparsebody #1#2#3#4 {% - \parsebodycommon{#1}{#2}{#3}% - \spacesplit{\parsetpheaderline{#3{#4}}}\empty -} - -% Fine, but then we have to eventually remove the \empty *and* the -% braces (if any). That's what this does, putting the result in \tptemp. -% -\def\removeemptybraces\empty#1\relax{\def\tptemp{#1}}% - -% After \spacesplit has done its work, this is called -- #1 is the final -% thing to call, #2 the type name (which starts with \empty), and #3 -% (which might be empty) the arguments. -% -\def\parsetpheaderline#1#2#3{% - \removeemptybraces#2\relax - #1{\tptemp}{#3}% -}% - -\def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 ##2 {\def#4{##1}% -\begingroup\obeylines\spacesplit{#3{##2}}}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\spacesplit{#3{#5}}} - -% Split up #2 at the first space token. -% call #1 with two arguments: -% the first is all of #2 before the space token, -% the second is all of #2 after that space token. -% If #2 contains no space token, all of it is passed as the first arg -% and the second is passed as empty. - -{\obeylines -\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}% -\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{% -\ifx\relax #3% -#1{#2}{}\else #1{#2}{#3#4}\fi}} - -% So much for the things common to all kinds of definitions. - -% Define @defun. - -% First, define the processing that is wanted for arguments of \defun -% Use this to expand the args and terminate the paragraph they make up - -\def\defunargs #1{\functionparens \sl -% Expand, preventing hyphenation at `-' chars. -% Note that groups don't affect changes in \hyphenchar. -\hyphenchar\tensl=0 -#1% -\hyphenchar\tensl=45 -\ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi% -\interlinepenalty=10000 -\advance\rightskip by 0pt plus 1fil -\endgraf\penalty 10000\vskip -\parskip\penalty 10000% -} - -\def\deftypefunargs #1{% -% Expand, preventing hyphenation at `-' chars. -% Note that groups don't affect changes in \hyphenchar. -% Use \boldbraxnoamp, not \functionparens, so that & is not special. -\boldbraxnoamp -\tclose{#1}% avoid \code because of side effects on active chars -\interlinepenalty=10000 -\advance\rightskip by 0pt plus 1fil -\endgraf\penalty 10000\vskip -\parskip\penalty 10000% -} - -% Do complete processing of one @defun or @defunx line already parsed. - -% @deffn Command forward-char nchars - -\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader} - -\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}% -\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @defun == @deffn Function - -\def\defun{\defparsebody\Edefun\defunx\defunheader} - -\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index -\begingroup\defname {#1}{Function}% -\defunargs {#2}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @deftypefun int foobar (int @var{foo}, float @var{bar}) - -\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader} - -% #1 is the data type. #2 is the name and args. -\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax} -% #1 is the data type, #2 the name, #3 the args. -\def\deftypefunheaderx #1#2 #3\relax{% -\doind {fn}{\code{#2}}% Make entry in function index -\begingroup\defname {\defheaderxcond#1\relax$$$#2}{Function}% -\deftypefunargs {#3}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) - -\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader} - -% \defheaderxcond#1\relax$$$ -% puts #1 in @code, followed by a space, but does nothing if #1 is null. -\def\defheaderxcond#1#2$$${\ifx#1\relax\else\code{#1#2} \fi} - -% #1 is the classification. #2 is the data type. #3 is the name and args. -\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax} -% #1 is the classification, #2 the data type, #3 the name, #4 the args. -\def\deftypefnheaderx #1#2#3 #4\relax{% -\doind {fn}{\code{#3}}% Make entry in function index -\begingroup -\normalparens % notably, turn off `&' magic, which prevents -% at least some C++ text from working -\defname {\defheaderxcond#2\relax$$$#3}{#1}% -\deftypefunargs {#4}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @defmac == @deffn Macro - -\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader} - -\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index -\begingroup\defname {#1}{Macro}% -\defunargs {#2}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @defspec == @deffn Special Form - -\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader} - -\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index -\begingroup\defname {#1}{Special Form}% -\defunargs {#2}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% This definition is run if you use @defunx -% anywhere other than immediately after a @defun or @defunx. - -\def\deffnx #1 {\errmessage{@deffnx in invalid context}} -\def\defunx #1 {\errmessage{@defunx in invalid context}} -\def\defmacx #1 {\errmessage{@defmacx in invalid context}} -\def\defspecx #1 {\errmessage{@defspecx in invalid context}} -\def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}} -\def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}} - -% @defmethod, and so on - -% @defop {Funny Method} foo-class frobnicate argument - -\def\defop #1 {\def\defoptype{#1}% -\defopparsebody\Edefop\defopx\defopheader\defoptype} - -\def\defopheader #1#2#3{% -\dosubind {fn}{\code{#2}}{on #1}% Make entry in function index -\begingroup\defname {#2}{\defoptype{} on #1}% -\defunargs {#3}\endgroup % -} - -% @defmethod == @defop Method - -\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader} - -\def\defmethodheader #1#2#3{% -\dosubind {fn}{\code{#2}}{on #1}% entry in function index -\begingroup\defname {#2}{Method on #1}% -\defunargs {#3}\endgroup % -} - -% @defcv {Class Option} foo-class foo-flag - -\def\defcv #1 {\def\defcvtype{#1}% -\defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype} - -\def\defcvarheader #1#2#3{% -\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index -\begingroup\defname {#2}{\defcvtype{} of #1}% -\defvarargs {#3}\endgroup % -} - -% @defivar == @defcv {Instance Variable} - -\def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader} - -\def\defivarheader #1#2#3{% -\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index -\begingroup\defname {#2}{Instance Variable of #1}% -\defvarargs {#3}\endgroup % -} - -% These definitions are run if you use @defmethodx, etc., -% anywhere other than immediately after a @defmethod, etc. - -\def\defopx #1 {\errmessage{@defopx in invalid context}} -\def\defmethodx #1 {\errmessage{@defmethodx in invalid context}} -\def\defcvx #1 {\errmessage{@defcvx in invalid context}} -\def\defivarx #1 {\errmessage{@defivarx in invalid context}} - -% Now @defvar - -% First, define the processing that is wanted for arguments of @defvar. -% This is actually simple: just print them in roman. -% This must expand the args and terminate the paragraph they make up -\def\defvarargs #1{\normalparens #1% -\interlinepenalty=10000 -\endgraf\penalty 10000\vskip -\parskip\penalty 10000} - -% @defvr Counter foo-count - -\def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader} - -\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}% -\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup} - -% @defvar == @defvr Variable - -\def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader} - -\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index -\begingroup\defname {#1}{Variable}% -\defvarargs {#2}\endgroup % -} - -% @defopt == @defvr {User Option} - -\def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader} - -\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index -\begingroup\defname {#1}{User Option}% -\defvarargs {#2}\endgroup % -} - -% @deftypevar int foobar - -\def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader} - -% #1 is the data type. #2 is the name. -\def\deftypevarheader #1#2{% -\doind {vr}{\code{#2}}% Make entry in variables index -\begingroup\defname {\defheaderxcond#1\relax$$$#2}{Variable}% -\interlinepenalty=10000 -\endgraf\penalty 10000\vskip -\parskip\penalty 10000 -\endgroup} - -% @deftypevr {Global Flag} int enable - -\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader} - -\def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}% -\begingroup\defname {\defheaderxcond#2\relax$$$#3}{#1} -\interlinepenalty=10000 -\endgraf\penalty 10000\vskip -\parskip\penalty 10000 -\endgroup} - -% This definition is run if you use @defvarx -% anywhere other than immediately after a @defvar or @defvarx. - -\def\defvrx #1 {\errmessage{@defvrx in invalid context}} -\def\defvarx #1 {\errmessage{@defvarx in invalid context}} -\def\defoptx #1 {\errmessage{@defoptx in invalid context}} -\def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}} -\def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}} - -% Now define @deftp -% Args are printed in bold, a slight difference from @defvar. - -\def\deftpargs #1{\bf \defvarargs{#1}} - -% @deftp Class window height width ... - -\def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader} - -\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}% -\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup} - -% This definition is run if you use @deftpx, etc -% anywhere other than immediately after a @deftp, etc. - -\def\deftpx #1 {\errmessage{@deftpx in invalid context}} - -\message{cross reference,} -% Define cross-reference macros -\newwrite \auxfile - -\newif\ifhavexrefs % True if xref values are known. -\newif\ifwarnedxrefs % True if we warned once that they aren't known. - -% \setref{foo} defines a cross-reference point named foo. - -\def\setref#1{% -\dosetq{#1-title}{Ytitle}% -\dosetq{#1-pg}{Ypagenumber}% -\dosetq{#1-snt}{Ysectionnumberandtype}} - -\def\unnumbsetref#1{% -\dosetq{#1-title}{Ytitle}% -\dosetq{#1-pg}{Ypagenumber}% -\dosetq{#1-snt}{Ynothing}} - -\def\appendixsetref#1{% -\dosetq{#1-title}{Ytitle}% -\dosetq{#1-pg}{Ypagenumber}% -\dosetq{#1-snt}{Yappendixletterandtype}} - -% \xref, \pxref, and \ref generate cross-references to specified points. -% For \xrefX, #1 is the node name, #2 the name of the Info -% cross-reference, #3 the printed node name, #4 the name of the Info -% file, #5 the name of the printed manual. All but the node name can be -% omitted. -% -\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]} -\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} -\def\ref#1{\xrefX[#1,,,,,,,]} -\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup - \def\printedmanual{\ignorespaces #5}% - \def\printednodename{\ignorespaces #3}% - \setbox1=\hbox{\printedmanual}% - \setbox0=\hbox{\printednodename}% - \ifdim \wd0 = 0pt - % No printed node name was explicitly given. - \ifx\SETxref-automatic-section-title\relax % - % Use the actual chapter/section title appear inside - % the square brackets. Use the real section title if we have it. - \ifdim \wd1>0pt% - % It is in another manual, so we don't have it. - \def\printednodename{\ignorespaces #1}% - \else - \ifhavexrefs - % We know the real title if we have the xref values. - \def\printednodename{\refx{#1-title}}% - \else - % Otherwise just copy the Info node name. - \def\printednodename{\ignorespaces #1}% - \fi% - \fi - \def\printednodename{#1-title}% - \else - % Use the node name inside the square brackets. - \def\printednodename{\ignorespaces #1}% - \fi - \fi - % - % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not - % insert empty discretionaries after hyphens, which means that it will - % not find a line break at a hyphen in a node names. Since some manuals - % are best written with fairly long node names, containing hyphens, this - % is a loss. Therefore, we give the text of the node name again, so it - % is as if TeX is seeing it for the first time. - \ifdim \wd1 > 0pt - \putwordsection{} ``\printednodename'' in \cite{\printedmanual}% - \else - % _ (for example) has to be the character _ for the purposes of the - % control sequence corresponding to the node, but it has to expand - % into the usual \leavevmode...\vrule stuff for purposes of - % printing. So we \turnoffactive for the \refx-snt, back on for the - % printing, back off for the \refx-pg. - {\turnoffactive \refx{#1-snt}{}}% - \space [\printednodename],\space - \turnoffactive \putwordpage\tie\refx{#1-pg}{}% - \fi -\endgroup} - -% \dosetq is the interface for calls from other macros - -% Use \turnoffactive so that punctuation chars such as underscore -% work in node names. -\def\dosetq #1#2{{\let\folio=0 \turnoffactive \auxhat% -\edef\next{\write\auxfile{\internalsetq {#1}{#2}}}% -\next}} - -% \internalsetq {foo}{page} expands into -% CHARACTERS 'xrdef {foo}{...expansion of \Ypage...} -% When the aux file is read, ' is the escape character - -\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}} - -% Things to be expanded by \internalsetq - -\def\Ypagenumber{\folio} - -\def\Ytitle{\thissection} - -\def\Ynothing{} - -\def\Ysectionnumberandtype{% -\ifnum\secno=0 \putwordChapter\xreftie\the\chapno % -\else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno % -\else \ifnum \subsubsecno=0 % -\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno % -\else % -\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno % -\fi \fi \fi } - -\def\Yappendixletterandtype{% -\ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}% -\else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno % -\else \ifnum \subsubsecno=0 % -\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno % -\else % -\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno % -\fi \fi \fi } - -\gdef\xreftie{'tie} - -% Use TeX 3.0's \inputlineno to get the line number, for better error -% messages, but if we're using an old version of TeX, don't do anything. -% -\ifx\inputlineno\thisisundefined - \let\linenumber = \empty % Non-3.0. -\else - \def\linenumber{\the\inputlineno:\space} -\fi - -% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. -% If its value is nonempty, SUFFIX is output afterward. - -\def\refx#1#2{% - \expandafter\ifx\csname X#1\endcsname\relax - % If not defined, say something at least. - $\langle$un\-de\-fined$\rangle$% - \ifhavexrefs - \message{\linenumber Undefined cross reference `#1'.}% - \else - \ifwarnedxrefs\else - \global\warnedxrefstrue - \message{Cross reference values unknown; you must run TeX again.}% - \fi - \fi - \else - % It's defined, so just use it. - \csname X#1\endcsname - \fi - #2% Output the suffix in any case. -} - -% Read the last existing aux file, if any. No error if none exists. - -% This is the macro invoked by entries in the aux file. -\def\xrdef #1#2{ -{\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}} - -\def\readauxfile{% -\begingroup -\catcode `\^^@=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\^^C=\other -\catcode `\^^D=\other -\catcode `\^^E=\other -\catcode `\^^F=\other -\catcode `\^^G=\other -\catcode `\^^H=\other -\catcode `\=\other -\catcode `\^^L=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode 26=\other -\catcode `\^^[=\other -\catcode `\^^\=\other -\catcode `\^^]=\other -\catcode `\^^^=\other -\catcode `\^^_=\other -\catcode `\@=\other -\catcode `\^=\other -\catcode `\~=\other -\catcode `\[=\other -\catcode `\]=\other -\catcode`\"=\other -\catcode`\_=\other -\catcode`\|=\other -\catcode`\<=\other -\catcode`\>=\other -\catcode `\$=\other -\catcode `\#=\other -\catcode `\&=\other -% `\+ does not work, so use 43. -\catcode 43=\other -% Make the characters 128-255 be printing characters -{% - \count 1=128 - \def\loop{% - \catcode\count 1=\other - \advance\count 1 by 1 - \ifnum \count 1<256 \loop \fi - }% -}% -% the aux file uses ' as the escape. -% Turn off \ as an escape so we do not lose on -% entries which were dumped with control sequences in their names. -% For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^ -% Reference to such entries still does not work the way one would wish, -% but at least they do not bomb out when the aux file is read in. -\catcode `\{=1 \catcode `\}=2 -\catcode `\%=\other -\catcode `\'=0 -\catcode`\^=7 % to make ^^e4 etc usable in xref tags -\catcode `\\=\other -\openin 1 \jobname.aux -\ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue -\global\warnedobstrue -\fi -% Open the new aux file. Tex will close it automatically at exit. -\openout \auxfile=\jobname.aux -\endgroup} - - -% Footnotes. - -\newcount \footnoteno - -% The trailing space in the following definition for supereject is -% vital for proper filling; pages come out unaligned when you do a -% pagealignmacro call if that space before the closing brace is -% removed. -\def\supereject{\par\penalty -20000\footnoteno =0 } - -% @footnotestyle is meaningful for info output only.. -\let\footnotestyle=\comment - -\let\ptexfootnote=\footnote - -{\catcode `\@=11 -% -% Auto-number footnotes. Otherwise like plain. -\gdef\footnote{% - \global\advance\footnoteno by \@ne - \edef\thisfootno{$^{\the\footnoteno}$}% - % - % In case the footnote comes at the end of a sentence, preserve the - % extra spacing after we do the footnote number. - \let\@sf\empty - \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi - % - % Remove inadvertent blank space before typesetting the footnote number. - \unskip - \thisfootno\@sf - \footnotezzz -}% - -% Don't bother with the trickery in plain.tex to not require the -% footnote text as a parameter. Our footnotes don't need to be so general. -% -\long\gdef\footnotezzz#1{\insert\footins{% - % We want to typeset this text as a normal paragraph, even if the - % footnote reference occurs in (for example) a display environment. - % So reset some parameters. - \interlinepenalty\interfootnotelinepenalty - \splittopskip\ht\strutbox % top baseline for broken footnotes - \splitmaxdepth\dp\strutbox - \floatingpenalty\@MM - \leftskip\z@skip - \rightskip\z@skip - \spaceskip\z@skip - \xspaceskip\z@skip - \parindent\defaultparindent - % - % Hang the footnote text off the number. - \hang - \textindent{\thisfootno}% - % - % Don't crash into the line above the footnote text. Since this - % expands into a box, it must come within the paragraph, lest it - % provide a place where TeX can split the footnote. - \footstrut - #1\strut}% -} - -}%end \catcode `\@=11 - -% Set the baselineskip to #1, and the lineskip and strut size -% correspondingly. There is no deep meaning behind these magic numbers -% used as factors; they just match (closely enough) what Knuth defined. -% -\def\lineskipfactor{.08333} -\def\strutheightpercent{.70833} -\def\strutdepthpercent {.29167} -% -\def\setleading#1{% - \normalbaselineskip = #1\relax - \normallineskip = \lineskipfactor\normalbaselineskip - \normalbaselines - \setbox\strutbox =\hbox{% - \vrule width0pt height\strutheightpercent\baselineskip - depth \strutdepthpercent \baselineskip - }% -} - -% @| inserts a changebar to the left of the current line. It should -% surround any changed text. This approach does *not* work if the -% change spans more than two lines of output. To handle that, we would -% have adopt a much more difficult approach (putting marks into the main -% vertical list for the beginning and end of each change). -% -\def\|{% - % \vadjust can only be used in horizontal mode. - \leavevmode - % - % Append this vertical mode material after the current line in the output. - \vadjust{% - % We want to insert a rule with the height and depth of the current - % leading; that is exactly what \strutbox is supposed to record. - \vskip-\baselineskip - % - % \vadjust-items are inserted at the left edge of the type. So - % the \llap here moves out into the left-hand margin. - \llap{% - % - % For a thicker or thinner bar, change the `1pt'. - \vrule height\baselineskip width1pt - % - % This is the space between the bar and the text. - \hskip 12pt - }% - }% -} - -% For a final copy, take out the rectangles -% that mark overfull boxes (in case you have decided -% that the text looks ok even though it passes the margin). -% -\def\finalout{\overfullrule=0pt} - - -% End of control word definitions. - -\message{and turning on texinfo input format.} - -\def\openindices{% - \newindex{cp}% - \newcodeindex{fn}% - \newcodeindex{vr}% - \newcodeindex{tp}% - \newcodeindex{ky}% - \newcodeindex{pg}% -} - -% Set some numeric style parameters, for 8.5 x 11 format. - -%\hsize = 6.5in -\newdimen\defaultparindent \defaultparindent = 15pt -\parindent = \defaultparindent -\parskip 18pt plus 1pt -\setleading{15pt} -\advance\topskip by 1.2cm - -% Prevent underfull vbox error messages. -\vbadness=10000 - -% Following George Bush, just get rid of widows and orphans. -\widowpenalty=10000 -\clubpenalty=10000 - -% Use TeX 3.0's \emergencystretch to help line breaking, but if we're -% using an old version of TeX, don't do anything. We want the amount of -% stretch added to depend on the line length, hence the dependence on -% \hsize. This makes it come to about 9pt for the 8.5x11 format. -% -\ifx\emergencystretch\thisisundefined - % Allow us to assign to \emergencystretch anyway. - \def\emergencystretch{\dimen0}% -\else - \emergencystretch = \hsize - \divide\emergencystretch by 45 -\fi - -% Use @smallbook to reset parameters for 7x9.5 format (or else 7x9.25) -\def\smallbook{ - -% These values for secheadingskip and subsecheadingskip are -% experiments. RJC 7 Aug 1992 -\global\secheadingskip = 17pt plus 6pt minus 3pt -\global\subsecheadingskip = 14pt plus 6pt minus 3pt - -\global\lispnarrowing = 0.3in -\setleading{12pt} -\advance\topskip by -1cm -\global\parskip 3pt plus 1pt -\global\hsize = 5in -\global\vsize=7.5in -\global\tolerance=700 -\global\hfuzz=1pt -\global\contentsrightmargin=0pt -\global\deftypemargin=0pt -\global\defbodyindent=.5cm - -\global\pagewidth=\hsize -\global\pageheight=\vsize - -\global\let\smalllisp=\smalllispx -\global\let\smallexample=\smalllispx -\global\def\Esmallexample{\Esmalllisp} -} - -% Use @afourpaper to print on European A4 paper. -\def\afourpaper{ -\global\tolerance=700 -\global\hfuzz=1pt -\setleading{12pt} -\global\parskip 15pt plus 1pt - -\global\vsize= 53\baselineskip -\advance\vsize by \topskip -%\global\hsize= 5.85in % A4 wide 10pt -\global\hsize= 6.5in -\global\outerhsize=\hsize -\global\advance\outerhsize by 0.5in -\global\outervsize=\vsize -\global\advance\outervsize by 0.6in - -\global\pagewidth=\hsize -\global\pageheight=\vsize -} - -% Allow control of the text dimensions. Parameters in order: textheight; -% textwidth; \voffset; \hoffset (!); binding offset. All require a dimension; -% header is additional; added length extends the bottom of the page. - -\def\changepagesizes#1#2#3#4#5{ - \global\vsize= #1 - \advance\vsize by \topskip - \global\voffset= #3 - \global\hsize= #2 - \global\outerhsize=\hsize - \global\advance\outerhsize by 0.5in - \global\outervsize=\vsize - \global\advance\outervsize by 0.6in - \global\pagewidth=\hsize - \global\pageheight=\vsize - \global\normaloffset= #4 - \global\bindingoffset= #5} - -% This layout is compatible with Latex on A4 paper. - -\def\afourlatex{\changepagesizes{22cm}{15cm}{7mm}{4.6mm}{5mm}} - -% Use @afourwide to print on European A4 paper in wide format. -\def\afourwide{\afourpaper -\changepagesizes{9.5in}{6.5in}{\hoffset}{\normaloffset}{\bindingoffset}} - -% Define macros to output various characters with catcode for normal text. -\catcode`\"=\other -\catcode`\~=\other -\catcode`\^=\other -\catcode`\_=\other -\catcode`\|=\other -\catcode`\<=\other -\catcode`\>=\other -\catcode`\+=\other -\def\normaldoublequote{"} -\def\normaltilde{~} -\def\normalcaret{^} -\def\normalunderscore{_} -\def\normalverticalbar{|} -\def\normalless{<} -\def\normalgreater{>} -\def\normalplus{+} - -% This macro is used to make a character print one way in ttfont -% where it can probably just be output, and another way in other fonts, -% where something hairier probably needs to be done. -% -% #1 is what to print if we are indeed using \tt; #2 is what to print -% otherwise. Since all the Computer Modern typewriter fonts have zero -% interword stretch (and shrink), and it is reasonable to expect all -% typewriter fonts to have this, we can check that font parameter. -% -\def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi} - -% Turn off all special characters except @ -% (and those which the user can use as if they were ordinary). -% Most of these we simply print from the \tt font, but for some, we can -% use math or other variants that look better in normal text. - -\catcode`\"=\active -\def\activedoublequote{{\tt \char '042}} -\let"=\activedoublequote -\catcode`\~=\active -\def~{{\tt \char '176}} -\chardef\hat=`\^ -\catcode`\^=\active -\def\auxhat{\def^{'hat}} -\def^{{\tt \hat}} - -\catcode`\_=\active -\def_{\ifusingtt\normalunderscore\_} -% Subroutine for the previous macro. -\def\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}} - -% \lvvmode is equivalent in function to \leavevmode. -% Using \leavevmode runs into trouble when written out to -% an index file due to the expansion of \leavevmode into ``\unhbox -% \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our -% magic tricks with @. -\def\lvvmode{\vbox to 0pt{}} - -\catcode`\|=\active -\def|{{\tt \char '174}} -\chardef \less=`\< -\catcode`\<=\active -\def<{{\tt \less}} -\chardef \gtr=`\> -\catcode`\>=\active -\def>{{\tt \gtr}} -\catcode`\+=\active -\def+{{\tt \char 43}} -%\catcode 27=\active -%\def^^[{$\diamondsuit$} - -% Set up an active definition for =, but don't enable it most of the time. -{\catcode`\==\active -\global\def={{\tt \char 61}}} - -\catcode`+=\active -\catcode`\_=\active - -% If a .fmt file is being used, characters that might appear in a file -% name cannot be active until we have parsed the command line. -% So turn them off again, and have \everyjob (or @setfilename) turn them on. -% \otherifyactive is called near the end of this file. -\def\otherifyactive{\catcode`+=\other \catcode`\_=\other} - -\catcode`\@=0 - -% \rawbackslashxx output one backslash character in current font -\global\chardef\rawbackslashxx=`\\ -%{\catcode`\\=\other -%@gdef@rawbackslashxx{\}} - -% \rawbackslash redefines \ as input to do \rawbackslashxx. -{\catcode`\\=\active -@gdef@rawbackslash{@let\=@rawbackslashxx }} - -% \normalbackslash outputs one backslash in fixed width font. -\def\normalbackslash{{\tt\rawbackslashxx}} - -% Say @foo, not \foo, in error messages. -\escapechar=`\@ - -% \catcode 17=0 % Define control-q -\catcode`\\=\active - -% Used sometimes to turn off (effectively) the active characters -% even after parsing them. -@def@turnoffactive{@let"=@normaldoublequote -@let\=@realbackslash -@let~=@normaltilde -@let^=@normalcaret -@let_=@normalunderscore -@let|=@normalverticalbar -@let<=@normalless -@let>=@normalgreater -@let+=@normalplus} - -@def@normalturnoffactive{@let"=@normaldoublequote -@let\=@normalbackslash -@let~=@normaltilde -@let^=@normalcaret -@let_=@normalunderscore -@let|=@normalverticalbar -@let<=@normalless -@let>=@normalgreater -@let+=@normalplus} - -% Make _ and + \other characters, temporarily. -% This is canceled by @fixbackslash. -@otherifyactive - -% If a .fmt file is being used, we don't want the `\input texinfo' to show up. -% That is what \eatinput is for; after that, the `\' should revert to printing -% a backslash. -% -@gdef@eatinput input texinfo{@fixbackslash} -@global@let\ = @eatinput - -% On the other hand, perhaps the file did not have a `\input texinfo'. Then -% the first `\{ in the file would cause an error. This macro tries to fix -% that, assuming it is called before the first `\' could plausibly occur. -% Also back turn on active characters that might appear in the input -% file name, in case not using a pre-dumped format. -% -@gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi - @catcode`+=@active @catcode`@_=@active} - -%% These look ok in all fonts, so just make them not special. The @rm below -%% makes sure that the current font starts out as the newly loaded cmr10 -@catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other - -@textfonts -@rm - -@c Local variables: -@c page-delimiter: "^\\\\message" -@c End: diff --git a/lib/termcap/ltcap.h b/lib/termcap/ltcap.h index 507481f..a97f0d8 100644 --- a/lib/termcap/ltcap.h +++ b/lib/termcap/ltcap.h @@ -1,19 +1,20 @@ -/* Local declarations for termcap library. - Copyright (C) 1999 Free Software Foundation, Inc. +/* ltcap.h - Local declarations for termcap library. */ - This program is free software; you can redistribute it and/or modify +/* Copyright (C) 1999-2009 Free Software Foundation, Inc. + + Bash is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef _LTCAP_H_ #define _LTCAP_H_ 1 diff --git a/lib/termcap/termcap.c b/lib/termcap/termcap.c index 0addcc6..7311349 100644 --- a/lib/termcap/termcap.c +++ b/lib/termcap/termcap.c @@ -1,19 +1,22 @@ -/* Work-alike for termcap, plus extra features. - Copyright (C) 1985, 86, 93, 94, 95 Free Software Foundation, Inc. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; see the file COPYING. If not, write to the -Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ +/* termcap.c - Work-alike for termcap, plus extra features. */ + +/* Copyright (C) 1985, 1986, 1993,1994, 1995, 1998, 2001,2003,2005,2006,2008,2009 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* Emacs config.h may rename various library functions such as malloc. */ #ifdef HAVE_CONFIG_H diff --git a/lib/termcap/termcap.h b/lib/termcap/termcap.h index 40c2e29..5d71595 100644 --- a/lib/termcap/termcap.h +++ b/lib/termcap/termcap.h @@ -1,19 +1,20 @@ -/* Declarations for termcap library. - Copyright (C) 1991, 1992, 1995 Free Software Foundation, Inc. +/* termcap.h - public declarations for termcap library. */ - This program is free software; you can redistribute it and/or modify +/* Copyright (C) 1991, 1992, 1995, 2001, 2005, 2006, 2008,2009 Free Software Foundation, Inc. + + Bash is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, + Bash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ #ifndef _TERMCAP_H #define _TERMCAP_H 1 diff --git a/lib/termcap/tparam.c b/lib/termcap/tparam.c index 644042d..c4bff08 100644 --- a/lib/termcap/tparam.c +++ b/lib/termcap/tparam.c @@ -1,19 +1,22 @@ -/* Merge parameters into a termcap entry string. - Copyright (C) 1985, 87, 93, 95 Free Software Foundation, Inc. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; see the file COPYING. If not, write to the -Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ +/* tparam.c - merge parameters into a termcap entry string. */ + +/* Copyright (C) 1985, 1986, 1993,1994, 1995, 1998, 2001,2003,2005,2006,2008,2009 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* Emacs config.h may rename various library functions such as malloc. */ #ifdef HAVE_CONFIG_H diff --git a/lib/termcap/version.c b/lib/termcap/version.c index ad2ab91..cad57be 100644 --- a/lib/termcap/version.c +++ b/lib/termcap/version.c @@ -1,18 +1,22 @@ -/* Copyright (C) 1985-2002 Free Software Foundation, Inc. +/* version.c - termcap library version information. */ - This program is free software; you can redistribute it and/or modify +/* Copyright (C) 1985-2009 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - Public License for more details. + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License along - with this program; see the file COPYING. If not, write to the Free - Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Bash. If not, see <http://www.gnu.org/licenses/>. +*/ /* Make the library identifiable with the RCS ident command. */ static char *termcap_version_string = "\n$Version: GNU termcap 1.3 $\n"; diff --git a/lib/tilde/Makefile.in b/lib/tilde/Makefile.in index a9d3741..d5506c5 100644 --- a/lib/tilde/Makefile.in +++ b/lib/tilde/Makefile.in @@ -4,21 +4,20 @@ # # #################################################################### -# Copyright (C) 1996-2005 Free Software Foundation, Inc. +# Copyright (C) 1996-2009 Free Software Foundation, Inc. -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. srcdir = @srcdir@ VPATH = .:@srcdir@ diff --git a/lib/tilde/shell.c b/lib/tilde/shell.c index a45af2d..40a95b6 100644 --- a/lib/tilde/shell.c +++ b/lib/tilde/shell.c @@ -1,24 +1,23 @@ /* shell.c -- tilde utility functions that are normally provided by bash when readline is linked as part of the shell. */ -/* Copyright (C) 1998 Free Software Foundation, Inc. +/* Copyright (C) 1998-2009 Free Software Foundation, Inc. This file is part of the GNU Tilde Library. - The GNU Tilde Library is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, or + The GNU Tilde Library is free software: you can redistribute it and/or + modify it under the terms of the GNU General Public License as published + by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - The GNU Tilde Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + The GNU Tilde Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with the GNU Tilde Library. If not, see <http://www.gnu.org/licenses/>. +*/ #if defined (HAVE_CONFIG_H) # include <config.h> diff --git a/lib/tilde/tilde.c b/lib/tilde/tilde.c index 1b76c9f..088ff15 100644 --- a/lib/tilde/tilde.c +++ b/lib/tilde/tilde.c @@ -1,23 +1,23 @@ /* tilde.c -- Tilde expansion code (~/foo := $HOME/foo). */ -/* Copyright (C) 1988,1989 Free Software Foundation, Inc. +/* Copyright (C) 1988-2009 Free Software Foundation, Inc. - This file is part of GNU Readline, a library for reading lines - of text with interactive input and history editing. + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. - Readline is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Readline is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with Readline; see the file COPYING. If not, write to the Free - Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if defined (HAVE_CONFIG_H) # include <config.h> @@ -236,7 +236,7 @@ tilde_expand (string) string += end; expansion = tilde_expand_word (tilde_word); - free (tilde_word); + xfree (tilde_word); len = strlen (expansion); #ifdef __CYGWIN__ @@ -251,7 +251,7 @@ tilde_expand (string) strcpy (result + result_index, expansion); result_index += len; } - free (expansion); + xfree (expansion); } result[result_index] = '\0'; @@ -377,7 +377,7 @@ tilde_expand_word (filename) if (expansion) { dirname = glue_prefix_and_suffix (expansion, filename, user_len); - free (username); + xfree (username); free (expansion); return (dirname); } @@ -414,7 +414,7 @@ tilde_expand_word (filename) dirname = glue_prefix_and_suffix (user_entry->pw_dir, filename, user_len); #endif - free (username); + xfree (username); #if defined (HAVE_GETPWENT) endpwent (); #endif diff --git a/lib/tilde/tilde.h b/lib/tilde/tilde.h index c58ce20..e26dd04 100644 --- a/lib/tilde/tilde.h +++ b/lib/tilde/tilde.h @@ -1,25 +1,24 @@ /* tilde.h: Externally available variables and function in libtilde.a. */ -/* Copyright (C) 1992 Free Software Foundation, Inc. +/* Copyright (C) 1992-2009 Free Software Foundation, Inc. - This file contains the Readline Library (the Library), a set of + This file contains the Readline Library (Readline), a set of routines for providing Emacs style line input to programs that ask for it. - The Library is free software; you can redistribute it and/or modify + Readline is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - The Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if !defined (_TILDE_H_) # define _TILDE_H_ |