From 808858ace09b9bf60f7154e33cb6572f49347101 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Sat, 4 Apr 2015 23:57:48 +0000 Subject: [PATCH] ncurses 5.9 - patch 20150404 + improve description of start_color() in the manual. + modify several files in ncurses- and progs-directories to allow const data used in internal tables to be put by the linker into the readonly text segment. --- NEWS | 8 +- VERSION | 2 +- dist.mk | 4 +- form/frm_req_name.c | 132 +++++++++--------- man/curs_color.3x | 36 ++++- menu/m_req_name.c | 42 +++--- ncurses/base/lib_screen.c | 32 ++--- ncurses/tinfo/parse_entry.c | 61 +++++---- ncurses/trace/lib_traceatr.c | 132 +++++++++--------- ncurses/trace/lib_tracebits.c | 111 +++++++-------- package/debian-mingw/changelog | 4 +- package/debian-mingw64/changelog | 4 +- package/debian/changelog | 4 +- package/mingw-ncurses.nsi | 4 +- package/mingw-ncurses.spec | 2 +- package/ncurses.spec | 2 +- progs/infocmp.c | 176 +++++++++++++----------- progs/tabs.c | 55 ++++---- progs/tic.c | 227 ++++++++++++++++--------------- progs/tparm_type.c | 11 +- progs/tset.c | 106 ++++++++------- 21 files changed, 608 insertions(+), 547 deletions(-) diff --git a/NEWS b/NEWS index f854d9e4..7b70997b 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.2365 2015/03/29 14:38:58 tom Exp $ +-- $Id: NEWS,v 1.2368 2015/04/04 19:43:50 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,12 @@ 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. +20150404 + + improve description of start_color() in the manual. + + modify several files in ncurses- and progs-directories to allow + const data used in internal tables to be put by the linker into the + readonly text segment. + 20150329 + correct cut/paste error for "--enable-ext-putwin" that made it the same as "--enable-ext-colors" (report by Roumen Petrov) diff --git a/VERSION b/VERSION index 3d0fb4fe..8d95633b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5:0:9 5.9 20150329 +5:0:9 5.9 20150404 diff --git a/dist.mk b/dist.mk index bab612a7..4702aea6 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.1041 2015/03/29 14:32:33 tom Exp $ +# $Id: dist.mk,v 1.1042 2015/04/04 00:24:36 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 = 20150329 +NCURSES_PATCH = 20150404 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/form/frm_req_name.c b/form/frm_req_name.c index c24db1a8..5686b222 100644 --- a/form/frm_req_name.c +++ b/form/frm_req_name.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2009,2012 Free Software Foundation, Inc. * + * Copyright (c) 1998-2012,2015 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 * @@ -37,73 +37,77 @@ #include "form.priv.h" -MODULE_ID("$Id: frm_req_name.c,v 1.18 2012/07/21 23:17:23 tom Exp $") +MODULE_ID("$Id: frm_req_name.c,v 1.19 2015/04/04 17:11:46 tom Exp $") -static const char *request_names[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] = +#define DATA(s) { s } + +static const char request_names[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1][13] = { - "NEXT_PAGE", - "PREV_PAGE", - "FIRST_PAGE", - "LAST_PAGE", - - "NEXT_FIELD", - "PREV_FIELD", - "FIRST_FIELD", - "LAST_FIELD", - "SNEXT_FIELD", - "SPREV_FIELD", - "SFIRST_FIELD", - "SLAST_FIELD", - "LEFT_FIELD", - "RIGHT_FIELD", - "UP_FIELD", - "DOWN_FIELD", - - "NEXT_CHAR", - "PREV_CHAR", - "NEXT_LINE", - "PREV_LINE", - "NEXT_WORD", - "PREV_WORD", - "BEG_FIELD", - "END_FIELD", - "BEG_LINE", - "END_LINE", - "LEFT_CHAR", - "RIGHT_CHAR", - "UP_CHAR", - "DOWN_CHAR", - - "NEW_LINE", - "INS_CHAR", - "INS_LINE", - "DEL_CHAR", - "DEL_PREV", - "DEL_LINE", - "DEL_WORD", - "CLR_EOL", - "CLR_EOF", - "CLR_FIELD", - "OVL_MODE", - "INS_MODE", - "SCR_FLINE", - "SCR_BLINE", - "SCR_FPAGE", - "SCR_BPAGE", - "SCR_FHPAGE", - "SCR_BHPAGE", - "SCR_FCHAR", - "SCR_BCHAR", - "SCR_HFLINE", - "SCR_HBLINE", - "SCR_HFHALF", - "SCR_HBHALF", - - "VALIDATION", - "NEXT_CHOICE", - "PREV_CHOICE" + DATA("NEXT_PAGE"), + DATA("PREV_PAGE"), + DATA("FIRST_PAGE"), + DATA("LAST_PAGE"), + + DATA("NEXT_FIELD"), + DATA("PREV_FIELD"), + DATA("FIRST_FIELD"), + DATA("LAST_FIELD"), + DATA("SNEXT_FIELD"), + DATA("SPREV_FIELD"), + DATA("SFIRST_FIELD"), + DATA("SLAST_FIELD"), + DATA("LEFT_FIELD"), + DATA("RIGHT_FIELD"), + DATA("UP_FIELD"), + DATA("DOWN_FIELD"), + + DATA("NEXT_CHAR"), + DATA("PREV_CHAR"), + DATA("NEXT_LINE"), + DATA("PREV_LINE"), + DATA("NEXT_WORD"), + DATA("PREV_WORD"), + DATA("BEG_FIELD"), + DATA("END_FIELD"), + DATA("BEG_LINE"), + DATA("END_LINE"), + DATA("LEFT_CHAR"), + DATA("RIGHT_CHAR"), + DATA("UP_CHAR"), + DATA("DOWN_CHAR"), + + DATA("NEW_LINE"), + DATA("INS_CHAR"), + DATA("INS_LINE"), + DATA("DEL_CHAR"), + DATA("DEL_PREV"), + DATA("DEL_LINE"), + DATA("DEL_WORD"), + DATA("CLR_EOL"), + DATA("CLR_EOF"), + DATA("CLR_FIELD"), + DATA("OVL_MODE"), + DATA("INS_MODE"), + DATA("SCR_FLINE"), + DATA("SCR_BLINE"), + DATA("SCR_FPAGE"), + DATA("SCR_BPAGE"), + DATA("SCR_FHPAGE"), + DATA("SCR_BHPAGE"), + DATA("SCR_FCHAR"), + DATA("SCR_BCHAR"), + DATA("SCR_HFLINE"), + DATA("SCR_HBLINE"), + DATA("SCR_HFHALF"), + DATA("SCR_HBHALF"), + + DATA("VALIDATION"), + DATA("NEXT_CHOICE"), + DATA("PREV_CHOICE") }; +#undef DATA + #define A_SIZE (sizeof(request_names)/sizeof(request_names[0])) /*--------------------------------------------------------------------------- diff --git a/man/curs_color.3x b/man/curs_color.3x index 1d887688..6be4fad4 100644 --- a/man/curs_color.3x +++ b/man/curs_color.3x @@ -1,5 +1,5 @@ .\"*************************************************************************** -.\" Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. * +.\" Copyright (c) 1998-2010,2015 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: curs_color.3x,v 1.36 2014/11/16 00:44:29 tom Exp $ +.\" $Id: curs_color.3x,v 1.37 2015/04/04 19:42:47 tom Exp $ .TH curs_color 3X "" .ie \n(.g .ds `` \(lq .el .ds `` `` @@ -94,12 +94,36 @@ The \fBstart_color\fR routine requires no arguments. It must be called if the programmer wants to use colors, and before any other color manipulation routine is called. It is good practice to call this routine right after \fBinitscr\fR. -\fBstart_color\fR initializes eight basic colors (black, red, green, yellow, blue, magenta, cyan, -and white), and two global variables, \fBCOLORS\fR and +\fBstart_color\fR does this: +.bP +It initializes two global variables, \fBCOLORS\fR and \fBCOLOR_PAIRS\fR (respectively defining the maximum number of colors and color-pairs the terminal can support). -It also restores the colors on the terminal to the values they had when the terminal was -just turned on. +.bP +It initializes the special color pair \fB0\fP to the default foreground +and background colors. +No other color pairs are initialized. +.bP +It restores the colors on the terminal to the values +they had when the terminal was just turned on. +.bP +If the terminal supports the \fBinitc\fP (\fBinitialize_color\fP) capability, +\fBstart_color\fP +initializes its internal table representing the +red, green and blue components of the color palette. +.IP +The components depend on whether the terminal uses +CGA (aka "ANSI") or +HLS (i.e., the \fBhls\fP (\fBhue_lightness_saturation\fP) capability is set). +The table is initialized first for eight basic colors +(black, red, green, yellow, blue, magenta, cyan, and white), +and after that (if the terminal supports more than eight colors) +the components are initialized to \fB1000\fP. +.IP +\fBstart_color\fP does not attempt to set the terminal's color palette +to match its built-in table. +An application may use \fBinit_color\fP to alter the internal table +along with the terminal's color. .PP These limits apply to color values and color pairs. Values outside these limits are not legal, and may result in a runtime error: diff --git a/menu/m_req_name.c b/menu/m_req_name.c index e5f2888e..cc0066d5 100644 --- a/menu/m_req_name.c +++ b/menu/m_req_name.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2009,2012 Free Software Foundation, Inc. * + * Copyright (c) 1998-2012,2015 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 * @@ -37,27 +37,29 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_req_name.c,v 1.22 2012/07/21 23:27:32 tom Exp $") +MODULE_ID("$Id: m_req_name.c,v 1.23 2015/04/04 18:00:23 tom Exp $") -static const char *request_names[MAX_MENU_COMMAND - MIN_MENU_COMMAND + 1] = +#define DATA(s) { s } + +static const char request_names[MAX_MENU_COMMAND - MIN_MENU_COMMAND + 1][14] = { - "LEFT_ITEM", - "RIGHT_ITEM", - "UP_ITEM", - "DOWN_ITEM", - "SCR_ULINE", - "SCR_DLINE", - "SCR_DPAGE", - "SCR_UPAGE", - "FIRST_ITEM", - "LAST_ITEM", - "NEXT_ITEM", - "PREV_ITEM", - "TOGGLE_ITEM", - "CLEAR_PATTERN", - "BACK_PATTERN", - "NEXT_MATCH", - "PREV_MATCH" + DATA("LEFT_ITEM"), + DATA("RIGHT_ITEM"), + DATA("UP_ITEM"), + DATA("DOWN_ITEM"), + DATA("SCR_ULINE"), + DATA("SCR_DLINE"), + DATA("SCR_DPAGE"), + DATA("SCR_UPAGE"), + DATA("FIRST_ITEM"), + DATA("LAST_ITEM"), + DATA("NEXT_ITEM"), + DATA("PREV_ITEM"), + DATA("TOGGLE_ITEM"), + DATA("CLEAR_PATTERN"), + DATA("BACK_PATTERN"), + DATA("NEXT_MATCH"), + DATA("PREV_MATCH") }; #define A_SIZE (sizeof(request_names)/sizeof(request_names[0])) diff --git a/ncurses/base/lib_screen.c b/ncurses/base/lib_screen.c index 4d310be2..f7fc7bad 100644 --- a/ncurses/base/lib_screen.c +++ b/ncurses/base/lib_screen.c @@ -41,7 +41,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_screen.c,v 1.72 2015/03/29 15:25:29 tom Exp $") +MODULE_ID("$Id: lib_screen.c,v 1.74 2015/04/04 14:00:34 tom Exp $") #define MAX_SIZE 0x3fff /* 16k is big enough for a window or pad */ @@ -56,7 +56,7 @@ MODULE_ID("$Id: lib_screen.c,v 1.72 2015/03/29 15:25:29 tom Exp $") * mistaken for the _cury/_curx pair of 16-bit numbers which start the old * format. It happens to be unused in the file 5.22 database (2015/03/07). */ -static char my_magic[] = +static const char my_magic[] = {'\210', '\210', '\210', '\210'}; #if NCURSES_EXT_PUTWIN @@ -73,19 +73,19 @@ typedef enum { } PARAM_TYPE; typedef struct { - const char *name; + const char name[11]; attr_t attr; } SCR_ATTRS; typedef struct { - const char *name; + const char name[17]; PARAM_TYPE type; size_t size; size_t offset; } SCR_PARAMS; -#define DATA(name) { #name, A_##name } -static SCR_ATTRS scr_attrs[] = +#define DATA(name) { { #name }, A_##name } +static const SCR_ATTRS scr_attrs[] = { DATA(NORMAL), DATA(STANDOUT), @@ -111,9 +111,9 @@ static SCR_ATTRS scr_attrs[] = #undef DATA #define sizeof2(type,name) sizeof(((type *)0)->name) -#define DATA(name, type) { #name, type, sizeof2(WINDOW, name), offsetof(WINDOW, name) } +#define DATA(name, type) { { #name }, type, sizeof2(WINDOW, name), offsetof(WINDOW, name) } -static SCR_PARAMS scr_params[] = +static const SCR_PARAMS scr_params[] = { DATA(_cury, pSIZE), DATA(_curx, pSIZE), @@ -220,16 +220,16 @@ decode_attr(char *source, attr_t *target, int *color) ++next; } else if (*next == 'C') { int value = 0; + unsigned pair; next++; while (isdigit(UChar(*next))) { value = value * 10 + (*next++ - '0'); } *target &= ~A_COLOR; - if (value > 256) { - *target |= COLOR_PAIR(255); - } else { - *target |= COLOR_PAIR(value); - } + pair = (unsigned) ((value > 256) + ? COLOR_PAIR(255) + : COLOR_PAIR(value)); + *target |= pair; *color = value; } else { while (isalnum(UChar(*next))) { @@ -315,7 +315,7 @@ static char * decode_chtype(char *source, chtype fillin, chtype *target) { attr_t attr = ChAttrOf(fillin); - int color = PAIR_NUMBER(attr); + int color = PAIR_NUMBER((int) attr); int value; T(("decode_chtype '%s'", source)); @@ -669,7 +669,7 @@ encode_attr(char *target, attr_t source, attr_t prior) if ((source & A_COLOR) != (prior & A_COLOR)) { if (!first) *target++ = '|'; - sprintf(target, "C%d", PAIR_NUMBER(source)); + sprintf(target, "C%d", PAIR_NUMBER((int) source)); target += strlen(target); } @@ -695,7 +695,7 @@ encode_cell(char *target, CARG_CH_T source, CARG_CH_T previous) } #endif for (n = 0; n < SIZEOF(source->chars); ++n) { - unsigned uch = source->chars[n]; + unsigned uch = (unsigned) source->chars[n]; if (uch == 0) continue; if (n) { diff --git a/ncurses/tinfo/parse_entry.c b/ncurses/tinfo/parse_entry.c index 2936a643..0dc1414f 100644 --- a/ncurses/tinfo/parse_entry.c +++ b/ncurses/tinfo/parse_entry.c @@ -47,7 +47,7 @@ #include #include -MODULE_ID("$Id: parse_entry.c,v 1.79 2012/10/27 21:43:45 tom Exp $") +MODULE_ID("$Id: parse_entry.c,v 1.80 2015/04/04 14:18:38 tom Exp $") #ifdef LINT static short const parametrized[] = @@ -581,32 +581,32 @@ append_acs(string_desc * dst, int code, char *src) * list. For each capability, we may assume there is a keycap that sends the * string which is the value of that capability. */ +#define DATA(from, to) { { from }, { to } } typedef struct { - const char *from; - const char *to; + const char from[3]; + const char to[6]; } assoc; static assoc const ko_xlate[] = { - {"al", "kil1"}, /* insert line key -> KEY_IL */ - {"bt", "kcbt"}, /* back tab -> KEY_BTAB */ - {"cd", "ked"}, /* clear-to-eos key -> KEY_EOL */ - {"ce", "kel"}, /* clear-to-eol key -> KEY_EOS */ - {"cl", "kclr"}, /* clear key -> KEY_CLEAR */ - {"ct", "tbc"}, /* clear all tabs -> KEY_CATAB */ - {"dc", "kdch1"}, /* delete char -> KEY_DC */ - {"dl", "kdl1"}, /* delete line -> KEY_DL */ - {"do", "kcud1"}, /* down key -> KEY_DOWN */ - {"ei", "krmir"}, /* exit insert key -> KEY_EIC */ - {"ho", "khome"}, /* home key -> KEY_HOME */ - {"ic", "kich1"}, /* insert char key -> KEY_IC */ - {"im", "kIC"}, /* insert-mode key -> KEY_SIC */ - {"le", "kcub1"}, /* le key -> KEY_LEFT */ - {"nd", "kcuf1"}, /* nd key -> KEY_RIGHT */ - {"nl", "kent"}, /* new line key -> KEY_ENTER */ - {"st", "khts"}, /* set-tab key -> KEY_STAB */ - {"ta", CANCELLED_STRING}, - {"up", "kcuu1"}, /* up-arrow key -> KEY_UP */ - {(char *) 0, (char *) 0}, + DATA("al", "kil1"), /* insert line key -> KEY_IL */ + DATA("bt", "kcbt"), /* back tab -> KEY_BTAB */ + DATA("cd", "ked"), /* clear-to-eos key -> KEY_EOL */ + DATA("ce", "kel"), /* clear-to-eol key -> KEY_EOS */ + DATA("cl", "kclr"), /* clear key -> KEY_CLEAR */ + DATA("ct", "tbc"), /* clear all tabs -> KEY_CATAB */ + DATA("dc", "kdch1"), /* delete char -> KEY_DC */ + DATA("dl", "kdl1"), /* delete line -> KEY_DL */ + DATA("do", "kcud1"), /* down key -> KEY_DOWN */ + DATA("ei", "krmir"), /* exit insert key -> KEY_EIC */ + DATA("ho", "khome"), /* home key -> KEY_HOME */ + DATA("ic", "kich1"), /* insert char key -> KEY_IC */ + DATA("im", "kIC"), /* insert-mode key -> KEY_SIC */ + DATA("le", "kcub1"), /* le key -> KEY_LEFT */ + DATA("nd", "kcuf1"), /* nd key -> KEY_RIGHT */ + DATA("nl", "kent"), /* new line key -> KEY_ENTER */ + DATA("st", "khts"), /* set-tab key -> KEY_STAB */ + DATA("ta", ""), + DATA("up", "kcuu1"), /* up-arrow key -> KEY_UP */ }; /* @@ -789,7 +789,6 @@ postprocess_termcap(TERMTYPE *tp, bool has_base) char *bp, *cp, *dp; struct name_table_entry const *from_ptr; struct name_table_entry const *to_ptr; - assoc const *ap; char buf2[MAX_TERMINFO_LENGTH]; bool foundim; @@ -802,17 +801,21 @@ postprocess_termcap(TERMTYPE *tp, bool has_base) (cp = strchr(base, ',')) != 0; base = cp + 1) { size_t len = (unsigned) (cp - base); + size_t n; + assoc const *ap = 0; - for (ap = ko_xlate; ap->from; ap++) { - if (len == strlen(ap->from) - && strncmp(ap->from, base, len) == 0) + for (n = 0; n < SIZEOF(ko_xlate); ++n) { + if (len == strlen(ko_xlate[n].from) + && strncmp(ko_xlate[n].from, base, len) == 0) { + ap = ko_xlate + n; break; + } } - if (!(ap->from && ap->to)) { + if (ap == 0) { _nc_warning("unknown capability `%.*s' in ko string", (int) len, base); continue; - } else if (ap->to == CANCELLED_STRING) /* ignore it */ + } else if (ap->to[0] == '\0') /* ignore it */ continue; /* now we know we found a match in ko_table, so... */ diff --git a/ncurses/trace/lib_traceatr.c b/ncurses/trace/lib_traceatr.c index 5fb0df95..24772d8d 100644 --- a/ncurses/trace/lib_traceatr.c +++ b/ncurses/trace/lib_traceatr.c @@ -43,7 +43,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_traceatr.c,v 1.81 2014/02/01 22:09:27 tom Exp $") +MODULE_ID("$Id: lib_traceatr.c,v 1.83 2015/04/04 13:41:37 tom Exp $") #define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name)) @@ -85,48 +85,44 @@ color_of(int c) NCURSES_EXPORT(char *) _traceattr2(int bufnum, chtype newmode) { +#define DATA(name) { name, { #name } } static const struct { unsigned int val; - const char *name; + const char name[14]; } names[] = { - /* *INDENT-OFF* */ - { A_STANDOUT, "A_STANDOUT" }, - { A_UNDERLINE, "A_UNDERLINE" }, - { A_REVERSE, "A_REVERSE" }, - { A_BLINK, "A_BLINK" }, - { A_DIM, "A_DIM" }, - { A_BOLD, "A_BOLD" }, - { A_ALTCHARSET, "A_ALTCHARSET" }, - { A_INVIS, "A_INVIS" }, - { A_PROTECT, "A_PROTECT" }, - { A_CHARTEXT, "A_CHARTEXT" }, - { A_NORMAL, "A_NORMAL" }, - { A_COLOR, "A_COLOR" }, + DATA(A_STANDOUT), + DATA(A_UNDERLINE), + DATA(A_REVERSE), + DATA(A_BLINK), + DATA(A_DIM), + DATA(A_BOLD), + DATA(A_ALTCHARSET), + DATA(A_INVIS), + DATA(A_PROTECT), + DATA(A_CHARTEXT), + DATA(A_NORMAL), + DATA(A_COLOR), #if USE_ITALIC - { A_ITALIC, "A_ITALIC" }, + DATA(A_ITALIC), #endif - /* *INDENT-ON* */ - } #ifndef USE_TERMLIB , colors[] = { - /* *INDENT-OFF* */ - { COLOR_BLACK, "COLOR_BLACK" }, - { COLOR_RED, "COLOR_RED" }, - { COLOR_GREEN, "COLOR_GREEN" }, - { COLOR_YELLOW, "COLOR_YELLOW" }, - { COLOR_BLUE, "COLOR_BLUE" }, - { COLOR_MAGENTA, "COLOR_MAGENTA" }, - { COLOR_CYAN, "COLOR_CYAN" }, - { COLOR_WHITE, "COLOR_WHITE" }, - /* *INDENT-ON* */ - + DATA(COLOR_BLACK), + DATA(COLOR_RED), + DATA(COLOR_GREEN), + DATA(COLOR_YELLOW), + DATA(COLOR_BLUE), + DATA(COLOR_MAGENTA), + DATA(COLOR_CYAN), + DATA(COLOR_WHITE), } #endif /* !USE_TERMLIB */ ; +#undef DATA size_t n; char temp[80]; char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ); @@ -205,49 +201,50 @@ _nc_retrace_attr_t(attr_t code) const char * _nc_altcharset_name(attr_t attr, chtype ch) { +#define DATA(code, name) { code, { #name } } typedef struct { unsigned int val; - const char *name; + const char name[13]; } ALT_NAMES; #if NCURSES_SP_FUNCS SCREEN *sp = CURRENT_SCREEN; #endif static const ALT_NAMES names[] = { - {'l', "ACS_ULCORNER"}, /* upper left corner */ - {'m', "ACS_LLCORNER"}, /* lower left corner */ - {'k', "ACS_URCORNER"}, /* upper right corner */ - {'j', "ACS_LRCORNER"}, /* lower right corner */ - {'t', "ACS_LTEE"}, /* tee pointing right */ - {'u', "ACS_RTEE"}, /* tee pointing left */ - {'v', "ACS_BTEE"}, /* tee pointing up */ - {'w', "ACS_TTEE"}, /* tee pointing down */ - {'q', "ACS_HLINE"}, /* horizontal line */ - {'x', "ACS_VLINE"}, /* vertical line */ - {'n', "ACS_PLUS"}, /* large plus or crossover */ - {'o', "ACS_S1"}, /* scan line 1 */ - {'s', "ACS_S9"}, /* scan line 9 */ - {'`', "ACS_DIAMOND"}, /* diamond */ - {'a', "ACS_CKBOARD"}, /* checker board (stipple) */ - {'f', "ACS_DEGREE"}, /* degree symbol */ - {'g', "ACS_PLMINUS"}, /* plus/minus */ - {'~', "ACS_BULLET"}, /* bullet */ - {',', "ACS_LARROW"}, /* arrow pointing left */ - {'+', "ACS_RARROW"}, /* arrow pointing right */ - {'.', "ACS_DARROW"}, /* arrow pointing down */ - {'-', "ACS_UARROW"}, /* arrow pointing up */ - {'h', "ACS_BOARD"}, /* board of squares */ - {'i', "ACS_LANTERN"}, /* lantern symbol */ - {'0', "ACS_BLOCK"}, /* solid square block */ - {'p', "ACS_S3"}, /* scan line 3 */ - {'r', "ACS_S7"}, /* scan line 7 */ - {'y', "ACS_LEQUAL"}, /* less/equal */ - {'z', "ACS_GEQUAL"}, /* greater/equal */ - {'{', "ACS_PI"}, /* Pi */ - {'|', "ACS_NEQUAL"}, /* not equal */ - {'}', "ACS_STERLING"}, /* UK pound sign */ - {'\0', (char *) 0} + DATA('l', ACS_ULCORNER), /* upper left corner */ + DATA('m', ACS_LLCORNER), /* lower left corner */ + DATA('k', ACS_URCORNER), /* upper right corner */ + DATA('j', ACS_LRCORNER), /* lower right corner */ + DATA('t', ACS_LTEE), /* tee pointing right */ + DATA('u', ACS_RTEE), /* tee pointing left */ + DATA('v', ACS_BTEE), /* tee pointing up */ + DATA('w', ACS_TTEE), /* tee pointing down */ + DATA('q', ACS_HLINE), /* horizontal line */ + DATA('x', ACS_VLINE), /* vertical line */ + DATA('n', ACS_PLUS), /* large plus or crossover */ + DATA('o', ACS_S1), /* scan line 1 */ + DATA('s', ACS_S9), /* scan line 9 */ + DATA('`', ACS_DIAMOND), /* diamond */ + DATA('a', ACS_CKBOARD), /* checker board (stipple) */ + DATA('f', ACS_DEGREE), /* degree symbol */ + DATA('g', ACS_PLMINUS), /* plus/minus */ + DATA('~', ACS_BULLET), /* bullet */ + DATA(',', ACS_LARROW), /* arrow pointing left */ + DATA('+', ACS_RARROW), /* arrow pointing right */ + DATA('.', ACS_DARROW), /* arrow pointing down */ + DATA('-', ACS_UARROW), /* arrow pointing up */ + DATA('h', ACS_BOARD), /* board of squares */ + DATA('i', ACS_LANTERN), /* lantern symbol */ + DATA('0', ACS_BLOCK), /* solid square block */ + DATA('p', ACS_S3), /* scan line 3 */ + DATA('r', ACS_S7), /* scan line 7 */ + DATA('y', ACS_LEQUAL), /* less/equal */ + DATA('z', ACS_GEQUAL), /* greater/equal */ + DATA('{', ACS_PI), /* Pi */ + DATA('|', ACS_NEQUAL), /* not equal */ + DATA('}', ACS_STERLING), /* UK pound sign */ }; +#undef DATA const char *result = 0; @@ -257,7 +254,7 @@ _nc_altcharset_name(attr_t attr, chtype ch) if (SP_PARM != 0 && (attr & A_ALTCHARSET) && (acs_chars != 0)) { char *cp; char *found = 0; - const ALT_NAMES *strp; + size_t n; for (cp = acs_chars; cp[0] && cp[1]; cp += 2) { if (ChCharOf(UChar(cp[1])) == ChCharOf(ch)) { @@ -268,11 +265,12 @@ _nc_altcharset_name(attr_t attr, chtype ch) if (found != 0) { ch = ChCharOf(UChar(*found)); - for (strp = names; strp->val; strp++) - if (strp->val == ch) { - result = strp->name; + for (n = 0; n < SIZEOF(names); ++n) { + if (names[n].val == ch) { + result = names[n].name; break; } + } } } return result; diff --git a/ncurses/trace/lib_tracebits.c b/ncurses/trace/lib_tracebits.c index 7d8325a8..6f7c8ca2 100644 --- a/ncurses/trace/lib_tracebits.c +++ b/ncurses/trace/lib_tracebits.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc. * + * Copyright (c) 1998-2012,2015 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 * @@ -34,7 +34,7 @@ #include -MODULE_ID("$Id: lib_tracebits.c,v 1.23 2012/06/09 19:55:46 tom Exp $") +MODULE_ID("$Id: lib_tracebits.c,v 1.25 2015/04/04 13:45:27 tom Exp $") #if HAVE_SYS_TERMIO_H #include /* needed for ISC */ @@ -73,7 +73,7 @@ MODULE_ID("$Id: lib_tracebits.c,v 1.23 2012/06/09 19:55:46 tom Exp $") typedef struct { unsigned int val; - const char *name; + const char name[8]; } BITNAMES; #define TRACE_BUF_SIZE(num) (_nc_globals.tracebuf_ptr[num].size) @@ -103,56 +103,59 @@ _nc_trace_ttymode(TTY * tty) char *buf; #ifdef TERMIOS +#define DATA(name) { name, { #name } } +#define DATA2(name,name2) { name, { #name2 } } +#define DATAX() { 0, { "" } } static const BITNAMES iflags[] = { - {BRKINT, "BRKINT"}, - {IGNBRK, "IGNBRK"}, - {IGNPAR, "IGNPAR"}, - {PARMRK, "PARMRK"}, - {INPCK, "INPCK"}, - {ISTRIP, "ISTRIP"}, - {INLCR, "INLCR"}, - {IGNCR, "IGNC"}, - {ICRNL, "ICRNL"}, - {IXON, "IXON"}, - {IXOFF, "IXOFF"}, - {0, NULL} + DATA(BRKINT), + DATA(IGNBRK), + DATA(IGNPAR), + DATA(PARMRK), + DATA(INPCK), + DATA(ISTRIP), + DATA(INLCR), + DATA(IGNCR), + DATA(ICRNL), + DATA(IXON), + DATA(IXOFF), + DATAX() #define ALLIN (BRKINT|IGNBRK|IGNPAR|PARMRK|INPCK|ISTRIP|INLCR|IGNCR|ICRNL|IXON|IXOFF) }, oflags[] = { - {OPOST, "OPOST"}, - {OFLAGS_TABS, "XTABS"}, - {ONLCR, "ONLCR"}, - {OCRNL, "OCRNL"}, - {ONOCR, "ONOCR"}, - {ONLRET, "ONLRET"}, - {0, NULL} + DATA(OPOST), + DATA2(OFLAGS_TABS, XTABS), + DATA(ONLCR), + DATA(OCRNL), + DATA(ONOCR), + DATA(ONLRET), + DATAX() #define ALLOUT (OPOST|OFLAGS_TABS|ONLCR|OCRNL|ONOCR|ONLRET) }, cflags[] = { - {CLOCAL, "CLOCAL"}, - {CREAD, "CREAD"}, - {CSTOPB, "CSTOPB"}, + DATA(CLOCAL), + DATA(CREAD), + DATA(CSTOPB), #if !defined(CS5) || !defined(CS8) - {CSIZE, "CSIZE"}, + DATA(CSIZE), #endif - {HUPCL, "HUPCL"}, - {PARENB, "PARENB"}, - {PARODD | PARENB, "PARODD"}, /* concession to readability */ - {0, NULL} + DATA(HUPCL), + DATA(PARENB), + DATA2(PARODD | PARENB, PARODD), + DATAX() #define ALLCTRL (CLOCAL|CREAD|CSIZE|CSTOPB|HUPCL|PARENB|PARODD) }, lflags[] = { - {ECHO, "ECHO"}, - {ECHOE | ECHO, "ECHOE"}, /* concession to readability */ - {ECHOK | ECHO, "ECHOK"}, /* concession to readability */ - {ECHONL, "ECHONL"}, - {ICANON, "ICANON"}, - {ISIG, "ISIG"}, - {NOFLSH, "NOFLSH"}, - {TOSTOP, "TOSTOP"}, - {IEXTEN, "IEXTEN"}, - {0, NULL} + DATA(ECHO), + DATA2(ECHOE | ECHO, ECHOE), + DATA2(ECHOK | ECHO, ECHOK), + DATA(ECHONL), + DATA(ICANON), + DATA(ISIG), + DATA(NOFLSH), + DATA(TOSTOP), + DATA(IEXTEN), + DATAX() #define ALLLOCAL (ECHO|ECHONL|ICANON|ISIG|NOFLSH|TOSTOP|IEXTEN) }; @@ -175,11 +178,11 @@ _nc_trace_ttymode(TTY * tty) #if defined(CS5) && defined(CS8) { - static struct { + static const struct { int value; - const char *name; + const char name[5]; } csizes[] = { -#define CS_DATA(name) { name, #name " " } +#define CS_DATA(name) { name, { #name " " } } CS_DATA(CS5), #ifdef CS6 CS_DATA(CS6), @@ -228,17 +231,17 @@ _nc_trace_ttymode(TTY * tty) static const BITNAMES cflags[] = { - {CBREAK, "CBREAK"}, - {CRMOD, "CRMOD"}, - {ECHO, "ECHO"}, - {EVENP, "EVENP"}, - {LCASE, "LCASE"}, - {LLITOUT, "LLITOUT"}, - {ODDP, "ODDP"}, - {RAW, "RAW"}, - {TANDEM, "TANDEM"}, - {XTABS, "XTABS"}, - {0, NULL} + DATA(CBREAK), + DATA(CRMOD), + DATA(ECHO), + DATA(EVENP), + DATA(LCASE), + DATA(LLITOUT), + DATA(ODDP), + DATA(RAW), + DATA(TANDEM), + DATA(XTABS), + DATAX() #define ALLCTRL (CBREAK|CRMOD|ECHO|EVENP|LCASE|LLITOUT|ODDP|RAW|TANDEM|XTABS) }; diff --git a/package/debian-mingw/changelog b/package/debian-mingw/changelog index dd8d4708..6747b1b4 100644 --- a/package/debian-mingw/changelog +++ b/package/debian-mingw/changelog @@ -1,8 +1,8 @@ -ncurses6 (5.9+20150329) unstable; urgency=low +ncurses6 (5.9+20150404) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sun, 29 Mar 2015 10:32:33 -0400 + -- Thomas E. Dickey Fri, 03 Apr 2015 20:24:36 -0400 ncurses6 (5.9-20131005) unstable; urgency=low diff --git a/package/debian-mingw64/changelog b/package/debian-mingw64/changelog index dd8d4708..6747b1b4 100644 --- a/package/debian-mingw64/changelog +++ b/package/debian-mingw64/changelog @@ -1,8 +1,8 @@ -ncurses6 (5.9+20150329) unstable; urgency=low +ncurses6 (5.9+20150404) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sun, 29 Mar 2015 10:32:33 -0400 + -- Thomas E. Dickey Fri, 03 Apr 2015 20:24:36 -0400 ncurses6 (5.9-20131005) unstable; urgency=low diff --git a/package/debian/changelog b/package/debian/changelog index 9982b33d..46d67148 100644 --- a/package/debian/changelog +++ b/package/debian/changelog @@ -1,8 +1,8 @@ -ncurses6 (5.9+20150329) unstable; urgency=low +ncurses6 (5.9+20150404) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Sun, 29 Mar 2015 10:32:33 -0400 + -- Thomas E. Dickey Fri, 03 Apr 2015 20:24:36 -0400 ncurses6 (5.9-20120608) unstable; urgency=low diff --git a/package/mingw-ncurses.nsi b/package/mingw-ncurses.nsi index bfb24012..3f2ba374 100644 --- a/package/mingw-ncurses.nsi +++ b/package/mingw-ncurses.nsi @@ -1,4 +1,4 @@ -; $Id: mingw-ncurses.nsi,v 1.94 2015/03/29 14:32:33 tom Exp $ +; $Id: mingw-ncurses.nsi,v 1.95 2015/04/04 00:24:36 tom Exp $ ; TODO add examples ; TODO bump ABI to 6 @@ -10,7 +10,7 @@ !define VERSION_MAJOR "5" !define VERSION_MINOR "9" !define VERSION_YYYY "2015" -!define VERSION_MMDD "0329" +!define VERSION_MMDD "0404" !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD} !define MY_ABI "5" diff --git a/package/mingw-ncurses.spec b/package/mingw-ncurses.spec index 58a627c7..9150176f 100644 --- a/package/mingw-ncurses.spec +++ b/package/mingw-ncurses.spec @@ -3,7 +3,7 @@ Summary: shared libraries for terminal handling Name: mingw32-ncurses6 Version: 5.9 -Release: 20150329 +Release: 20150404 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz diff --git a/package/ncurses.spec b/package/ncurses.spec index 850a06e3..e9b43ee5 100644 --- a/package/ncurses.spec +++ b/package/ncurses.spec @@ -1,7 +1,7 @@ Summary: shared libraries for terminal handling Name: ncurses6 Version: 5.9 -Release: 20150329 +Release: 20150404 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz diff --git a/progs/infocmp.c b/progs/infocmp.c index 587cbc34..3116fd4b 100644 --- a/progs/infocmp.c +++ b/progs/infocmp.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc. * + * Copyright (c) 1998-2014,2015 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 * @@ -42,7 +42,7 @@ #include -MODULE_ID("$Id: infocmp.c,v 1.129 2014/02/01 22:11:03 tom Exp $") +MODULE_ID("$Id: infocmp.c,v 1.131 2015/04/04 16:22:19 tom Exp $") #define L_CURL "{" #define R_CURL "}" @@ -631,99 +631,104 @@ compare_predicate(PredType type, PredIdx idx, const char *name) * ***************************************************************************/ +#define DATA(from, to) { { from }, { to } } +#define DATAX() DATA("", "") + typedef struct { - const char *from; - const char *to; + const char from[4]; + const char to[12]; } assoc; static const assoc std_caps[] = { /* these are specified by X.364 and iBCS2 */ - {"\033c", "RIS"}, /* full reset */ - {"\0337", "SC"}, /* save cursor */ - {"\0338", "RC"}, /* restore cursor */ - {"\033[r", "RSR"}, /* not an X.364 mnemonic */ - {"\033[m", "SGR0"}, /* not an X.364 mnemonic */ - {"\033[2J", "ED2"}, /* clear page */ + DATA("\033c", "RIS"), /* full reset */ + DATA("\0337", "SC"), /* save cursor */ + DATA("\0338", "RC"), /* restore cursor */ + DATA("\033[r", "RSR"), /* not an X.364 mnemonic */ + DATA("\033[m", "SGR0"), /* not an X.364 mnemonic */ + DATA("\033[2J", "ED2"), /* clear page */ /* this group is specified by ISO 2022 */ - {"\033(0", "ISO DEC G0"}, /* enable DEC graphics for G0 */ - {"\033(A", "ISO UK G0"}, /* enable UK chars for G0 */ - {"\033(B", "ISO US G0"}, /* enable US chars for G0 */ - {"\033)0", "ISO DEC G1"}, /* enable DEC graphics for G1 */ - {"\033)A", "ISO UK G1"}, /* enable UK chars for G1 */ - {"\033)B", "ISO US G1"}, /* enable US chars for G1 */ + DATA("\033(0", "ISO DEC G0"), /* enable DEC graphics for G0 */ + DATA("\033(A", "ISO UK G0"), /* enable UK chars for G0 */ + DATA("\033(B", "ISO US G0"), /* enable US chars for G0 */ + DATA("\033)0", "ISO DEC G1"), /* enable DEC graphics for G1 */ + DATA("\033)A", "ISO UK G1"), /* enable UK chars for G1 */ + DATA("\033)B", "ISO US G1"), /* enable US chars for G1 */ /* these are DEC private controls widely supported by emulators */ - {"\033=", "DECPAM"}, /* application keypad mode */ - {"\033>", "DECPNM"}, /* normal keypad mode */ - {"\033<", "DECANSI"}, /* enter ANSI mode */ - {"\033[!p", "DECSTR"}, /* soft reset */ - {"\033 F", "S7C1T"}, /* 7-bit controls */ + DATA("\033=", "DECPAM"), /* application keypad mode */ + DATA("\033>", "DECPNM"), /* normal keypad mode */ + DATA("\033<", "DECANSI"), /* enter ANSI mode */ + DATA("\033[!p", "DECSTR"), /* soft reset */ + DATA("\033 F", "S7C1T"), /* 7-bit controls */ - {(char *) 0, (char *) 0} + DATAX() }; static const assoc std_modes[] = /* ECMA \E[ ... [hl] modes recognized by many emulators */ { - {"2", "AM"}, /* keyboard action mode */ - {"4", "IRM"}, /* insert/replace mode */ - {"12", "SRM"}, /* send/receive mode */ - {"20", "LNM"}, /* linefeed mode */ - {(char *) 0, (char *) 0} + DATA("2", "AM"), /* keyboard action mode */ + DATA("4", "IRM"), /* insert/replace mode */ + DATA("12", "SRM"), /* send/receive mode */ + DATA("20", "LNM"), /* linefeed mode */ + DATAX() }; static const assoc private_modes[] = /* DEC \E[ ... [hl] modes recognized by many emulators */ { - {"1", "CKM"}, /* application cursor keys */ - {"2", "ANM"}, /* set VT52 mode */ - {"3", "COLM"}, /* 132-column mode */ - {"4", "SCLM"}, /* smooth scroll */ - {"5", "SCNM"}, /* reverse video mode */ - {"6", "OM"}, /* origin mode */ - {"7", "AWM"}, /* wraparound mode */ - {"8", "ARM"}, /* auto-repeat mode */ - {(char *) 0, (char *) 0} + DATA("1", "CKM"), /* application cursor keys */ + DATA("2", "ANM"), /* set VT52 mode */ + DATA("3", "COLM"), /* 132-column mode */ + DATA("4", "SCLM"), /* smooth scroll */ + DATA("5", "SCNM"), /* reverse video mode */ + DATA("6", "OM"), /* origin mode */ + DATA("7", "AWM"), /* wraparound mode */ + DATA("8", "ARM"), /* auto-repeat mode */ + DATAX() }; static const assoc ecma_highlights[] = /* recognize ECMA attribute sequences */ { - {"0", "NORMAL"}, /* normal */ - {"1", "+BOLD"}, /* bold on */ - {"2", "+DIM"}, /* dim on */ - {"3", "+ITALIC"}, /* italic on */ - {"4", "+UNDERLINE"}, /* underline on */ - {"5", "+BLINK"}, /* blink on */ - {"6", "+FASTBLINK"}, /* fastblink on */ - {"7", "+REVERSE"}, /* reverse on */ - {"8", "+INVISIBLE"}, /* invisible on */ - {"9", "+DELETED"}, /* deleted on */ - {"10", "MAIN-FONT"}, /* select primary font */ - {"11", "ALT-FONT-1"}, /* select alternate font 1 */ - {"12", "ALT-FONT-2"}, /* select alternate font 2 */ - {"13", "ALT-FONT-3"}, /* select alternate font 3 */ - {"14", "ALT-FONT-4"}, /* select alternate font 4 */ - {"15", "ALT-FONT-5"}, /* select alternate font 5 */ - {"16", "ALT-FONT-6"}, /* select alternate font 6 */ - {"17", "ALT-FONT-7"}, /* select alternate font 7 */ - {"18", "ALT-FONT-1"}, /* select alternate font 1 */ - {"19", "ALT-FONT-1"}, /* select alternate font 1 */ - {"20", "FRAKTUR"}, /* Fraktur font */ - {"21", "DOUBLEUNDER"}, /* double underline */ - {"22", "-DIM"}, /* dim off */ - {"23", "-ITALIC"}, /* italic off */ - {"24", "-UNDERLINE"}, /* underline off */ - {"25", "-BLINK"}, /* blink off */ - {"26", "-FASTBLINK"}, /* fastblink off */ - {"27", "-REVERSE"}, /* reverse off */ - {"28", "-INVISIBLE"}, /* invisible off */ - {"29", "-DELETED"}, /* deleted off */ - {(char *) 0, (char *) 0} + DATA("0", "NORMAL"), /* normal */ + DATA("1", "+BOLD"), /* bold on */ + DATA("2", "+DIM"), /* dim on */ + DATA("3", "+ITALIC"), /* italic on */ + DATA("4", "+UNDERLINE"), /* underline on */ + DATA("5", "+BLINK"), /* blink on */ + DATA("6", "+FASTBLINK"), /* fastblink on */ + DATA("7", "+REVERSE"), /* reverse on */ + DATA("8", "+INVISIBLE"), /* invisible on */ + DATA("9", "+DELETED"), /* deleted on */ + DATA("10", "MAIN-FONT"), /* select primary font */ + DATA("11", "ALT-FONT-1"), /* select alternate font 1 */ + DATA("12", "ALT-FONT-2"), /* select alternate font 2 */ + DATA("13", "ALT-FONT-3"), /* select alternate font 3 */ + DATA("14", "ALT-FONT-4"), /* select alternate font 4 */ + DATA("15", "ALT-FONT-5"), /* select alternate font 5 */ + DATA("16", "ALT-FONT-6"), /* select alternate font 6 */ + DATA("17", "ALT-FONT-7"), /* select alternate font 7 */ + DATA("18", "ALT-FONT-1"), /* select alternate font 1 */ + DATA("19", "ALT-FONT-1"), /* select alternate font 1 */ + DATA("20", "FRAKTUR"), /* Fraktur font */ + DATA("21", "DOUBLEUNDER"), /* double underline */ + DATA("22", "-DIM"), /* dim off */ + DATA("23", "-ITALIC"), /* italic off */ + DATA("24", "-UNDERLINE"), /* underline off */ + DATA("25", "-BLINK"), /* blink off */ + DATA("26", "-FASTBLINK"), /* fastblink off */ + DATA("27", "-REVERSE"), /* reverse off */ + DATA("28", "-INVISIBLE"), /* invisible off */ + DATA("29", "-DELETED"), /* deleted off */ + DATAX() }; +#undef DATA + static int skip_csi(const char *cap) { @@ -757,7 +762,7 @@ lookup_params(const assoc * table, char *dst, char *src) do { bool found = FALSE; - for (ap = table; ap->from; ap++) { + for (ap = table; ap->from[0]; ap++) { size_t tlen = strlen(ap->from); if (same_param(ap->from, ep, tlen)) { @@ -839,7 +844,7 @@ analyze_string(const char *name, const char *cap, TERMTYPE *tp) /* now check the standard capabilities */ if (!expansion) { csi = skip_csi(sp); - for (ap = std_caps; ap->from; ap++) { + for (ap = std_caps; ap->from[0]; ap++) { size_t adj = (size_t) (csi ? 2 : 0); len = strlen(ap->from); @@ -1155,12 +1160,18 @@ file_comparison(int argc, char *argv[]) static void usage(void) { - static const char *tbl[] = +#define DATA(s) s "\n" + static const char head[] = + { + DATA("Usage: infocmp [options] [-A directory] [-B directory] [termname...]") + DATA("") + DATA("Options:") + }; +#undef DATA +#define DATA(s) s + static const char options[][45] = { - "Usage: infocmp [options] [-A directory] [-B directory] [termname...]" - ,"" - ,"Options:" - ," -0 print single-row" + " -0 print single-row" ," -1 print single-column" ," -K use termcap-names and BSD syntax" ," -C use termcap-names" @@ -1169,7 +1180,7 @@ usage(void) ," -L use long names" ," -R subset (see manpage)" ," -T eliminate size limits (test)" - ," -U eliminate post-processing of entries" + ," -U do not post-process entries" ," -D print database locations" ," -V print version" #if NCURSES_XNAMES @@ -1197,20 +1208,21 @@ usage(void) ," -v number (verbose)" ," -w number (width)" #if NCURSES_XNAMES - ," -x treat unknown capabilities as user-defined" + ," -x unknown capabilities are user-defined" #endif }; - const size_t first = 3; - const size_t last = SIZEOF(tbl); - const size_t left = (last - first + 1) / 2 + first; +#undef DATA + const size_t last = SIZEOF(options); + const size_t left = (last + 1) / 2; size_t n; + fputs(head, stderr); for (n = 0; n < left; n++) { - size_t m = (n < first) ? last : n + left - first; + size_t m = n + left; if (m < last) - fprintf(stderr, "%-40.40s%s\n", tbl[n], tbl[m]); + fprintf(stderr, "%-40.40s%s\n", options[n], options[m]); else - fprintf(stderr, "%s\n", tbl[n]); + fprintf(stderr, "%s\n", options[n]); } ExitProgram(EXIT_FAILURE); } diff --git a/progs/tabs.c b/progs/tabs.c index 7ed30075..e638a2c5 100644 --- a/progs/tabs.c +++ b/progs/tabs.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2008-2012,2013 Free Software Foundation, Inc. * + * Copyright (c) 2008-2013,2015 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 * @@ -37,7 +37,7 @@ #define USE_LIBTINFO #include -MODULE_ID("$Id: tabs.c,v 1.34 2013/06/11 08:18:27 tom Exp $") +MODULE_ID("$Id: tabs.c,v 1.35 2015/04/04 14:57:47 tom Exp $") static void usage(void) GCC_NORETURN; @@ -338,36 +338,35 @@ skip_list(char *value) static void usage(void) { - static const char *msg[] = +#define DATA(s) s "\n" + static const char msg[] = { - "Usage: tabs [options] [tabstop-list]" - ,"" - ,"Options:" - ," -0 reset tabs" - ," -8 set tabs to standard interval" - ," -a Assembler, IBM S/370, first format" - ," -a2 Assembler, IBM S/370, second format" - ," -c COBOL, normal format" - ," -c2 COBOL compact format" - ," -c3 COBOL compact format extended" - ," -d debug (show ruler with expected/actual tab positions)" - ," -f FORTRAN" - ," -n no-op (do not modify terminal settings)" - ," -p PL/I" - ," -s SNOBOL" - ," -u UNIVAC 1100 Assembler" - ," -T name use terminal type 'name'" - ," -V print version" - ,"" - ,"A tabstop-list is an ordered list of column numbers, e.g., 1,11,21" - ,"or 1,+10,+10 which is the same." + DATA("Usage: tabs [options] [tabstop-list]") + DATA("") + DATA("Options:") + DATA(" -0 reset tabs") + DATA(" -8 set tabs to standard interval") + DATA(" -a Assembler, IBM S/370, first format") + DATA(" -a2 Assembler, IBM S/370, second format") + DATA(" -c COBOL, normal format") + DATA(" -c2 COBOL compact format") + DATA(" -c3 COBOL compact format extended") + DATA(" -d debug (show ruler with expected/actual tab positions)") + DATA(" -f FORTRAN") + DATA(" -n no-op (do not modify terminal settings)") + DATA(" -p PL/I") + DATA(" -s SNOBOL") + DATA(" -u UNIVAC 1100 Assembler") + DATA(" -T name use terminal type 'name'") + DATA(" -V print version") + DATA("") + DATA("A tabstop-list is an ordered list of column numbers, e.g., 1,11,21") + DATA("or 1,+10,+10 which is the same.") }; - unsigned n; +#undef DATA fflush(stdout); - for (n = 0; n < SIZEOF(msg); ++n) { - fprintf(stderr, "%s\n", msg[n]); - } + fputs(msg, stderr); ExitProgram(EXIT_FAILURE); } diff --git a/progs/tic.c b/progs/tic.c index 763c2b79..a9a4edc5 100644 --- a/progs/tic.c +++ b/progs/tic.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc. * + * Copyright (c) 1998-2014,2015 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 * @@ -48,7 +48,7 @@ #include #include -MODULE_ID("$Id: tic.c,v 1.208 2014/10/18 09:34:29 tom Exp $") +MODULE_ID("$Id: tic.c,v 1.209 2015/04/04 14:53:41 tom Exp $") #define STDIN_NAME "" @@ -138,50 +138,48 @@ failed(const char *msg) static void usage(void) { - static const char *const tbl[] = +#define DATA(s) s "\n" + static const char options_string[] = { - "Options:", - " -1 format translation output one capability per line", + DATA("Options:") + DATA(" -1 format translation output one capability per line") #if NCURSES_XNAMES - " -a retain commented-out capabilities (sets -x also)", + DATA(" -a retain commented-out capabilities (sets -x also)") #endif - " -C translate entries to termcap source form", - " -D print list of tic's database locations (first must be writable)", - " -c check only, validate input without compiling or translating", - " -e translate/compile only entries named by comma-separated list", - " -f format complex strings for readability", - " -G format %{number} to %'char'", - " -g format %'char' to %{number}", - " -I translate entries to terminfo source form", - " -K translate entries to termcap source form with BSD syntax", - " -L translate entries to full terminfo source form", - " -N disable smart defaults for source translation", - " -o set output directory for compiled entry writes", - " -R restrict translation to given terminfo/termcap version", - " -r force resolution of all use entries in source translation", - " -s print summary statistics", - " -T remove size-restrictions on compiled description", + DATA(" -C translate entries to termcap source form") + DATA(" -D print list of tic's database locations (first must be writable)") + DATA(" -c check only, validate input without compiling or translating") + DATA(" -e translate/compile only entries named by comma-separated list") + DATA(" -f format complex strings for readability") + DATA(" -G format %{number} to %'char'") + DATA(" -g format %'char' to %{number}") + DATA(" -I translate entries to terminfo source form") + DATA(" -K translate entries to termcap source form with BSD syntax") + DATA(" -L translate entries to full terminfo source form") + DATA(" -N disable smart defaults for source translation") + DATA(" -o set output directory for compiled entry writes") + DATA(" -R restrict translation to given terminfo/termcap version") + DATA(" -r force resolution of all use entries in source translation") + DATA(" -s print summary statistics") + DATA(" -T remove size-restrictions on compiled description") #if NCURSES_XNAMES - " -t suppress commented-out capabilities", + DATA(" -t suppress commented-out capabilities") #endif - " -U suppress post-processing of entries", - " -V print version", - " -v[n] set verbosity level", - " -w[n] set format width for translation output", + DATA(" -U suppress post-processing of entries") + DATA(" -V print version") + DATA(" -v[n] set verbosity level") + DATA(" -w[n] set format width for translation output") #if NCURSES_XNAMES - " -x treat unknown capabilities as user-defined", + DATA(" -x treat unknown capabilities as user-defined") #endif - "", - "Parameters:", - " file to translate or compile" + DATA("") + DATA("Parameters:") + DATA(" file to translate or compile") }; - size_t j; +#undef DATA fprintf(stderr, "Usage: %s %s\n", _nc_progname, usage_string); - for (j = 0; j < SIZEOF(tbl); j++) { - fputs(tbl[j], stderr); - putc('\n', stderr); - } + fputs(options_string, stderr); ExitProgram(EXIT_FAILURE); } @@ -1580,78 +1578,81 @@ check_screen(TERMTYPE *tp) static int expected_params(const char *name) { +#define DATA(name,count) { { name }, count } /* *INDENT-OFF* */ static const struct { - const char *name; + const char name[9]; int count; } table[] = { - { "S0", 1 }, /* 'screen' extension */ - { "birep", 2 }, - { "chr", 1 }, - { "colornm", 1 }, - { "cpi", 1 }, - { "csnm", 1 }, - { "csr", 2 }, - { "cub", 1 }, - { "cud", 1 }, - { "cuf", 1 }, - { "cup", 2 }, - { "cuu", 1 }, - { "cvr", 1 }, - { "cwin", 5 }, - { "dch", 1 }, - { "defc", 3 }, - { "dial", 1 }, - { "dispc", 1 }, - { "dl", 1 }, - { "ech", 1 }, - { "getm", 1 }, - { "hpa", 1 }, - { "ich", 1 }, - { "il", 1 }, - { "indn", 1 }, - { "initc", 4 }, - { "initp", 7 }, - { "lpi", 1 }, - { "mc5p", 1 }, - { "mrcup", 2 }, - { "mvpa", 1 }, - { "pfkey", 2 }, - { "pfloc", 2 }, - { "pfx", 2 }, - { "pfxl", 3 }, - { "pln", 2 }, - { "qdial", 1 }, - { "rcsd", 1 }, - { "rep", 2 }, - { "rin", 1 }, - { "sclk", 3 }, - { "scp", 1 }, - { "scs", 1 }, - { "scsd", 2 }, - { "setab", 1 }, - { "setaf", 1 }, - { "setb", 1 }, - { "setcolor", 1 }, - { "setf", 1 }, - { "sgr", 9 }, - { "sgr1", 6 }, - { "slength", 1 }, - { "slines", 1 }, - { "smgbp", 1 }, /* 2 if smgtp is not given */ - { "smglp", 1 }, - { "smglr", 2 }, - { "smgrp", 1 }, - { "smgtb", 2 }, - { "smgtp", 1 }, - { "tsl", 1 }, - { "u6", -1 }, - { "vpa", 1 }, - { "wind", 4 }, - { "wingo", 1 }, + DATA( "S0", 1 ), /* 'screen' extension */ + DATA( "birep", 2 ), + DATA( "chr", 1 ), + DATA( "colornm", 1 ), + DATA( "cpi", 1 ), + DATA( "csnm", 1 ), + DATA( "csr", 2 ), + DATA( "cub", 1 ), + DATA( "cud", 1 ), + DATA( "cuf", 1 ), + DATA( "cup", 2 ), + DATA( "cuu", 1 ), + DATA( "cvr", 1 ), + DATA( "cwin", 5 ), + DATA( "dch", 1 ), + DATA( "defc", 3 ), + DATA( "dial", 1 ), + DATA( "dispc", 1 ), + DATA( "dl", 1 ), + DATA( "ech", 1 ), + DATA( "getm", 1 ), + DATA( "hpa", 1 ), + DATA( "ich", 1 ), + DATA( "il", 1 ), + DATA( "indn", 1 ), + DATA( "initc", 4 ), + DATA( "initp", 7 ), + DATA( "lpi", 1 ), + DATA( "mc5p", 1 ), + DATA( "mrcup", 2 ), + DATA( "mvpa", 1 ), + DATA( "pfkey", 2 ), + DATA( "pfloc", 2 ), + DATA( "pfx", 2 ), + DATA( "pfxl", 3 ), + DATA( "pln", 2 ), + DATA( "qdial", 1 ), + DATA( "rcsd", 1 ), + DATA( "rep", 2 ), + DATA( "rin", 1 ), + DATA( "sclk", 3 ), + DATA( "scp", 1 ), + DATA( "scs", 1 ), + DATA( "scsd", 2 ), + DATA( "setab", 1 ), + DATA( "setaf", 1 ), + DATA( "setb", 1 ), + DATA( "setcolor", 1 ), + DATA( "setf", 1 ), + DATA( "sgr", 9 ), + DATA( "sgr1", 6 ), + DATA( "slength", 1 ), + DATA( "slines", 1 ), + DATA( "smgbp", 1 ), /* 2 if smgtp is not given */ + DATA( "smglp", 1 ), + DATA( "smglr", 2 ), + DATA( "smgrp", 1 ), + DATA( "smgtb", 2 ), + DATA( "smgtp", 1 ), + DATA( "tsl", 1 ), + DATA( "u6", -1 ), + DATA( "vpa", 1 ), + DATA( "wind", 4 ), + DATA( "wingo", 1 ), }; /* *INDENT-ON* */ +#undef DATA + unsigned n; int result = 0; /* function-keys, etc., use none */ @@ -1999,19 +2000,21 @@ ignore_delays(char *s) static bool similar_sgr(int num, char *a, char *b) { - static const char *names[] = +#define DATA(name) { #name } + static const char names[][11] = { - "none" - ,"standout" - ,"underline" - ,"reverse" - ,"blink" - ,"dim" - ,"bold" - ,"invis" - ,"protect" - ,"altcharset" + DATA(none), + DATA(standout), + DATA(underline), + DATA(reverse), + DATA(blink), + DATA(dim), + DATA(bold), + DATA(invis), + DATA(protect), + DATA(altcharset), }; +#undef DATA char *base_a = a; char *base_b = b; int delaying = 0; diff --git a/progs/tparm_type.c b/progs/tparm_type.c index 26eee698..125e43c2 100644 --- a/progs/tparm_type.c +++ b/progs/tparm_type.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc. * + * Copyright (c) 1998-2013,2015 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 * @@ -32,7 +32,7 @@ #include -MODULE_ID("$Id: tparm_type.c,v 1.1 2014/05/21 16:50:57 tom Exp $") +MODULE_ID("$Id: tparm_type.c,v 1.2 2015/04/04 15:01:13 tom Exp $") /* * Lookup the type of call we should make to tparm(). This ignores the actual @@ -42,12 +42,15 @@ MODULE_ID("$Id: tparm_type.c,v 1.1 2014/05/21 16:50:57 tom Exp $") TParams tparm_type(const char *name) { -#define TD(code, longname, ti, tc) {code,longname},{code,ti},{code,tc} +#define TD(code, longname, ti, tc) \ + {code, {longname} }, \ + {code, {ti} }, \ + {code, {tc} } TParams result = Numbers; /* *INDENT-OFF* */ static const struct { TParams code; - const char *name; + const char name[12]; } table[] = { TD(Num_Str, "pkey_key", "pfkey", "pk"), TD(Num_Str, "pkey_local", "pfloc", "pl"), diff --git a/progs/tset.c b/progs/tset.c index 475b3e63..472146dc 100644 --- a/progs/tset.c +++ b/progs/tset.c @@ -119,7 +119,7 @@ char *ttyname(int fd); #include #include -MODULE_ID("$Id: tset.c,v 1.94 2015/03/21 16:34:59 tom Exp $") +MODULE_ID("$Id: tset.c,v 1.95 2015/04/04 15:09:24 tom Exp $") /* * SCO defines TIOCGSIZE and the corresponding struct. Other systems (SunOS, @@ -307,87 +307,91 @@ typedef struct map { static MAP *cur, *maplist; +#define DATA(name,value) { { name }, value } + typedef struct speeds { - const char *string; + const char string[7]; int speed; } SPEEDS; static const SPEEDS speeds[] = { - {"0", B0}, - {"50", B50}, - {"75", B75}, - {"110", B110}, - {"134", B134}, - {"134.5", B134}, - {"150", B150}, - {"200", B200}, - {"300", B300}, - {"600", B600}, - {"1200", B1200}, - {"1800", B1800}, - {"2400", B2400}, - {"4800", B4800}, - {"9600", B9600}, + DATA("0", B0), + DATA("50", B50), + DATA("75", B75), + DATA("110", B110), + DATA("134", B134), + DATA("134.5", B134), + DATA("150", B150), + DATA("200", B200), + DATA("300", B300), + DATA("600", B600), + DATA("1200", B1200), + DATA("1800", B1800), + DATA("2400", B2400), + DATA("4800", B4800), + DATA("9600", B9600), /* sgttyb may define up to this point */ #ifdef B19200 - {"19200", B19200}, + DATA("19200", B19200), #endif #ifdef B38400 - {"38400", B38400}, + DATA("38400", B38400), #endif #ifdef B19200 - {"19200", B19200}, + DATA("19200", B19200), #endif #ifdef B38400 - {"38400", B38400}, + DATA("38400", B38400), #endif #ifdef B19200 - {"19200", B19200}, + DATA("19200", B19200), #else #ifdef EXTA - {"19200", EXTA}, + DATA("19200", EXTA), #endif #endif #ifdef B38400 - {"38400", B38400}, + DATA("38400", B38400), #else #ifdef EXTB - {"38400", EXTB}, + DATA("38400", EXTB), #endif #endif #ifdef B57600 - {"57600", B57600}, + DATA("57600", B57600), #endif #ifdef B115200 - {"115200", B115200}, + DATA("115200", B115200), #endif #ifdef B230400 - {"230400", B230400}, + DATA("230400", B230400), #endif #ifdef B460800 - {"460800", B460800}, + DATA("460800", B460800), #endif - {(char *) 0, 0} }; +#undef DATA static int tbaudrate(char *rate) { - const SPEEDS *sp; + const SPEEDS *sp = 0; int found = FALSE; + size_t n; /* The baudrate number can be preceded by a 'B', which is ignored. */ if (*rate == 'B') ++rate; - for (sp = speeds; sp->string; ++sp) { - if (!CaselessCmp(rate, sp->string)) { + for (n = 0; n < SIZEOF(speeds); ++n) { + if (!CaselessCmp(rate, speeds[n].string)) { found = TRUE; + sp = speeds + n; break; } } - if (!found) + if (sp == 0) err("unknown baud rate %s", rate); return (sp->speed); } @@ -1167,26 +1171,26 @@ obsolete(char **argv) static void usage(void) { - static const char *tbl[] = +#define DATA(s) s "\n" + static const char msg[] = { - "" - ,"Options:" - ," -c set control characters" - ," -e ch erase character" - ," -I no initialization strings" - ," -i ch interrupt character" - ," -k ch kill character" - ," -m mapping map identifier to type" - ," -Q do not output control key settings" - ," -r display term on stderr" - ," -s output TERM set command" - ," -V print curses-version" - ," -w set window-size" + DATA("") + DATA("Options:") + DATA(" -c set control characters") + DATA(" -e ch erase character") + DATA(" -I no initialization strings") + DATA(" -i ch interrupt character") + DATA(" -k ch kill character") + DATA(" -m mapping map identifier to type") + DATA(" -Q do not output control key settings") + DATA(" -r display term on stderr") + DATA(" -s output TERM set command") + DATA(" -V print curses-version") + DATA(" -w set window-size") }; - unsigned n; +#undef DATA (void) fprintf(stderr, "Usage: %s [options] [terminal]\n", _nc_progname); - for (n = 0; n < sizeof(tbl) / sizeof(tbl[0]); ++n) - fprintf(stderr, "%s\n", tbl[n]); + fputs(msg, stderr); exit_error(); /* NOTREACHED */ } -- 2.44.0