[BACK]Return to opttbl.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / less

Annotation of src/usr.bin/less/opttbl.c, Revision 1.14

1.1       etheisen    1: /*
1.12      shadchin    2:  * Copyright (C) 1984-2012  Mark Nudelman
1.1       etheisen    3:  *
1.6       millert     4:  * You may distribute under the terms of either the GNU General Public
                      5:  * License or the Less License, as specified in the README file.
1.1       etheisen    6:  *
1.12      shadchin    7:  * For more information, see the README file.
1.1       etheisen    8:  */
1.14    ! nicm        9: /*
        !            10:  * Modified for use with illumos.
        !            11:  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
        !            12:  */
1.1       etheisen   13:
                     14: /*
                     15:  * The option table.
                     16:  */
                     17:
                     18: #include "less.h"
                     19: #include "option.h"
                     20:
                     21: /*
                     22:  * Variables controlled by command line options.
                     23:  */
1.14    ! nicm       24: int quiet;             /* Should we suppress the audible bell? */
        !            25: int how_search;                /* Where should forward searches start? */
        !            26: int top_scroll;                /* Repaint screen from top? (vs scroll from bottom) */
        !            27: int pr_type;           /* Type of prompt (short, medium, long) */
        !            28: int bs_mode;           /* How to process backspaces */
        !            29: int know_dumb;         /* Don't complain about dumb terminals */
        !            30: int quit_at_eof;       /* Quit after hitting end of file twice */
        !            31: int quit_if_one_screen;        /* Quit if EOF on first screen */
        !            32: int squeeze;           /* Squeeze multiple blank lines into one */
        !            33: int back_scroll;       /* Repaint screen on backwards movement */
        !            34: int forw_scroll;       /* Repaint screen on forward movement */
        !            35: int caseless;          /* Do "caseless" searches */
        !            36: int linenums;          /* Use line numbers */
        !            37: int autobuf;           /* Automatically allocate buffers as needed */
        !            38: int bufspace;          /* Max buffer space per file (K) */
        !            39: int ctldisp;           /* Send control chars to screen untranslated */
        !            40: int force_open;                /* Open the file even if not regular file */
        !            41: int swindow;           /* Size of scrolling window */
        !            42: int jump_sline;                /* Screen line of "jump target" */
        !            43: long jump_sline_fraction = -1;
        !            44: int chopline;          /* Truncate displayed lines at screen width */
        !            45: int no_init;           /* Disable sending ti/te termcap strings */
        !            46: int no_keypad;         /* Disable sending ks/ke termcap strings */
        !            47: int twiddle;           /* Show tildes after EOF */
        !            48: int show_attn;         /* Hilite first unread line */
        !            49: int status_col;                /* Display a status column */
        !            50: int use_lessopen;      /* Use the LESSOPEN filter */
        !            51: int quit_on_intr;      /* Quit on interrupt */
        !            52: int follow_mode;       /* F cmd Follows file desc or file name? */
        !            53: int oldbot;            /* Old bottom of screen behavior {{REMOVE}} */
        !            54: int opt_use_backslash; /* Use backslash escaping in option parsing */
        !            55: int hilite_search;     /* Highlight matched search patterns? */
1.1       etheisen   56:
1.14    ! nicm       57: int less_is_more = 0;  /* Make compatible with POSIX more */
1.10      shadchin   58:
1.1       etheisen   59: /*
1.6       millert    60:  * Long option names.
                     61:  */
