MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / doargs

Function doargs

deps/lua/src/luac.c:70–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.85

Calls 1

usageFunction · 0.70

Tested by

no test coverage detected