commit 90a6d10f4fcf1bd2577bbcca43b37c3389201fc0
parent 9411d4d4bca6717cc534c0c047b4370d98f8c278
Author: tgoodwin <tgoodwin>
Date: Wed, 28 Oct 1998 11:43:19 +0000
add braces to avoid "ambiguous" else
Diffstat:
M | fn.c | | | 3 | ++- |
M | getopt.c | | | 73 | +++++++++++++++++++++++++++++++++++++------------------------------------ |
2 files changed, 39 insertions(+), 37 deletions(-)
diff --git a/fn.c b/fn.c
@@ -243,13 +243,14 @@ extern void fnrm(char *name) {
extern void whatare_all_signals() {
int i;
for (i = 1; i < NUMOFSIGNALS; i++)
- if (*signals[i].name != '\0')
+ if (*signals[i].name != '\0') {
if (sighandlers[i] == SIG_IGN)
fprint(1, "fn %s {}\n", signals[i].name);
else if (sighandlers[i] == fn_handler)
fprint(1, "fn %S {%T}\n", signals[i].name, handlers[i]);
else
fprint(1, "fn %s\n", signals[i].name);
+ }
}
extern void prettyprint_fn(int fd, char *name, Node *n) {
diff --git a/getopt.c b/getopt.c
@@ -9,42 +9,43 @@ char *rc_optarg;
extern int rc_getopt(int argc, char **argv, char *opts) {
static int sp = 1;
- int c;
- char *cp;
+ int c;
+ char *cp;
if (rc_optind == 0) /* reset rc_getopt() */
rc_optind = sp = 1;
- if (sp == 1)
- if (rc_optind >= argc || argv[rc_optind][0] != '-' || argv[rc_optind][1] == '\0') {
- return -1;
- } else if (strcmp(argv[rc_optind], "--") == 0) {
- rc_optind++;
- return -1;
- }
- rc_optopt = c = argv[rc_optind][sp];
- if (c == ':' || (cp=strchr(opts, c)) == 0) {
- fprint(2, "%s: bad option: -%c\n", argv[0], c);
- if (argv[rc_optind][++sp] == '\0') {
- rc_optind++;
- sp = 1;
- }
- return '?';
- }
- if (*++cp == ':') {
- if (argv[rc_optind][sp+1] != '\0') {
- rc_optarg = &argv[rc_optind++][sp+1];
- } else if (++rc_optind >= argc) {
- fprint(2, "%s: option requires an argument -- %c\n", argv[0], c);
- sp = 1;
- return '?';
- } else
- rc_optarg = argv[rc_optind++];
- sp = 1;
- } else {
- if (argv[rc_optind][++sp] == '\0') {
- sp = 1;
- rc_optind++;
- }
- rc_optarg = NULL;
- }
- return c;
+ if (sp == 1) {
+ if (rc_optind >= argc || argv[rc_optind][0] != '-' || argv[rc_optind][1] == '\0') {
+ return -1;
+ } else if (strcmp(argv[rc_optind], "--") == 0) {
+ rc_optind++;
+ return -1;
+ }
+ }
+ rc_optopt = c = argv[rc_optind][sp];
+ if (c == ':' || (cp=strchr(opts, c)) == 0) {
+ fprint(2, "%s: bad option: -%c\n", argv[0], c);
+ if (argv[rc_optind][++sp] == '\0') {
+ rc_optind++;
+ sp = 1;
+ }
+ return '?';
+ }
+ if (*++cp == ':') {
+ if (argv[rc_optind][sp+1] != '\0') {
+ rc_optarg = &argv[rc_optind++][sp+1];
+ } else if (++rc_optind >= argc) {
+ fprint(2, "%s: option requires an argument -- %c\n", argv[0], c);
+ sp = 1;
+ return '?';
+ } else
+ rc_optarg = argv[rc_optind++];
+ sp = 1;
+ } else {
+ if (argv[rc_optind][++sp] == '\0') {
+ sp = 1;
+ rc_optind++;
+ }
+ rc_optarg = NULL;
+ }
+ return c;
}