From deaa0868adb37486ddcd0c1db422dd117be30c97 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Thu, 27 Dec 2012 17:23:01 -0800 Subject: [PATCH] apply ncurses-5.9-20120204.patch --- NEWS | 8 +++- dist.mk | 4 +- man/tic.1m | 38 +++++++++++------ progs/tic.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++-------- test/movewindow.c | 5 +-- 5 files changed, 136 insertions(+), 38 deletions(-) diff --git a/NEWS b/NEWS index 810327f..4518a4c 100644 --- a/NEWS +++ b/NEWS @@ -25,7 +25,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: NEWS,v 1.1853 2012/01/29 01:47:05 tom Exp $ +-- $Id: NEWS,v 1.1854 2012/02/04 22:25:57 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,10 @@ See the AUTHORS file for the corresponding full names. Changes through 1.9.9e did not credit all contributions; it is not possible to add this information. +20120204 + + improved tic -D option, avoid making target directory and provide + better diagnostics. + 20120128 + add mach-gnu (Debian #614316, patch by Samuel Thibault) + add mach-gnu-color, tweaks to mach-gnu terminfo -TD @@ -58,7 +62,7 @@ it is not possible to add this information. + amend fix intended to separate fixups for acsc to allow "tic -cv" to give verbose warnings (cf: 20110730). + modify misc/gen-edit.sh to make the location of the tabset directory - consistent with misc/Makefile.in, i.., using ${datadir}/tabset + consistent with misc/Makefile.in, i.e., using ${datadir}/tabset (Debian #653435, patch by Sven Joachim). 20120121 diff --git a/dist.mk b/dist.mk index 5fcec1b..a4bc0b5 100644 --- a/dist.mk +++ b/dist.mk @@ -25,7 +25,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: dist.mk,v 1.855 2012/01/28 15:26:26 tom Exp $ +# $Id: dist.mk,v 1.856 2012/02/04 16:54:39 tom Exp $ # Makefile for creating ncurses distributions. # # This only needs to be used directly as a makefile by developers, but @@ -37,7 +37,7 @@ SHELL = /bin/sh # These define the major/minor/patch versions of ncurses. NCURSES_MAJOR = 5 NCURSES_MINOR = 9 -NCURSES_PATCH = 20120128 +NCURSES_PATCH = 20120204 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/man/tic.1m b/man/tic.1m index 57c9b8a..580abf4 100644 --- a/man/tic.1m +++ b/man/tic.1m @@ -1,5 +1,5 @@ .\"*************************************************************************** -.\" Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. * +.\" Copyright (c) 1998-2011,2012 Free Software Foundation, Inc. * .\" * .\" Permission is hereby granted, free of charge, to any person obtaining a * .\" copy of this software and associated documentation files (the * @@ -26,7 +26,7 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: tic.1m,v 1.53 2011/12/17 23:13:19 tom Exp $ +.\" $Id: tic.1m,v 1.54 2012/02/04 23:09:43 tom Exp $ .TH @TIC@ 1M "" .ds n 5 .ds d @TERMINFO@ @@ -74,7 +74,8 @@ the library routines in \fBncurses\fR(3X). .PP As described in \fBterm\fR(\*n), the database may be either a directory tree (one file per terminal entry) or a hashed database (one record per entry). -The \fB@TIC@\fR writes only one type of entry, depending on how it was built: +The \fB@TIC@\fR command writes only one type of entry, +depending on how it was built: .bP For directory trees, the top-level directory, e.g., /usr/share/terminfo, specifies the location of the database. @@ -87,14 +88,20 @@ then that is used. The default name for the hashed database is the same as the default directory name (only adding a ".db" suffix). .PP +In either case (directory or hashed database), +\fB@TIC@\fP will create the container if it does not exist. +For a directory, this would be the "terminfo" leaf, +versus a "terminfo.db" file. +.PP The results are normally placed in the system terminfo database \fB\*d\fR. -The compiled terminal description can be placed in a different terminfo database. +The compiled terminal description can be placed +in a different terminfo database. There are two ways to achieve this: .bP -First, you may override the system default by setting the variable -\fBTERMINFO\fR in your shell environment to a valid database -location, e.g., an existing directory (for directory trees) or -valid location for a hashed database. +First, you may override the system default either by +using the \fB\-o\fP option, +or by setting the variable \fBTERMINFO\fR +in your shell environment to a valid database location. .bP Secondly, if \fB@TIC@\fR cannot write in \fI\*d\fR or the location specified using your TERMINFO variable, @@ -103,9 +110,15 @@ it looks for the directory \fI$HOME/.terminfo\fR if that location exists, the entry is placed there. .PP Libraries that read terminfo entries are expected to check for +.bP a location specified with the TERMINFO variable first, -look at \fI$HOME/.terminfo\fR if TERMINFO is not set, and -finally look in \fI\*d\fR. +.bP +look in \fI$HOME/.terminfo\fR if TERMINFO is not set, next +.bP +directories listed in the TERMINFO_DIRS symbol, and +.bP +finally look in the system terminfo database (\fI\*d\fR). +.SS OPTIONS .TP \fB\-0\fR restricts the output to a single line @@ -265,6 +278,7 @@ it will infer its type (boolean, number or string) from the syntax and make an extended table entry for that. User-defined capability strings whose name begins with ``k'' are treated as function keys. +.SS PARAMETERS .TP \fIfile\fR contains one or more \fBterminfo\fR terminal descriptions in source @@ -296,6 +310,7 @@ List of tokens encountered by scanner All values computed in construction of the hash table .LP If the debug level \fIn\fR is not given, it is taken to be one. +.SS PROCESSING .PP All but one of the capabilities recognized by \fB@TIC@\fR are documented in \fBterminfo\fR(\*n). @@ -318,9 +333,6 @@ capabilities in \fIentry\fR_\fIname\fR_\fI2\fR must also appear in \fBentry_name_1\fR before \fBuse=\fR for these capabilities to be canceled in \fBentry_name_1\fR. .PP -If the environment variable \fBTERMINFO\fR is set, the compiled -results are placed there instead of \fB\*d\fR. -.PP Total compiled entries cannot exceed 4096 bytes. The name field cannot exceed 512 bytes. diff --git a/progs/tic.c b/progs/tic.c index 04ab3e5..aa38840 100644 --- a/progs/tic.c +++ b/progs/tic.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. * + * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -43,9 +43,10 @@ #include #include +#include #include -MODULE_ID("$Id: tic.c,v 1.157 2011/12/31 21:11:59 tom Exp $") +MODULE_ID("$Id: tic.c,v 1.160 2012/02/05 01:39:39 tom Exp $") const char *_nc_progname = "tic"; @@ -476,25 +477,107 @@ open_tempfile(char *name) return result; } +static const char * +valid_db_path(const char *nominal) +{ + struct stat sb; +#if USE_HASHED_DB + char suffix[] = DBM_SUFFIX; + size_t need = strlen(nominal) + sizeof(suffix); + char *result = malloc(need); + + strcpy(result, nominal); + if (strcmp(result + need - sizeof(suffix), suffix)) { + strcat(result, suffix); + } +#else + char *result = strdup(nominal); +#endif + + DEBUG(1, ("** stat(%s)", result)); + if (stat(result, &sb) >= 0) { +#if USE_HASHED_DB + if (!S_ISREG(sb.st_mode) + || access(result, R_OK | W_OK) != 0) { + DEBUG(1, ("...not a writable file")); + free(result); + result = 0; + } +#else + if (!S_ISDIR(sb.st_mode) + || access(result, R_OK | W_OK | X_OK) != 0) { + DEBUG(1, ("...not a writable directory")); + free(result); + result = 0; + } +#endif + } else { + /* check if parent is directory and is writable */ + unsigned leaf = _nc_pathlast(result); + + DEBUG(1, ("...not found")); + if (leaf) { + char save = result[leaf]; + result[leaf] = 0; + if (stat(result, &sb) >= 0 + && S_ISDIR(sb.st_mode) + && access(result, R_OK | W_OK | X_OK) == 0) { + result[leaf] = save; + } else { + DEBUG(1, ("...parent directory %s is not writable", result)); + free(result); + result = 0; + } + } else { + DEBUG(1, ("... no parent directory")); + free(result); + result = 0; + } + } + return result; +} + /* - * Show the databases that tic knows about. The location to which it writes is - * always the first one. If that is not writable, then tic errors out before - * reaching this function. + * Show the databases to which tic could write. The location to which it + * writes is always the first one. If none are writable, print an error + * message. */ static void -show_databases(void) +show_databases(const char *outdir) { - DBDIRS state; - int offset; - const char *path; + bool specific = (outdir != 0) || getenv("TERMINFO") != 0; + const char *result; + const char *tried = 0; + + if (outdir == 0) { + outdir = _nc_tic_dir(0); + } + if ((result = valid_db_path(outdir)) != 0) { + printf("%s\n", result); + } else { + tried = outdir; + } - _nc_first_db(&state, &offset); - while ((path = _nc_next_db(&state, &offset)) != 0) { - printf("%s\n", path); + if ((outdir = _nc_home_terminfo())) { + if ((result = valid_db_path(outdir)) != 0) { + printf("%s\n", result); + } else if (!specific) { + tried = outdir; + } + } + + /* + * If we can write in neither location, give an error message. + */ + if (tried) { + fflush(stdout); + fprintf(stderr, "%s: %s (no permission)\n", _nc_progname, tried); + ExitProgram(EXIT_FAILURE); } - _nc_last_db(); } +#define VtoTrace(opt) (unsigned) ((opt > 0) ? opt : (opt == 0)) + int main(int argc, char *argv[]) { @@ -586,8 +669,9 @@ main(int argc, char *argv[]) sortmode = S_TERMCAP; break; case 'D': - _nc_set_writedir(outdir); - show_databases(); + debug_level = VtoTrace(v_opt); + set_trace_level(debug_level); + show_databases(outdir); ExitProgram(EXIT_SUCCESS); break; case 'I': @@ -665,7 +749,7 @@ main(int argc, char *argv[]) last_opt = this_opt; } - debug_level = (unsigned) ((v_opt > 0) ? v_opt : (v_opt == 0)); + debug_level = VtoTrace(v_opt); set_trace_level(debug_level); if (_nc_tracing) { @@ -685,7 +769,8 @@ main(int argc, char *argv[]) */ if (namelst && (!infodump && !capdump)) { (void) fprintf(stderr, - "Sorry, -e can't be used without -I or -C\n"); + "%s: Sorry, -e can't be used without -I or -C\n", + _nc_progname); cleanup(namelst); ExitProgram(EXIT_FAILURE); } diff --git a/test/movewindow.c b/test/movewindow.c index 8fc0a71..7905a93 100644 --- a/test/movewindow.c +++ b/test/movewindow.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: movewindow.c,v 1.33 2012/01/15 00:30:35 tom Exp $ + * $Id: movewindow.c,v 1.34 2012/02/05 01:16:47 tom Exp $ * * Demonstrate move functions for windows and derived windows from the curses * library. @@ -492,9 +492,6 @@ move_derwin(WINDOW *win) max_line, max_col, TRUE, &more)) != 0) { - int y0, x0; - - getbegyx(parent, y0, x0); if (mvderwin(win, tmp->y, tmp->x) != ERR) { refresh_all(win); doupdate(); -- 2.7.4