exit 0 on success, 1 on failure
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 17 Feb 1989 08:50:57 +0000 (00:50 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 17 Feb 1989 08:50:57 +0000 (00:50 -0800)
SCCS-vsn: usr.bin/printf/printf.1 5.5
SCCS-vsn: usr.bin/printf/printf.c 5.4

usr/src/usr.bin/printf/printf.1
usr/src/usr.bin/printf/printf.c

index 90dc69f..c26ac46 100644 (file)
@@ -13,7 +13,7 @@
 .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
 .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.\"    @(#)printf.1    5.4 (Berkeley) %G%
+.\"    @(#)printf.1    5.5 (Berkeley) %G%
 .\"
 .TH PRINTF 1 "
 .AT 1
 .\"
 .TH PRINTF 1 "
 .AT 1
@@ -227,12 +227,9 @@ Print a `%'; no argument is used.
 In no case does a non-existent or small field width cause truncation of
 a field; padding takes place only if the specified field width exceeds
 the actual width.
 In no case does a non-existent or small field width cause truncation of
 a field; padding takes place only if the specified field width exceeds
 the actual width.
-.SH DIAGNOSTICS
-None.
 .SH "RETURN VALUE"
 .SH "RETURN VALUE"
-.IR Printf 's
-exit value is the number of characters printed.  If an error occurs,
-printf exits with a -1.
+.IR Printf
+exits 0 on success, 1 on failure.
 .SH "SEE ALSO"
 printf(3)
 .SH BUGS
 .SH "SEE ALSO"
 printf(3)
 .SH BUGS
index 4b6529c..cec7c51 100644 (file)
@@ -22,7 +22,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)printf.c   5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)printf.c   5.4 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -31,13 +31,13 @@ static char sccsid[] = "@(#)printf.c        5.3 (Berkeley) %G%";
 #define PF(f, func) { \
        if (fieldwidth) \
                if (precision) \
 #define PF(f, func) { \
        if (fieldwidth) \
                if (precision) \
-                       cnt += printf(f, fieldwidth, precision, func); \
+                       (void)printf(f, fieldwidth, precision, func); \
                else \
                else \
-                       cnt += printf(f, fieldwidth, func); \
+                       (void)printf(f, fieldwidth, func); \
        else if (precision) \
        else if (precision) \
-               cnt += printf(f, precision, func); \
+               (void)printf(f, precision, func); \
        else \
        else \
-               cnt += printf(f, func); \
+               (void)printf(f, func); \
 }
 
 char **gargv;
 }
 
 char **gargv;
@@ -48,14 +48,14 @@ main(argc, argv)
 {
        static char *skip1, *skip2;
        register char *format, *fmt, *start;
 {
        static char *skip1, *skip2;
        register char *format, *fmt, *start;
-       register int end, cnt, fieldwidth, precision;
+       register int end, fieldwidth, precision;
        char convch, nextch, *getstr(), *index(), *mklong();
        double getdouble();
        long getlong();
 
        if (argc < 2) {
                fprintf(stderr, "usage: printf format [arg ...]\n");
        char convch, nextch, *getstr(), *index(), *mklong();
        double getdouble();
        long getlong();
 
        if (argc < 2) {
                fprintf(stderr, "usage: printf format [arg ...]\n");
-               exit(0);
+               exit(1);
        }
 
        /*
        }
 
        /*
@@ -71,7 +71,7 @@ main(argc, argv)
 
        escape(fmt = format = *++argv);         /* backslash interpretation */
        gargv = ++argv;
 
        escape(fmt = format = *++argv);         /* backslash interpretation */
        gargv = ++argv;
-       for (cnt = 0;;) {
+       for (;;) {
                end = 0;
                /* find next format specification */
 next:          for (start = fmt;; ++fmt) {
                end = 0;
                /* find next format specification */
 next:          for (start = fmt;; ++fmt) {
@@ -80,13 +80,13 @@ next:               for (start = fmt;; ++fmt) {
                                if (end == 1) {
                                        fprintf(stderr,
                                            "printf: missing format character.\n");
                                if (end == 1) {
                                        fprintf(stderr,
                                            "printf: missing format character.\n");
-                                       exit(0);
+                                       exit(1);
                                }
                                end = 1;
                                if (fmt > start)
                                }
                                end = 1;
                                if (fmt > start)
-                                       cnt += printf("%s", start);
+                                       (void)printf("%s", start);
                                if (!*gargv)
                                if (!*gargv)
-                                       exit(cnt);
+                                       exit(0);
                                fmt = format;
                                goto next;
                        }
                                fmt = format;
                                goto next;
                        }
@@ -109,7 +109,7 @@ next:               for (start = fmt;; ++fmt) {
                for (; index(skip2, *fmt); ++fmt);
                if (!*fmt) {
                        fprintf(stderr, "printf: missing format character.\n");
                for (; index(skip2, *fmt); ++fmt);
                if (!*fmt) {
                        fprintf(stderr, "printf: missing format character.\n");
-                       exit(-1);
+                       exit(1);
                }
 
                convch = *fmt;
                }
 
                convch = *fmt;
@@ -139,7 +139,7 @@ next:               for (start = fmt;; ++fmt) {
                }
                default:
                        fprintf(stderr, "printf: illegal format character.\n");
                }
                default:
                        fprintf(stderr, "printf: illegal format character.\n");
-                       exit(-1);
+                       exit(1);
                }
                *fmt = nextch;
        }
                }
                *fmt = nextch;
        }
@@ -156,7 +156,7 @@ mklong(str, ch)
        len = strlen(str) + 2;
        if (!(copy = malloc((u_int)len))) {     /* never freed; XXX */
                fprintf(stderr, "printf: out of memory.\n");
        len = strlen(str) + 2;
        if (!(copy = malloc((u_int)len))) {     /* never freed; XXX */
                fprintf(stderr, "printf: out of memory.\n");
-               exit(-1);
+               exit(1);
        }
        bcopy(str, copy, len - 3);
        copy[len - 3] = 'l';
        }
        bcopy(str, copy, len - 3);
        copy[len - 3] = 'l';