svn commit: r246931 - head/lib/libstand

Tim Kientzle kientzle at FreeBSD.org
Mon Feb 18 01:55:54 UTC 2013


Author: kientzle
Date: Mon Feb 18 01:55:53 2013
New Revision: 246931
URL: http://svnweb.freebsd.org/changeset/base/246931

Log:
  Add strtoul() to libstand by copying from libc and clipping out
  locale code.

Added:
  head/lib/libstand/strtoul.c
     - copied, changed from r246713, head/lib/libc/stdlib/strtoul.c
Modified:
  head/lib/libstand/Makefile
  head/lib/libstand/stand.h

Modified: head/lib/libstand/Makefile
==============================================================================
--- head/lib/libstand/Makefile	Mon Feb 18 01:37:55 2013	(r246930)
+++ head/lib/libstand/Makefile	Mon Feb 18 01:55:53 2013	(r246931)
@@ -39,7 +39,7 @@ CFLAGS+=	-msoft-float -D_STANDALONE
 
 # standalone components and stuff we have modified locally
 SRCS+=	gzguts.h zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \
-	globals.c pager.c printf.c strdup.c strerror.c strtol.c random.c \
+	globals.c pager.c printf.c strdup.c strerror.c strtol.c strtoul.c random.c \
 	sbrk.c twiddle.c zalloc.c zalloc_malloc.c
 
 # private (pruned) versions of libc string functions

Modified: head/lib/libstand/stand.h
==============================================================================
--- head/lib/libstand/stand.h	Mon Feb 18 01:37:55 2013	(r246930)
+++ head/lib/libstand/stand.h	Mon Feb 18 01:55:53 2013	(r246931)
@@ -261,6 +261,7 @@ extern u_long	random(void);
     
 /* imports from stdlib, locally modified */
 extern long	strtol(const char *, char **, int);
+extern unsigned long	strtoul(const char *, char **, int);
 extern char	*optarg;			/* getopt(3) external variables */
 extern int	optind, opterr, optopt, optreset;
 extern int	getopt(int, char * const [], const char *);

Copied and modified: head/lib/libstand/strtoul.c (from r246713, head/lib/libc/stdlib/strtoul.c)
==============================================================================
--- head/lib/libc/stdlib/strtoul.c	Tue Feb 12 16:57:20 2013	(r246713, copy source)
+++ head/lib/libstand/strtoul.c	Mon Feb 18 01:55:53 2013	(r246931)
@@ -42,7 +42,6 @@ __FBSDID("$FreeBSD$");
 #include <ctype.h>
 #include <errno.h>
 #include <stdlib.h>
-#include "xlocale_private.h"
 
 /*
  * Convert a string to an unsigned long integer.
@@ -51,14 +50,13 @@ __FBSDID("$FreeBSD$");
  * alphabets and digits are each contiguous.
  */
 unsigned long
-strtoul_l(const char * __restrict nptr, char ** __restrict endptr, int base, locale_t locale)
+strtoul(const char * __restrict nptr, char ** __restrict endptr, int base)
 {
 	const char *s;
 	unsigned long acc;
 	char c;
 	unsigned long cutoff;
 	int neg, any, cutlim;
-	FIX_LOCALE(locale);
 
 	/*
 	 * See strtol for comments as to the logic used.
@@ -66,7 +64,7 @@ strtoul_l(const char * __restrict nptr, 
 	s = nptr;
 	do {
 		c = *s++;
-	} while (isspace_l((unsigned char)c, locale));
+	} while (isspace((unsigned char)c));
 	if (c == '-') {
 		neg = 1;
 		c = *s++;
@@ -123,8 +121,3 @@ noconv:
 		*endptr = (char *)(any ? s - 1 : nptr);
 	return (acc);
 }
-unsigned long
-strtoul(const char * __restrict nptr, char ** __restrict endptr, int base)
-{
-	return strtoul_l(nptr, endptr, base, __get_locale());
-}


More information about the svn-src-head mailing list