1.14    ! nicm       62: static struct optname a_optname                = { "search-skip-screen",       NULL };
        !            63: static struct optname b_optname                = { "buffers",                  NULL };
        !            64: static struct optname B__optname       = { "auto-buffers",             NULL };
        !            65: static struct optname c_optname                = { "clear-screen",             NULL };
        !            66: static struct optname d_optname                = { "dumb",                     NULL };
        !            67: static struct optname e_optname                = { "quit-at-eof",              NULL };
        !            68: static struct optname f_optname                = { "force",                    NULL };
        !            69: static struct optname F__optname       = { "quit-if-one-screen",       NULL };
        !            70: static struct optname g_optname                = { "hilite-search",            NULL };
        !            71: static struct optname h_optname                = { "max-back-scroll",          NULL };
        !            72: static struct optname i_optname                = { "ignore-case",              NULL };
        !            73: static struct optname j_optname                = { "jump-target",              NULL };
        !            74: static struct optname J__optname       = { "status-column",            NULL };
        !            75: static struct optname k_optname                = { "lesskey-file",             NULL };
        !            76: static struct optname K__optname       = { "quit-on-intr",             NULL };
        !            77: static struct optname L__optname       = { "no-lessopen",              NULL };
        !            78: static struct optname m_optname                = { "long-prompt",              NULL };
        !            79: static struct optname n_optname                = { "line-numbers",             NULL };
        !            80: static struct optname o_optname                = { "log-file",                 NULL };
        !            81: static struct optname O__optname       = { "LOG-FILE",                 NULL };
        !            82: static struct optname p_optname                = { "pattern",                  NULL };
        !            83: static struct optname P__optname       = { "prompt",                   NULL };
        !            84: static struct optname q2_optname       = { "silent",                   NULL };
        !            85: static struct optname q_optname                = { "quiet",            &q2_optname };
        !            86: static struct optname r_optname                = { "raw-control-chars",        NULL };
        !            87: static struct optname s_optname                = { "squeeze-blank-lines",      NULL };
        !            88: static struct optname S__optname       = { "chop-long-lines",          NULL };
        !            89: static struct optname t_optname                = { "tag",                      NULL };
        !            90: static struct optname T__optname       = { "tag-file",                 NULL };
        !            91: static struct optname u_optname                = { "underline-special",        NULL };
        !            92: static struct optname V__optname       = { "version",                  NULL };
        !            93: static struct optname w_optname                = { "hilite-unread",            NULL };
        !            94: static struct optname x_optname                = { "tabs",                     NULL };
        !            95: static struct optname X__optname       = { "no-init",                  NULL };
        !            96: static struct optname y_optname                = { "max-forw-scroll",          NULL };
        !            97: static struct optname z_optname                = { "window",                   NULL };
        !            98: static struct optname quote_optname    = { "quotes",                   NULL };
        !            99: static struct optname tilde_optname    = { "tilde",                    NULL };
        !           100: static struct optname query_optname    = { "help",                     NULL };
        !           101: static struct optname pound_optname    = { "shift",                    NULL };
        !           102: static struct optname keypad_optname   = { "no-keypad",                NULL };
        !           103: static struct optname oldbot_optname   = { "old-bot",                  NULL };
        !           104: static struct optname follow_optname   = { "follow-name",              NULL };
        !           105: static struct optname use_backslash_optname = { "use-backslash",       NULL };
