Upgrading printf

Change-Id: I78dbbf0d14e4d61f5dfbec53d3938453b3e03ee6
This commit is contained in:
Lionel Sambuc 2013-01-30 15:45:47 +01:00
parent 252a83f614
commit 2c96f0541b
7 changed files with 33 additions and 20 deletions

View file

@ -18,7 +18,7 @@ SUBDIR= add_route arp ash at backup banner basename btrace cal \
mesg mined mkfifo \
mount mt netconf nice acknm nohup \
nonamed od paste patch \
ping postinstall poweroff pr prep printf printroot \
ping postinstall poweroff pr prep printroot \
profile progressbar pr_routes ps pwd pwdauth \
ramdisk rarpd rawspeed rcp rdate readclock \
reboot remsync rev rget rlogin \

View file

@ -1,6 +0,0 @@
# $NetBSD: Makefile,v 1.9 2004/10/30 19:28:35 christos Exp $
# from: @(#)Makefile 8.1 (Berkeley) 6/6/93
PROG= printf
.include <bsd.prog.mk>

View file

@ -137,6 +137,7 @@
2012/10/17 12:00:00,usr.bin/nvi
2010/05/14 17:28:23,usr.bin/newgrp
2012/10/17 12:00:00,usr.bin/passwd
2012/10/17 12:00:00,usr.bin/printf
2010/02/19 16:35:27,usr.bin/sed
2010/05/27 08:40:19,usr.bin/seq
2012/10/17 12:00:00,usr.bin/sort

View file

@ -20,7 +20,7 @@ SUBDIR= \
\
nbperf newgrp nvi \
passwd \
\
printf \
\
\
sed seq \

8
usr.bin/printf/Makefile Normal file
View file

@ -0,0 +1,8 @@
# $NetBSD: Makefile,v 1.11 2011/08/16 10:37:21 christos Exp $
# from: @(#)Makefile 8.1 (Berkeley) 6/6/93
PROG= printf
COPTS.printf.c = -Wno-format-nonliteral
.include <bsd.prog.mk>

View file

@ -1,4 +1,4 @@
.\" $NetBSD: printf.1,v 1.22 2008/09/01 09:20:41 dholland Exp $
.\" $NetBSD: printf.1,v 1.24 2010/04/05 21:24:14 joerg Exp $
.\"
.\" Copyright (c) 1989, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@ -277,7 +277,7 @@ The
.Ar argument
is printed in the style
.Sm off
.Pf [\-]d Cm \&. No ddd Cm e No \\*(Pmdd
.Pf [\-]d Cm \&. No ddd Cm e No \*(Pmdd
.Sm on
where there
is one digit before the decimal point and the number after is equal to
@ -299,7 +299,7 @@ whichever gives full precision in minimum space.
Characters from the string
.Ar argument
are printed with backslash-escape sequences expanded.
.br
.Pp
The following additional backslash-escape sequences are supported:
.Bl -tag -width Ds
.It Cm \ec

View file

@ -1,4 +1,4 @@
/* $NetBSD: printf.c,v 1.33.8.1 2009/10/14 18:37:30 sborrill Exp $ */
/* $NetBSD: printf.c,v 1.35 2011/03/15 23:11:49 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@ -30,6 +30,20 @@
*/
#include <sys/cdefs.h>
#ifndef lint
#if !defined(BUILTIN) && !defined(SHELL)
__COPYRIGHT("@(#) Copyright (c) 1989, 1993\
The Regents of the University of California. All rights reserved.");
#endif
#endif
#ifndef lint
#if 0
static char sccsid[] = "@(#)printf.c 8.2 (Berkeley) 3/22/95";
#else
__RCSID("$NetBSD: printf.c,v 1.35 2011/03/15 23:11:49 christos Exp $");
#endif
#endif /* not lint */
#include <sys/types.h>
@ -44,7 +58,6 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <inttypes.h>
#ifdef __GNUC__
#define ESCAPE '\e'
@ -94,7 +107,6 @@ static char **gargv;
error = printf(f, func); \
}
#if 0
#define APF(cpp, f, func) { \
if (fieldwidth != -1) { \
if (precision != -1) \
@ -106,7 +118,6 @@ static char **gargv;
else \
error = asprintf(cpp, f, func); \
}
#endif
#ifdef main
int main(int, char *[]);
@ -143,7 +154,7 @@ int main(int argc, char *argv[])
format = *argv;
gargv = ++argv;
#define SKIP1 "#-+ 0"
#define SKIP1 "#-+ 0'"
#define SKIP2 "0123456789"
do {
/*
@ -238,8 +249,7 @@ int main(int argc, char *argv[])
t[b_length] = 0;
/* Get printf to calculate the lengths */
*fmt = 's';
abort();
/* APF(&a, start, t); */
APF(&a, start, t);
if (error == -1)
goto out;
b_fmt = a;
@ -609,7 +619,7 @@ getintmax(void)
return *(cp+1);
errno = 0;
val = strtol(cp, &ep, 0);
val = strtoimax(cp, &ep, 0);
check_conversion(cp, ep);
return val;
}
@ -638,7 +648,7 @@ getuintmax(void)
}
errno = 0;
val = strtoul(cp, &ep, 0);
val = strtoumax(cp, &ep, 0);
check_conversion(cp, ep);
return val;
}