chiark / gitweb /
Use EXIT_SUCCESS and EXIT_FAILURE
authorBen Harris <bjh21@bjh21.me.uk>
Sun, 10 Nov 2024 09:27:31 +0000 (09:27 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Sun, 10 Nov 2024 09:27:31 +0000 (09:27 +0000)
This is a bit of C pedantry.  POSIX requires that an exit status of
zero is success and non-zero is failure, but the C standard says no
such thing.  Instead it provides EXIT_SUCCESS and EXIT_FAILURE.  Since
Bedstead aspires to work on non-POSIX systems, it should use the
defined constants.  Also removing magic numbers is a good thing.

bedstead.c

index 2523e576061daaf084413bd0c1309bd7cec8e3c4..f30bac94766f7f1251f4f8010fbb2949e3bb8d08 100644 (file)
@@ -2733,7 +2733,7 @@ main(int argc, char **argv)
 
        if (argc == 2 && strcmp(argv[1], "--complement") == 0) {
                glyph_complement();
-               return 0;
+               return EXIT_SUCCESS;
        }
              
        while (argc > 1) {
@@ -2757,7 +2757,7 @@ main(int argc, char **argv)
                        break;
                } else if (argv[1][0] == '-') {
                        fprintf(stderr, "unknown option '%s'\n", argv[1]);
-                       return 1;
+                       return EXIT_FAILURE;
                } else break;
                argv++; argc--;
        next:;
@@ -2775,18 +2775,18 @@ main(int argc, char **argv)
                for (i = 1; i < argc; i++) {
                        if (y >= YSIZE) {
                                fprintf(stderr, "too many arguments\n");
-                               return 1;
+                               return EXIT_FAILURE;
                        }
                        u = strtoul(argv[i], &endptr, 0);
                        if (u > 077 || !argv[i] || *endptr) {
                                fprintf(stderr, "invalid argument \"%s\"\n",
                                        argv[i]);
-                               return 1;
+                               return EXIT_FAILURE;
                        }
                        data[y++] = u;
                }
                dochar(data, 0);
-               return 0;
+               return EXIT_SUCCESS;
        }
 
        /* Put glyphs into FontForge-compatible order. */
@@ -2935,7 +2935,7 @@ main(int argc, char **argv)
        }
        printf("EndChars\n");
        printf("EndSplineFont\n");
-       return 0;
+       return EXIT_SUCCESS;
 }
 
 static void