minix cut, printf from netbsd
This commit is contained in:
		
							parent
							
								
									ff26d9a4ff
								
							
						
					
					
						commit
						988b95f150
					
				@ -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 \
 | 
			
		||||
 | 
			
		||||
@ -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 <bsd.prog.mk>
 | 
			
		||||
.include <minix.prog.mk>
 | 
			
		||||
 | 
			
		||||
@ -33,17 +33,6 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <sys/cdefs.h>
 | 
			
		||||
#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 <ctype.h>
 | 
			
		||||
#include <err.h>
 | 
			
		||||
@ -58,6 +47,8 @@ __RCSID("$NetBSD: cut.c,v 1.25 2008/07/21 14:19:22 lukem Exp $");
 | 
			
		||||
#include <wchar.h>
 | 
			
		||||
#include <sys/param.h>
 | 
			
		||||
 | 
			
		||||
#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
 | 
			
		||||
 | 
			
		||||
@ -4,4 +4,4 @@
 | 
			
		||||
PROG=	printf
 | 
			
		||||
WARNS=	3
 | 
			
		||||
 | 
			
		||||
.include <bsd.prog.mk>
 | 
			
		||||
.include <minix.prog.mk>
 | 
			
		||||
 | 
			
		||||
@ -30,20 +30,6 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#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.33.8.1 2009/10/14 18:37:30 sborrill Exp $");
 | 
			
		||||
#endif
 | 
			
		||||
#endif /* not lint */
 | 
			
		||||
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
 | 
			
		||||
@ -58,6 +44,7 @@ __RCSID("$NetBSD: printf.c,v 1.33.8.1 2009/10/14 18:37:30 sborrill Exp $");
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <inttypes.h>
 | 
			
		||||
 | 
			
		||||
#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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user