Mercurial > hg > octave-kai > gnulib-hg
comparison lib/getopt.c @ 496:39f6e38131a6
Get latest from FSF.
author | Jim Meyering <jim@meyering.net> |
---|---|
date | Wed, 18 Oct 1995 14:29:16 +0000 |
parents | 7ea6df68b1a1 |
children | 1df6981c6f31 |
comparison
equal
deleted
inserted
replaced
495:44604817c6e2 | 496:39f6e38131a6 |
---|---|
57 /* Don't include stdlib.h for non-GNU C libraries because some of them | 57 /* Don't include stdlib.h for non-GNU C libraries because some of them |
58 contain conflicting prototypes for getopt. */ | 58 contain conflicting prototypes for getopt. */ |
59 #include <stdlib.h> | 59 #include <stdlib.h> |
60 #endif /* GNU C library. */ | 60 #endif /* GNU C library. */ |
61 | 61 |
62 #ifndef _ | |
62 /* This is for other GNU distributions with internationalized messages. | 63 /* This is for other GNU distributions with internationalized messages. |
63 The GNU C Library itself does not yet support such messages. */ | 64 When compiling libc, the _ macro is predefined. */ |
64 #if HAVE_LIBINTL_H | 65 #ifdef HAVE_LIBINTL_H |
65 # include <libintl.h> | 66 # include <libintl.h> |
67 # define _(msgid) gettext (msgid) | |
66 #else | 68 #else |
67 # define gettext(msgid) (msgid) | 69 # define _(msgid) (msgid) |
70 #endif | |
68 #endif | 71 #endif |
69 | 72 |
70 /* This version of `getopt' appears to the caller like standard Unix `getopt' | 73 /* This version of `getopt' appears to the caller like standard Unix `getopt' |
71 but it behaves differently for the user, since it allows the user | 74 but it behaves differently for the user, since it allows the user |
72 to intersperse the options with the other arguments. | 75 to intersperse the options with the other arguments. |
519 } | 522 } |
520 | 523 |
521 if (ambig && !exact) | 524 if (ambig && !exact) |
522 { | 525 { |
523 if (opterr) | 526 if (opterr) |
524 fprintf (stderr, gettext ("%s: option `%s' is ambiguous\n"), | 527 fprintf (stderr, _("%s: option `%s' is ambiguous\n"), |
525 argv[0], argv[optind]); | 528 argv[0], argv[optind]); |
526 nextchar += strlen (nextchar); | 529 nextchar += strlen (nextchar); |
527 optind++; | 530 optind++; |
528 return '?'; | 531 return '?'; |
529 } | 532 } |
542 { | 545 { |
543 if (opterr) | 546 if (opterr) |
544 if (argv[optind - 1][1] == '-') | 547 if (argv[optind - 1][1] == '-') |
545 /* --option */ | 548 /* --option */ |
546 fprintf (stderr, | 549 fprintf (stderr, |
547 gettext ("%s: option `--%s' doesn't allow an argument\n"), | 550 _("%s: option `--%s' doesn't allow an argument\n"), |
548 argv[0], pfound->name); | 551 argv[0], pfound->name); |
549 else | 552 else |
550 /* +option or -option */ | 553 /* +option or -option */ |
551 fprintf (stderr, | 554 fprintf (stderr, |
552 gettext ("%s: option `%c%s' doesn't allow an argument\n"), | 555 _("%s: option `%c%s' doesn't allow an argument\n"), |
553 argv[0], argv[optind - 1][0], pfound->name); | 556 argv[0], argv[optind - 1][0], pfound->name); |
554 | 557 |
555 nextchar += strlen (nextchar); | 558 nextchar += strlen (nextchar); |
556 return '?'; | 559 return '?'; |
557 } | 560 } |
562 optarg = argv[optind++]; | 565 optarg = argv[optind++]; |
563 else | 566 else |
564 { | 567 { |
565 if (opterr) | 568 if (opterr) |
566 fprintf (stderr, | 569 fprintf (stderr, |
567 gettext ("%s: option `%s' requires an argument\n"), | 570 _("%s: option `%s' requires an argument\n"), |
568 argv[0], argv[optind - 1]); | 571 argv[0], argv[optind - 1]); |
569 nextchar += strlen (nextchar); | 572 nextchar += strlen (nextchar); |
570 return optstring[0] == ':' ? ':' : '?'; | 573 return optstring[0] == ':' ? ':' : '?'; |
571 } | 574 } |
572 } | 575 } |
590 { | 593 { |
591 if (opterr) | 594 if (opterr) |
592 { | 595 { |
593 if (argv[optind][1] == '-') | 596 if (argv[optind][1] == '-') |
594 /* --option */ | 597 /* --option */ |
595 fprintf (stderr, gettext ("%s: unrecognized option `--%s'\n"), | 598 fprintf (stderr, _("%s: unrecognized option `--%s'\n"), |
596 argv[0], nextchar); | 599 argv[0], nextchar); |
597 else | 600 else |
598 /* +option or -option */ | 601 /* +option or -option */ |
599 fprintf (stderr, gettext ("%s: unrecognized option `%c%s'\n"), | 602 fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), |
600 argv[0], argv[optind][0], nextchar); | 603 argv[0], argv[optind][0], nextchar); |
601 } | 604 } |
602 nextchar = (char *) ""; | 605 nextchar = (char *) ""; |
603 optind++; | 606 optind++; |
604 return '?'; | 607 return '?'; |
619 { | 622 { |
620 if (opterr) | 623 if (opterr) |
621 { | 624 { |
622 if (posixly_correct) | 625 if (posixly_correct) |
623 /* 1003.2 specifies the format of this message. */ | 626 /* 1003.2 specifies the format of this message. */ |
624 fprintf (stderr, gettext ("%s: illegal option -- %c\n"), | 627 fprintf (stderr, _("%s: illegal option -- %c\n"), |
625 argv[0], c); | 628 argv[0], c); |
626 else | 629 else |
627 fprintf (stderr, gettext ("%s: invalid option -- %c\n"), | 630 fprintf (stderr, _("%s: invalid option -- %c\n"), |
628 argv[0], c); | 631 argv[0], c); |
629 } | 632 } |
630 optopt = c; | 633 optopt = c; |
631 return '?'; | 634 return '?'; |
632 } | 635 } |
658 { | 661 { |
659 if (opterr) | 662 if (opterr) |
660 { | 663 { |
661 /* 1003.2 specifies the format of this message. */ | 664 /* 1003.2 specifies the format of this message. */ |
662 fprintf (stderr, | 665 fprintf (stderr, |
663 gettext ("%s: option requires an argument -- %c\n"), | 666 _("%s: option requires an argument -- %c\n"), |
664 argv[0], c); | 667 argv[0], c); |
665 } | 668 } |
666 optopt = c; | 669 optopt = c; |
667 if (optstring[0] == ':') | 670 if (optstring[0] == ':') |
668 c = ':'; | 671 c = ':'; |