MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / static_get_options

Function static_get_options

extra/replace.c:150–216  ·  view source on GitHub ↗
(argc,argv)

Source from the content-addressed store, hash-verified

148 /* Initiates DEBUG - but no debugging here ! */
149
150static int static_get_options(argc,argv)
151register int *argc;
152register char **argv[];
153{
154 int help,version;
155 char *pos;
156
157 silent=verbose=help=0;
158
159 while (--*argc > 0 && *(pos = *(++*argv)) == '-' && pos[1] != '-') {
160 while (*++pos)
161 {
162 version=0;
163 switch((*pos)) {
164 case 's':
165 silent=1;
166 break;
167 case 'v':
168 verbose=1;
169 break;
170 case '#':
171 DBUG_PUSH (++pos);
172 pos= (char*) " "; /* Skip rest of arguments */
173 break;
174 case 'V':
175 version=1;
176 case 'I':
177 case '?':
178 help=1; /* Help text written */
179 printf("%s Ver 1.4 for %s at %s\n",my_progname,SYSTEM_TYPE,
180 MACHINE_TYPE);
181 if (version)
182 break;
183 puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n");
184 puts("This program replaces strings in files or from stdin to stdout.\n"
185 "It accepts a list of from-string/to-string pairs and replaces\n"
186 "each occurrence of a from-string with the corresponding to-string.\n"
187 "The first occurrence of a found string is matched. If there is\n"
188 "more than one possibility for the string to replace, longer\n"
189 "matches are preferred before shorter matches.\n\n"
190 "A from-string can contain these special characters:\n"
191 " \\^ Match start of line.\n"
192 " \\$ Match end of line.\n"
193 " \\b Match space-character, start of line or end of line.\n"
194 " For a end \\b the next replace starts locking at the end\n"
195 " space-character. A \\b alone in a string matches only a\n"
196 " space-character.\n");
197 printf("Usage: %s [-?svIV] from to from to ... -- [files]\n", my_progname);
198 puts("or");
199 printf("Usage: %s [-?svIV] from to from to ... < fromfile > tofile\n", my_progname);
200 puts("");
201 puts("Options: -? or -I \"Info\" -s \"silent\" -v \"verbose\"");
202 break;
203 default:
204 fprintf(stderr,"illegal option: -%c\n",*pos);
205 break;
206 }
207 }

Callers 1

mainFunction · 0.85

Calls 1

my_messageFunction · 0.85

Tested by

no test coverage detected