1N/A/*********************************************************************** 1N/A* This software is part of the ast package * 1N/A* Copyright (c) 1985-2011 AT&T Intellectual Property * 1N/A* and is licensed under the * 1N/A* Common Public License, Version 1.0 * 1N/A* by AT&T Intellectual Property * 1N/A* A copy of the License is available at * 1N/A* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 1N/A* Information and Software Systems Research * 1N/A* Glenn Fowler <gsf@research.att.com> * 1N/A* David Korn <dgk@research.att.com> * 1N/A* Phong Vo <kpv@research.att.com> * 1N/A***********************************************************************/ 1N/A * command line option parser and usage formatter 1N/A * its a monster but its all in one place 1N/A * widen your window while you're at it 1N/A#
define OMIT "*@(\\[[-+]*\\?*\\]|\\@\\(#\\)|Copyright \\(c\\)|\\$\\I\\d\\: )*" 1N/A#
define GO '{' /* group nest open */ 1N/A#
define OG '}' /* group nest close */ 1N/A#
define sep(c) ((c)==
'-'||(c)==
'_')
1N/A const char*
match;
/* builtin help match name */ 1N/A const char*
name;
/* builtin help name */ 1N/A unsigned int size;
/* strlen text */ 1N/A const char*
text;
/* default message text */ 1N/A char text[
1];
/* saved text text */ 1N/A char*
ob;
/* next char in old string */ 1N/A char*
oe;
/* end of old string */ 1N/A char*
nb;
/* next char in new string */ 1N/A char*
ne;
/* end of new string */ 1N/A int ch;
/* localize() translation */ 1N/A int stop;
/* tab column position */ 1N/A 0,
2,
4,
10,
12,
18,
20,
26,
28,
34,
36,
42,
44,
50, 0,0
1N/A "",
"",
"",
"",
"",
"",
1N/A "",
"",
"",
"",
"",
"",
1N/A "</TT>",
"<TT>",
"\\fP",
"\\f5",
"",
"",
1N/A#
define Z(x) C(x),
sizeof(x)-
1 1N/A * translate with C_LC_MESSAGES_libast[] check 1N/A#
define Z(x) C(x),
sizeof(x)-
1 1N/A C(
"options available to all \bast\b commands"),
1N/A '+', C(
"DESCRIPTION"),
1N/A C(
"\b-?\b and \b--?\b* options are the same \ 1N/Afor all \bast\b commands. For any \aitem\a below, if \b--\b\aitem\a is not \ 1N/Asupported by a given command then it is equivalent to \b--\?\?\b\aitem\a. The \ 1N/A\b--\?\?\b form should be used for portability. All output is written to the \ 1N/A Z(
"List all implementation info."),
1N/A Z(
"List detailed info in program readable form."),
1N/A Z(
"List detailed help option info."),
1N/A Z(
"List detailed info in html."),
1N/A Z(
"List the usage translation key strings with C style escapes."),
1N/A Z(
"List long option usage."),
1N/A Z(
"List detailed info in displayed man page form."),
1N/A Z(
"List detailed info in nroff."),
1N/A Z(
"List short and long option details."),
1N/A Z(
"List posix getopt usage."),
1N/A Z(
"List short option usage."),
1N/A Z(
"List the usage string with C style escapes."),
1N/A ':', C(
"\?\?-\alabel\a"),
1N/A C(
"List implementation info matching \alabel\a*."),
1N/A ':', C(
"\?\?\aname\a"),
1N/A C(
"Equivalent to \b--help=\b\aname\a."),
1N/A C(
"Equivalent to \b--\?\?options\b."),
1N/A C(
"Equivalent to \b--\?\?man\b."),
1N/A ':', C(
"\?\?\?\?\?\?"),
1N/A C(
"Equivalent to \b--\?\?help\b."),
1N/A ':', C(
"\?\?\?\?\?\?\aitem\a"),
1N/A C(
"If the next argument is \b--\b\aoption\a then list \ 1N/Athe \aoption\a output in the \aitem\a style. Otherwise print \ 1N/A\bversion=\b\an\a where \an\a>0 if \b--\?\?\b\aitem\a is supported, \b0\b \ 1N/A ':', C(
"\?\?\?\?\?\?ESC"),
1N/A C(
"Emit escape codes even if output is not a terminal."),
1N/A ':', C(
"\?\?\?\?\?\?MAN[=\asection\a]]"),
1N/A C(
"List the \bman\b(1) section title for \asection\a [the \ 1N/Acurrent command]]."),
1N/A ':', C(
"\?\?\?\?\?\?SECTION"),
1N/A C(
"List the \bman\b(1) section number for the current command."),
1N/A ':', C(
"\?\?\?\?\?\?TEST"),
1N/A C(
"Massage the output for regression testing."),
1N/Astatic const char unknown[] = C(
"unknown option or attribute");
1N/A C(
"SYSTEM LIBRARY"),
1N/A C(
"GAMES and DEMOS"),
1N/A C(
"ADMINISTRATIVE COMMANDS"),
1N/A * list of common man page strings 1N/A * NOTE: add but do not delete from this table 1N/A { C(
"APPLICATION USAGE") },
1N/A { C(
"ASYNCHRONOUS EVENTS") },
1N/A { C(
"CONSEQUENCES OF ERRORS") },
1N/A { C(
"DESCRIPTION") },
1N/A { C(
"ENVIRONMENT VARIABLES") },
1N/A { C(
"EXIT STATUS") },
1N/A { C(
"EXTENDED DESCRIPTION") },
1N/A { C(
"INPUT FILES") },
1N/A { C(
"OUTPUT FILES") },
1N/A * 2007-03-19 move opt_info from _opt_info_ to (*_opt_data_) 1N/A * to allow future Opt_t growth 1N/A * by 2009 _opt_info_ can be static 1N/AOpt_t _opt_info_ = { 0,0,0,0,0,0,0,{0},{0},0,0,0,{0},{0},&
state };
1N/A * debug usage string segment format 1N/A "1M",
"MAKE ASSERTION OPERATORS AND RULES",
1N/A "1",
"USER COMMANDS",
1N/A "2",
"SYSTEM CALLS",
1N/A "3F",
"FORTRAN LIBRARY ROUTINES",
1N/A "3K",
"KERNEL VM LIBRARY FUNCTIONS",
1N/A "3L",
"LIGHTWEIGHT PROCESSES LIBRARY",
1N/A "3M",
"MATHEMATICAL LIBRARY",
1N/A "3N",
"NETWORK FUNCTIONS",
1N/A "3R",
"RPC SERVICES LIBRARY",
1N/A "3S",
"STANDARD I/O FUNCTIONS",
1N/A "3V",
"SYSTEM V LIBRARY",
1N/A "3",
"C LIBRARY FUNCTIONS",
1N/A "4F",
"PROTOCOL FAMILIES",
1N/A "4",
"DEVICES AND NETWORK INTERFACES",
1N/A "5",
"FILE FORMATS",
1N/A "6",
"GAMES AND DEMOS",
1N/A "7",
"PUBLIC FILES AND TABLES",
1N/A "8",
"ADMINISTRATIVE COMMANDS",
1N/A "L",
"LOCAL COMMANDS",
1N/A * return section name given abbreviation 1N/A s =
"COMPATIBILITY ";
1N/A s =
"MISCELLANEOUS ";
1N/A * pop the push stack 1N/A * skip over line space to the next token 1N/A while (*s ==
'\t' || *s ==
'\r' ||
version >=
1 && *s ==
' ')
1N/A while (*++s ==
' ' || *s ==
'\t' || *s ==
'\r');
1N/A * skip to t1 or t2 or t3, whichever first, in s 1N/A * n==0 outside [...] 1N/A * n==1 inside [...] before ? 1N/A * n==2 inside [...] after ? 1N/A * b==0 outside {...} 1N/A * past skips past the terminator to the next token 1N/A * otherwise a pointer to the terminator is returned 1N/A * ]] for ] inside [...] 1N/A * ?? for ? inside [...] before ? 1N/A * :: for : inside [...] before ? 1N/Askip(
register char* s,
register int t1,
register int t2,
register int t3,
register int n,
register int b,
int past,
int version)
1N/A else while (c = *s++)
1N/A if (n ==
1 && c ==
':' && *s == c)
1N/A * *s points to '(' on input 1N/A * return is one past matching ')' 1N/A * t translated if possible 1N/A * embedded { - _ ' } ignored 1N/A * * separates required prefix from optional suffix 1N/A * otherwise prefix match 1N/A for (n = 0; n <
2; n++)
1N/A if (*x ==
'*' && !v++ || *x ==
'\a')
1N/A }
while (*x !=
'\a');
1N/A if (j ==
':' || j ==
'|' || j ==
'?' || j ==
']' || j == 0)
1N/A while (w >
ww && *w != *x)
1N/A * prefix search for s in tab with num elements of size 1N/A * with optional translation 1N/A * save ap+bp+cp and return the saved pointer 1N/A * expand \f...\f info 1N/A * *p set to next char after second \f 1N/A * expanded value returned 1N/A register char* b = s;
1N/A while ((!e || s < e) && (c = *s++) && c !=
'\f');
1N/A * initialize the translation dictionary and flag maps 1N/A * initialize the attributes for pass p from opt string s 1N/A else if (*s++ ==
'-')
1N/A if (*s ==
'?' || *s ==
']')
1N/A while (*s && *s !=
']')
1N/A if ((c = *s++) ==
'?')
1N/A while (*s && *s !=
']')
1N/A n = n *
10 + (*s++ -
'0');
1N/A if (
strneq(s -
1,
"+NAME?",
6) && (s +=
5) ||
strneq(s -
1,
"+LIBRARY?",
9) && (s +=
8) && (l =
1) ||
strneq(s -
1,
"+PLUGIN?",
8) && (s +=
7) && (l =
1))
1N/A for (; *s ==
'\a' || *s ==
'\b' || *s ==
'\v' || *s ==
' '; s++);
1N/A if (*(s +
1) ==
'?' && *(s +
2) ==
'\f')
1N/A for (t = s; *t && *t !=
' ' && *t !=
']'; t++);
1N/A if (*(t -
1) ==
'\a' || *(t -
1) ==
'\b' || *(t -
1) ==
'\v')
1N/A while (*u ==
' ' || *u ==
'\\')
1N/A if (*u ==
'-' || *u ==
']')
1N/A for (t = s, a = 0; *t; t++)
1N/A if (!a && *t ==
'-')
1N/A * solaris long option compatibility 1N/A if (a = (c = *s++) ==
':')
1N/A while ((c = *s++) && c !=
')')
1N/A if (!c || (c = *s++) !=
'(')
1N/A * output label s from [ ...label...[?...] ] to sp 1N/A * 1 returned if the label was translated 1N/Alabel(
register Sfio_t*
sp,
int sep,
register char* s,
int about,
int z,
int level,
int style,
int f,
Sfio_t*
ip,
int version,
char*
id,
char*
catalog)
1N/A if (*++p ==
'?' || *p == *(p -
1))
1N/A label(
sp, 0, y, 0, -
1, 0,
style, f >= 0 ?
FONT_ITALIC : f,
ip,
version,
id,
catalog);
1N/A else if (*s ==
']' && *(s +
1) !=
']')
1N/A if (*t == c && *++t ==
'(')
1N/A if (t < e && *t ==
')' && t > w +
1)
1N/A for (q = s; q < w -
1; q++)
1N/A if (*q ==
':' && q < w -
2 && *(q +
1) ==
':')
1N/A for (t = s; t < e; t++)
1N/A if (!
isalnum(*t) && *t !=
'_' && *t !=
'.' && *t !=
'-')
1N/A sfprintf(
sp,
"<A href=\"mailto:%-.*s>%-.*s</A>>", t - s, s, t - s, s);
1N/A * output args description to sp from p of length n 1N/A register char* a = 0;
1N/A sfprintf(
sp,
"\t%s%s%s%s[%s%s%s%s%s]",
font(
FONT_BOLD,
style,
1), a,
font(
FONT_BOLD,
style, 0), b, b,
font(
FONT_ITALIC,
style,
1), o,
font(
FONT_ITALIC,
style, 0), b);
1N/A sfprintf(
sp,
"%*.*s%s%s%s[%s%s%s]",
OPT_USAGE -
1,
OPT_USAGE -
1, T(
NiL,
ID,
"Or:"), b, a, b, b, o, b);
1N/A while (n > 0 && (*p ==
' ' || *p ==
'\t'))
1N/A label(
sp,
sep, p, 0, n, 0,
style, 0,
ip,
version,
id,
catalog);
1N/A * output [+-...label...?...] label s to sp 1N/A * according to {...} level and style 1N/A * return 0:header 1:paragraph 1N/A label(
sp, 0, s +
1,
about, -
1,
level,
style,
FONT_LITERAL,
ip,
version,
id,
catalog);
1N/A else if (*s !=
']' && (*s !=
'?' || *(s +
1) ==
'?'))
1N/A if (s[-
1] ==
'-' && s[0] ==
'l' && s[
1] ==
'i' && s[
2] ==
'c' && s[
3] ==
'e' && s[
4] ==
'n' && s[
5] ==
's' && s[
6] ==
'e' && s[
7] ==
'?')
1N/A for (t = s +
8; *t && *t !=
']'; t++)
1N/A if (t[0] ==
'p' && (!
strncmp(t,
"proprietary",
11) || !
strncmp(t,
"private",
7)) || t[0] ==
'n' && !
strncmp(t,
"noncommercial",
13))
1N/A label(
sp, 0, s,
about, -
1,
level,
style, -
1,
ip,
version,
id,
catalog);
1N/A label(
sp, 0, s,
about, -
1,
level,
style,
level ?
FONT_BOLD : 0,
ip,
version,
id,
catalog);
1N/A label(
sp, 0, s,
about, -
1,
level,
style,
FONT_BOLD,
ip,
version,
id,
catalog);
1N/A * output text to sp from p according to style 1N/Astatic char*
textout(
Sfio_t*,
char*,
char*,
int,
int,
int,
int,
Sfio_t*,
int,
char*,
char*);
1N/Atrace_textout(
Sfio_t*
sp,
register char* p,
char*
conform,
int conformlen,
int style,
int level,
int bump,
Sfio_t*
ip,
int version,
char*
id,
char*
catalog,
int line)
1N/A p =
textout(
sp, p,
conform,
conformlen,
style,
level,
bump,
ip,
version,
id,
catalog);
1N/Atextout(
Sfio_t*
sp,
register char* s,
char*
conform,
int conformlen,
int style,
int level,
int bump,
Sfio_t*
ip,
int version,
char*
id,
char*
catalog)
1N/A#
define textout(
sp,s,
conform,
conformlen,
style,
level,
bump,
ip,
version,
id,
catalog)
trace_textout(
sp,s,
conform,
conformlen,
style,
level,
bump,
ip,
version,
id,
catalog,
__LINE__)
1N/A if (*(s +
1) ==
'-')
1N/A if ((c = *++s) !=
'-')
1N/A if (c ==
'+' || c ==
'-' && (
bump =
3) || c !=
' ' &&
level >
1)
1N/A if (c ==
'-' && (*t ==
'?' ||
isdigit(*t) || *s ==
'?' && *(s +
1) ==
'\n'))
1N/A if ((c = *s) !=
'?')
1N/A if (w[
1] ==
'@' && w[
2] ==
'(' && w[
3] ==
'#' && w[
4] ==
')')
1N/A else if (w[
1] ==
'$' && w[
2] ==
'I' && w[
3] ==
'd' && w[
4] ==
':' && w[
5] ==
' ')
1N/A *((t = w) +
1) =
'|';
1N/A if ((c ==
']' || c ==
'?' && *(s +
1) ==
']' && *(s +
2) !=
']' && s++) && (c = *(s =
next(s +
1,
version))) ==
GO)
1N/A s =
textout(
sp, s,
conform,
conformlen,
style,
level +
bump +
par +
1, 0,
ip,
version,
id,
catalog);
1N/A else if (c ==
'?' || c ==
' ')
1N/A if (*++s ==
'?' || *s == *(s -
1))
1N/A if (((c = *o++) ==
':' || c ==
'?') && *o == c)
1N/A if (((c = *v++) ==
':' || c ==
'?') && *v == c)
1N/A s =
textout(
sp, s, 0, 0,
style,
level +
bump + !
level, 0,
ip,
version,
id,
catalog);
1N/A else if (*s ==
'\f')
1N/A if (*t == c && *++t ==
'(')
1N/A if (*t ==
')' && t > w +
1)
1N/A for (q = s; q < w -
1; q++)
1N/A if (*q ==
':' && q < w -
2 && *(q +
1) ==
':')
1N/A if (
ident && *s ==
'$')
1N/A if (*(s +
1) !=
']')
1N/A while (*s ==
' ' || *s ==
'\t' || *s ==
'\r' || *s ==
'\n')
1N/A if (*s ==
']' && *(s +
1) !=
']' && (!
psp || !
psp->
ch))
1N/A for (t = s; *t; t++)
1N/A if (!
isalnum(*t) && *t !=
'_' && *t !=
'.' && *t !=
'-')
1N/A sfprintf(
sp,
"<A href=\"mailto:%-.*s\">%-.*s</A>>", t - s, s, t - s, s);
1N/A * generate optget() help [...] list from lp 1N/A * return pointer to help message sans `Usage: command' 1N/A * if oopts is 0 then state.pass is used 1N/A * 0 ?short by default, ?long if any long options used 1N/A * * otherwise see help_text[] (--???) 1N/A * external formatter: 1N/A * \f...\f discipline infof callback on ... 1N/A * internal formatter: 1N/A * margin flush pops to previous indent 1N/A * this is a workaround for static optjoin() data 1N/A * evaluating \f...\f -- it would be good to hide 1N/A * optjoin() interactions a bit more ... 1N/A return T(
NiL,
ID,
"[* call optget() before opthelp() *]");
1N/A for (q = o; q < e; q++)
1N/A for (q = o; q < e; q++)
1N/A if (a == 0 && (c ==
' ' || c ==
'\n' && *p ==
'\n'))
1N/A if (c ==
' ' && *p ==
']')
1N/A else if (a ==
'\n' || *p ==
'\n')
1N/A else if ((c ==
':' || c ==
'#') && (*p ==
'[' || *p ==
'?' && *(p +
1) ==
'[' && p++))
1N/A if (
vl > 0 && *p !=
'\a')
1N/A if (f && *p ==
'?' && *(p +
1) !=
'?')
1N/A if (*p ==
']' && *(p +
1) !=
']')
1N/A if (a ==
'\n' || *p ==
'\n')
1N/A if (z && (*p !=
']' || *(p +
1) ==
']'))
1N/A if (*p ==
'\n' || *p ==
' ')
1N/A while (*++p ==
' ' || *p ==
'\t' || *p ==
'\r');
1N/A if (*(p +
1) !=
'-')
1N/A p =
textout(
sp_misc, p,
cb,
cl,
style,
1,
3,
sp_info,
version,
id,
catalog);
1N/A if (*s !=
'-' || *(w +
1) ==
'-')
1N/A if (*(w +
1) ==
'-')
1N/A if (*(p +
1) ==
'-')
1N/A p =
textout(
sp, p,
cb,
cl,
style,
1,
3,
sp_info,
version,
id,
catalog);
1N/A p =
textout(
sp_body, p,
cb,
cl,
style, 0, 0,
sp_info,
version,
id,
catalog);
1N/A p =
textout(
sp, p,
cb,
cl,
style,
1,
3,
sp_info,
version,
id,
catalog);
1N/A p =
textout(
sp, p,
cb,
cl,
style,
1,
3,
sp_info,
version,
id,
catalog);
1N/A if (*(p +
1) ==
'|')
1N/A while (*++p && *p !=
'=' && *p !=
'!' && *p !=
':' && *p !=
'?');
1N/A if (*(p +
1) ==
'\f')
1N/A if (
sl || (p - s) ==
1 || *(s +
1) ==
'=' || *(s +
1) ==
'!' && (a |=
OPT_invert) || *(s +
1) ==
'|')
1N/A if (*p ==
':' || *p ==
'?')
1N/A if (*p ==
':' || *p ==
'?')
1N/A if (*++p ==
'?' || *p == *(p -
1))
1N/A label(
sp_body,
' ', w, 0, -
1, 0,
style,
FONT_BOLD,
sp_info,
version,
id,
catalog);
1N/A if (
label(
sp_body, 0, w, 0, -
1, 0,
style, 0,
sp_info,
version,
id,
catalog))
1N/A label(
sp_body, 0, w, 0, -
1, 0,
style, 0,
sp_info,
version,
id,
native);
1N/A label(
sp_body, 0, y, 0, -
1, 0,
style, 0,
sp_info,
version,
id,
catalog);
1N/A if (
label(
sp_body, 0, w, 0, -
1, 0,
style,
FONT_BOLD,
sp_info,
version,
id,
catalog))
1N/A label(
sp_body, 0, w, 0, -
1, 0,
style,
FONT_BOLD,
sp_info,
version,
id,
native);
1N/A label(
sp_body, 0, y, 0, -
1, 0,
style,
FONT_ITALIC,
sp_info,
version,
id,
catalog);
1N/A textout(
sp_body, d,
cb,
cl,
style, 0,
3,
sp_info,
version,
id,
catalog);
1N/A textout(
sp_body, u,
cb,
cl,
style, 0,
3,
sp_info,
version,
id,
catalog);
1N/A sfprintf(
sp_info,
" %s; -\b%c\b %s --\bno%-.*s\b.", T(
NiL,
ID,
"On by default"), f, T(
NiL,
ID,
"means"), u - w, w);
1N/A sfprintf(
sp_info,
" %s %s\bno%-.*s\b %s.", T(
NiL,
ID,
"On by default; use"),
"--"+
2-
prefix, u - w, w, T(
NiL,
ID,
"to turn off"));
1N/A textout(
sp_body, t, 0, 0,
style, 0, 0,
sp_info,
version,
NiL,
NiL);
1N/A p = u ?
skip(p +
1, 0, 0, 0, 0,
1,
1,
version) :
textout(
sp_body, p, 0, 0,
style,
4, 0,
sp_info,
version,
id,
catalog);
1N/A if (((c = *
ov++) ==
':' || c ==
'?') && *
ov == c)
1N/A textout(
sp_body, t, 0, 0,
style,
4, 0,
sp_info,
version,
NiL,
NiL);
1N/A if (((c = *v++) ==
':' || c ==
'?') && *v == c)
1N/A textout(
sp_body, t, 0, 0,
style,
4, 0,
sp_info,
version,
NiL,
NiL);
1N/A p =
textout(
sp_body, p, 0, 0,
style,
4, 0,
sp_info,
version,
id,
catalog);
1N/A for (t = p; *t ==
'\t' || *t ==
'\n'; t++);
1N/A while (t < &
ud[
sizeof(
ud)-
2] && (c = *s++))
1N/A while (t < &
rd[
sizeof(
rd)-
2] && (c = *s++) && c !=
']')
1N/A.\\\" format with nroff|troff|groff -man\n\ 1N/A.ie !'\\\\$1'-' \\{\n\ 1N/A.ds mO \\\\fB\\\\-\\\\$1\\\\fP\n\ 1N/A.ie '\\\\$2'-' \\{\n\ 1N/A.if !'\\\\$4'-' .as mO \\\\0\\\\fI\\\\$4\\\\fP\n\ 1N/A.as mO \\\\*(mS\\\\fB%s\\\\$2\\\\fP\n\ 1N/A.if !'\\\\$4'-' .as mO =\\\\fI\\\\$4\\\\fP\n\ 1N/A.if \\\\n(mH==2 .in 9n\n\ 1N/A.if \\\\n(mH==3 .in 13n\n\ 1N/A.if \\\\n(mH==4 .in 17n\n\ 1N/A for (; *t ==
'\n'; t++);
1N/A for (t = x +
xl; t > x && (*(t -
1) ==
'\n' || *(t -
1) ==
'\r'); t--);
1N/A while (t < &
ud[
sizeof(
ud)-
2] && (c = *s++))
1N/A sfprintf(
mp,
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n<HTML>\n<HEAD>\n<META name=\"generator\" content=\"optget (AT&T Research) 2010-04-22\">\n%s<TITLE>%s man document</TITLE>\n</HEAD>\n<BODY bgcolor=white>\n", (
state.
flags &
OPT_proprietary) ?
"<!--INTERNAL-->\n" :
"",
id);
1N/A sfprintf(
mp,
"<H4><TABLE width=100%%><TR><TH align=left> %s ( %s ) <TH align=center><A href=\".\" title=\"Index\">%s</A><TH align=right>%s ( %s )</TR></TABLE></H4>\n<HR>\n",
ud,
section, T(
NiL,
ID,
secname(
section)),
ud,
section);
1N/A while (*++p ==
'\n');
1N/A else if (n &&
strneq(p,
"/NOBR>",
6) && !--n)
1N/A for (y = p +=
6; (c = *p) && c !=
' ' && c !=
'\t' && c !=
'\n' && c !=
'<'; p++)
1N/A else if (c ==
'>' && !n)
1N/A for (y = --p; (c = *p) && c !=
' ' && c !=
'\t' && c !=
'\n' && c !=
'<'; p++)
1N/A if (*y++ ==
't' && *y++ ==
't' && *y++ ==
'p' && (*y ==
':' || *y++ ==
's' && *y ==
':') && *y++ ==
':' && *y++ ==
'/' && *y++ ==
'/')
1N/A while (
isalnum(*y) || *y ==
'_' || *y ==
'/' || *y ==
'-' || *y ==
'.')
1N/A while (
isalnum(*y) || *y ==
'_' || *y ==
'/' || *y ==
'-' || *y ==
'.' || *y ==
'?' || *y ==
'=' || *y ==
'%' || *y ==
'&' || *y ==
';' || *y ==
'#')
1N/A if (*(y -
1) ==
'.')
1N/A if (*y++ ==
'o' && *y++ ==
'p' && *y++ ==
'y' && *y++ ==
'r' && *y++ ==
'i' && *y++ ==
'g' && *y++ ==
'h' && *y++ ==
't' && *y++ ==
' ' && *y++ ==
'(' && (*y++ ==
'c' || *(y -
1) ==
'C') && *y++ ==
')')
1N/A }
while (c <
'a' || c >
'z');
1N/A else if (c !=
' ' && c !=
'\n')
1N/A * compatibility wrapper to opthelp() 1N/A * convert number using strtonll() *except* that 1N/A * 0*[[:digit:]].* is treated as [[:digit:]].* 1N/A * i.e., it looks octal but isn't, to meet 1N/A * posix Utility Argument Syntax -- use 1N/A * 0x.* or <base>#* for alternate bases 1N/A * point opt_info.arg to an error/info message for opt_info.name 1N/A * p points to opts location for opt_info.name 1N/A * optget() return value is returned 1N/A if (*p ==
'#' || *p ==
':')
1N/A if ((c = *s++) ==
'?' || c ==
']')
1N/A else if (*p ==
'*' || *p ==
'&')
1N/A p = *p ==
'&' ? C(
"ambiguous option argument value") : C(
"unknown option argument value");
1N/A else if (*p ==
'=' || *p ==
'!')
1N/A p = C(
"value not expected");
1N/A p = *(p +
1) ==
'?' ? C(
"optget: option not supported") : C(
"ambiguous option");
1N/A p = C(
"section not found");
1N/A p = C(
"unknown option");
1N/A * argv: command line argv where argv[0] is command name 1N/A * opts: option control string 1N/A * '[' [flag][=][index][:<long-name>[|<alias-name>...]['?'description]] ']' 1N/A * long option name, index, description; -index returned 1N/A * ':' option takes string arg 1N/A * '#' option takes numeric arg (concat option may follow) 1N/A * '?' (option) following options not in usage 1N/A * (following # or :) optional arg 1N/A * '[' '[' ... ] ... '[' ... ']' ']' 1N/A * mutually exclusive option grouping 1N/A * '[' name [:attr]* [?description] ']' 1N/A * (following # or :) optional option arg description 1N/A * '\n'[' '|'\t']* ignored for legibility 1N/A * ' ' ... optional argument(s) description (to end of string) 1N/A * or after blank line 1N/A * ']]' literal ']' within '[' ... ']' 1N/A * '?' usage: opt_info.arg points to message sans 1N/A * ':' error: opt_info.arg points to message sans `command: ' 1N/A * ':' '#' ' ' '[' ']' 1N/A * invalid option chars 1N/A * -- terminates option list and returns 0 1N/A * + as first opts char makes + equivalent to - 1N/A * if any # option is specified then numeric options (e.g., -123) 1N/A * are associated with the leftmost # option in opts 1N/A * usage info in placed opt_info.arg when '?' returned 1N/A * see help_text[] (--???) for more info 1N/A * these are not initialized by all dlls! 1N/A * check if any options remain and determine if the 1N/A * next option is short or long 1N/A * finished with the previous arg 1N/A * long with no prefix (dd style) 1N/A if ((c = *s) !=
'-' && c !=
'+')
1N/A * -- or ++ end of options 1N/A * ---* or +++* are operands 1N/A * long with double prefix 1N/A * short option char '-' 1N/A * long with single prefix (find style) 1N/A * short (always with single prefix) 1N/A * just a prefix is an option (e.g., `-' == stdin) 1N/A if ((*s ==
'n' || *s ==
'N') && (*(s +
1) ==
'o' || *(s +
1) ==
'O') && *(s +
2) && *(s +
2) !=
'=')
1N/A no = *(s +
2) ==
'-' ?
3 :
2;
1N/A for (c = *s; *s; s++)
1N/A if (*(s +
1) ==
'=')
1N/A * c the first character of the option 1N/A * w long option name if != 0, otherwise short 1N/A * v long option value (via =) if w != 0 1N/A * ? always triggers internal help 1N/A else if (w[0] !=
'?' || w[
1])
1N/A * no option can start with these characters 1N/A if (c ==
':' || c ==
'#' || c ==
' ' || c ==
'[' || c ==
']')
1N/A * this is a ksh getopts workaround 1N/A * the first loop pass 1N/A * initialized the cache 1N/A * so one more pass to 1N/A * check the cache or 1N/A * bail for a full scan 1N/A * the first loop pass 1N/A * were no matches so 1N/A * one more pass for C 1N/A if (k ==
'+' || k ==
'-')
1N/A if (*s ==
'*' || *s ==
'\a')
1N/A }
while (*s !=
'\a');
1N/A if (j ==
':' || j ==
'|' || j ==
'?' || j ==
']' || j == 0)
1N/A for (q = s; *q && !
sep(*q) && *q !=
'|' && *q !=
'?' && *q !=
']'; q++);
1N/A for (s = q; w > y && *w != *(s +
1); w--);
1N/A else if (*w != *(s +
1))
1N/A if (*s ==
'*' || *s ==
'\a')
1N/A }
while (*s !=
'\a');
1N/A if (j ==
':' || j ==
'|' || j ==
'?' || j ==
']' || j == 0)
1N/A for (q = s; *q && !
sep(*q) && *q !=
'|' && *q !=
'?' && *q !=
']'; q++);
1N/A for (s = q; w > y && *w != *(s +
1); w--);
1N/A else if (*w != *(s +
1))
1N/A if (!(n = (m || *s ==
':' || *s ==
'|' || *s ==
'?' || *s ==
']' || *s == 0)) && x)
1N/A for (x = k; *(f +
1) ==
'|' && (j = *(f +
2)) && j !=
'!' && j !=
'=' && j !=
':' && j !=
'?' && j !=
']'; f +=
2);
1N/A else if (*(f +
1) ==
':' || *(f +
1) ==
'!' && *(f +
2) ==
':')
1N/A if (*(a +
1) ==
'!')
1N/A if (*(a +
1) ==
'=')
1N/A else if (*v == *(v -
1))
1N/A else if (*(f +
1) ==
'=')
1N/A while (*(f +
1) ==
'|')
1N/A if (!(j = *f) || j ==
'!' || j ==
'=' || j ==
':' || j ==
'?' || j ==
']')
1N/A while (*(f +
1) ==
'|')
1N/A else if (j ==
'!' || j ==
'=' || j ==
':' || j ==
'?' || j ==
']')
1N/A else if (*(f +
1) !=
':' && *(f +
1) !=
'!' && *(f +
1) !=
']')
1N/A if (*(a +
1) ==
'!')
1N/A if (*(a +
1) ==
'=')
1N/A if (*(s +
1) ==
'#')
1N/A if (*(s +
2) ==
'?')
1N/A else if (*(s +
1) ==
':')
1N/A if (*(s +
2) ==
'?')
1N/A if (*++s ==
'?' || *s == *(s -
1))
1N/A if (v && (a == 0 || *a == 0 || *(a +
1) !=
':' && *(a +
1) !=
'#') && (*v ==
'0' || *v ==
'1') && !*(v +
1))
1N/A * this is a ksh getopts workaround 1N/A if (*(s +
1) !=
'?')
1N/A if (!v || *v ==
'1')
1N/A else if (*(s +
1) !=
'?')
1N/A if (*s ==
'+' || *s ==
'-')
1N/A if (*s ==
'*' || *s ==
'\a')
1N/A }
while (*s !=
'\a');
1N/A if (j ==
':' || j ==
'|' || j ==
'?' || j ==
']' || j == 0)
1N/A for (q = s; *q && !
sep(*q) && *q !=
'|' && *q !=
'?' && *q !=
']'; q++);
1N/A for (s = q; w > y && *w != *(s +
1); w--);
1N/A else if (*w != *(s +
1))
1N/A if (!(n = (m || *s ==
':' || *s ==
'|' || *s ==
'?' || *s ==
']')) && x)
1N/A for (x = k; *(f +
1) ==
'|' && (j = *(f +
2)) && j !=
'!' && j !=
'=' && j !=
':' && j !=
'?' && j !=
']'; f +=
2);
1N/A else if (*(f +
1) ==
':' || *(f +
1) ==
'!' && *(f +
2) ==
':')
1N/A if (*(a +
1) ==
'!')
1N/A if (*(a +
1) ==
'=')
1N/A if (v && *v ==
'?' && *(v +
1) ==
'?' && *(v +
2))
1N/A if ((s[0] ==
'n' || s[0] ==
'N') && (s[
1] ==
'o' || s[
1] ==
'O'))
1N/A * parse long options with 0,1,2 leading '-' or '+' from string and pass to optget() 1N/A * syntax is the unquoted 1N/A * <length> [-|+|--|++]<name>[[-+:|&=]=<value>\n (or \0 for the last) 1N/A * [-|+|--|++][no]name[[-+:|&=]=['"{(]value[)}"']][, ]... 1N/A * with \x escapes passed to chresc() 1N/A * return '#' for `label:', with opt_info.name==label 1N/A * str[opt_info.offset] next arg 1N/A * return '-' if arg, 0 otherwise 1N/A * use previous parsed str 1N/A register char* s = (
char*)
str;
1N/A while (*s ==
',' || *s ==
' ' || *s ==
'\t' || *s ==
'\n' || *s ==
'\r')
1N/A if (*s ==
'-' || *s ==
'+')
1N/A while (*s && *s !=
',' && *s !=
' ' && *s !=
'\t' && *s !=
'\n' && *s !=
'\r' && *s !=
'=' && *s !=
':')
1N/A if ((c = *s) ==
':' && *(s +
1) !=
'=')
1N/A if (c ==
':' || c ==
'=')
1N/A else if (c ==
',' || c ==
' ' || c ==
'\t' || c ==
'\n' || c ==
'\r')
1N/A else if (c ==
'"' || c ==
'\'')
1N/A if (*s++ ==
'-' && *s++ ==
'-' && *s)
1N/A while (*e++ = *s++);