1.6       millert   106:
                    107:
                    108: /*
1.1       etheisen  109:  * Table of all options and their semantics.
1.6       millert   110:  *
                    111:  * For BOOL and TRIPLE options, odesc[0], odesc[1], odesc[2] are
                    112:  * the description of the option when set to 0, 1 or 2, respectively.
                    113:  * For NUMBER options, odesc[0] is the prompt to use when entering
1.14    ! nicm      114:  * a new value, and odesc[1] is the description, which should contain
1.6       millert   115:  * one %d which is replaced by the value of the number.
                    116:  * For STRING options, odesc[0] is the prompt to use when entering
                    117:  * a new value, and odesc[1], if not NULL, is the set of characters
                    118:  * that are valid in the string.
1.1       etheisen  119:  */
1.14    ! nicm      120: static struct loption option[] = {
1.6       millert   121:        { 'a', &a_optname,
1.10      shadchin  122:                TRIPLE, OPT_ONPLUS, &how_search, NULL,
1.6       millert   123:                {
                    124:                        "Search includes displayed screen",
                    125:                        "Search skips displayed screen",
1.10      shadchin  126:                        "Search includes all of displayed screen"
1.6       millert   127:                }
                    128:        },
                    129:
                    130:        { 'b', &b_optname,
1.14    ! nicm      131:                NUMBER|INIT_HANDLER, 64, &bufspace, opt_b,
1.6       millert   132:                {
                    133:                        "Max buffer space per file (K): ",
                    134:                        "Max buffer space per file: %dK",
                    135:                        NULL
                    136:                }
                    137:        },
                    138:        { 'B', &B__optname,
                    139:                BOOL, OPT_ON, &autobuf, NULL,
                    140:                {
                    141:                        "Don't automatically allocate buffers",
                    142:                        "Automatically allocate buffers when needed",
                    143:                        NULL
                    144:                }
                    145:        },
                    146:        { 'c', &c_optname,
1.14    ! nicm      147:                TRIPLE|MORE_OK, OPT_ON, &top_scroll, NULL,
1.6       millert   148:                {
                    149:                        "Repaint by scrolling from bottom of screen",
1.10      shadchin  150:                        "Repaint by painting from top of screen",
1.6       millert   151:                        "Repaint by painting from top of screen"
                    152:                }
                    153:        },
                    154:        { 'd', &d_optname,
1.14    ! nicm      155:                BOOL|MORE_OK|NO_TOGGLE, OPT_OFF, &know_dumb, NULL,
1.6       millert   156:                {
                    157:                        "Assume intelligent terminal",
                    158:                        "Assume dumb terminal",
                    159:                        NULL
                    160:                }
                    161:        },
                    162:        { 'e', &e_optname,
                    163:                TRIPLE, OPT_OFF, &quit_at_eof, NULL,
                    164:                {
                    165:                        "Don't quit at end-of-file",
                    166:                        "Quit at end-of-file",
                    167:                        "Quit immediately at end-of-file"
                    168:                }
                    169:        },
                    170:        { 'f', &f_optname,
                    171:                BOOL, OPT_OFF, &force_open, NULL,
                    172:                {
                    173:                        "Open only regular files",
                    174:                        "Open even non-regular files",
                    175:                        NULL
                    176:                }
                    177:        },
                    178:        { 'F', &F__optname,
                    179:                BOOL, OPT_OFF, &quit_if_one_screen, NULL,
                    180:                {
                    181:                        "Don't quit if end-of-file on first screen",
                    182:                        "Quit if end-of-file on first screen",
                    183:                        NULL
                    184:                }
1.1       etheisen  185:        },
1.6       millert   186:        { 'g', &g_optname,
                    187:                TRIPLE|HL_REPAINT, OPT_ONPLUS, &hilite_search, NULL,
                    188:                {
                    189:                        "Don't highlight search matches",
                    190:                        "Highlight matches for previous search only",
                    191:                        "Highlight all matches for previous search pattern",
                    192:                }
                    193:        },
                    194:        { 'h', &h_optname,
                    195:                NUMBER, -1, &back_scroll, NULL,
                    196:                {
                    197:                        "Backwards scroll limit: ",
                    198:                        "Backwards scroll limit is %d lines",
1.7       millert   199:                        NULL
                    200:                }
                    201:        },
1.6       millert   202:        { 'i', &i_optname,
                    203:                TRIPLE|HL_REPAINT, OPT_OFF, &caseless, opt_i,
                    204:                {
                    205:                        "Case is significant in searches",
                    206:                        "Ignore case in searches",
                    207:                        "Ignore case in searches and in patterns"
                    208:                }
                    209:        },
                    210:        { 'j', &j_optname,
1.10      shadchin  211:                STRING, 0, NULL, opt_j,
1.6       millert   212:                {
                    213:                        "Target line: ",
1.10      shadchin  214:                        "0123456789.-",
1.6       millert   215:                        NULL
                    216:                }
                    217:        },
                    218:        { 'J', &J__optname,
                    219:                BOOL|REPAINT, OPT_OFF, &status_col, NULL,
                    220:                {
                    221:                        "Don't display a status column",
                    222:                        "Display a status column",
                    223:                        NULL
                    224:                }
1.1       etheisen  225:        },
1.6       millert   226:        { 'k', &k_optname,
                    227:                STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_k,
                    228:                { NULL, NULL, NULL }
1.1       etheisen  229:        },
1.10      shadchin  230:        { 'K', &K__optname,
                    231:                BOOL, OPT_OFF, &quit_on_intr, NULL,
                    232:                {
                    233:                        "Interrupt (ctrl-C) returns to prompt",
                    234:                        "Interrupt (ctrl-C) exits less",
                    235:                        NULL
                    236:                }
1.6       millert   237:        },
                    238:        { 'L', &L__optname,
                    239:                BOOL, OPT_ON, &use_lessopen, NULL,
                    240:                {
                    241:                        "Don't use the LESSOPEN filter",
                    242:                        "Use the LESSOPEN filter",
                    243:                        NULL
                    244:                }
                    245:        },
                    246:        { 'm', &m_optname,
                    247:                TRIPLE, OPT_OFF, &pr_type, NULL,
                    248:                {
                    249:                        "Short prompt",
                    250:                        "Medium prompt",
                    251:                        "Long prompt"
                    252:                }
                    253:        },
                    254:        { 'n', &n_optname,
                    255:                TRIPLE|REPAINT, OPT_ON, &linenums, NULL,
                    256:                {
                    257:                        "Don't use line numbers",
                    258:                        "Use line numbers",
                    259:                        "Constantly display line numbers"
                    260:                }
1.1       etheisen  261:        },
1.6       millert   262:        { 'o', &o_optname,
                    263:                STRING, 0, NULL, opt_o,
                    264:                { "log file: ", NULL, NULL }
                    265:        },
                    266:        { 'O', &O__optname,
                    267:                STRING, 0, NULL, opt__O,
                    268:                { "Log file: ", NULL, NULL }
1.1       etheisen  269:        },
1.6       millert   270:        { 'p', &p_optname,
1.14    ! nicm      271:                STRING|NO_TOGGLE|NO_QUERY|MORE_OK, 0, NULL, opt_p,
1.6       millert   272:                { NULL, NULL, NULL }
                    273:        },
                    274:        { 'P', &P__optname,
                    275:                STRING, 0, NULL, opt__P,
                    276:                { "prompt: ", NULL, NULL }
                    277:        },
                    278:        { 'q', &q_optname,
                    279:                TRIPLE, OPT_OFF, &quiet, NULL,
                    280:                {
                    281:                        "Ring the bell for errors AND at eof/bof",
                    282:                        "Ring the bell for errors but not at eof/bof",
                    283:                        "Never ring the bell"
                    284:                }
                    285:        },
                    286:        { 'r', &r_optname,
                    287:                TRIPLE|REPAINT, OPT_OFF, &ctldisp, NULL,
                    288:                {
                    289:                        "Display control characters as ^X",
                    290:                        "Display control characters directly",
1.14    ! nicm      291:                        "Display control characters directly, "
        !           292:                        "processing ANSI sequences"
1.6       millert   293:                }
                    294:        },
                    295:        { 's', &s_optname,
1.14    ! nicm      296:                BOOL|REPAINT|MORE_OK, OPT_OFF, &squeeze, NULL,
1.6       millert   297:                {
                    298:                        "Display all blank lines",
                    299:                        "Squeeze multiple blank lines",
                    300:                        NULL
                    301:                }
                    302:        },
                    303:        { 'S', &S__optname,
                    304:                BOOL|REPAINT, OPT_OFF, &chopline, NULL,
                    305:                {
                    306:                        "Fold long lines",
                    307:                        "Chop long lines",
                    308:                        NULL
                    309:                }
1.1       etheisen  310:        },
1.6       millert   311:        { 't', &t_optname,
1.14    ! nicm      312:                STRING|NO_QUERY|MORE_OK, 0, NULL, opt_t,
1.6       millert   313:                { "tag: ", NULL, NULL }
                    314:        },
                    315:        { 'T', &T__optname,
1.14    ! nicm      316:                STRING|MORE_OK, 0, NULL, opt__T,
1.6       millert   317:                { "tags file: ", NULL, NULL }
1.1       etheisen  318:        },
1.6       millert   319:        { 'u', &u_optname,
                    320:                TRIPLE|REPAINT, OPT_OFF, &bs_mode, NULL,
                    321:                {
                    322:                        "Display underlined text in underline mode",
                    323:                        "Backspaces cause overstrike",
                    324:                        "Print backspace as ^H"
                    325:                }
                    326:        },
                    327:        { 'V', &V__optname,
                    328:                NOVAR, 0, NULL, opt__V,
                    329:                { NULL, NULL, NULL }
                    330:        },
                    331:        { 'w', &w_optname,
                    332:                TRIPLE|REPAINT, OPT_OFF, &show_attn, NULL,
                    333:                {
                    334:                        "Don't highlight first unread line",
                    335:                        "Highlight first unread line after forward-screen",
1.14    ! nicm      336:                        "Highlight first unread line after any "
        !           337:                        "forward movement",
1.6       millert   338:                }
                    339:        },
                    340:        { 'x', &x_optname,
                    341:                STRING|REPAINT, 0, NULL, opt_x,
                    342:                {
                    343:                        "Tab stops: ",
                    344:                        "0123456789,",
                    345:                        NULL
                    346:                }
                    347:        },
                    348:        { 'X', &X__optname,
                    349:                BOOL|NO_TOGGLE, OPT_OFF, &no_init, NULL,
                    350:                {
                    351:                        "Send init/deinit strings to terminal",
                    352:                        "Don't use init/deinit strings",
                    353:                        NULL
                    354:                }
                    355:        },
                    356:        { 'y', &y_optname,
                    357:                NUMBER, -1, &forw_scroll, NULL,
                    358:                {
                    359:                        "Forward scroll limit: ",
                    360:                        "Forward scroll limit is %d lines",
                    361:                        NULL
                    362:                }
                    363:        },
                    364:        { 'z', &z_optname,
                    365:                NUMBER, -1, &swindow, NULL,
                    366:                {
                    367:                        "Scroll window size: ",
                    368:                        "Scroll window size is %d lines",
                    369:                        NULL
                    370:                }
                    371:        },
                    372:        { '"', &quote_optname,
                    373:                STRING, 0, NULL, opt_quote,
                    374:                { "quotes: ", NULL, NULL }
                    375:        },
                    376:        { '~', &tilde_optname,
                    377:                BOOL|REPAINT, OPT_ON, &twiddle, NULL,
                    378:                {
                    379:                        "Don't show tildes after end of file",
                    380:                        "Show tildes after end of file",
                    381:                        NULL
                    382:                }
                    383:        },
                    384:        { '?', &query_optname,
                    385:                NOVAR, 0, NULL, opt_query,
                    386:                { NULL, NULL, NULL }
                    387:        },
                    388:        { '#', &pound_optname,
1.10      shadchin  389:                STRING, 0, NULL, opt_shift,
1.6       millert   390:                {
                    391:                        "Horizontal shift: ",
1.10      shadchin  392:                        "0123456789.",
1.6       millert   393:                        NULL
                    394:                }
                    395:        },
1.10      shadchin  396:        { OLETTER_NONE, &keypad_optname,
1.6       millert   397:                BOOL|NO_TOGGLE, OPT_OFF, &no_keypad, NULL,
                    398:                {
                    399:                        "Use keypad mode",
                    400:                        "Don't use keypad mode",
                    401:                        NULL
                    402:                }
1.1       etheisen  403:        },
1.10      shadchin  404:        { OLETTER_NONE, &oldbot_optname,
                    405:                BOOL, OPT_OFF, &oldbot, NULL,
                    406:                {
                    407:                        "Use new bottom of screen behavior",
                    408:                        "Use old bottom of screen behavior",
                    409:                        NULL
                    410:                }
                    411:        },
                    412:        { OLETTER_NONE, &follow_optname,
                    413:                BOOL, FOLLOW_DESC, &follow_mode, NULL,
                    414:                {
                    415:                        "F command follows file descriptor",
                    416:                        "F command follows file name",
1.12      shadchin  417:                        NULL
                    418:                }
                    419:        },
                    420:        { OLETTER_NONE, &use_backslash_optname,
                    421:                BOOL, OPT_OFF, &opt_use_backslash, NULL,
                    422:                {
                    423:                        "Use backslash escaping in command line parameters",
1.14    ! nicm      424:                        "Don't use backslash escaping in command line "
        !           425:                        "parameters",
1.10      shadchin  426:                        NULL
                    427:                }
                    428:        },
1.6       millert   429:        { '\0', NULL, NOVAR, 0, NULL, NULL, { NULL, NULL, NULL } }
1.1       etheisen  430: };
                    431:
                    432:
                    433: /*
                    434:  * Initialize each option to its default value.
                    435:  */
