MCPcopy Create free account
hub / github.com/DFHack/dfhack / doargs

Function doargs

depends/lua/src/luac.c:72–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70#define IS(s) (strcmp(argv[i],s)==0)
71
72static int doargs(int argc, char* argv[])
73{
74 int i;
75 int version=0;
76 if (argv[0]!=NULL && *argv[0]!=0) progname=argv[0];
77 for (i=1; i<argc; i++)
78 {
79 if (*argv[i]!='-') /* end of options; keep it */
80 break;
81 else if (IS("--")) /* end of options; skip it */
82 {
83 ++i;
84 if (version) ++version;
85 break;
86 }
87 else if (IS("-")) /* end of options; use stdin */
88 break;
89 else if (IS("-l")) /* list */
90 ++listing;
91 else if (IS("-o")) /* output file */
92 {
93 output=argv[++i];
94 if (output==NULL || *output==0 || (*output=='-' && output[1]!=0))
95 usage("'-o' needs argument");
96 if (IS("-")) output=NULL;
97 }
98 else if (IS("-p")) /* parse only */
99 dumping=0;
100 else if (IS("-s")) /* strip debug information */
101 stripping=1;
102 else if (IS("-v")) /* show version */
103 ++version;
104 else /* unknown option */
105 usage(argv[i]);
106 }
107 if (i==argc && (listing || !dumping))
108 {
109 dumping=0;
110 argv[--i]=Output;
111 }
112 if (version)
113 {
114 printf("%s\n",LUA_COPYRIGHT);
115 if (version==argc-1) exit(EXIT_SUCCESS);
116 }
117 return i;
118}
119
120#define FUNCTION "(function()end)();"
121

Callers 1

mainFunction · 0.85

Calls 1

usageFunction · 0.85

Tested by

no test coverage detected