/[public]/getopt/trunk/getopt.c
ViewVC logotype

Diff of /getopt/trunk/getopt.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 322 Revision 323
115 free(BUFFER); 115 free(BUFFER);
116 116
117 if (!quote) { 117 if (!quote) {
118 /* Just copy arg */ 118 /* Just copy arg */
119 BUFFER = xmalloc(strlen(arg) + 1); 119 BUFFER = xmalloc(strlen(arg) + 1);
120
121 strcpy(BUFFER, arg); 120 strcpy(BUFFER, arg);
122 return BUFFER; 121 return BUFFER;
123 } 122 }
124 123
125 /* 124 /*
221 * we already sent a message, we just exit with a helpful hint. 220 * we already sent a message, we just exit with a helpful hint.
222 */ 221 */
223static void __attribute__ ((__noreturn__)) parse_error(const char *message) 222static void __attribute__ ((__noreturn__)) parse_error(const char *message)
224{ 223{
225 if (message) 224 if (message)
226 fprintf(stderr, "getopt: %s\n", message); 225 fprintf(stderr, "%s: %s\n", ,program_short_invocation_name, message);
227 fputs(_("Try `getopt --help' for more information.\n"), stderr); 226 fprintf(stderr, _("Try `%s --help' for more information.\n"),
227 program_invocation_short_name);
228 exit(PARAMETER_EXIT_CODE); 228 exit(PARAMETER_EXIT_CODE);
229} 229}
230 230
231static struct option *long_options = NULL; 231static struct option *long_options = NULL;
232static int long_options_length = 0; /* Length of array */ 232static int long_options_length = 0; /* Length of array */
320{ 320{
321 fputs(_("Usage: getopt optstring parameters\n"), stderr); 321 fputs(_("Usage: getopt optstring parameters\n"), stderr);
322 fputs(_(" getopt [options] [--] optstring parameters\n"), stderr); 322 fputs(_(" getopt [options] [--] optstring parameters\n"), stderr);
323 fputs(_(" getopt [options] -o|--options optstring [options] [--]\n"), stderr); 323 fputs(_(" getopt [options] -o|--options optstring [options] [--]\n"), stderr);
324 fputs(_(" parameters\n"), stderr); 324 fputs(_(" parameters\n"), stderr);
325 fputs(_("\nOptions:\n"), stderr);
325 fputs(_(" -a, --alternative Allow long options starting with single -\n"), stderr); 326 fputs(_(" -a, --alternative Allow long options starting with single -\n"), stderr);
326 fputs(_(" -h, --help This small usage guide\n"), stderr); 327 fputs(_(" -h, --help This small usage guide\n"), stderr);
327 fputs(_(" -l, --longoptions=longopts Long options to be recognized\n"), stderr); 328 fputs(_(" -l, --longoptions <longopts> Long options to be recognized\n"), stderr);
328 fputs(_(" -n, --name=progname The name under which errors are reported\n"), stderr); 329 fputs(_(" -n, --name <progname> The name under which errors are reported\n"), stderr);
329 fputs(_(" -o, --options=optstring Short options to be recognized\n"), stderr); 330 fputs(_(" -o, --options <optstring> Short options to be recognized\n"), stderr);
330 fputs(_(" -q, --quiet Disable error reporting by getopt(3)\n"), stderr); 331 fputs(_(" -q, --quiet Disable error reporting by getopt(3)\n"), stderr);
331 fputs(_(" -Q, --quiet-output No normal output\n"), stderr); 332 fputs(_(" -Q, --quiet-output No normal output\n"), stderr);
332 fputs(_(" -s, --shell=shell Set shell quoting conventions\n"), stderr); 333 fputs(_(" -s, --shell <shell> Set shell quoting conventions\n"), stderr);
333 fputs(_(" -T, --test Test for getopt(1) version\n"), stderr); 334 fputs(_(" -T, --test Test for getopt(1) version\n"), stderr);
334 fputs(_(" -u, --unqote Do not quote the output\n"), stderr); 335 fputs(_(" -u, --unquote Do not quote the output\n"), stderr);
335 fputs(_(" -V, --version Output version information\n"), stderr); 336 fputs(_(" -V, --version Output version information\n"), stderr);
337 fputc('\n', stderr);
338
336 exit(PARAMETER_EXIT_CODE); 339 exit(PARAMETER_EXIT_CODE);
337} 340}
338 341
339int main(int argc, char *argv[]) 342int main(int argc, char *argv[])
340{ 343{
428 return TEST_EXIT_CODE; 431 return TEST_EXIT_CODE;
429 case 'u': 432 case 'u':
430 quote = 0; 433 quote = 0;
431 break; 434 break;
432 case 'V': 435 case 'V':
433 printf(_("getopt (enhanced) 1.1.4\n")); 436 printf(_("%s (enhanced) %s\n"), program_invocation_short_name, program_version);
434 return EXIT_SUCCESS; 437 return EXIT_SUCCESS;
435 case '?': 438 case '?':
436 case ':': 439 case ':':
437 parse_error(NULL); 440 parse_error(NULL);
438 default: 441 default:

Legend:
Removed from v.322  
changed lines
  Added in v.323

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26