Module Name: src Committed By: riz Date: Thu Mar 14 15:48:29 UTC 2013
Modified Files: src/lib/libterminfo [netbsd-6]: Makefile.hash genman term.h term_private.h terminfo.3 terminfo.5.in tparm.c src/usr.bin/tput [netbsd-6]: Makefile tput.c Log Message: Pull up following revision(s) (requested by roy in ticket #835): lib/libterminfo/terminfo.3: revision 1.9 lib/libterminfo/term.h: revision 1.13 lib/libterminfo/term.h: revision 1.14 usr.bin/tput/Makefile: revision 1.11 lib/libterminfo/terminfo.3: revision 1.10 lib/libterminfo/genman: revision 1.5 lib/libterminfo/term_private.h: revision 1.11 usr.bin/tput/tput.c: revision 1.23 usr.bin/tput/tput.c: revision 1.24 usr.bin/tput/tput.c: revision 1.25 lib/libterminfo/tparm.c: revision 1.11 lib/libterminfo/Makefile.hash: revision 1.7 usr.bin/tput/tput.c: revision 1.26 lib/libterminfo/tparm.c: revision 1.12 lib/libterminfo/tparm.c: revision 1.13 lib/libterminfo/tparm.c: revision 1.14 lib/libterminfo/terminfo.5.in: revision 1.18 As tparm accepts longs we should treat them as long during expansion. Also, fix the ~ and ! logic. Move the strings vs long analysis to a private function, but allow tput(1) to use it so we can work with string parameters to capabilities. Fix building our terminals with a non standard NETBSDSRCDIR, PR lib/46793. Thanks to Bernd Ernesti. Remove debug accidently commited. If char * > long then print a suitable error when passing a string parameter. For platforms where we cannot fit a char * into a long, return NULL and set errno to ENOTSUPP. Add descriptions for terminfo keys to term.h These are extracted by genman and placed into the compiled terminfo.5 Fixes PR lib/47090 Provide a disabled implentation of tlparm and ti_tlparm for completeness. This also improves the readability of _ti_tiparm. Use putp(3) to output our strings. Fixes PR lib/47532 To generate a diff of this commit: cvs rdiff -u -r1.4.4.1 -r1.4.4.2 src/lib/libterminfo/Makefile.hash cvs rdiff -u -r1.4 -r1.4.8.1 src/lib/libterminfo/genman cvs rdiff -u -r1.10.4.2 -r1.10.4.3 src/lib/libterminfo/term.h cvs rdiff -u -r1.9.4.1 -r1.9.4.2 src/lib/libterminfo/term_private.h cvs rdiff -u -r1.8 -r1.8.4.1 src/lib/libterminfo/terminfo.3 cvs rdiff -u -r1.15.6.1 -r1.15.6.2 src/lib/libterminfo/terminfo.5.in cvs rdiff -u -r1.7.4.2 -r1.7.4.3 src/lib/libterminfo/tparm.c cvs rdiff -u -r1.10 -r1.10.8.1 src/usr.bin/tput/Makefile cvs rdiff -u -r1.22 -r1.22.4.1 src/usr.bin/tput/tput.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libterminfo/Makefile.hash diff -u src/lib/libterminfo/Makefile.hash:1.4.4.1 src/lib/libterminfo/Makefile.hash:1.4.4.2 --- src/lib/libterminfo/Makefile.hash:1.4.4.1 Sat Jun 23 22:54:57 2012 +++ src/lib/libterminfo/Makefile.hash Thu Mar 14 15:48:29 2013 @@ -1,6 +1,7 @@ -# $NetBSD: Makefile.hash,v 1.4.4.1 2012/06/23 22:54:57 riz Exp $ +# $NetBSD: Makefile.hash,v 1.4.4.2 2013/03/14 15:48:29 riz Exp $ SCRIPT_ENV= \ + NETBSDSRCDIR=${NETBSDSRCDIR:Q} \ TOOL_AWK=${TOOL_AWK:Q} \ TOOL_NBPERF=${TOOL_NBPERF:Q} \ TOOL_SED=${TOOL_SED:Q} \ Index: src/lib/libterminfo/genman diff -u src/lib/libterminfo/genman:1.4 src/lib/libterminfo/genman:1.4.8.1 --- src/lib/libterminfo/genman:1.4 Tue Oct 12 12:57:51 2010 +++ src/lib/libterminfo/genman Thu Mar 14 15:48:29 2013 @@ -1,7 +1,7 @@ #!/bin/sh -# $NetBSD: genman,v 1.4 2010/10/12 12:57:51 christos Exp $ +# $NetBSD: genman,v 1.4.8.1 2013/03/14 15:48:29 riz Exp $ -# Copyright (c) 2009 The NetBSD Foundation, Inc. +# Copyright (c) 2009, 2013 The NetBSD Foundation, Inc. # # This code is derived from software contributed to The NetBSD Foundation # by Roy Marples. @@ -47,7 +47,8 @@ gentab() $ti | $TOOL_SORT | while read name code foo; do cap=$($TOOL_SED -ne "s/.*{ \"\(..\)\", TICODE_$code }.*/\1/p" \ $tc | head -n 1) - echo ".It Li \"$name\" Ta Sy \"\\&$code\" Ta Sy \"\\&$cap\"" + desc=$($TOOL_SED -ne "s/ \* $name\: \(.*\)/\1/p" $ti) + echo ".It \"\\&$name\" Ta Sy \"\\&$code\" Ta Sy \"\\&$cap\" Ta \"\\&$desc\"" done } Index: src/lib/libterminfo/term.h diff -u src/lib/libterminfo/term.h:1.10.4.2 src/lib/libterminfo/term.h:1.10.4.3 --- src/lib/libterminfo/term.h:1.10.4.2 Mon Jun 11 17:48:37 2012 +++ src/lib/libterminfo/term.h Thu Mar 14 15:48:28 2013 @@ -1,7 +1,7 @@ -/* $NetBSD: term.h,v 1.10.4.2 2012/06/11 17:48:37 riz Exp $ */ +/* $NetBSD: term.h,v 1.10.4.3 2013/03/14 15:48:28 riz Exp $ */ /* - * Copyright (c) 2009, 2010, 2011 The NetBSD Foundation, Inc. + * Copyright (c) 2009, 2010, 2011, 2013 The NetBSD Foundation, Inc. * * This code is derived from software contributed to The NetBSD Foundation * by Roy Marples. @@ -153,6 +153,48 @@ enum TIFLAGS { #define transparent_underline t_transparent_underline(cur_term) #define xon_xoff t_xon_xoff(cur_term) +/* + * BOOLEAN DESCRIPTIONS + * + * auto_left_margin: cub1 wraps from column 0 to last column + * auto_right_margin: Terminal has automatic margins + * back_color_erase: Screen erased with background colour + * can_change: Terminal can re-define existing colour + * ceol_standout_glitch: Standout not erased by overwriting (hp) + * col_addr_glitch: Only positive motion for hpa/mhba caps + * cpi_changes_res: Changing character pitch changes resolution + * cr_cancels_micro_mode: Using cr turns off micro mode + * dest_tabs_magic_smso: Destructive tabs, magic smso char (t1061) + * eat_newline_glitch: Newline ignored after 80 columns (Concept) + * erase_overstrike: Can erase overstrikes with a blank line + * generic_type: Generic line type (e.g. dialup, switch) + * hard_copy: Hardcopy terminal + * hard_cursor: Cursor is hard to see + * has_meta_key: Has a meta key (shift, sets parity bit) + * has_print_wheel: Printer needs operator to change character set + * has_status_line: Has extra "status line" + * hue_light_saturation: Terminal only uses HLS colour notion (Tektronix) + * insert_null_glitch: Insert mode distinguishes nulls + * lpi_changes_yes: Changing line pitch changes resolution + * memory_above: Display may be retained above the screen + * memory_below: Display may be retained below the screen + * move_insert_mode: Safe to move while in insert mode + * move_standout_mode: Safe to move in standout modes + * needs_xon_xoff: Padding won't work, xon/xoff required + * no_esc_ctlc: Beehive (f1=escape, f2=ctrl C) + * no_pad_char: Pad character doesn't exist + * non_dest_scroll_region: Scrolling region is nondestructive + * non_rev_rmcup: smcup does not reverse rmcup + * over_strike: Terminal overstrikes on hard-copy terminal + * prtr_silent: Printer won't echo on screen + * row_addr_glitch: Only positive motion for vpa/mvpa caps + * semi_auto_right_margin: Printing in last column causes cr + * status_line_esc_ok: Escape can be used on the status line + * tilde_glitch: Hazeltine; can't print tilde (~) + * transparent_underline: Underline character overstrikes + * xon_xoff: Terminal uses xon/xoff handshaking +*/ + /* Define available terminfo numbers */ enum TINUMS { TICODE_bitwin, @@ -259,6 +301,44 @@ enum TINUMS { #define wide_char_size t_wide_char_size(cur_term) #define width_status_line t_width_status_line(cur_term) +/* + * NUMBER DESCRIPTIONS + * + * bit_image_entwining: Number of passes for each bit-map row + * bit_image_type: Type of bit image device + * buffer_capacity: Number of bytes buffered before printing + * buttons: Number of buttons on the mouse + * columns: Number of columns in a line + * dot_horz_spacing: Spacing of dots horizontally in dots per inch + * dot_vert_spacing: Spacing of pins vertically in pins per inch + * init_tabs: Tabs initially every #1 spaces + * label_height: Number of rows in each label + * label_width: Numbre of columns in each label + * lines: Number of lines on a screen or a page + * lines_of_memory: Lines of memory of > lines; 0 means varies + * max_attributes: Maximum combined video attributes terminal can display + * magic_cookie_glitch: Number of blank characters left by smso or rmso + * max_colors: Maximum number of colours on the screen + * max_micro_address: Maximum value in micro_..._addresss + * max_micro_jump: Maximum value in parm_..._micro + * max_pairs: Maximum number of colour-pairs on the screen + * maximum_windows: Maximum number of definable windows + * micro_col_size: Character step size when in micro mode + * micro_line_size: Line step size when in micro mode + * no_color_video: Video attributes that can't be used with colours + * num_labels: Number of labels on screen (start at 1) + * number_of_pins: Number of pins in print-head + * output_res_char: Horizontal resolution in units per character + * output_res_line: Vertical resolution in units per line + * output_res_horz_inch: Horizontal resolution in units per inch + * output_res_vert_inch: Vertical resolution in units per inch + * padding_baud_rate: Lowest baud rate where padding needed + * print_rate: Print rate in characters per second + * virtual_terminal: Virtual terminal number + * wide_char_size: Character step size when in double-wide mode + * width_status_line: Number of columns in status line + */ + /* Define available terminfo strings */ enum TISTRS{ TICODE_acsc, @@ -1448,6 +1528,405 @@ enum TISTRS{ #define xon_character t_xon_character(cur_term) #define zero_motion t_zero_motion(cur_term) +/* + * STRING DESCRIPTIONS + * + * acs_chars: Graphic charset pairs aAbBcC + * alt_scancode_esc: Alternate escape for scancode emulation + * back_tab: Back tab + * bell: Audible signal (bell) + * bit_image_carriage_return: Move to beginning of same row + * bit_image_newline: Move to next row of the bit image + * bit_image_repeat: Repeat bit-image cell #1 #2 times + * carriage_return: Carriage return + * change_char_pitch: Change number of characters per inch + * change_line_pitch: Change number of lines per inch + * change_res_horz: Change horizontal resolution + * change_res_vert: Change vertical resolution + * change_scroll_region: Change to lines #1 through #2 (VT100) + * char_padding: Like ip but when in replace mode + * char_set_names: Returns a list of character set names + * clear_all_tabs: Clear all tab stops + * clear_margins: Clear all margins (top, bottom and sides) + * clear_screen: Clear screen and home cursor + * clr_bol: Clear to beginning of line, inclusive + * clr_eol: Clear to end of line + * clr_eos: Clear to end of display + * code_set_init: Init sequence for multiple codesets + * color_names: Give name for colour #1 + * column_address: Set horizontal position to absolute #1 + * command_character: Terminal settable cmd character in prototype + * create_window: Define win #1 to go from #2,#3 to #4,#5 + * cursor_address: Move to row #1, col #2 + * cursor_down: Down one line + * cursor_home: Home cursor (if no cup) + * cursor_invisible: Make cursor invisible + * cursor_left: Move left one space + * cursor_mem_address: Memory relative cursor addressing + * cursor_normal: Make cursor appear normal (under vs/vi) + * cursor_right: Non-destructive space (cursor or carriage right) + * cursor_to_ll: Last line, first column (if no cup) + * cursor_up: Upline (cursor up) + * cursor_visible: Make cursor very visible + * define_bit_image_region: Define rectangular bit-image region + * define_char: Define a character in a character set + * delete_character: Delete character + * delete_line: Delete line + * device_type: Indicate language/codeset support + * dial_phone: Dial phone number #1 + * dis_status_line: Disable status line + * display_clock: Display time-of-day clock + * display_pc_char: Display PC character + * down_half_time: Half-line down (forward 1/2 linefeed) + * ena_acs: Enable alternate character set + * end_bit_image_region: End a bit-image region + * enter_alt_charset_mode: Start alternate character set + * enter_am_mode: Turn on automatic margins + * enter_blink_mode: Turn on blinking + * enter_bold_mode: Turn on bold (extra bright) mode + * enter_ca_mode: String to begin programs that use cup + * enter_delete_mode: Delete mode (enter) + * enter_dim_mode: Turn on half-bright mode + * enter_doublewide_mode: Enable double wide printing + * enter_draft_quality: Set draft qualify print + * enter_horizontal_hl_mode: Turn on horizontal highlight mode + * enter_insert_mode: Insert mode (enter) + * enter_italics_mode: Enable italics + * enter_left_hl_mode: Turn on left highlight mode + * enter_leftward_mode: Enable leftward carriage motion + * enter_low_hl_mode: Turn on low highlight mode + * enter_micro_mode: Enable micro motion capabilities + * enter_near_quality_letter: Set near-letter quality print + * enter_normal_quality: Set normal quality print + * enter_pc_charset_mode: Enter PC character display mode + * enter_protected_mode: Turn on protected mode + * enter_reverse_mode: Turn on reverse video mode + * enter_right_hl_mode: Turn on right highlight mode + * enter_scancode_mode: Enter PC scancode mode + * enter_secure_mode: Turn on blank mode (characters invisible) + * enter_shadow_mode: Enable shadow printing + * enter_standout_mode: Begin standout mode + * enter_subscript_mode: Enable subscript printing + * enter_superscript_mode: Enable superscript printing + * enter_top_hl_mode: Turn on top highlight mode + * enter_underline_mode: Start underscore mode + * enter_upward_mode: Enable upward carriage motion + * enter_vertical_hl_mode: Turn on verticle highlight mode + * enter_xon_mode: Turn on xon/xoff handshaking + * erase_chars: Erase #1 characters + * exit_alt_charset_mode: End alternate character set + * exit_am_mode: Turn off automatic margins + * exit_attribute_mode: Turn off all attributes + * exit_ca_mode: String to end programs that use cup + * exit_delete_mode: End delete mode + * exit_doublewide_mode: Disable double wide printing + * exit_insert_mode: End insert mode + * exit_italics_mode: Disable italics + * exit_leftward_mode: Enable rightward (normal) carriage motion + * exit_micro_mode: Disable micro motion capabilities + * exit_pc_charset_mode: Disable PC character display mode + * exit_scancode_mode: Disable PC scancode mode + * exit_shadow_mode: Disable shadow printing + * exit_standout_mode: End standout mode + * exit_subscript_mode: Disable subscript printing + * exit_superscript_mode: Disable superscript printing + * exit_underline_mode: End underscore mode + * exit_upward_mode: Enable downward (normal) carriage motion + * exit_xon_mode: Turn off xon/xoff handshaking + * fixed_pause: Pause for 2-3 seconds + * flash_hook: Flash the switch hook + * flash_screen: Visible bell (may move cursor) + * form_feed: Hardcopy terminal eject page + * from_status_line: Return from status line + * get_mouse: Curses should get button events + * goto_window: Go to window #1 + * hangup: Hang-up phone + * init_1string: Terminal or printer initialisation string + * init_2string: Terminal or printer initialisation string + * init_3string: Terminal or printer initialisation string + * init_file: Name of initialisation file + * init_prog: Path name of program for initialisation + * initialize_color: Set colour #1 to RGB #2, #3, #4 + * initialize_pair: Set colour-pair #1 to fg #2, bg #3 + * insert_character: Insert character + * insert_line: Add new blank line + * insert_padding: Insert pad after character inserted + * key_a1: upper left of keypad + * key_a3: upper right of keypad + * key_b2: center of keypad + * key_backspace: set by backspace key + * key_beg: 1 + * key_btab: sent by back-tab key + * key_c1: lower left of keypad + * key_c3: lower right of keypad + * key_cancel: 2 + * key_catab: sent by clear-all-tabs key + * key_clear: sent by clear-screen or erase key + * key_close: 3 + * key_command: 4 + * key_copy: 5 + * key_create: 6 + * key_ctab: sent by clear-tab key + * key_dc: sent by delete-character key + * key_dl: sent by delete-line key + * key_down: sent by terminal down-arrow key + * key_eic: sent by rmir or smir in insert mode + * key_end: 7 + * key_enter: 8 + * key_eol: sent by clear-to-end-of-line key + * key_eos: sent by clear-to-end-of-screen key + * key_exit: 9 + * key_f0: sent by function key f0 + * key_f1: sent by function key f1 + * key_f2: sent by function key f2 + * key_f3: sent by function key f3 + * key_f4: sent by function key f4 + * key_f5: sent by function key f5 + * key_f6: sent by function key f6 + * key_f7: sent by function key f7 + * key_f8: sent by function key f8 + * key_f9: sent by function key f9 + * key_f10: sent by function key f10 + * key_f11: sent by function key f11 + * key_f12: sent by function key f12 + * key_f13: sent by function key f13 + * key_f14: sent by function key f14 + * key_f15: sent by function key f15 + * key_f16: sent by function key f16 + * key_f17: sent by function key f17 + * key_f18: sent by function key f18 + * key_f19: sent by function key f19 + * key_f20: sent by function key f20 + * key_f21: sent by function key f21 + * key_f22: sent by function key f22 + * key_f23: sent by function key f23 + * key_f24: sent by function key f24 + * key_f25: sent by function key f25 + * key_f26: sent by function key f26 + * key_f27: sent by function key f27 + * key_f28: sent by function key f28 + * key_f29: sent by function key f29 + * key_f30: sent by function key f30 + * key_f31: sent by function key f31 + * key_f32: sent by function key f32 + * key_f33: sent by function key f33 + * key_f34: sent by function key f34 + * key_f35: sent by function key f35 + * key_f36: sent by function key f36 + * key_f37: sent by function key f37 + * key_f38: sent by function key f38 + * key_f39: sent by function key f39 + * key_f40: sent by function key f40 + * key_f41: sent by function key f41 + * key_f42: sent by function key f42 + * key_f43: sent by function key f43 + * key_f44: sent by function key f44 + * key_f45: sent by function key f45 + * key_f46: sent by function key f46 + * key_f47: sent by function key f47 + * key_f48: sent by function key f48 + * key_f49: sent by function key f49 + * key_f50: sent by function key f50 + * key_f51: sent by function key f51 + * key_f52: sent by function key f52 + * key_f53: sent by function key f53 + * key_f54: sent by function key f54 + * key_f55: sent by function key f55 + * key_f56: sent by function key f56 + * key_f57: sent by function key f57 + * key_f58: sent by function key f58 + * key_f59: sent by function key f59 + * key_f60: sent by function key f60 + * key_f61: sent by function key f61 + * key_f62: sent by function key f62 + * key_f63: sent by function key f63 + * key_find: 0 + * key_help: sent by help key + * key_home: sent by home key + * key_ic: sent by ins-char/enter ins-mode key + * key_il: sent by insert-line key + * key_left: sent by terminal left-arrow key + * key_ll: sent by home-down key + * key_mark: sent by mark key + * key_message: sent by message key + * key_mouse: 0631, Mouse event has occured + * key_move: sent by move key + * key_next: sent by next-object key + * key_npage: sent by next-page key + * key_open: sent by open key + * key_options: sent by options key + * key_ppage: sent by previous-page key + * key_previous: sent by previous-object key + * key_print: sent by print or copy key + * key_redo: sent by redo key + * key_reference: sent by ref(erence) key + * key_refresh: sent by refresh key + * key_replace: sent by replace key + * key_restart: sent by restart key + * key_resume: sent by resume key + * key_right: sent by terminal right-arrow key + * key_save: sent by save key + * key_sbeg: sent by shifted beginning key + * key_scancel: sent by shifted cancel key + * key_scommand: sent by shifted command key + * key_scopy: sent by shifted copy key + * key_screate: sent by shifted create key + * key_sdc: sent by shifted delete-char key + * key_sdl: sent by shifted delete-line key + * key_select: sent by select key + * key_send: sent by shifted end key + * key_seol: sent by shifted clear-line key + * key_sexit: sent by shited exit key + * key_sf: sent by scroll-forward/down key + * key_sfind: sent by shifted find key + * key_shelp: sent by shifted help key + * key_shome: sent by shifted home key + * key_sic: sent by shifted input key + * key_sleft: sent by shifted left-arrow key + * key_smessage: sent by shifted message key + * key_smove: sent by shifted move key + * key_snext: sent by shifted next key + * key_soptions: sent by shifted options key + * key_sprevious: sent by shifted prev key + * key_sprint: sent by shifted print key + * key_sr: sent by scroll-backwards/up key + * key_sredo: sent by shifted redo key + * key_sreplace: sent by shifted replace key + * key_sright: sent by shifted right-arrow key + * key_srsume: sent by shifted resume key + * key_ssave: sent by shifted save key + * key_ssuspend: sent by shifted suspend key + * key_stab: sent by set-tab key + * key_sundo: sent by shifted undo key + * key_suspend: sent by suspend key + * key_undo: sent by undo key + * key_up: sent by terminal up-arrow key + * keypad_local: Out of "keypad-transmit" mode + * keypad_xmit: Put terminal in "keypad-transmit" mode + * lab_f0: Labels on function key f0 if not f0 + * lab_f1: Labels on function key f1 if not f1 + * lab_f2: Labels on function key f2 if not f2 + * lab_f3: Labels on function key f3 if not f3 + * lab_f4: Labels on function key f4 if not f4 + * lab_f5: Labels on function key f5 if not f5 + * lab_f6: Labels on function key f6 if not f6 + * lab_f7: Labels on function key f7 if not f7 + * lab_f8: Labels on function key f8 if not f8 + * lab_f8: Labels on function key f9 if not f9 + * lab_f10: Labels on function key f10 if not f10 + * label_format: Label format + * label_off: Turn off soft labels + * label_on: Turn on soft labels + * meta_off: Turn off "meta mode" + * meta_on: Turn on "meta mode" (8th bit) + * micro_column_address: Like column_address for micro adjustment + * micro_down: Like cursor_down for micro adjustment + * micro_left: Like cursor_left for micro adjustment + * micro_right: Like cursor_right for micro adjustment + * micro_row_address: Like row_address for micro adjustment + * micro_up: Like cursor_up for micro adjustment + * mouse_info: Mouse status information + * newline: Newline (behaves like cr followed by lf) + * order_of_pins: Matches software bits to print-head pins + * orig_colors: Set all colour(-pair)s to original ones + * orig_pair: Set default colour-pair to the original one + * pad_char: Pad character (rather than NULL) + * parm_dch: Delete #1 chars + * parm_delete_line: Delete #1 lines + * parm_down_cursor: Move down #1 lines + * parm_down_micro: Like parm_down_cursor for micro adjustment + * parm_ich: Insert #1 blank chars + * parm_index: Scroll forward #1 lines + * parm_insert_line: Add #1 new blank lines + * parm_left_cursor: Move cursor left #1 lines + * parm_left_micro: Like parm_left_cursor for micro adjustment + * parm_right_cursor: Move right #1 spaces + * parm_right_micro: Like parm_right_cursor for micro adjustment + * parm_rindex: Scroll backward #1 lines + * parm_up_cursor: Move cursor up #1 lines + * parm_up_micro: Like parm_up_cursor for micro adjustment + * pc_term_options: PC terminal options + * pkey_key: Prog funct key #1 to type string #2 + * pkey_local: Prog funct key #1 to execute string #2 + * pkey_plab: Prog key #1 to xmit string #2 and show string #3 + * pkey_xmit: Prog funct key #1 to xmit string #2 + * pkey_norm: Prog label #1 to show string #3 + * print_screen: Print contents of screen + * ptr_non: Turn off printer for #1 bytes + * ptr_off: Turn off the printer + * ptr_on: Turn on the printer + * pulse: Select pulse dialing + * quick_dial: Dial phone number #1, without progress detection + * remove_clock: Remove time-of-day clock + * repeat_char: Repeat char #1 #2 times + * req_for_input: Send next input char (for ptys) + * req_mouse_pos: Request mouse position report + * reset_1string: Reset terminal completely to sane modes + * reset_2string: Reset terminal completely to sane modes + * reset_3string: Reset terminal completely to sane modes + * reset_file: Name of file containing reset string + * restore_cursor: Restore cursor to position of last sc + * row_address: Set vertical position to absolute #1 + * save_cursor: Save cursor position + * scancode_escape: Escape for scancode emulation + * scroll_forward: Scroll text up + * scroll_reverse: Scroll text down + * select_char_set: Select character set + * set0_des_seq: Shift into codeset 0 (EUC set 0, ASCII) + * set1_des_seq: Shift into codeset 1 + * set2_des_seq: Shift into codeset 2 + * set3_des_seq: Shift into codeset 3 + * set_a_attributes: Define second set of video attributes #1-#6 + * set_a_background: Set background colour to #1 using ANSI escape + * set_a_foreground: Set foreground colour to #1 using ANSI escape + * set_attributes: Define first set of video attributes #1-#9 + * set_background: Set background colour to #1 + * set_bottom_margin: Set bottom margin at current line + * set_bottom_margin_parm: Set bottom margin at line #1 or #2 lines from bottom + * set_clock: Set clock to hours (#1), minutes (#2), seconds (#3) + * set_color_band: Change ribbon to colour #1 + * set_color_pair: Set current colour pair to #1 + * set_foreground: Set foreground colour to #1 + * set_left_margin: Set left margin at current column + * set_left_margin_parm: Set left (right) margin at column #1 (#2) + * set_lr_margin: Sets both left and right margins + * set_page_length: Set page length to #1 lines + * set_pglen_inch: Set page length to #1 hundredth of an inch + * set_right_margin: Set right margin at current column + * set_right_margin_parm: Set right margin at #1 + * set_tab: Set a tab in all rows, current column + * set_tb_margin: Sets both top and bottom margins + * set_top_margin: Set top margin at current line + * set_top_margin_parm: Set top (bottom) margin at line #1 (#2) + * set_window: Current window is lines #1-#2 cols #3-#4 + * start_bit_image: Start printing bit image graphics + * start_char_set_def: Start definition of a character set + * stop_bit_image: End printing bit image graphics + * stop_char_set_def: End definition of a character set + * subscript_characters: List of "subscript-able" characters + * superscript_characters: List of "superscript-able" characters + * tab: Tab to next 8-space hardware tab stop + * these_cause_cr: Printing any of these characters causes cr + * to_status_line: Go to status line, col #1 + * tone: Select tone touch dialing + * user0: User string 0 + * user1: User string 1 + * user2: User string 2 + * user3: User string 3 + * user4: User string 4 + * user5: User string 5 + * user6: User string 6 + * user7: User string 7 + * user8: User string 8 + * user9: User string 9 + * underline_char: Underscore one char and move past it + * up_half_line: Half-line up (reverse 1/2 linefeed) + * wait_tone: Wait for dial tone + * xoff_character: X-off character + * xon_character: X-on character + * zero_motion: No motion for the subsequent character + */ + #ifndef _TERMINFO typedef struct { int fildes; @@ -1495,12 +1974,20 @@ int ti_puts(const TERMINAL *, const cha int (*)(int, void *), void *); int ti_putp(const TERMINAL *, const char *); -/* Using tparm can be kunkly, so provide a variadic function */ +/* Using tparm can be kunkly, so provide a variadic function + * Numbers have to be passed as int */ /* This is not standard, but ncurses also provides this */ char * tiparm(const char *, ...); /* And a thread safe version */ char * ti_tiparm(TERMINAL *, const char *, ...); +#ifdef TPARM_TLPARM +/* Same as the above, but numbers have to be passed as long */ +char * tlparm(const char *, ...); +/* And a thread safe version */ +char * ti_tlparm(TERMINAL *, const char *, ...); +#endif + /* Default to X/Open tparm, but allow it to be variadic also */ #ifdef TPARM_VARARGS # define tparm tiparm Index: src/lib/libterminfo/term_private.h diff -u src/lib/libterminfo/term_private.h:1.9.4.1 src/lib/libterminfo/term_private.h:1.9.4.2 --- src/lib/libterminfo/term_private.h:1.9.4.1 Sat Jun 23 22:54:57 2012 +++ src/lib/libterminfo/term_private.h Thu Mar 14 15:48:29 2013 @@ -1,7 +1,7 @@ -/* $NetBSD: term_private.h,v 1.9.4.1 2012/06/23 22:54:57 riz Exp $ */ +/* $NetBSD: term_private.h,v 1.9.4.2 2013/03/14 15:48:29 riz Exp $ */ /* - * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc. + * Copyright (c) 2009, 2010, 2013 The NetBSD Foundation, Inc. * * This code is derived from software contributed to The NetBSD Foundation * by Roy Marples. @@ -157,4 +157,7 @@ size_t _ti_store_extra(TIC *, int, char TIC *_ti_compile(char *, int); ssize_t _ti_flatten(uint8_t **, const TIC *); void _ti_freetic(TIC *); + +#define TPARM_MAX 9 /* not likely to change */ +int _ti_parm_analyse(const char *, int *, int); #endif Index: src/lib/libterminfo/terminfo.3 diff -u src/lib/libterminfo/terminfo.3:1.8 src/lib/libterminfo/terminfo.3:1.8.4.1 --- src/lib/libterminfo/terminfo.3:1.8 Tue Oct 4 11:01:14 2011 +++ src/lib/libterminfo/terminfo.3 Thu Mar 14 15:48:28 2013 @@ -1,4 +1,4 @@ -.\" $NetBSD: terminfo.3,v 1.8 2011/10/04 11:01:14 roy Exp $ +.\" $NetBSD: terminfo.3,v 1.8.4.1 2013/03/14 15:48:28 riz Exp $ .\" .\" Copyright (c) 2009, 2011 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd October 4, 2011 +.Dd January 25, 2013 .Dt TERMINFO 3 .Os .Sh NAME @@ -187,6 +187,12 @@ a pointer inside a .Vt long can use them. +For platforms which don't support this, +.Dv NULL +is returned and +.Va errno +is set to +.Er ENOTSUPP . The string encoding and parameter application is described in .Xr terminfo 5 . .Pp @@ -213,11 +219,12 @@ always goes to stdout. The .Fn tiparm function allows variadic parameters instead of 9 fixed longs. -Numeric parameters must be integers (int) instead of longs. -String parameters can be used even if the platform cannot fit a +Numeric parameters must be passed as +.Vt int . +String parameters must be passed as .Vt char * -into a -.Vt long . +and works on all platforms, unlike +.Fn tparm . .Pp The .Fn ti_* Index: src/lib/libterminfo/terminfo.5.in diff -u src/lib/libterminfo/terminfo.5.in:1.15.6.1 src/lib/libterminfo/terminfo.5.in:1.15.6.2 --- src/lib/libterminfo/terminfo.5.in:1.15.6.1 Sat Jun 23 22:54:57 2012 +++ src/lib/libterminfo/terminfo.5.in Thu Mar 14 15:48:29 2013 @@ -1,6 +1,6 @@ -.\" $NetBSD: terminfo.5.in,v 1.15.6.1 2012/06/23 22:54:57 riz Exp $ +.\" $NetBSD: terminfo.5.in,v 1.15.6.2 2013/03/14 15:48:29 riz Exp $ .\" -.\" Copyright (c) 2009, 2010, 2011 The NetBSD Foundation, Inc. +.\" Copyright (c) 2009, 2010, 2011, 2013 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" This code is derived from software contributed to The NetBSD Foundation @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd June 6, 2012 +.Dd January 25, 2013 .Dt TERMINFO 5 .Os .Sh NAME @@ -154,18 +154,18 @@ add 1 to parameters 1 and 2. If expr equates to zero then control passes to the optional else part. .El .Ss Boolean Capabilities -.Bl -column "enter_near_quality_letter" "setcolor" "TC" -.It Sy "Long name" Ta Sy "Code" Ta Sy "TC" +.Bl -column "enter_near_quality_letter" "setcolor" "TC" "desc" +.It Sy "Long name" Ta Sy "Code" Ta Sy "TC" Ta Sy "Description" @BOOLCAPS@ .El .Ss Numeric Capabilities -.Bl -column "enter_near_quality_letter" "setcolor" "TC" -.It Sy "Long name" Ta Sy "Code" Ta Sy "TC" +.Bl -column "enter_near_quality_letter" "setcolor" "TC" "Desc" +.It Sy "Long name" Ta Sy "Code" Ta Sy "TC" Ta Sy "Description" @NUMCAPS@ .El .Ss String Capabilities -.Bl -column "enter_near_quality_letter" "setcolor" "TC" -.It Sy "Long name" Ta Sy "Code" Ta Sy "TC" +.Bl -column "enter_near_quality_letter" "setcolor" "TC" "Desc" +.It Sy "Long name" Ta Sy "Code" Ta Sy "TC" Ta Sy "Description" @STRCAPS@ .El .Ss A Sample Entry Index: src/lib/libterminfo/tparm.c diff -u src/lib/libterminfo/tparm.c:1.7.4.2 src/lib/libterminfo/tparm.c:1.7.4.3 --- src/lib/libterminfo/tparm.c:1.7.4.2 Thu Mar 14 15:40:58 2013 +++ src/lib/libterminfo/tparm.c Thu Mar 14 15:48:29 2013 @@ -1,7 +1,7 @@ -/* $NetBSD: tparm.c,v 1.7.4.2 2013/03/14 15:40:58 riz Exp $ */ +/* $NetBSD: tparm.c,v 1.7.4.3 2013/03/14 15:48:29 riz Exp $ */ /* - * Copyright (c) 2009, 2011 The NetBSD Foundation, Inc. + * Copyright (c) 2009, 2011, 2013 The NetBSD Foundation, Inc. * * This code is derived from software contributed to The NetBSD Foundation * by Roy Marples. @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: tparm.c,v 1.7.4.2 2013/03/14 15:40:58 riz Exp $"); +__RCSID("$NetBSD: tparm.c,v 1.7.4.3 2013/03/14 15:48:29 riz Exp $"); #include <assert.h> #include <ctype.h> @@ -40,21 +40,28 @@ __RCSID("$NetBSD: tparm.c,v 1.7.4.2 2013 #include <term_private.h> #include <term.h> +#define LONG_STR_MAX ((CHAR_BIT * sizeof(long)) / 3) +#define BUFINC 128 /* Size to increament the terminal buffer by */ + +#define VA_LONG_LONG 1 +#define VA_CHAR_INT 2 +//#define VA_CHAR_LONG 3 + static TERMINAL *dumbterm; /* For non thread safe functions */ typedef struct { - int nums[20]; + long nums[20]; char *strings[20]; size_t offset; } TPSTACK; typedef struct { - int num; + long num; char *string; } TPVAR; static int -push(int num, char *string, TPSTACK *stack) +push(long num, char *string, TPSTACK *stack) { if (stack->offset >= sizeof(stack->nums)) { errno = E2BIG; @@ -67,7 +74,7 @@ push(int num, char *string, TPSTACK *sta } static int -pop(int *num, char **string, TPSTACK *stack) +pop(long *num, char **string, TPSTACK *stack) { if (stack->offset == 0) { if (num) @@ -114,32 +121,76 @@ ochar(TERMINAL *term, int c) } static size_t -onum(TERMINAL *term, const char *fmt, int num, int len) +onum(TERMINAL *term, const char *fmt, int num, unsigned int len) { size_t l; - /* Assume we never have natural number longer than 64 chars */ - if (len < 64) - len = 64; - if (checkbuf(term, (size_t)len + 1) == NULL) + if (len < LONG_STR_MAX) + len = LONG_STR_MAX; + if (checkbuf(term, len + 2) == NULL) return 0; l = sprintf(term->_buf + term->_bufpos, fmt, num); term->_bufpos += l; return l; } +/* + Make a pass through the string so we can work out + which parameters are ints and which are char *. + Basically we only use char * if %p[1-9] is followed by %l or %s. +*/ +int +_ti_parm_analyse(const char *str, int *piss, int piss_len) +{ + int nparm, lpop; + char c; + + nparm = 0; + lpop = -1; + while ((c = *str++) != '\0') { + if (c != '%') + continue; + c = *str++; + switch (c) { + case 'l': /* FALLTHROUGH */ + case 's': + if (lpop > 0) { + if (lpop <= piss_len) + piss[lpop - 1] = 1; + else if (piss) + errno = E2BIG; + } + break; + case 'p': + c = *str++; + if (c < '1' || c > '9') { + errno = EINVAL; + continue; + } else { + lpop = c - '0'; + if (lpop > nparm) + nparm = lpop; + } + break; + default: + lpop = -1; + } + } + + return nparm; +} + static char * -_ti_tiparm(TERMINAL *term, const char *str, va_list parms) +_ti_tiparm(TERMINAL *term, const char *str, int va_type, va_list parms) { - const char *sp; char c, fmt[64], *fp, *ostr; - int val, val2; - int dnums[26]; /* dynamic variables a-z, not preserved */ + long val, val2; + long dnums[26]; /* dynamic variables a-z, not preserved */ size_t l, max; TPSTACK stack; - TPVAR params[9]; - int done, dot, minus, width, precision, olen; - int piss[9]; /* Parameter IS String - piss ;) */ + TPVAR params[TPARM_MAX]; + unsigned int done, dot, minus, width, precision, olen; + int piss[TPARM_MAX]; /* Parameter IS String - piss ;) */ if (str == NULL) return NULL; @@ -150,7 +201,6 @@ _ti_tiparm(TERMINAL *term, const char *s still work with non thread safe functions (which sadly are still the norm and standard). */ - if (term == NULL) { if (dumbterm == NULL) { dumbterm = malloc(sizeof(*dumbterm)); @@ -164,57 +214,39 @@ _ti_tiparm(TERMINAL *term, const char *s term->_bufpos = 0; /* Ensure we have an initial buffer */ if (term->_buflen == 0) { - term->_buf = malloc(BUFSIZ); + term->_buf = malloc(BUFINC); if (term->_buf == NULL) return NULL; - term->_buflen = BUFSIZ; + term->_buflen = BUFINC; } - /* - Make a first pass through the string so we can work out - which parameters are ints and which are char *. - Basically we only use char * if %p[1-9] is followed by %l or %s. - */ memset(&piss, 0, sizeof(piss)); - max = 0; - sp = str; - while ((c = *sp++) != '\0') { - if (c != '%') - continue; - c = *sp++; - if (c == '\0') - break; - if (c != 'p') - continue; - c = *sp++; - if (c < '1' || c > '9') { - errno = EINVAL; - continue; - } - l = c - '0'; - if (l > max) - max = l; - if (*sp != '%') - continue; - /* Skip formatting */ - sp++; - while (*sp == '.' || *sp == '#' || *sp == ' ' || *sp == ':' || - *sp == '-' || isdigit((unsigned char)*sp)) - sp++; - if (*sp == 'l' || *sp == 's') - piss[l - 1] = 1; - } + max = _ti_parm_analyse(str, piss, TPARM_MAX); /* Put our parameters into variables */ memset(¶ms, 0, sizeof(params)); for (l = 0; l < max; l++) { - if (piss[l] == 0) - params[l].num = va_arg(parms, int); - else - params[l].string = va_arg(parms, char *); + if (piss[l]) { + if (va_type == VA_LONG_LONG) { + /* This only works if char * fits into a long + * on this platform. */ + if (sizeof(char *) <= sizeof(long)/*CONSTCOND*/) + params[l].string = + (char *)va_arg(parms, long); + else { + errno = ENOTSUP; + return NULL; + } + } else + params[l].string = va_arg(parms, char *); + } else { + if (va_type == VA_CHAR_INT) + params[l].num = (long)va_arg(parms, int); + else + params[l].num = va_arg(parms, long); + } } - term->_bufpos = 0; memset(&stack, 0, sizeof(stack)); while ((c = *str++) != '\0') { if (c != '%' || (c = *str++) == '%') { @@ -233,11 +265,15 @@ _ti_tiparm(TERMINAL *term, const char *s while (done == 0 && (size_t)(fp - fmt) < sizeof(fmt)) { switch (c) { case 'c': /* FALLTHROUGH */ + case 's': + *fp++ = c; + done = 1; + break; case 'd': /* FALLTHROUGH */ case 'o': /* FALLTHROUGH */ case 'x': /* FALLTHROUGH */ case 'X': /* FALLTHROUGH */ - case 's': + *fp++ = 'l'; *fp++ = c; done = 1; break; @@ -286,7 +322,7 @@ _ti_tiparm(TERMINAL *term, const char *s width = val; else precision = val; - olen = (width > precision) ? width : precision; + olen = MAX(width, precision); } *fp++ = '\0'; @@ -316,15 +352,19 @@ _ti_tiparm(TERMINAL *term, const char *s l = 0; else l = strlen(ostr); - if (onum(term, "%d", (int)l, 0) == 0) +#ifdef NCURSES_COMPAT_57 + if (onum(term, "%ld", (long)l, 0) == 0) return NULL; +#else + push((long)l, NULL, &stack); +#endif break; case 'd': /* FALLTHROUGH */ case 'o': /* FALLTHROUGH */ case 'x': /* FALLTHROUGH */ case 'X': pop(&val, NULL, &stack); - if (onum(term, fmt, val, olen) == 0) + if (onum(term, fmt, (int)val, olen) == 0) return NULL; break; case 'p': @@ -358,7 +398,7 @@ _ti_tiparm(TERMINAL *term, const char *s params[1].num++; break; case '\'': - if (push((int)(unsigned char)*str++, NULL, &stack)) + if (push((long)(unsigned char)*str++, NULL, &stack)) return NULL; while (*str != '\0' && *str != '\'') str++; @@ -438,7 +478,7 @@ _ti_tiparm(TERMINAL *term, const char *s case '!': case '~': pop(&val, NULL, &stack); - switch (*str) { + switch (c) { case '!': val = !val; break; @@ -511,7 +551,7 @@ ti_tiparm(TERMINAL *term, const char *st _DIAGASSERT(str != NULL); va_start(va, str); - ret = _ti_tiparm(term, str, va); + ret = _ti_tiparm(term, str, VA_CHAR_INT, va); va_end(va); return ret; } @@ -525,18 +565,61 @@ tiparm(const char *str, ...) _DIAGASSERT(str != NULL); va_start(va, str); - ret = _ti_tiparm(NULL, str, va); + ret = _ti_tiparm(NULL, str, VA_CHAR_INT, va); + va_end(va); + return ret; +} + +#ifdef VA_CHAR_LONG +char * +ti_tlparm(TERMINAL *term, const char *str, ...) +{ + va_list va; + char *ret; + + _DIAGASSERT(term != NULL); + _DIAGASSERT(str != NULL); + + va_start(va, str); + ret = _ti_tiparm(term, str, VA_CHAR_LONG, va); + va_end(va); + return ret; +} + +char * +tlparm(const char *str, ...) +{ + va_list va; + char *ret; + + _DIAGASSERT(str != NULL); + + va_start(va, str); + ret = _ti_tiparm(NULL, str, VA_CHAR_LONG, va); + va_end(va); + return ret; +} +#endif + +static char * +_tparm(const char *str, ...) +{ + va_list va; + char *ret; + + _DIAGASSERT(str != NULL); + + va_start(va, str); + ret = _ti_tiparm(NULL, str, VA_LONG_LONG, va); va_end(va); return ret; } char * tparm(const char *str, - long lp1, long lp2, long lp3, long lp4, long lp5, - long lp6, long lp7, long lp8, long lp9) + long p1, long p2, long p3, long p4, long p5, + long p6, long p7, long p8, long p9) { - int p1 = lp1, p2 = lp2, p3 = lp3, p4 = lp4, p5 = lp5; - int p6 = lp6, p7 = lp7, p8 = lp8, p9 = lp9; - return tiparm(str, p1, p2, p3, p4, p5, p6, p7, p8, p9); + return _tparm(str, p1, p2, p3, p4, p5, p6, p7, p8, p9); } Index: src/usr.bin/tput/Makefile diff -u src/usr.bin/tput/Makefile:1.10 src/usr.bin/tput/Makefile:1.10.8.1 --- src/usr.bin/tput/Makefile:1.10 Wed Feb 3 15:34:46 2010 +++ src/usr.bin/tput/Makefile Thu Mar 14 15:48:29 2013 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.10 2010/02/03 15:34:46 roy Exp $ +# $NetBSD: Makefile,v 1.10.8.1 2013/03/14 15:48:29 riz Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 PROG= tput @@ -7,4 +7,6 @@ LDADD= -lterminfo MLINKS= tput.1 clear.1 SCRIPTS=clear.sh +CPPFLAGS+= -I${.CURDIR}/../../lib/libterminfo + .include <bsd.prog.mk> Index: src/usr.bin/tput/tput.c diff -u src/usr.bin/tput/tput.c:1.22 src/usr.bin/tput/tput.c:1.22.4.1 --- src/usr.bin/tput/tput.c:1.22 Tue Oct 4 12:23:14 2011 +++ src/usr.bin/tput/tput.c Thu Mar 14 15:48:29 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: tput.c,v 1.22 2011/10/04 12:23:14 roy Exp $ */ +/* $NetBSD: tput.c,v 1.22.4.1 2013/03/14 15:48:29 riz Exp $ */ /*- * Copyright (c) 1980, 1988, 1993 @@ -39,20 +39,21 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)tput.c 8.3 (Berkeley) 4/28/95"; #endif -__RCSID("$NetBSD: tput.c,v 1.22 2011/10/04 12:23:14 roy Exp $"); +__RCSID("$NetBSD: tput.c,v 1.22.4.1 2013/03/14 15:48:29 riz Exp $"); #endif /* not lint */ #include <termios.h> #include <err.h> +#include <errno.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <term_private.h> #include <term.h> -#include <termcap.h> #include <unistd.h> -static int outc(int); static void usage(void) __dead; static char **process(const char *, const char *, char **); @@ -91,7 +92,7 @@ main(int argc, char **argv) if (!strcmp(p, "init")) { s = tigetstr("is1"); if (s != NULL) - tputs(s, 0, outc); + putp(s); p = "is2"; } break; @@ -105,7 +106,7 @@ main(int argc, char **argv) if (!strcmp(p, "reset")) { s = tigetstr("rs1"); if (s != NULL) - tputs(s, 0, outc); + putp(s); p = "rs2"; } break; @@ -140,93 +141,50 @@ process(const char *cap, const char *str static const char errfew[] = "Not enough arguments (%d) for capability `%s'"; static const char erresc[] = - "Unknown %% escape `%c' for capability `%s'"; - char c, l; - const char *p; - int arg_need, p1, p2, p3, p4, p5, p6, p7, p8, p9; + "Unknown %% escape (%s) for capability `%s'"; + static const char errnum[] = + "Expected a numeric argument [%d] (%s) for capability `%s'"; + static const char errcharlong[] = + "Platform does not fit a string into a long for capability '%s'"; + int i, nparams, piss[TPARM_MAX]; + long nums[TPARM_MAX]; + char *strs[TPARM_MAX], *tmp; /* Count how many values we need for this capability. */ - arg_need = 0; - p = str; - while ((c = *p++) != '\0') { - if (c != '%') - continue; - c = *p++; - if (c == '\0') - break; - if (c != 'p') - continue; - c = *p++; - if (c < '1' || c > '9') - errx(2, erresc, c, cap); - l = c - '0'; - if (l > arg_need) - arg_need = l; - } - -#define NEXT_ARG \ - { \ - if (*++argv == NULL || *argv[0] == '\0') \ - errx(2, errfew, 1, cap); \ + errno = 0; + memset(&piss, 0, sizeof(piss)); + nparams = _ti_parm_analyse(str, piss, TPARM_MAX); + if (errno == EINVAL) + errx(2, erresc, str, cap); + + /* Create our arrays of integers and strings */ + for (i = 0; i < nparams; i++) { + if (*++argv == NULL || *argv[0] == '\0') + errx(2, errfew, nparams, cap); + if (piss[i]) { + if (sizeof(char *) > sizeof(long) /* CONSTCOND */) + errx(2, errcharlong, cap); + strs[i] = *argv; + } else { + errno = 0; + nums[i] = strtol(*argv, &tmp, 0); + if ((errno == ERANGE && + (nums[i] == LONG_MIN || nums[i] == LONG_MAX)) || + (errno != 0 && nums[i] == 0) || + tmp == str || + *tmp != '\0') + errx(2, errnum, i + 1, *argv, cap); + } } - if (arg_need > 0) { - NEXT_ARG; - p1 = atoi(*argv); - } else - p1 = 0; - if (arg_need > 1) { - NEXT_ARG; - p2 = atoi(*argv); - } else - p2 = 0; - if (arg_need > 2) { - NEXT_ARG; - p3 = atoi(*argv); - } else - p3 = 0; - if (arg_need > 3) { - NEXT_ARG; - p4 = atoi(*argv); - } else - p4 = 0; - if (arg_need > 4) { - NEXT_ARG; - p5 = atoi(*argv); - } else - p5 = 0; - if (arg_need > 5) { - NEXT_ARG; - p6 = atoi(*argv); - } else - p6 = 0; - if (arg_need > 6) { - NEXT_ARG; - p7 = atoi(*argv); - } else - p7 = 0; - if (arg_need > 7) { - NEXT_ARG; - p8 = atoi(*argv); - } else - p8 = 0; - if (arg_need > 8) { - NEXT_ARG; - p9 = atoi(*argv); - } else - p9 = 0; + /* And output */ +#define p(i) (i <= nparams ? \ + (piss[i - 1] ? (long)strs[i - 1] : nums[i - 1]) : 0) + putp(tparm(str, p(1), p(2), p(3), p(4), p(5), p(6), p(7), p(8), p(9))); - /* And print them. */ - (void)tputs(tparm(str, p1, p2, p3, p4, p5, p6, p7, p8, p9), 0, outc); return argv; } -static int -outc(int c) -{ - return putchar(c); -} - static void usage(void) {