opttbl.c revision 161475
160786Sps/* 2161475Sdelphij * Copyright (C) 1984-2004 Mark Nudelman 360786Sps * 460786Sps * You may distribute under the terms of either the GNU General Public 560786Sps * License or the Less License, as specified in the README file. 660786Sps * 760786Sps * For more information about less, or for information on how to 860786Sps * contact the author, see the README file. 960786Sps */ 1060786Sps 1160786Sps 1260786Sps/* 1360786Sps * The option table. 1460786Sps */ 1560786Sps 1660786Sps#include "less.h" 1760786Sps#include "option.h" 1860786Sps 1960786Sps/* 2060786Sps * Variables controlled by command line options. 2160786Sps */ 2260786Spspublic int quiet; /* Should we suppress the audible bell? */ 2360786Spspublic int how_search; /* Where should forward searches start? */ 2460786Spspublic int top_scroll; /* Repaint screen from top? 2560786Sps (alternative is scroll from bottom) */ 2660786Spspublic int pr_type; /* Type of prompt (short, medium, long) */ 2760786Spspublic int bs_mode; /* How to process backspaces */ 2860786Spspublic int know_dumb; /* Don't complain about dumb terminals */ 2960786Spspublic int quit_at_eof; /* Quit after hitting end of file twice */ 3060786Spspublic int quit_if_one_screen; /* Quit if EOF on first screen */ 3160786Spspublic int squeeze; /* Squeeze multiple blank lines into one */ 3260786Spspublic int tabstop; /* Tab settings */ 3360786Spspublic int back_scroll; /* Repaint screen on backwards movement */ 3460786Spspublic int forw_scroll; /* Repaint screen on forward movement */ 3560786Spspublic int caseless; /* Do "caseless" searches */ 3660786Spspublic int linenums; /* Use line numbers */ 3760786Spspublic int autobuf; /* Automatically allocate buffers as needed */ 38128345Stjrpublic int bufspace; /* Max buffer space per file (K) */ 3960786Spspublic int ctldisp; /* Send control chars to screen untranslated */ 4060786Spspublic int force_open; /* Open the file even if not regular file */ 4160786Spspublic int swindow; /* Size of scrolling window */ 4260786Spspublic int jump_sline; /* Screen line of "jump target" */ 4360786Spspublic int chopline; /* Truncate displayed lines at screen width */ 4460786Spspublic int no_init; /* Disable sending ti/te termcap strings */ 4589019Spspublic int no_keypad; /* Disable sending ks/ke termcap strings */ 4660786Spspublic int twiddle; /* Show tildes after EOF */ 4760786Spspublic int show_attn; /* Hilite first unread line */ 4863128Spspublic int shift_count; /* Number of positions to shift horizontally */ 4963128Spspublic int status_col; /* Display a status column */ 50128345Stjrpublic int use_lessopen; /* Use the LESSOPEN filter */ 51161475Sdelphijpublic int quit_on_intr; /* Quit on interrupt */ 5260786Sps#if HILITE_SEARCH 5360786Spspublic int hilite_search; /* Highlight matched search patterns? */ 5460786Sps#endif 5560786Sps 56161475Sdelphijpublic int less_is_more = 0; /* Make compatible with POSIX more */ 57161475Sdelphij 5860786Sps/* 5960786Sps * Long option names. 6060786Sps */ 6160786Spsstatic struct optname a_optname = { "search-skip-screen", NULL }; 6260786Spsstatic struct optname b_optname = { "buffers", NULL }; 6360786Spsstatic struct optname B__optname = { "auto-buffers", NULL }; 6460786Spsstatic struct optname c_optname = { "clear-screen", NULL }; 6560786Spsstatic struct optname d_optname = { "dumb", NULL }; 6660786Sps#if MSDOS_COMPILER 6760786Spsstatic struct optname D__optname = { "color", NULL }; 6860786Sps#endif 6960786Spsstatic struct optname e_optname = { "quit-at-eof", NULL }; 7060786Spsstatic struct optname f_optname = { "force", NULL }; 7160786Spsstatic struct optname F__optname = { "quit-if-one-screen", NULL }; 7260786Sps#if HILITE_SEARCH 7360786Spsstatic struct optname g_optname = { "hilite-search", NULL }; 7460786Sps#endif 7560786Spsstatic struct optname h_optname = { "max-back-scroll", NULL }; 7660786Spsstatic struct optname i_optname = { "ignore-case", NULL }; 7760786Spsstatic struct optname j_optname = { "jump-target", NULL }; 7863128Spsstatic struct optname J__optname = { "status-column", NULL }; 7960786Sps#if USERFILE 8060786Spsstatic struct optname k_optname = { "lesskey-file", NULL }; 8160786Sps#endif 82161475Sdelphijstatic struct optname K__optname = { "quit-on-intr", NULL }; 83128345Stjrstatic struct optname L__optname = { "no-lessopen", NULL }; 8460786Spsstatic struct optname m_optname = { "long-prompt", NULL }; 8560786Spsstatic struct optname n_optname = { "line-numbers", NULL }; 8660786Sps#if LOGFILE 8760786Spsstatic struct optname o_optname = { "log-file", NULL }; 8860786Spsstatic struct optname O__optname = { "LOG-FILE", NULL }; 8960786Sps#endif 9060786Spsstatic struct optname p_optname = { "pattern", NULL }; 9160786Spsstatic struct optname P__optname = { "prompt", NULL }; 9260786Spsstatic struct optname q2_optname = { "silent", NULL }; 9360786Spsstatic struct optname q_optname = { "quiet", &q2_optname }; 9460786Spsstatic struct optname r_optname = { "raw-control-chars", NULL }; 9560786Spsstatic struct optname s_optname = { "squeeze-blank-lines", NULL }; 9660786Spsstatic struct optname S__optname = { "chop-long-lines", NULL }; 9760786Sps#if TAGS 9860786Spsstatic struct optname t_optname = { "tag", NULL }; 9960786Spsstatic struct optname T__optname = { "tag-file", NULL }; 10060786Sps#endif 10160786Spsstatic struct optname u_optname = { "underline-special", NULL }; 10260786Spsstatic struct optname V__optname = { "version", NULL }; 10360786Spsstatic struct optname w_optname = { "hilite-unread", NULL }; 10460786Spsstatic struct optname x_optname = { "tabs", NULL }; 10560786Spsstatic struct optname X__optname = { "no-init", NULL }; 10660786Spsstatic struct optname y_optname = { "max-forw-scroll", NULL }; 10760786Spsstatic struct optname z_optname = { "window", NULL }; 10860786Spsstatic struct optname quote_optname = { "quotes", NULL }; 10960786Spsstatic struct optname tilde_optname = { "tilde", NULL }; 11060786Spsstatic struct optname query_optname = { "help", NULL }; 11163128Spsstatic struct optname pound_optname = { "shift", NULL }; 11289019Spsstatic struct optname keypad_optname = { "no-keypad", NULL }; 11360786Sps 11460786Sps 11560786Sps/* 11660786Sps * Table of all options and their semantics. 11789019Sps * 11889019Sps * For BOOL and TRIPLE options, odesc[0], odesc[1], odesc[2] are 11989019Sps * the description of the option when set to 0, 1 or 2, respectively. 12089019Sps * For NUMBER options, odesc[0] is the prompt to use when entering 12189019Sps * a new value, and odesc[1] is the description, which should contain 12289019Sps * one %d which is replaced by the value of the number. 12389019Sps * For STRING options, odesc[0] is the prompt to use when entering 12489019Sps * a new value, and odesc[1], if not NULL, is the set of characters 12589019Sps * that are valid in the string. 12660786Sps */ 127128345Stjrstatic struct loption option[] = 12860786Sps{ 12960786Sps { 'a', &a_optname, 13060786Sps BOOL, OPT_OFF, &how_search, NULL, 131128345Stjr { 132128345Stjr "Search includes displayed screen", 133128345Stjr "Search skips displayed screen", 134128345Stjr NULL 135128345Stjr } 13660786Sps }, 13760786Sps 13860786Sps { 'b', &b_optname, 139128345Stjr NUMBER|INIT_HANDLER, 64, &bufspace, opt_b, 140128345Stjr { 141128345Stjr "Max buffer space per file (K): ", 142128345Stjr "Max buffer space per file: %dK", 143128345Stjr NULL 144128345Stjr } 14560786Sps }, 14660786Sps { 'B', &B__optname, 14760786Sps BOOL, OPT_ON, &autobuf, NULL, 148128345Stjr { 149128345Stjr "Don't automatically allocate buffers", 150128345Stjr "Automatically allocate buffers when needed", 151128345Stjr NULL 152128345Stjr } 15360786Sps }, 15460786Sps { 'c', &c_optname, 15560786Sps TRIPLE, OPT_OFF, &top_scroll, NULL, 156128345Stjr { 157128345Stjr "Repaint by scrolling from bottom of screen", 158128345Stjr "Repaint by clearing each line", 159128345Stjr "Repaint by painting from top of screen" 160128345Stjr } 16160786Sps }, 16260786Sps { 'd', &d_optname, 16360786Sps BOOL|NO_TOGGLE, OPT_OFF, &know_dumb, NULL, 164128345Stjr { 165128345Stjr "Assume intelligent terminal", 166128345Stjr "Assume dumb terminal", 167128345Stjr NULL 168128345Stjr } 16960786Sps }, 17060786Sps#if MSDOS_COMPILER 17160786Sps { 'D', &D__optname, 17260786Sps STRING|REPAINT|NO_QUERY, 0, NULL, opt_D, 173128345Stjr { 174128345Stjr "color desc: ", 175128345Stjr "Ddknsu0123456789.", 176128345Stjr NULL 177128345Stjr } 17860786Sps }, 17960786Sps#endif 18060786Sps { 'e', &e_optname, 18160786Sps TRIPLE, OPT_OFF, &quit_at_eof, NULL, 182128345Stjr { 183128345Stjr "Don't quit at end-of-file", 184128345Stjr "Quit at end-of-file", 185128345Stjr "Quit immediately at end-of-file" 186128345Stjr } 18760786Sps }, 18860786Sps { 'f', &f_optname, 18960786Sps BOOL, OPT_OFF, &force_open, NULL, 190128345Stjr { 191128345Stjr "Open only regular files", 192128345Stjr "Open even non-regular files", 193128345Stjr NULL 194128345Stjr } 19560786Sps }, 19660786Sps { 'F', &F__optname, 19760786Sps BOOL, OPT_OFF, &quit_if_one_screen, NULL, 198128345Stjr { 199128345Stjr "Don't quit if end-of-file on first screen", 200128345Stjr "Quit if end-of-file on first screen", 201128345Stjr NULL 202128345Stjr } 20360786Sps }, 20460786Sps#if HILITE_SEARCH 20560786Sps { 'g', &g_optname, 20660786Sps TRIPLE|HL_REPAINT, OPT_ONPLUS, &hilite_search, NULL, 207128345Stjr { 208128345Stjr "Don't highlight search matches", 209128345Stjr "Highlight matches for previous search only", 210128345Stjr "Highlight all matches for previous search pattern", 211128345Stjr } 21260786Sps }, 21360786Sps#endif 21460786Sps { 'h', &h_optname, 21560786Sps NUMBER, -1, &back_scroll, NULL, 216128345Stjr { 217128345Stjr "Backwards scroll limit: ", 218128345Stjr "Backwards scroll limit is %d lines", 219128345Stjr NULL 220128345Stjr } 22160786Sps }, 22260786Sps { 'i', &i_optname, 22360786Sps TRIPLE|HL_REPAINT, OPT_OFF, &caseless, opt_i, 224128345Stjr { 225128345Stjr "Case is significant in searches", 226128345Stjr "Ignore case in searches", 227128345Stjr "Ignore case in searches and in patterns" 228128345Stjr } 22960786Sps }, 23060786Sps { 'j', &j_optname, 23160786Sps NUMBER, 1, &jump_sline, NULL, 232128345Stjr { 233128345Stjr "Target line: ", 234128345Stjr "Position target at screen line %d", 235128345Stjr NULL 236128345Stjr } 23760786Sps }, 23863128Sps { 'J', &J__optname, 23963128Sps BOOL|REPAINT, OPT_OFF, &status_col, NULL, 240128345Stjr { 241128345Stjr "Don't display a status column", 242128345Stjr "Display a status column", 243128345Stjr NULL 244128345Stjr } 24563128Sps }, 24660786Sps#if USERFILE 24760786Sps { 'k', &k_optname, 24860786Sps STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_k, 249128345Stjr { NULL, NULL, NULL } 25060786Sps }, 25160786Sps#endif 252161475Sdelphij { 'K', &K__optname, 253161475Sdelphij BOOL, OPT_OFF, &quit_on_intr, NULL, 254161475Sdelphij { 255161475Sdelphij "Interrupt (ctrl-C) returns to prompt", 256161475Sdelphij "Interrupt (ctrl-C) exits less", 257161475Sdelphij NULL 258161475Sdelphij } 259161475Sdelphij }, 26060786Sps { 'l', NULL, 26160786Sps STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_l, 262128345Stjr { NULL, NULL, NULL } 26360786Sps }, 264128345Stjr { 'L', &L__optname, 265128345Stjr BOOL, OPT_ON, &use_lessopen, NULL, 266128345Stjr { 267128345Stjr "Don't use the LESSOPEN filter", 268128345Stjr "Use the LESSOPEN filter", 269128345Stjr NULL 270128345Stjr } 271128345Stjr }, 27260786Sps { 'm', &m_optname, 27360786Sps TRIPLE, OPT_OFF, &pr_type, NULL, 274128345Stjr { 275128345Stjr "Short prompt", 276128345Stjr "Medium prompt", 277128345Stjr "Long prompt" 278128345Stjr } 27960786Sps }, 28060786Sps { 'n', &n_optname, 28160786Sps TRIPLE|REPAINT, OPT_ON, &linenums, NULL, 282128345Stjr { 283128345Stjr "Don't use line numbers", 284128345Stjr "Use line numbers", 285128345Stjr "Constantly display line numbers" 286128345Stjr } 28760786Sps }, 28860786Sps#if LOGFILE 28960786Sps { 'o', &o_optname, 29060786Sps STRING, 0, NULL, opt_o, 291128345Stjr { "log file: ", NULL, NULL } 29260786Sps }, 29360786Sps { 'O', &O__optname, 29460786Sps STRING, 0, NULL, opt__O, 295128345Stjr { "Log file: ", NULL, NULL } 29660786Sps }, 29760786Sps#endif 29860786Sps { 'p', &p_optname, 29960786Sps STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_p, 300128345Stjr { NULL, NULL, NULL } 30160786Sps }, 30260786Sps { 'P', &P__optname, 30360786Sps STRING, 0, NULL, opt__P, 304128345Stjr { "prompt: ", NULL, NULL } 30560786Sps }, 30660786Sps { 'q', &q_optname, 30760786Sps TRIPLE, OPT_OFF, &quiet, NULL, 308128345Stjr { 309128345Stjr "Ring the bell for errors AND at eof/bof", 310128345Stjr "Ring the bell for errors but not at eof/bof", 311128345Stjr "Never ring the bell" 312128345Stjr } 31360786Sps }, 31460786Sps { 'r', &r_optname, 31560786Sps TRIPLE|REPAINT, OPT_OFF, &ctldisp, NULL, 316128345Stjr { 317128345Stjr "Display control characters as ^X", 318128345Stjr "Display control characters directly", 319128345Stjr "Display control characters directly, processing ANSI sequences" 320128345Stjr } 32160786Sps }, 32260786Sps { 's', &s_optname, 32360786Sps BOOL|REPAINT, OPT_OFF, &squeeze, NULL, 324128345Stjr { 325128345Stjr "Display all blank lines", 326128345Stjr "Squeeze multiple blank lines", 327128345Stjr NULL 328128345Stjr } 32960786Sps }, 33060786Sps { 'S', &S__optname, 33160786Sps BOOL|REPAINT, OPT_OFF, &chopline, NULL, 332128345Stjr { 333128345Stjr "Fold long lines", 334128345Stjr "Chop long lines", 335128345Stjr NULL 336128345Stjr } 33760786Sps }, 33860786Sps#if TAGS 33960786Sps { 't', &t_optname, 34060786Sps STRING|NO_QUERY, 0, NULL, opt_t, 341128345Stjr { "tag: ", NULL, NULL } 34260786Sps }, 34360786Sps { 'T', &T__optname, 34460786Sps STRING, 0, NULL, opt__T, 345128345Stjr { "tags file: ", NULL, NULL } 34660786Sps }, 34760786Sps#endif 34860786Sps { 'u', &u_optname, 34960786Sps TRIPLE|REPAINT, OPT_OFF, &bs_mode, NULL, 350128345Stjr { 351128345Stjr "Display underlined text in underline mode", 352128345Stjr "Backspaces cause overstrike", 353128345Stjr "Print backspace as ^H" 354128345Stjr } 35560786Sps }, 35660786Sps { 'V', &V__optname, 35760786Sps NOVAR, 0, NULL, opt__V, 358128345Stjr { NULL, NULL, NULL } 35960786Sps }, 36060786Sps { 'w', &w_optname, 36160786Sps TRIPLE|REPAINT, OPT_OFF, &show_attn, NULL, 362128345Stjr { 363128345Stjr "Don't highlight first unread line", 364128345Stjr "Highlight first unread line after forward-screen", 365128345Stjr "Highlight first unread line after any forward movement", 366128345Stjr } 36760786Sps }, 36860786Sps { 'x', &x_optname, 36989019Sps STRING|REPAINT, 0, NULL, opt_x, 370128345Stjr { 371128345Stjr "Tab stops: ", 372128345Stjr "0123456789,", 373128345Stjr NULL 374128345Stjr } 37560786Sps }, 37660786Sps { 'X', &X__optname, 37760786Sps BOOL|NO_TOGGLE, OPT_OFF, &no_init, NULL, 378128345Stjr { 379128345Stjr "Send init/deinit strings to terminal", 380128345Stjr "Don't use init/deinit strings", 381128345Stjr NULL 382128345Stjr } 38360786Sps }, 38460786Sps { 'y', &y_optname, 38560786Sps NUMBER, -1, &forw_scroll, NULL, 386128345Stjr { 387128345Stjr "Forward scroll limit: ", 388128345Stjr "Forward scroll limit is %d lines", 389128345Stjr NULL 390128345Stjr } 39160786Sps }, 39260786Sps { 'z', &z_optname, 39360786Sps NUMBER, -1, &swindow, NULL, 394128345Stjr { 395128345Stjr "Scroll window size: ", 396128345Stjr "Scroll window size is %d lines", 397128345Stjr NULL 398128345Stjr } 39960786Sps }, 40060786Sps { '"', "e_optname, 40160786Sps STRING, 0, NULL, opt_quote, 402128345Stjr { "quotes: ", NULL, NULL } 40360786Sps }, 40460786Sps { '~', &tilde_optname, 40560786Sps BOOL|REPAINT, OPT_ON, &twiddle, NULL, 406128345Stjr { 407128345Stjr "Don't show tildes after end of file", 408128345Stjr "Show tildes after end of file", 409128345Stjr NULL 410128345Stjr } 41160786Sps }, 41260786Sps { '?', &query_optname, 41360786Sps NOVAR, 0, NULL, opt_query, 414128345Stjr { NULL, NULL, NULL } 41560786Sps }, 41663128Sps { '#', £_optname, 41763128Sps NUMBER, 0, &shift_count, NULL, 418128345Stjr { 419128345Stjr "Horizontal shift: ", 420128345Stjr "Horizontal shift %d positions", 421128345Stjr NULL 422128345Stjr } 42363128Sps }, 42489019Sps { '.', &keypad_optname, 42589019Sps BOOL|NO_TOGGLE, OPT_OFF, &no_keypad, NULL, 426128345Stjr { 427128345Stjr "Use keypad mode", 428128345Stjr "Don't use keypad mode", 429128345Stjr NULL 430128345Stjr } 43189019Sps }, 432128345Stjr { '\0', NULL, NOVAR, 0, NULL, NULL, { NULL, NULL, NULL } } 43360786Sps}; 43460786Sps 43560786Sps 43660786Sps/* 43760786Sps * Initialize each option to its default value. 43860786Sps */ 43960786Sps public void 44060786Spsinit_option() 44160786Sps{ 442128345Stjr register struct loption *o; 443161475Sdelphij char *p; 44460786Sps 445161475Sdelphij p = lgetenv("LESS_IS_MORE"); 446161475Sdelphij if (p != NULL && *p != '\0') 447161475Sdelphij less_is_more = 1; 448161475Sdelphij 44960786Sps for (o = option; o->oletter != '\0'; o++) 45060786Sps { 45160786Sps /* 45260786Sps * Set each variable to its default. 45360786Sps */ 45460786Sps if (o->ovar != NULL) 45560786Sps *(o->ovar) = o->odefault; 456128345Stjr if (o->otype & INIT_HANDLER) 457128345Stjr (*(o->ofunc))(INIT, (char *) NULL); 45860786Sps } 45960786Sps} 46060786Sps 46160786Sps/* 46260786Sps * Find an option in the option table, given its option letter. 46360786Sps */ 464128345Stjr public struct loption * 46560786Spsfindopt(c) 46660786Sps int c; 46760786Sps{ 468128345Stjr register struct loption *o; 46960786Sps 47060786Sps for (o = option; o->oletter != '\0'; o++) 47160786Sps { 47260786Sps if (o->oletter == c) 47360786Sps return (o); 474161475Sdelphij if ((o->otype & TRIPLE) && ASCII_TO_UPPER(o->oletter) == c) 47560786Sps return (o); 47660786Sps } 47760786Sps return (NULL); 47860786Sps} 47960786Sps 48060786Sps/* 481128345Stjr * 482128345Stjr */ 483128345Stjr static int 484128345Stjris_optchar(c) 485128345Stjr char c; 486128345Stjr{ 487161475Sdelphij if (ASCII_IS_UPPER(c)) 488128345Stjr return 1; 489161475Sdelphij if (ASCII_IS_LOWER(c)) 490128345Stjr return 1; 491128345Stjr if (c == '-') 492128345Stjr return 1; 493128345Stjr return 0; 494128345Stjr} 495128345Stjr 496128345Stjr/* 49760786Sps * Find an option in the option table, given its option name. 49860786Sps * p_optname is the (possibly partial) name to look for, and 49960786Sps * is updated to point after the matched name. 50060786Sps * p_oname if non-NULL is set to point to the full option name. 50160786Sps */ 502128345Stjr public struct loption * 50360786Spsfindopt_name(p_optname, p_oname, p_err) 50460786Sps char **p_optname; 50560786Sps char **p_oname; 50660786Sps int *p_err; 50760786Sps{ 50860786Sps char *optname = *p_optname; 509128345Stjr register struct loption *o; 51060786Sps register struct optname *oname; 51160786Sps register int len; 51260786Sps int uppercase; 513128345Stjr struct loption *maxo = NULL; 51460786Sps struct optname *maxoname = NULL; 51560786Sps int maxlen = 0; 51660786Sps int ambig = 0; 51760786Sps int exact = 0; 51860786Sps 51960786Sps /* 52060786Sps * Check all options. 52160786Sps */ 52260786Sps for (o = option; o->oletter != '\0'; o++) 52360786Sps { 52460786Sps /* 52560786Sps * Check all names for this option. 52660786Sps */ 52760786Sps for (oname = o->onames; oname != NULL; oname = oname->onext) 52860786Sps { 52960786Sps /* 53060786Sps * Try normal match first (uppercase == 0), 53160786Sps * then, then if it's a TRIPLE option, 53260786Sps * try uppercase match (uppercase == 1). 53360786Sps */ 53460786Sps for (uppercase = 0; uppercase <= 1; uppercase++) 53560786Sps { 53660786Sps len = sprefix(optname, oname->oname, uppercase); 537128345Stjr if (len <= 0 || is_optchar(optname[len])) 538128345Stjr { 539128345Stjr /* 540128345Stjr * We didn't use all of the option name. 541128345Stjr */ 542128345Stjr continue; 543128345Stjr } 54460786Sps if (!exact && len == maxlen) 54560786Sps /* 54660786Sps * Already had a partial match, 54760786Sps * and now there's another one that 54860786Sps * matches the same length. 54960786Sps */ 55060786Sps ambig = 1; 55160786Sps else if (len > maxlen) 55260786Sps { 55360786Sps /* 55460786Sps * Found a better match than 55560786Sps * the one we had. 55660786Sps */ 55760786Sps maxo = o; 55860786Sps maxoname = oname; 55960786Sps maxlen = len; 56060786Sps ambig = 0; 56189019Sps exact = (len == (int)strlen(oname->oname)); 56260786Sps } 56360786Sps if (!(o->otype & TRIPLE)) 56460786Sps break; 56560786Sps } 56660786Sps } 56760786Sps } 56860786Sps if (ambig) 56960786Sps { 57060786Sps /* 57160786Sps * Name matched more than one option. 57260786Sps */ 57360786Sps if (p_err != NULL) 57460786Sps *p_err = OPT_AMBIG; 57560786Sps return (NULL); 57660786Sps } 57760786Sps *p_optname = optname + maxlen; 57860786Sps if (p_oname != NULL) 579128345Stjr *p_oname = maxoname == NULL ? NULL : maxoname->oname; 58060786Sps return (maxo); 58160786Sps} 582