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 \
 | 
						mdb mesg mined mkdep mkdir mkdist mkfifo mkfs mknod \
 | 
				
			||||||
	mkproto modem mount mt netconf newroot nice nm nohup \
 | 
						mkproto modem mount mt netconf newroot nice nm nohup \
 | 
				
			||||||
	nonamed od packit packman passwd paste patch pax \
 | 
						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 \
 | 
						profile progressbar proto pr_routes ps pwd pwdauth \
 | 
				
			||||||
	ramdisk rarpd rawspeed rcp rdate readall readclock \
 | 
						ramdisk rarpd rawspeed rcp rdate readall readclock \
 | 
				
			||||||
	readfs reboot remsync rev rget rlogin rlogind rmdir \
 | 
						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 $
 | 
					#	$NetBSD: Makefile,v 1.5 2007/07/02 18:41:03 christos Exp $
 | 
				
			||||||
#	@(#)Makefile	8.1 (Berkeley) 6/6/93
 | 
					#	@(#)Makefile	8.1 (Berkeley) 6/6/93
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WARNS?=	4
 | 
					 | 
				
			||||||
PROG=	cut
 | 
					PROG=	cut
 | 
				
			||||||
 | 
					
 | 
				
			||||||
LDADD+=	-lutil
 | 
					LDADD+=	-lutil
 | 
				
			||||||
DPADD+=	${LIBUTIL}
 | 
					DPADD+=	${LIBUTIL}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.include <bsd.prog.mk>
 | 
					.include <minix.prog.mk>
 | 
				
			||||||
 | 
				
			|||||||
@ -33,17 +33,6 @@
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <sys/cdefs.h>
 | 
					#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 <ctype.h>
 | 
				
			||||||
#include <err.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 <wchar.h>
 | 
				
			||||||
#include <sys/param.h>
 | 
					#include <sys/param.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define roundup(x, y)      ((((x)+((y)-1))/(y))*(y))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int bflag;
 | 
					static int bflag;
 | 
				
			||||||
static int	cflag;
 | 
					static int	cflag;
 | 
				
			||||||
static char	dchar;
 | 
					static char	dchar;
 | 
				
			||||||
