1N/A/*********************************************************************** 1N/A* This software is part of the ast package * 1N/A* Copyright (c) 1986-2010 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***********************************************************************/ 1N/A * common preprocessor command line argument parse 1N/A * called by optjoin() 1N/A"[-?\n@(#)$Id: cpp (AT&T Research) 2009-02-02 $\n]" 1N/A"[+NAME?cpp - C language preprocessor]" 1N/A"[+DESCRIPTION?\bcpp\b is the preprocessor for all C language dialects. It is" 1N/A" a standalone version of the \blibpp\b(3) preprocessor library. The" 1N/A" C dialect implemented by \bcpp\b is determined by probing \bcc\b(1)" 1N/A" using \bprobe\b(1). The path of the emulated compiler can be changed" 1N/A" by the \b-D-X\b command line option.]" 1N/A"[+?If \aoutput\a is omitted then the standard output is written; if \ainput\a" 1N/A" is also omitted then the standard input is read. NOTE: this is an" 1N/A" ancient, non-standard, non-intuitiive file operand syntax that is" 1N/A" required by \bcc\b(1); use shell file name expansion at your peril.]" 1N/A"[+?\bcpp\b specific options are set by the \b-D-\b and \b-I-\b options.]" 1N/A"[C:comments?Pass comments to the output. By default comments are omitted.]" 1N/A"[D:define?Define the macro \aname\a to have \avalue\a; \b1\b is assumed if" 1N/A" \b=\b\avalue\a is omitted. If \aname\a begins with \b:\b then it is" 1N/A" interpreted as a \blibpp\b(3) \b#pragma pp:\b statement; if \aname\a" 1N/A" begins with \b%\b then it is interpreted as a \blibpp\b(3) \b#\b" 1N/A" directive statement; if \aname\a begins with \b-\b or \b+\b then it is" 1N/A" interpreted as a \blibpp\b(3) option; \b-\b turns the option on," 1N/A" \b+\b turns it off. Most options have a \b#pragma\b counterpart that" 1N/A" is listed with the option definition. Right, this is ugly, but its the" 1N/A" only portable way to pass options through \bcc\b(1) to" 1N/A" \bcpp\b:]:[name[=value]]]{" 1N/A" [+-D-C, pp::compatibility?Preprocess for K&R compatibility.]" 1N/A" [+-D-D\alevel\a, \bpp::debug\b \alevel\a?Set the debug trace level." 1N/A" Higher levels produce more output. Levels higher than 3" 1N/A" enabled only in \b-g\b compiled versions.]" 1N/A" [+-D-F\aname\a?Set the main input file name to \aname\a. This only" 1N/A" affects error message and line sync output.]" 1N/A" [+-D-H, pp::hosted?All directories are hosted; compatibility" 1N/A" warning messages from hosted directory headers are suppressed.]" 1N/A" [+-D-I, pp::cdir?All directories contain C headers; used only with" 1N/A" [+-D-K, pp::keyargs?Enable the non-standard \aname=value\a macro" 1N/A" [+-D-L\b[\aid\a]], \bpp::lineid\b [\aid\a]]?Set the line sync directive" 1N/A" id to \aid\a or null if omitted.]" 1N/A" [+-D-M, pp::nomultiple?Disable multiple include detection.]" 1N/A" [+-D-P, pp::passthrough?Enable the non-standard passthrough mode; may" 1N/A" be useful for processing non-C input.]" 1N/A" [+-D-Q, pp::dump?Dump macro definitions to the output so that the" 1N/A" output may be passed through \bcpp\b again. Used for" 1N/A" generating precompiled headers.]" 1N/A" [+-D-R, pp::transition?Enable the transition preprocessing mode. Used" 1N/A" for compilers that can't make up their semantics between" 1N/A" [+-D-S, pp::strict?Enable strict preprocessing semantics and warnings." 1N/A" Works with any mode (compatibiliy, transition," 1N/A" or the default ISO).]" 1N/A" [+-D-T\atest\a, \bpp::test\b \atest\a?Enable implementation specific" 1N/A" test code according to \atest\a.]" 1N/A" [+-D-W, pp::warn?Enable warnings in non-hosted files.]" 1N/A" [+-D-X\b[\acc\a]]?Preprocess for the compiler \acc\a which must be" 1N/A" an executable path or an executable on \b$PATH\b.]" 1N/A" [+-D-Y, pp::pedantic?Enable pedantic \bpp::warn\b warnings in" 1N/A" non-hosted files.]" 1N/A" [+-D-Z, pp::pool?Enable pool mode. See \blibpp\b(3).]" 1N/A" [+-D-d?List canonicalized \b#define\b statements for non-predefined" 1N/A" macros in the output. ]" 1N/A" [+-D-m?List canonicalized \b#define\b statements for all macros. All" 1N/A" other output is disabled.]" 1N/A" [+-D-+, pp::plusplus?Preprocess for the C++ dialect.]" 1N/A"[I:include?Append \adirectory\a to the list of directories searched for" 1N/A" \b#include\b files. If \adirectory\a is \b-\b then: (1) \b-I\b" 1N/A" directories before \b-I-\b are searched only for \"...\" include" 1N/A" files; (2) \b-I\b directories after \b-I-\b are searched for" 1N/A" \"...\" and <...> include files; (3) the directory \b.\b is searched" 1N/A" only if it is explicitly specified by a \b-I\b option.]:?[directory]{" 1N/A" [+-I-C\adirectory\a, \bpp::cdir\b \adirectory\a?Mark \adirectory\a" 1N/A" as a C header directory. Used with \bpp:plusplus\b.]" 1N/A" [+-I-D[\afile\a]]?Read the default \bprobe\b(1) definitions from" 1N/A" \afile\a, or ignore the default definitions if \afile\a" 1N/A" [+-I-H\adirectory\a, \bpp::hostdir\b \adirectory\a?Mark \adirectory\a" 1N/A" as a hosted directory. Headers from hosted directories have" 1N/A" compatibility warnings disabled.]" 1N/A" [+-I-I\aheader\a, \bpp::ignore\b \aheader\a?Add \aheader\a to the" 1N/A" list of ignored headers.]" 1N/A" [+-I-M\afile\a?\afile\a contains a sequence of \aheader\a" 1N/A" [= \"\amap\a\" ]] lines, where \aheader\a is either <\aname\a>" 1N/A" or \"\aname\a\", and \"\amap\a\" is an explicit binding" 1N/A" for \aheader\a. \aheader\a is ignored if = \"\amap\a\" is" 1N/A" [+-I-R\afile\a?Include \afile\a but do not emit text or line syncs.]" 1N/A" [+-I-S\adirectory\a?Add \adirectory\a to the default standard include" 1N/A" [+-I-T\afile\a?Include \afile\a and emit text to the output file.]" 1N/A"[M:dependencies?Generate \bmake\b(1) dependencies. Not needed with" 1N/A" \bnmake\b(1). \b-M\b may be followed by optional \aflags\a to change" 1N/A" dependency output styles:]{" 1N/A" [+D?Generate dependencies in a separate \b.d\b file. Preprocessed" 1N/A" output is still written to \aoutput\a, or the standard output" 1N/A" if \aoutput\a is omitted.]" 1N/A" [+G?Generate missing dependencies too.]" 1N/A" [+M?Only generate local header dependencies; \ahosted\a headers are" 1N/A" omitted. Note that \ahosted\a headers are determined by" 1N/A" \b-I-H\b and the \bpp:hosted\b and \bpp:hostdir\b pragmas;" 1N/A" no special distiction is made between \"\" and <> \binclude\b" 1N/A"[P!:sync?Emit line syncs.]" 1N/A"[U:undefine?Remove the definition for the macro \aname\a.]:[name]" 1N/A"[A:assert?Enter the assertion via \b#assert\b for system V" 1N/A" compatibility.]:[assertion]" 1N/A"[E:preprocess?Ignored for compatibility with ancient compilers.]" 1N/A"[H:include-reference?Emit \b#include\b file paths on the standard error," 1N/A" one per line, indented to show nesting. If the optional \asize\a" 1N/A" argument is specified then the entire \b-H\b option is" 1N/A"[T?If not \bgcc\b(1) then truncate identifiers to \alength\a" 1N/A" characters for compatibility with old AT&T (I guess only Lucent needs" 1N/A" them now) compilers.]#?[length]" 1N/A"[V:version?Emit the \blibpp\b(3) version.]" 1N/A"[X:argmode?Enable \aname\a=\avalue\a macro arguments for \beasel\b(1)" 1N/A"[Y:standard?Add \adirectory\a to the list searched for" 1N/A" \b#include\b \b<...>\b files.]:[directory]" 1N/A"\n[ input [ output ] ]\n" 1N/A"[+SEE ALSO?\bcc\b(1), \bgcc\b(1), \blibpp\b(3)]" 1N/A * convert lint comments to pragmas 1N/A if (
strmatch(
comment,
"(ARGSUSED|PRINTFLIKE|PROTOLIB|SCANFLIKE|VARARGS)*([0-9])|CONSTCOND|CONSTANTCOND|CONSTANTCONDITION|EMPTY|FALLTHRU|FALLTHROUGH|LINTLIBRARY|LINTED*|NOTREACHED"))
1N/A * if last!=0 then argv[opt_info.index]==0 with return(0) 1N/A * else if argv[opt_info.index]==0 then return(0) 1N/A * otherwise argv[opt_info.index] is the first unrecognized 1N/A * option with return(1) 1N/A * use last=0 if the preprocessor is combined with other passes 1N/A * so that unknown options may be interpreted for those passes 1N/A * check the args and initialize 1N/A * this allows single arg pp option extensions 1N/A * without touching cc 1N/A * (not all cc wrappers have -W...) 1N/A while (c = *s++)
switch (c)
1N/A error(
1,
"%c%s: unknown -D option overload", n ?
'-' :
'+', s -
1);
1N/A /* historically ignored */ 1N/A * some compilers interpret `-I ...' as 1N/A * `-I-S' and arg ... while others interpret 1N/A if (*s && *s !=
'=' && *s !=
'-' && *s !=
'+')
1N/A n = *(p = s++) ==
'-';
1N/A if (!n && !*s) s = 0;
1N/A error(
1,
"%s: unknown -I option overload", p);
1N/A * System V CCS compatibility 1N/A /* else enable ANSI trigraphs -- default */ 1N/A if (*s !=
'I')
break;
1N/A * cross your fingers 1N/A ppop(
PP_DIRECTIVE,
"pragma pp:map \"/#(pragma )?import>/\" \"/#(pragma )?import(.*)/__STDPP__IMPORT__(\\2)/\"\n\ 1N/A#macdef __STDPP__IMPORT__(x)\n\ 1N/A#pragma pp:noallmultiple\n\ 1N/A#pragma pp:allmultiple\n\ 1N/A else if (
strmatch(s,
"*@(ansi|conform|pedantic|stand|std1|strict[!-])*"))
1N/A else if (
strmatch(s,
"*@(classic|compat|std0|tradition|[kK][n&+][rR])*"))
1N/A * ignore unknown options 1N/A * the probe info takes care of these 1N/A * fails if an option value is in the next arg 1N/A * and this is the last option 1N/A error(
1,
"%s: extraneous argument ignored", s);
1N/A * old versions allow options after file args