=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/less/opttbl.c,v retrieving revision 1.13 retrieving revision 1.14 diff -c -r1.13 -r1.14 *** src/usr.bin/less/opttbl.c 2014/04/29 12:11:25 1.13 --- src/usr.bin/less/opttbl.c 2015/11/05 22:08:44 1.14 *************** *** 6,13 **** * * For more information, see the README file. */ - /* * The option table. */ --- 6,16 ---- * * For more information, see the README file. */ + /* + * Modified for use with illumos. + * Copyright 2014 Garrett D'Amore + */ /* * The option table. */ *************** *** 18,181 **** /* * Variables controlled by command line options. */ ! public int quiet; /* Should we suppress the audible bell? */ ! public int how_search; /* Where should forward searches start? */ ! public int top_scroll; /* Repaint screen from top? ! (alternative is scroll from bottom) */ ! public int pr_type; /* Type of prompt (short, medium, long) */ ! public int bs_mode; /* How to process backspaces */ ! public int know_dumb; /* Don't complain about dumb terminals */ ! public int quit_at_eof; /* Quit after hitting end of file twice */ ! public int quit_if_one_screen; /* Quit if EOF on first screen */ ! public int squeeze; /* Squeeze multiple blank lines into one */ ! public int tabstop; /* Tab settings */ ! public int back_scroll; /* Repaint screen on backwards movement */ ! public int forw_scroll; /* Repaint screen on forward movement */ ! public int caseless; /* Do "caseless" searches */ ! public int linenums; /* Use line numbers */ ! public int autobuf; /* Automatically allocate buffers as needed */ ! public int bufspace; /* Max buffer space per file (K) */ ! public int ctldisp; /* Send control chars to screen untranslated */ ! public int force_open; /* Open the file even if not regular file */ ! public int swindow; /* Size of scrolling window */ ! public int jump_sline; /* Screen line of "jump target" */ ! public long jump_sline_fraction = -1; ! public long shift_count_fraction = -1; ! public int chopline; /* Truncate displayed lines at screen width */ ! public int no_init; /* Disable sending ti/te termcap strings */ ! public int no_keypad; /* Disable sending ks/ke termcap strings */ ! public int twiddle; /* Show tildes after EOF */ ! public int show_attn; /* Hilite first unread line */ ! public int shift_count; /* Number of positions to shift horizontally */ ! public int status_col; /* Display a status column */ ! public int use_lessopen; /* Use the LESSOPEN filter */ ! public int quit_on_intr; /* Quit on interrupt */ ! public int follow_mode; /* F cmd Follows file desc or file name? */ ! public int oldbot; /* Old bottom of screen behavior {{REMOVE}} */ ! public int opt_use_backslash; /* Use backslash escaping in option parsing */ ! #if HILITE_SEARCH ! public int hilite_search; /* Highlight matched search patterns? */ ! #endif ! public int less_is_more = 0; /* Make compatible with POSIX more */ /* * Long option names. */ ! #if GNU_OPTIONS ! static struct optname a_optname = { "search-skip-screen", NULL }; ! static struct optname b_optname = { "buffers", NULL }; ! static struct optname B__optname = { "auto-buffers", NULL }; ! static struct optname c_optname = { "clear-screen", NULL }; ! static struct optname d_optname = { "dumb", NULL }; ! #if MSDOS_COMPILER ! static struct optname D__optname = { "color", NULL }; ! #endif ! static struct optname e_optname = { "quit-at-eof", NULL }; ! static struct optname f_optname = { "force", NULL }; ! static struct optname F__optname = { "quit-if-one-screen", NULL }; ! #if HILITE_SEARCH ! static struct optname g_optname = { "hilite-search", NULL }; ! #endif ! static struct optname h_optname = { "max-back-scroll", NULL }; ! static struct optname i_optname = { "ignore-case", NULL }; ! static struct optname j_optname = { "jump-target", NULL }; ! static struct optname J__optname = { "status-column", NULL }; ! #if USERFILE ! static struct optname k_optname = { "lesskey-file", NULL }; ! #endif ! static struct optname K__optname = { "quit-on-intr", NULL }; ! static struct optname L__optname = { "no-lessopen", NULL }; ! static struct optname m_optname = { "long-prompt", NULL }; ! static struct optname n_optname = { "line-numbers", NULL }; ! #if LOGFILE ! static struct optname o_optname = { "log-file", NULL }; ! static struct optname O__optname = { "LOG-FILE", NULL }; ! #endif ! static struct optname p_optname = { "pattern", NULL }; ! static struct optname P__optname = { "prompt", NULL }; ! static struct optname q2_optname = { "silent", NULL }; ! static struct optname q_optname = { "quiet", &q2_optname }; ! static struct optname r_optname = { "raw-control-chars", NULL }; ! static struct optname s_optname = { "squeeze-blank-lines", NULL }; ! static struct optname S__optname = { "chop-long-lines", NULL }; ! #if TAGS ! static struct optname t_optname = { "tag", NULL }; ! static struct optname T__optname = { "tag-file", NULL }; ! #endif ! static struct optname u_optname = { "underline-special", NULL }; ! static struct optname V__optname = { "version", NULL }; ! static struct optname w_optname = { "hilite-unread", NULL }; ! static struct optname x_optname = { "tabs", NULL }; ! static struct optname X__optname = { "no-init", NULL }; ! static struct optname y_optname = { "max-forw-scroll", NULL }; ! static struct optname z_optname = { "window", NULL }; ! static struct optname quote_optname = { "quotes", NULL }; ! static struct optname tilde_optname = { "tilde", NULL }; ! static struct optname query_optname = { "help", NULL }; ! static struct optname pound_optname = { "shift", NULL }; ! static struct optname keypad_optname = { "no-keypad", NULL }; ! static struct optname oldbot_optname = { "old-bot", NULL }; ! static struct optname follow_optname = { "follow-name", NULL }; ! static struct optname use_backslash_optname = { "use-backslash", NULL }; ! #else ! static struct optname fake_optname = { "fake", NULL }; ! #define a_optname fake_optname ! #define b_optname fake_optname ! #define B__optname fake_optname ! #define c_optname fake_optname ! #define d_optname fake_optname ! #if MSDOS_COMPILER ! #define D__optname fake_optname ! #endif ! #define e_optname fake_optname ! #define f_optname fake_optname ! #define F__optname fake_optname ! #if HILITE_SEARCH ! #define g_optname fake_optname ! #endif ! #define h_optname fake_optname ! #define i_optname fake_optname ! #define j_optname fake_optname ! #define J__optname fake_optname ! #if USERFILE ! #define k_optname fake_optname ! #endif ! #define K__optname fake_optname ! #define L__optname fake_optname ! #define m_optname fake_optname ! #define n_optname fake_optname ! #if LOGFILE ! #define o_optname fake_optname ! #define O__optname fake_optname ! #endif ! #define p_optname fake_optname ! #define P__optname fake_optname ! #define q2_optname fake_optname ! #define q_optname fake_optname ! #define r_optname fake_optname ! #define s_optname fake_optname ! #define S__optname fake_optname ! #if TAGS ! #define t_optname fake_optname ! #define T__optname fake_optname ! #endif ! #define u_optname fake_optname ! #define V__optname fake_optname ! #define w_optname fake_optname ! #define x_optname fake_optname ! #define X__optname fake_optname ! #define y_optname fake_optname ! #define z_optname fake_optname ! #define quote_optname fake_optname ! #define tilde_optname fake_optname ! #define query_optname fake_optname ! #define pound_optname fake_optname ! #define keypad_optname fake_optname ! #define oldbot_optname fake_optname ! #define follow_optname fake_optname ! #define use_backslash_optname fake_optname ! #endif /* --- 21,108 ---- /* * Variables controlled by command line options. */ ! int quiet; /* Should we suppress the audible bell? */ ! int how_search; /* Where should forward searches start? */ ! int top_scroll; /* Repaint screen from top? (vs scroll from bottom) */ ! int pr_type; /* Type of prompt (short, medium, long) */ ! int bs_mode; /* How to process backspaces */ ! int know_dumb; /* Don't complain about dumb terminals */ ! int quit_at_eof; /* Quit after hitting end of file twice */ ! int quit_if_one_screen; /* Quit if EOF on first screen */ ! int squeeze; /* Squeeze multiple blank lines into one */ ! int back_scroll; /* Repaint screen on backwards movement */ ! int forw_scroll; /* Repaint screen on forward movement */ ! int caseless; /* Do "caseless" searches */ ! int linenums; /* Use line numbers */ ! int autobuf; /* Automatically allocate buffers as needed */ ! int bufspace; /* Max buffer space per file (K) */ ! int ctldisp; /* Send control chars to screen untranslated */ ! int force_open; /* Open the file even if not regular file */ ! int swindow; /* Size of scrolling window */ ! int jump_sline; /* Screen line of "jump target" */ ! long jump_sline_fraction = -1; ! int chopline; /* Truncate displayed lines at screen width */ ! int no_init; /* Disable sending ti/te termcap strings */ ! int no_keypad; /* Disable sending ks/ke termcap strings */ ! int twiddle; /* Show tildes after EOF */ ! int show_attn; /* Hilite first unread line */ ! int status_col; /* Display a status column */ ! int use_lessopen; /* Use the LESSOPEN filter */ ! int quit_on_intr; /* Quit on interrupt */ ! int follow_mode; /* F cmd Follows file desc or file name? */ ! int oldbot; /* Old bottom of screen behavior {{REMOVE}} */ ! int opt_use_backslash; /* Use backslash escaping in option parsing */ ! int hilite_search; /* Highlight matched search patterns? */ ! int less_is_more = 0; /* Make compatible with POSIX more */ /* * Long option names. */ ! static struct optname a_optname = { "search-skip-screen", NULL }; ! static struct optname b_optname = { "buffers", NULL }; ! static struct optname B__optname = { "auto-buffers", NULL }; ! static struct optname c_optname = { "clear-screen", NULL }; ! static struct optname d_optname = { "dumb", NULL }; ! static struct optname e_optname = { "quit-at-eof", NULL }; ! static struct optname f_optname = { "force", NULL }; ! static struct optname F__optname = { "quit-if-one-screen", NULL }; ! static struct optname g_optname = { "hilite-search", NULL }; ! static struct optname h_optname = { "max-back-scroll", NULL }; ! static struct optname i_optname = { "ignore-case", NULL }; ! static struct optname j_optname = { "jump-target", NULL }; ! static struct optname J__optname = { "status-column", NULL }; ! static struct optname k_optname = { "lesskey-file", NULL }; ! static struct optname K__optname = { "quit-on-intr", NULL }; ! static struct optname L__optname = { "no-lessopen", NULL }; ! static struct optname m_optname = { "long-prompt", NULL }; ! static struct optname n_optname = { "line-numbers", NULL }; ! static struct optname o_optname = { "log-file", NULL }; ! static struct optname O__optname = { "LOG-FILE", NULL }; ! static struct optname p_optname = { "pattern", NULL }; ! static struct optname P__optname = { "prompt", NULL }; ! static struct optname q2_optname = { "silent", NULL }; ! static struct optname q_optname = { "quiet", &q2_optname }; ! static struct optname r_optname = { "raw-control-chars", NULL }; ! static struct optname s_optname = { "squeeze-blank-lines", NULL }; ! static struct optname S__optname = { "chop-long-lines", NULL }; ! static struct optname t_optname = { "tag", NULL }; ! static struct optname T__optname = { "tag-file", NULL }; ! static struct optname u_optname = { "underline-special", NULL }; ! static struct optname V__optname = { "version", NULL }; ! static struct optname w_optname = { "hilite-unread", NULL }; ! static struct optname x_optname = { "tabs", NULL }; ! static struct optname X__optname = { "no-init", NULL }; ! static struct optname y_optname = { "max-forw-scroll", NULL }; ! static struct optname z_optname = { "window", NULL }; ! static struct optname quote_optname = { "quotes", NULL }; ! static struct optname tilde_optname = { "tilde", NULL }; ! static struct optname query_optname = { "help", NULL }; ! static struct optname pound_optname = { "shift", NULL }; ! static struct optname keypad_optname = { "no-keypad", NULL }; ! static struct optname oldbot_optname = { "old-bot", NULL }; ! static struct optname follow_optname = { "follow-name", NULL }; ! static struct optname use_backslash_optname = { "use-backslash", NULL }; /* *************** *** 184,197 **** * For BOOL and TRIPLE options, odesc[0], odesc[1], odesc[2] are * the description of the option when set to 0, 1 or 2, respectively. * For NUMBER options, odesc[0] is the prompt to use when entering ! * a new value, and odesc[1] is the description, which should contain * one %d which is replaced by the value of the number. * For STRING options, odesc[0] is the prompt to use when entering * a new value, and odesc[1], if not NULL, is the set of characters * that are valid in the string. */ ! static struct loption option[] = ! { { 'a', &a_optname, TRIPLE, OPT_ONPLUS, &how_search, NULL, { --- 111,123 ---- * For BOOL and TRIPLE options, odesc[0], odesc[1], odesc[2] are * the description of the option when set to 0, 1 or 2, respectively. * For NUMBER options, odesc[0] is the prompt to use when entering ! * a new value, and odesc[1] is the description, which should contain * one %d which is replaced by the value of the number. * For STRING options, odesc[0] is the prompt to use when entering * a new value, and odesc[1], if not NULL, is the set of characters * that are valid in the string. */ ! static struct loption option[] = { { 'a', &a_optname, TRIPLE, OPT_ONPLUS, &how_search, NULL, { *************** *** 202,208 **** }, { 'b', &b_optname, ! NUMBER|INIT_HANDLER, 64, &bufspace, opt_b, { "Max buffer space per file (K): ", "Max buffer space per file: %dK", --- 128,134 ---- }, { 'b', &b_optname, ! NUMBER|INIT_HANDLER, 64, &bufspace, opt_b, { "Max buffer space per file (K): ", "Max buffer space per file: %dK", *************** *** 218,224 **** } }, { 'c', &c_optname, ! TRIPLE, OPT_ON, &top_scroll, NULL, { "Repaint by scrolling from bottom of screen", "Repaint by painting from top of screen", --- 144,150 ---- } }, { 'c', &c_optname, ! TRIPLE|MORE_OK, OPT_ON, &top_scroll, NULL, { "Repaint by scrolling from bottom of screen", "Repaint by painting from top of screen", *************** *** 226,248 **** } }, { 'd', &d_optname, ! BOOL|NO_TOGGLE, OPT_OFF, &know_dumb, NULL, { "Assume intelligent terminal", "Assume dumb terminal", NULL } }, - #if MSDOS_COMPILER - { 'D', &D__optname, - STRING|REPAINT|NO_QUERY, 0, NULL, opt_D, - { - "color desc: ", - "Ddknsu0123456789.", - NULL - } - }, - #endif { 'e', &e_optname, TRIPLE, OPT_OFF, &quit_at_eof, NULL, { --- 152,164 ---- } }, { 'd', &d_optname, ! BOOL|MORE_OK|NO_TOGGLE, OPT_OFF, &know_dumb, NULL, { "Assume intelligent terminal", "Assume dumb terminal", NULL } }, { 'e', &e_optname, TRIPLE, OPT_OFF, &quit_at_eof, NULL, { *************** *** 267,273 **** NULL } }, - #if HILITE_SEARCH { 'g', &g_optname, TRIPLE|HL_REPAINT, OPT_ONPLUS, &hilite_search, NULL, { --- 183,188 ---- *************** *** 276,282 **** "Highlight all matches for previous search pattern", } }, - #endif { 'h', &h_optname, NUMBER, -1, &back_scroll, NULL, { --- 191,196 ---- *************** *** 309,320 **** NULL } }, - #if USERFILE { 'k', &k_optname, STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_k, { NULL, NULL, NULL } }, - #endif { 'K', &K__optname, BOOL, OPT_OFF, &quit_on_intr, NULL, { --- 223,232 ---- *************** *** 347,353 **** "Constantly display line numbers" } }, - #if LOGFILE { 'o', &o_optname, STRING, 0, NULL, opt_o, { "log file: ", NULL, NULL } --- 259,264 ---- *************** *** 356,364 **** STRING, 0, NULL, opt__O, { "Log file: ", NULL, NULL } }, - #endif { 'p', &p_optname, ! STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_p, { NULL, NULL, NULL } }, { 'P', &P__optname, --- 267,274 ---- STRING, 0, NULL, opt__O, { "Log file: ", NULL, NULL } }, { 'p', &p_optname, ! STRING|NO_TOGGLE|NO_QUERY|MORE_OK, 0, NULL, opt_p, { NULL, NULL, NULL } }, { 'P', &P__optname, *************** *** 378,388 **** { "Display control characters as ^X", "Display control characters directly", ! "Display control characters directly, processing ANSI sequences" } }, { 's', &s_optname, ! BOOL|REPAINT, OPT_OFF, &squeeze, NULL, { "Display all blank lines", "Squeeze multiple blank lines", --- 288,299 ---- { "Display control characters as ^X", "Display control characters directly", ! "Display control characters directly, " ! "processing ANSI sequences" } }, { 's', &s_optname, ! BOOL|REPAINT|MORE_OK, OPT_OFF, &squeeze, NULL, { "Display all blank lines", "Squeeze multiple blank lines", *************** *** 397,412 **** NULL } }, - #if TAGS { 't', &t_optname, ! STRING|NO_QUERY, 0, NULL, opt_t, { "tag: ", NULL, NULL } }, { 'T', &T__optname, ! STRING, 0, NULL, opt__T, { "tags file: ", NULL, NULL } }, - #endif { 'u', &u_optname, TRIPLE|REPAINT, OPT_OFF, &bs_mode, NULL, { --- 308,321 ---- NULL } }, { 't', &t_optname, ! STRING|NO_QUERY|MORE_OK, 0, NULL, opt_t, { "tag: ", NULL, NULL } }, { 'T', &T__optname, ! STRING|MORE_OK, 0, NULL, opt__T, { "tags file: ", NULL, NULL } }, { 'u', &u_optname, TRIPLE|REPAINT, OPT_OFF, &bs_mode, NULL, { *************** *** 424,430 **** { "Don't highlight first unread line", "Highlight first unread line after forward-screen", ! "Highlight first unread line after any forward movement", } }, { 'x', &x_optname, --- 333,340 ---- { "Don't highlight first unread line", "Highlight first unread line after forward-screen", ! "Highlight first unread line after any " ! "forward movement", } }, { 'x', &x_optname, *************** *** 511,517 **** BOOL, OPT_OFF, &opt_use_backslash, NULL, { "Use backslash escaping in command line parameters", ! "Don't use backslash escaping in command line parameters", NULL } }, --- 421,428 ---- BOOL, OPT_OFF, &opt_use_backslash, NULL, { "Use backslash escaping in command line parameters", ! "Don't use backslash escaping in command line " ! "parameters", NULL } }, *************** *** 522,563 **** /* * Initialize each option to its default value. */ ! public void ! init_option() { ! register struct loption *o; ! char *p; ! p = lgetenv("LESS_IS_MORE"); ! if (p != NULL && *p != '\0') ! less_is_more = 1; ! ! for (o = option; o->oletter != '\0'; o++) ! { /* * Set each variable to its default. */ if (o->ovar != NULL) *(o->ovar) = o->odefault; if (o->otype & INIT_HANDLER) ! (*(o->ofunc))(INIT, (char *) NULL); } } /* * Find an option in the option table, given its option letter. */ ! public struct loption * ! findopt(c) ! int c; { ! register struct loption *o; ! for (o = option; o->oletter != '\0'; o++) ! { if (o->oletter == c) return (o); ! if ((o->otype & TRIPLE) && ASCII_TO_UPPER(o->oletter) == c) return (o); } return (NULL); --- 433,466 ---- /* * Initialize each option to its default value. */ ! void ! init_option(void) { ! struct loption *o; ! for (o = option; o->oletter != '\0'; o++) { /* * Set each variable to its default. */ if (o->ovar != NULL) *(o->ovar) = o->odefault; if (o->otype & INIT_HANDLER) ! (*(o->ofunc))(INIT, NULL); } } /* * Find an option in the option table, given its option letter. */ ! struct loption * ! findopt(int c) { ! struct loption *o; ! for (o = option; o->oletter != '\0'; o++) { if (o->oletter == c) return (o); ! if ((o->otype & TRIPLE) && (toupper(o->oletter) == c)) return (o); } return (NULL); *************** *** 566,601 **** /* * */ ! static int ! is_optchar(c) ! char c; { ! if (ASCII_IS_UPPER(c)) ! return 1; ! if (ASCII_IS_LOWER(c)) ! return 1; if (c == '-') ! return 1; ! return 0; } - #if GNU_OPTIONS /* * Find an option in the option table, given its option name. * p_optname is the (possibly partial) name to look for, and * is updated to point after the matched name. * p_oname if non-NULL is set to point to the full option name. */ ! public struct loption * ! findopt_name(p_optname, p_oname, p_err) ! char **p_optname; ! char **p_oname; ! int *p_err; { char *optname = *p_optname; ! register struct loption *o; ! register struct optname *oname; ! register int len; int uppercase; struct loption *maxo = NULL; struct optname *maxoname = NULL; --- 469,499 ---- /* * */ ! static int ! is_optchar(char c) { ! if (isupper(c)) ! return (1); ! if (islower(c)) ! return (1); if (c == '-') ! return (1); ! return (0); } /* * Find an option in the option table, given its option name. * p_optname is the (possibly partial) name to look for, and * is updated to point after the matched name. * p_oname if non-NULL is set to point to the full option name. */ ! struct loption * ! findopt_name(char **p_optname, char **p_oname, int *p_err) { char *optname = *p_optname; ! struct loption *o; ! struct optname *oname; ! int len; int uppercase; struct loption *maxo = NULL; struct optname *maxoname = NULL; *************** *** 606,642 **** /* * Check all options. */ ! for (o = option; o->oletter != '\0'; o++) ! { /* * Check all names for this option. */ ! for (oname = o->onames; oname != NULL; oname = oname->onext) ! { ! /* * Try normal match first (uppercase == 0), * then, then if it's a TRIPLE option, * try uppercase match (uppercase == 1). */ ! for (uppercase = 0; uppercase <= 1; uppercase++) ! { len = sprefix(optname, oname->oname, uppercase); ! if (len <= 0 || is_optchar(optname[len])) ! { /* * We didn't use all of the option name. */ continue; } ! if (!exact && len == maxlen) /* * Already had a partial match, * and now there's another one that * matches the same length. */ ambig = 1; ! else if (len > maxlen) ! { /* * Found a better match than * the one we had. --- 504,535 ---- /* * Check all options. */ ! for (o = option; o->oletter != '\0'; o++) { /* * Check all names for this option. */ ! for (oname = o->onames; oname != NULL; oname = oname->onext) { ! /* * Try normal match first (uppercase == 0), * then, then if it's a TRIPLE option, * try uppercase match (uppercase == 1). */ ! for (uppercase = 0; uppercase <= 1; uppercase++) { len = sprefix(optname, oname->oname, uppercase); ! if (len <= 0 || is_optchar(optname[len])) { /* * We didn't use all of the option name. */ continue; } ! if (!exact && len == maxlen) { /* * Already had a partial match, * and now there's another one that * matches the same length. */ ambig = 1; ! } else if (len > maxlen) { /* * Found a better match than * the one we had. *************** *** 645,659 **** maxoname = oname; maxlen = len; ambig = 0; ! exact = (len == (int)strlen(oname->oname)); } if (!(o->otype & TRIPLE)) break; } } } ! if (ambig) ! { /* * Name matched more than one option. */ --- 538,551 ---- maxoname = oname; maxlen = len; ambig = 0; ! exact = (len == strlen(oname->oname)); } if (!(o->otype & TRIPLE)) break; } } } ! if (ambig) { /* * Name matched more than one option. */ *************** *** 666,669 **** *p_oname = maxoname == NULL ? NULL : maxoname->oname; return (maxo); } - #endif --- 558,560 ----