X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=progs%2Ftic.c;h=e559d1b35c283d61c3b6c0010764b4b13caf987a;hp=4b3a4c843203ee69f395659a7d10c7de6f51ad65;hb=646aa4040ea415c39a376991d2d9658eff0fce77;hpb=4b1d778499db088254fdf97fa7dc271c82c36622 diff --git a/progs/tic.c b/progs/tic.c index 4b3a4c84..e559d1b3 100644 --- a/progs/tic.c +++ b/progs/tic.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2014,2015 Free Software Foundation, Inc. * + * Copyright (c) 1998-2015,2016 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.220 2015/12/27 01:46:01 tom Exp $") +MODULE_ID("$Id: tic.c,v 1.224 2016/10/01 12:46:54 tom Exp $") #define STDIN_NAME "" @@ -170,6 +170,7 @@ usage(void) #endif DATA(" -U suppress post-processing of entries") DATA(" -V print version") + DATA(" -W wrap long strings according to -w[n] option") DATA(" -v[n] set verbosity level") DATA(" -w[n] set format width for translation output") #if NCURSES_XNAMES @@ -700,6 +701,7 @@ main(int argc, char *argv[]) bool suppress_untranslatable = FALSE; int quickdump = 0; bool quiet = FALSE; + bool wrap_strings = FALSE; log_fp = stderr; @@ -725,7 +727,7 @@ main(int argc, char *argv[]) * be optional. */ while ((this_opt = getopt(argc, argv, - "0123456789CDIKLNQR:TUVace:fGgo:qrstvwx")) != -1) { + "0123456789CDIKLNQR:TUVWace:fGgo:qrstvwx")) != -1) { if (isdigit(this_opt)) { switch (last_opt) { case 'Q': @@ -801,6 +803,9 @@ main(int argc, char *argv[]) case 'V': puts(curses_version()); ExitProgram(EXIT_SUCCESS); + case 'W': + wrap_strings = TRUE; + break; case 'c': check_only = TRUE; break; @@ -929,15 +934,18 @@ main(int argc, char *argv[]) if (infodump || check_only) { dump_init(tversion, - smart_defaults - ? outform - : F_LITERAL, - sortmode, width, height, debug_level, formatted || - check_only, check_only, quickdump); + (smart_defaults + ? outform + : F_LITERAL), + sortmode, + wrap_strings, width, height, + debug_level, formatted || check_only, check_only, quickdump); } else if (capdump) { dump_init(tversion, outform, - sortmode, width, height, debug_level, FALSE, FALSE, FALSE); + sortmode, + wrap_strings, width, height, + debug_level, FALSE, FALSE, FALSE); } /* parse entries out of the source file */ @@ -1776,7 +1784,9 @@ check_1_infotocap(const char *name, NCURSES_CONST char *value, int count) *next++ = '\0'; for (k = 1; k <= NUM_PARM; k++) { numbers[k] = count; - sprintf(next, "XYZ%d", count); + _nc_SPRINTF(next, + _nc_SLIMIT(sizeof(blob) - (next - blob)) + "XYZ%d", count); strings[k] = next; next += strlen(next) + 1; } @@ -2274,7 +2284,7 @@ check_conflict(TERMTYPE *tp) static void check_exit_attribute(const char *name, char *test, char *trimmed, char *untrimmed) { - if (VALID_STRING(test)) { + if (VALID_STRING(test) && (trimmed != 0)) { if (similar_sgr(-1, trimmed, test) || similar_sgr(-1, untrimmed, test)) { _nc_warning("%s matches exit_attribute_mode", name); @@ -2327,13 +2337,23 @@ check_sgr_param(TERMTYPE *tp, int code, const char *name, char *value) if (is_sgr_string(test)) { int param = 0; int count = 0; + int skips = 0; + int color = (value == set_a_foreground || + value == set_a_background || + value == set_foreground || + value == set_background); while (*test != 0) { if (isdigit(UChar(*test))) { param = 10 * param + (*test - '0'); ++count; } else { if (count) { - if (param == code) + /* + * Avoid unnecessary warning for xterm 256color codes. + */ + if (color && (param == 38 || param == 48)) + skips = 3; + if ((skips-- <= 0) && (param == code)) break; } count = 0;