1.14    ! nicm      436: void
        !           437: init_option(void)
1.1       etheisen  438: {
1.14    ! nicm      439:        struct loption *o;
1.10      shadchin  440:
1.14    ! nicm      441:        for (o = option;  o->oletter != '\0';  o++) {
1.6       millert   442:                /*
1.1       etheisen  443:                 * Set each variable to its default.
                    444:                 */
                    445:                if (o->ovar != NULL)
                    446:                        *(o->ovar) = o->odefault;
1.6       millert   447:                if (o->otype & INIT_HANDLER)
1.14    ! nicm      448:                        (*(o->ofunc))(INIT, NULL);
1.1       etheisen  449:        }
                    450: }
                    451:
                    452: /*
1.6       millert   453:  * Find an option in the option table, given its option letter.
1.1       etheisen  454:  */
1.14    ! nicm      455: struct loption *
        !           456: findopt(int c)
1.1       etheisen  457: {
1.14    ! nicm      458:        struct loption *o;
1.1       etheisen  459:
1.14    ! nicm      460:        for (o = option;  o->oletter != '\0';  o++) {
1.1       etheisen  461:                if (o->oletter == c)
                    462:                        return (o);
1.14    ! nicm      463:                if ((o->otype & TRIPLE) && (toupper(o->oletter) == c))
1.1       etheisen  464:                        return (o);
                    465:        }
                    466:        return (NULL);
1.6       millert   467: }
                    468:
                    469: /*
                    470:  *
                    471:  */
