X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=progs%2Ftput.c;h=022d4940c2a1cbe02bae8433ef2aa2b01b16c2de;hp=70b762f7eb3f6c22e6bcc71c5b29fd73120327de;hb=d8b5e3f8187d68e90f8146e866470fcff148073d;hpb=a8987e73ec254703634802b4f7ee30d3a485524d diff --git a/progs/tput.c b/progs/tput.c index 70b762f7..022d4940 100644 --- a/progs/tput.c +++ b/progs/tput.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 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 * @@ -38,14 +38,16 @@ * Ross Ridge's mytinfo package. */ +#define USE_LIBTINFO #include #if !PURE_TERMINFO +#include #include #endif #include -MODULE_ID("$Id: tput.c,v 1.34 2004/01/16 23:23:11 Daniel.Jacobowitz Exp $") +MODULE_ID("$Id: tput.c,v 1.42 2008/07/13 11:05:12 tom Exp $") #define PUTS(s) fputs(s, stdout) #define PUTCHAR(c) putchar(c) @@ -151,7 +153,6 @@ tput(int argc, char *argv[]) int i, j, c; int status; FILE *f; - int token = UNDEF; if ((name = argv[0]) == 0) name = ""; @@ -178,14 +179,14 @@ tput(int argc, char *argv[]) #ifdef set_lr_margin if (set_lr_margin != 0) { - PUTS(tparm(set_lr_margin, 0, columns - 1)); + PUTS(TPARM_2(set_lr_margin, 0, columns - 1)); } else #endif #ifdef set_left_margin_parm if (set_left_margin_parm != 0 && set_right_margin_parm != 0) { - PUTS(tparm(set_left_margin_parm, 0)); - PUTS(tparm(set_right_margin_parm, columns - 1)); + PUTS(TPARM_1(set_left_margin_parm, 0)); + PUTS(TPARM_1(set_right_margin_parm, columns - 1)); } else #endif if (clear_margins != 0 @@ -199,7 +200,7 @@ tput(int argc, char *argv[]) } PUTS(set_left_margin); if (parm_right_cursor) { - PUTS(tparm(parm_right_cursor, columns - 1)); + PUTS(TPARM_1(parm_right_cursor, columns - 1)); } else { for (i = 0; i < columns - 1; i++) { PUTCHAR(' '); @@ -218,7 +219,7 @@ tput(int argc, char *argv[]) if (clear_all_tabs != 0 && set_tab != 0) { for (i = 0; i < columns - 1; i += 8) { if (parm_right_cursor) { - PUTS(tparm(parm_right_cursor, 8)); + PUTS(TPARM_1(parm_right_cursor, 8)); } else { for (j = 0; j < 8; j++) PUTCHAR(' '); @@ -252,8 +253,8 @@ tput(int argc, char *argv[]) if (is_reset && reset_3string != 0) { PUTS(reset_3string); - } else if (init_2string != 0) { - PUTS(init_2string); + } else if (init_3string != 0) { + PUTS(init_3string); } FLUSH; return 0; @@ -295,7 +296,6 @@ tput(int argc, char *argv[]) } else if ((s = tigetstr(name)) == CANCELLED_STRING) { quit(4, "unknown terminfo capability '%s'", name); } else if (s != ABSENT_STRING) { - token = STRING; if (argc > 1) { int k; int popcount; @@ -322,24 +322,25 @@ tput(int argc, char *argv[]) switch (tparm_type(name)) { case Num_Str: - s = tparm(s, numbers[1], strings[2]); + s = TPARM_2(s, numbers[1], strings[2]); break; case Num_Str_Str: - s = tparm(s, numbers[1], strings[2], strings[3]); + s = TPARM_3(s, numbers[1], strings[2], strings[3]); break; + case Numbers: default: (void) _nc_tparm_analyze(s, p_is_s, &popcount); #define myParam(n) (p_is_s[n - 1] != 0 ? ((long) strings[n]) : numbers[n]) - s = tparm(s, - myParam(1), - myParam(2), - myParam(3), - myParam(4), - myParam(5), - myParam(6), - myParam(7), - myParam(8), - myParam(9)); + s = TPARM_9(s, + myParam(1), + myParam(2), + myParam(3), + myParam(4), + myParam(5), + myParam(6), + myParam(7), + myParam(8), + myParam(9)); break; } } @@ -360,13 +361,12 @@ main(int argc, char **argv) int c; char buf[BUFSIZ]; int result = 0; - int err; check_aliases(prg_name = _nc_rootname(argv[0])); term = getenv("TERM"); - while ((c = getopt(argc, argv, "ST:V")) != EOF) { + while ((c = getopt(argc, argv, "ST:V")) != -1) { switch (c) { case 'S': cmdline = FALSE; @@ -377,7 +377,7 @@ main(int argc, char **argv) break; case 'V': puts(curses_version()); - return EXIT_SUCCESS; + ExitProgram(EXIT_SUCCESS); default: usage(); /* NOTREACHED */ @@ -407,7 +407,7 @@ main(int argc, char **argv) if (cmdline) { if ((argc <= 0) && !is_reset && !is_init) usage(); - return tput(argc, argv); + ExitProgram(tput(argc, argv)); } while (fgets(buf, sizeof(buf), stdin) != 0) { @@ -428,12 +428,12 @@ main(int argc, char **argv) argvec[argnum] = 0; if (argnum != 0 - && (err = tput(argnum, argvec)) != 0) { + && tput(argnum, argvec) != 0) { if (result == 0) result = 4; /* will return value >4 */ ++result; } } - return result; + ExitProgram(result); }