@ -88,15 +79,18 @@ main(int argc, char *argv[])
 | 
				
			|||||||
	while ((ch = getopt(argc, argv, "b:c:d:f:sn")) != -1)
 | 
						while ((ch = getopt(argc, argv, "b:c:d:f:sn")) != -1)
 | 
				
			||||||
		switch(ch) {
 | 
							switch(ch) {
 | 
				
			||||||
		case 'b':
 | 
							case 'b':
 | 
				
			||||||
 | 
							case 'c':
 | 
				
			||||||
			fcn = b_cut;
 | 
								fcn = b_cut;
 | 
				
			||||||
			get_list(optarg);
 | 
								get_list(optarg);
 | 
				
			||||||
			bflag = 1;
 | 
								bflag = 1;
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
		case 'c':
 | 
							case 'c':
 | 
				
			||||||
			fcn = c_cut;
 | 
								fcn = c_cut;
 | 
				
			||||||
			get_list(optarg);
 | 
								get_list(optarg);
 | 
				
			||||||
			cflag = 1;
 | 
								cflag = 1;
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
		case 'd':
 | 
							case 'd':
 | 
				
			||||||
			dchar = *optarg;
 | 
								dchar = *optarg;
 | 
				
			||||||
			dflag = 1;
 | 
								dflag = 1;
 | 
				
			||||||
@ -146,7 +140,7 @@ static size_t autostart, autostop, maxval;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static char *positions = NULL;
 | 
					static char *positions = NULL;
 | 
				
			||||||
static size_t numpositions = 0;
 | 
					static size_t numpositions = 0;
 | 
				
			||||||
#define ALLOC_CHUNK	_POSIX2_LINE_MAX	/* malloc granularity */
 | 
					#define ALLOC_CHUNK	4096	/* malloc granularity */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
get_list(char *list)
 | 
					get_list(char *list)
 | 
				
			||||||
@ -296,7 +290,9 @@ usage(void)
 | 
				
			|||||||
#include "x_cut.c"
 | 
					#include "x_cut.c"
 | 
				
			||||||
#undef CUT_BYTE
 | 
					#undef CUT_BYTE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
/* make c_put(): */
 | 
					/* make c_put(): */
 | 
				
			||||||
#define CUT_BYTE 0
 | 
					#define CUT_BYTE 0
 | 
				
			||||||
#include "x_cut.c"
 | 
					#include "x_cut.c"
 | 
				
			||||||
#undef CUT_BYTE
 | 
					#undef CUT_BYTE
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -4,4 +4,4 @@
 | 
				
			|||||||
PROG=	printf
 | 
					PROG=	printf
 | 
				
			||||||
WARNS=	3
 | 
					WARNS=	3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.include <bsd.prog.mk>
 | 
					.include <minix.prog.mk>
 | 
				
			||||||
 | 
				
			|||||||
@ -30,20 +30,6 @@
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <sys/cdefs.h>
 | 
					#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>
 | 
					#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 <stdlib.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					#include <inttypes.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __GNUC__
 | 
					#ifdef __GNUC__
 | 
				
			||||||
#define ESCAPE '\e'
 | 
					#define ESCAPE '\e'
 | 
				
			||||||
@ -107,6 +94,7 @@ static char  **gargv;
 | 
				
			|||||||
		error = printf(f, func); \
 | 
							error = printf(f, func); \
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
#define APF(cpp, f, func) { \
 | 
					#define APF(cpp, f, func) { \
 | 
				
			||||||
	if (fieldwidth != -1) { \
 | 
						if (fieldwidth != -1) { \
 | 
				
			||||||
		if (precision != -1) \
 | 
							if (precision != -1) \
 | 
				
			||||||
@ -118,6 +106,7 @@ static char  **gargv;
 | 
				
			|||||||
	else \
 | 
						else \
 | 
				
			||||||
		error = asprintf(cpp, f, func); \
 | 
							error = asprintf(cpp, f, func); \
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef main
 | 
					#ifdef main
 | 
				
			||||||
int main(int, char *[]);
 | 
					int main(int, char *[]);
 | 
				
			||||||
@ -249,7 +238,8 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
				t[b_length] = 0;
 | 
									t[b_length] = 0;
 | 
				
			||||||
				/* Get printf to calculate the lengths */
 | 
									/* Get printf to calculate the lengths */
 | 
				
			||||||
				*fmt = 's';
 | 
									*fmt = 's';
 | 
				
			||||||
				APF(&a, start, t);
 | 
									abort();
 | 
				
			||||||
 | 
					/* APF(&a, start, t); */
 | 
				
			||||||
				if (error == -1)
 | 
									if (error == -1)
 | 
				
			||||||
					goto out;
 | 
										goto out;
 | 
				
			||||||
				b_fmt = a;
 | 
									b_fmt = a;
 | 
				
			||||||
@ -619,7 +609,7 @@ getintmax(void)
 | 
				
			|||||||
		return *(cp+1);
 | 
							return *(cp+1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	errno = 0;
 | 
						errno = 0;
 | 
				
			||||||
	val = strtoimax(cp, &ep, 0);
 | 
						val = strtol(cp, &ep, 0);
 | 
				
			||||||
	check_conversion(cp, ep);
 | 
						check_conversion(cp, ep);
 | 
				
			||||||
	return val;
 | 
						return val;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -648,7 +638,7 @@ getuintmax(void)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	errno = 0;
 | 
						errno = 0;
 | 
				
			||||||
	val = strtoumax(cp, &ep, 0);
 | 
						val = strtoul(cp, &ep, 0);
 | 
				
			||||||
	check_conversion(cp, ep);
 | 
						check_conversion(cp, ep);
 | 
				
			||||||
	return val;
 | 
						return val;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user