SCCS-vsn: usr.bin/printf/printf.1 5.5
SCCS-vsn: usr.bin/printf/printf.c 5.4
.\" 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%
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.
-.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
#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>
#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); \
- cnt += printf(f, fieldwidth, func); \
+ (void)printf(f, fieldwidth, func); \
- cnt += printf(f, precision, func); \
+ (void)printf(f, precision, func); \
- cnt += printf(f, func); \
+ (void)printf(f, func); \
{
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");
escape(fmt = format = *++argv); /* backslash interpretation */
gargv = ++argv;
escape(fmt = format = *++argv); /* backslash interpretation */
gargv = ++argv;
end = 0;
/* find next format specification */
next: for (start = fmt;; ++fmt) {
end = 0;
/* find next format specification */
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");
}
end = 1;
if (fmt > start)
}
end = 1;
if (fmt > start)
- cnt += printf("%s", start);
+ (void)printf("%s", start);
fmt = format;
goto next;
}
fmt = format;
goto next;
}
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");
}
default:
fprintf(stderr, "printf: illegal format character.\n");
}
default:
fprintf(stderr, "printf: illegal format character.\n");
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");
}
bcopy(str, copy, len - 3);
copy[len - 3] = 'l';
}
bcopy(str, copy, len - 3);
copy[len - 3] = 'l';