1.14    ! nicm      472: static int
        !           473: is_optchar(char c)
1.6       millert   474: {
1.14    ! nicm      475:        if (isupper(c))
        !           476:                return (1);
        !           477:        if (islower(c))
        !           478:                return (1);
1.6       millert   479:        if (c == '-')
1.14    ! nicm      480:                return (1);
        !           481:        return (0);
1.6       millert   482: }
                    483:
                    484: /*
                    485:  * Find an option in the option table, given its option name.
                    486:  * p_optname is the (possibly partial) name to look for, and
                    487:  * is updated to point after the matched name.
                    488:  * p_oname if non-NULL is set to point to the full option name.
                    489:  */
1.14    ! nicm      490: struct loption *
        !           491: findopt_name(char **p_optname, char **p_oname, int *p_err)
1.6       millert   492: {
                    493:        char *optname = *p_optname;
1.14    ! nicm      494:        struct loption *o;
        !           495:        struct optname *oname;
        !           496:        int len;
1.6       millert   497:        int uppercase;
                    498:        struct loption *maxo = NULL;
                    499:        struct optname *maxoname = NULL;
                    500:        int maxlen = 0;
                    501:        int ambig = 0;
                    502:        int exact = 0;
                    503:
                    504:        /*
                    505:         * Check all options.
                    506:         */
1.14    ! nicm      507:        for (o = option;  o->oletter != '\0';  o++) {
1.6       millert   508:                /*
                    509:                 * Check all names for this option.
                    510:                 */
1.14    ! nicm      511:                for (oname = o->onames;  oname != NULL;  oname = oname->onext) {
        !           512:                        /*
1.6       millert   513:                         * Try normal match first (uppercase == 0),
                    514:                         * then, then if it's a TRIPLE option,
                    515:                         * try uppercase match (uppercase == 1).
                    516:                         */
1.14    ! nicm      517:                        for (uppercase = 0;  uppercase <= 1;  uppercase++) {
1.6       millert   518:                                len = sprefix(optname, oname->oname, uppercase);
1.14    ! nicm      519:                                if (len <= 0 || is_optchar(optname[len])) {
1.6       millert   520:                                        /*
                    521:                                         * We didn't use all of the option name.
                    522:                                         */
                    523:                                        continue;
                    524:                                }
1.14    ! nicm      525:                                if (!exact && len == maxlen) {
1.6       millert   526:                                        /*
                    527:                                         * Already had a partial match,
                    528:                                         * and now there's another one that
                    529:                                         * matches the same length.
                    530:                                         */
                    531:                                        ambig = 1;
1.14    ! nicm      532:                                } else if (len > maxlen) {
1.6       millert   533:                                        /*
                    534:                                         * Found a better match than
                    535:                                         * the one we had.
                    536:                                         */
                    537:                                        maxo = o;
                    538:                                        maxoname = oname;
                    539:                                        maxlen = len;
                    540:                                        ambig = 0;
1.14    ! nicm      541:                                        exact = (len == strlen(oname->oname));
1.6       millert   542:                                }
                    543:                                if (!(o->otype & TRIPLE))
                    544:                                        break;
                    545:                        }
                    546:                }
                    547:        }
1.14    ! nicm      548:        if (ambig) {
1.6       millert   549:                /*
                    550:                 * Name matched more than one option.
                    551:                 */
                    552:                if (p_err != NULL)
                    553:                        *p_err = OPT_AMBIG;
                    554:                return (NULL);
                    555:        }
                    556:        *p_optname = optname + maxlen;
                    557:        if (p_oname != NULL)
                    558:                *p_oname = maxoname == NULL ? NULL : maxoname->oname;
                    559:        return (maxo);
1.1       etheisen  560: }