MCPcopy Create free account
hub / github.com/Singular/Singular / ParseOpt

Function ParseOpt

ppcc/src/ppcc.cc:108–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106};
107
108int ParseOpt(Str *opt, char *arg) {
109 for (OptSpec *spec = optspecs; spec->name; spec++) {
110 Word len = strlen(spec->name);
111 if (len <= opt->len()) {
112 if (strncmp(spec->name, opt->c_str(), len) == 0) {
113 OptFunc handler = spec->handler;
114 switch (spec->argtype) {
115 case NoArg:
116 case IntegralArg:
117 if (handler) {
118 handler(opt, NULL);
119 } else {
120 AddArg(spec->mode, opt);
121 }
122 return 0;
123 case FollowArg:
124 if (!arg)
125 Error("missing argument");
126 if (handler) {
127 handler(opt, arg);
128 } else {
129 AddArg(spec->mode, opt);
130 AddArg(spec->mode, new Str(arg));
131 }
132 return 1;
133 case IntegralOrFollowArg:
134 if (len == opt->len()) {
135 if (!arg)
136 Error("missing argument");
137 if (handler) {
138 handler(opt, arg);
139 } else {
140 AddArg(spec->mode, opt);
141 AddArg(spec->mode, new Str(arg));
142 }
143 return 1;
144 } else {
145 if (handler) {
146 handler(opt, arg);
147 } else {
148 AddArg(spec->mode, opt);
149 }
150 return 0;
151 }
152 }
153 }
154 }
155 }
156 AddArg(ALL, opt);
157 return 0;
158}
159
160void TestOutputExecutable() {
161 if (mode == LINK) {

Callers 1

ParseArgsFunction · 0.85

Calls 4

AddArgFunction · 0.85
ErrorFunction · 0.85
c_strMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected