From 988b95f15058c7a4dcdd9e439735503d99c5033f Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Tue, 22 Jun 2010 21:22:53 +0000 Subject: [PATCH] minix cut, printf from netbsd --- commands/Makefile | 2 +- commands/cut/Makefile | 3 +-- commands/cut/cut.c | 20 ++++++++------------ commands/printf/Makefile | 2 +- commands/printf/printf.c | 24 +++++++----------------- 5 files changed, 18 insertions(+), 33 deletions(-) diff --git a/commands/Makefile b/commands/Makefile index 409a5925b..2eeae97b3 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -20,7 +20,7 @@ SUBDIR= aal add_route adduser advent arp ash at autil awk \ mdb mesg mined mkdep mkdir mkdist mkfifo mkfs mknod \ mkproto modem mount mt netconf newroot nice nm nohup \ nonamed od packit packman passwd paste patch pax \ - ping postinstall poweroff pr prep printroot \ + ping postinstall poweroff pr prep printf printroot \ profile progressbar proto pr_routes ps pwd pwdauth \ ramdisk rarpd rawspeed rcp rdate readall readclock \ readfs reboot remsync rev rget rlogin rlogind rmdir \ diff --git a/commands/cut/Makefile b/commands/cut/Makefile index 1fa210486..3a6fb2909 100644 --- a/commands/cut/Makefile +++ b/commands/cut/Makefile @@ -1,10 +1,9 @@ # $NetBSD: Makefile,v 1.5 2007/07/02 18:41:03 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 -WARNS?= 4 PROG= cut LDADD+= -lutil DPADD+= ${LIBUTIL} -.include +.include diff --git a/commands/cut/cut.c b/commands/cut/cut.c index 30eff8dfc..eb9b9db89 100644 --- a/commands/cut/cut.c +++ b/commands/cut/cut.c @@ -33,17 +33,6 @@ */ #include -#ifndef lint -__COPYRIGHT("@(#) Copyright (c) 1989, 1993\ - The Regents of the University of California. All rights reserved."); -#endif /* not lint */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)cut.c 8.3 (Berkeley) 5/4/95"; -#endif -__RCSID("$NetBSD: cut.c,v 1.25 2008/07/21 14:19:22 lukem Exp $"); -#endif /* not lint */ #include #include @@ -58,6 +47,8 @@ __RCSID("$NetBSD: cut.c,v 1.25 2008/07/21 14:19:22 lukem Exp $"); #include #include +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) + static int bflag; static int cflag; static char dchar; @@ -88,15 +79,18 @@ main(int argc, char *argv[]) while ((ch = getopt(argc, argv, "b:c:d:f:sn")) != -1) switch(ch) { case 'b': + case 'c': fcn = b_cut; get_list(optarg); bflag = 1; break; +#if 0 case 'c': fcn = c_cut; get_list(optarg); cflag = 1; break; +#endif case 'd': dchar = *optarg; dflag = 1; @@ -146,7 +140,7 @@ static size_t autostart, autostop, maxval; static char *positions = NULL; static size_t numpositions = 0; -#define ALLOC_CHUNK _POSIX2_LINE_MAX /* malloc granularity */ +#define ALLOC_CHUNK 4096 /* malloc granularity */ static void get_list(char *list) @@ -296,7 +290,9 @@ usage(void) #include "x_cut.c" #undef CUT_BYTE +#if 0 /* make c_put(): */ #define CUT_BYTE 0 #include "x_cut.c" #undef CUT_BYTE +#endif diff --git a/commands/printf/Makefile b/commands/printf/Makefile index ec61ff2c5..df5f27a3f 100644 --- a/commands/printf/Makefile +++ b/commands/printf/Makefile @@ -4,4 +4,4 @@ PROG= printf WARNS= 3 -.include +.include diff --git a/commands/printf/printf.c b/commands/printf/printf.c index 386f4cdfc..532f64dab 100644 --- a/commands/printf/printf.c +++ b/commands/printf/printf.c @@ -30,20 +30,6 @@ */ #include -#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.33.8.1 2009/10/14 18:37:30 sborrill Exp $"); -#endif -#endif /* not lint */ #include @@ -58,6 +44,7 @@ __RCSID("$NetBSD: printf.c,v 1.33.8.1 2009/10/14 18:37:30 sborrill Exp $"); #include #include #include +#include #ifdef __GNUC__ #define ESCAPE '\e' @@ -107,6 +94,7 @@ static char **gargv; error = printf(f, func); \ } +#if 0 #define APF(cpp, f, func) { \ if (fieldwidth != -1) { \ if (precision != -1) \ @@ -118,6 +106,7 @@ static char **gargv; else \ error = asprintf(cpp, f, func); \ } +#endif #ifdef main int main(int, char *[]); @@ -249,7 +238,8 @@ int main(int argc, char *argv[]) t[b_length] = 0; /* Get printf to calculate the lengths */ *fmt = 's'; - APF(&a, start, t); + abort(); +/* APF(&a, start, t); */ if (error == -1) goto out; b_fmt = a; @@ -619,7 +609,7 @@ getintmax(void) return *(cp+1); errno = 0; - val = strtoimax(cp, &ep, 0); + val = strtol(cp, &ep, 0); check_conversion(cp, ep); return val; } @@ -648,7 +638,7 @@ getuintmax(void) } errno = 0; - val = strtoumax(cp, &ep, 0); + val = strtoul(cp, &ep, 0); check_conversion(cp, ep); return val; } -- 2.44.0