From 2e8c0cc75244b2354fea2cba5f11277fe47deed4 Mon Sep 17 00:00:00 2001 From: Darren Tucker Date: Tue, 7 Oct 2003 17:49:56 +1000 Subject: - (dtucker) [configure.ac openbsd-compat/Makefile.in openbsd-compat/strtoul.c] Bug #670: add strtoul() to openbsd-compat for platforms lacking it. ok djm@ --- openbsd-compat/strtoul.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 openbsd-compat/strtoul.c (limited to 'openbsd-compat/strtoul.c') diff --git a/openbsd-compat/strtoul.c b/openbsd-compat/strtoul.c new file mode 100644 index 000000000..877e6a01f --- /dev/null +++ b/openbsd-compat/strtoul.c @@ -0,0 +1,112 @@ +/* + * Copyright (c) 1990 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "includes.h" +#ifndef HAVE_STRTOUL + +#if defined(LIBC_SCCS) && !defined(lint) +static char *rcsid = "$OpenBSD: strtoul.c,v 1.5 2003/06/02 20:18:38 millert Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include + +/* + * Convert a string to an unsigned long integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +unsigned long +strtoul(nptr, endptr, base) + const char *nptr; + char **endptr; + register int base; +{ + register const char *s; + register unsigned long acc, cutoff; + register int c; + register int neg, any, cutlim; + + /* + * See strtol for comments as to the logic used. + */ + s = nptr; + do { + c = (unsigned char) *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else { + neg = 0; + if (c == '+') + c = *s++; + } + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + cutoff = ULONG_MAX / (unsigned long)base; + cutlim = ULONG_MAX % (unsigned long)base; + for (acc = 0, any = 0;; c = (unsigned char) *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0) + continue; + if (acc > cutoff || acc == cutoff && c > cutlim) { + any = -1; + acc = ULONG_MAX; + errno = ERANGE; + } else { + any = 1; + acc *= (unsigned long)base; + acc += c; + } + } + if (neg && any > 0) + acc = -acc; + if (endptr != 0) + *endptr = (char *) (any ? s - 1 : nptr); + return (acc); +} +#endif /* !HAVE_STRTOUL */ -- cgit v1.2.3 From 3db2e4daf7333ac0b3ae90f23aa9668c7723ddfb Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Mon, 24 Nov 2003 13:33:34 +1100 Subject: - (djm) Annotate OpenBSD-derived files in openbsd-compat/ with original source file path (in OpenBSD tree). --- ChangeLog | 4 +++- openbsd-compat/base64.c | 2 ++ openbsd-compat/basename.c | 2 ++ openbsd-compat/daemon.c | 2 ++ openbsd-compat/dirname.c | 2 ++ openbsd-compat/getcwd.c | 2 ++ openbsd-compat/getgrouplist.c | 2 ++ openbsd-compat/getopt.c | 2 ++ openbsd-compat/getrrsetbyname.c | 2 ++ openbsd-compat/getrrsetbyname.h | 2 ++ openbsd-compat/glob.c | 2 ++ openbsd-compat/glob.h | 2 ++ openbsd-compat/inet_aton.c | 2 ++ openbsd-compat/inet_ntoa.c | 2 ++ openbsd-compat/inet_ntop.c | 2 ++ openbsd-compat/mktemp.c | 2 ++ openbsd-compat/readpassphrase.c | 2 ++ openbsd-compat/readpassphrase.h | 2 ++ openbsd-compat/realpath.c | 2 ++ openbsd-compat/rresvport.c | 2 ++ openbsd-compat/setenv.c | 2 ++ openbsd-compat/sigact.c | 2 ++ openbsd-compat/strlcat.c | 2 ++ openbsd-compat/strlcpy.c | 2 ++ openbsd-compat/strmode.c | 2 ++ openbsd-compat/strsep.c | 2 ++ openbsd-compat/strtoul.c | 2 ++ openbsd-compat/sys-queue.h | 2 ++ openbsd-compat/sys-tree.h | 2 ++ openbsd-compat/vis.c | 2 ++ openbsd-compat/vis.h | 2 ++ 31 files changed, 63 insertions(+), 1 deletion(-) (limited to 'openbsd-compat/strtoul.c') diff --git a/ChangeLog b/ChangeLog index 4f9a9d769..472988cd2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,8 @@ - dtucker@cvs.openbsd.org 2003/11/24 00:16:35 [ssh.1 ssh.c] Make ssh -k mean GSSAPIDelegateCredentials=no. Suggestion & ok markus@ + - (djm) Annotate OpenBSD-derived files in openbsd-compat/ with original + source file path (in OpenBSD tree). 20031122 - (dtucker) [channels.c] Make AIX write limit code clearer. Suggested by djm@ @@ -1530,4 +1532,4 @@ - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo. Report from murple@murple.net, diagnosis from dtucker@zip.com.au -$Id: ChangeLog,v 1.3129 2003/11/24 02:10:09 djm Exp $ +$Id: ChangeLog,v 1.3130 2003/11/24 02:33:34 djm Exp $ diff --git a/openbsd-compat/base64.c b/openbsd-compat/base64.c index 91a5ab0ed..dcaa03e5d 100644 --- a/openbsd-compat/base64.c +++ b/openbsd-compat/base64.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/net/base64.c */ + /* $OpenBSD: base64.c,v 1.4 2002/01/02 23:00:10 deraadt Exp $ */ /* diff --git a/openbsd-compat/basename.c b/openbsd-compat/basename.c index 2054c8068..552dc1e1c 100644 --- a/openbsd-compat/basename.c +++ b/openbsd-compat/basename.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/gen/basename.c */ + /* $OpenBSD: basename.c,v 1.11 2003/06/17 21:56:23 millert Exp $ */ /* diff --git a/openbsd-compat/daemon.c b/openbsd-compat/daemon.c index 6dd45f6a7..c0be5fff9 100644 --- a/openbsd-compat/daemon.c +++ b/openbsd-compat/daemon.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/gen/daemon.c */ + /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. diff --git a/openbsd-compat/dirname.c b/openbsd-compat/dirname.c index 1ab7516d8..25ab34dd6 100644 --- a/openbsd-compat/dirname.c +++ b/openbsd-compat/dirname.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/gen/dirname.c */ + /* $OpenBSD: dirname.c,v 1.10 2003/06/17 21:56:23 millert Exp $ */ /* diff --git a/openbsd-compat/getcwd.c b/openbsd-compat/getcwd.c index 31d1cfe93..19be59172 100644 --- a/openbsd-compat/getcwd.c +++ b/openbsd-compat/getcwd.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/gen/getcwd.c */ + /* * Copyright (c) 1989, 1991, 1993 * The Regents of the University of California. All rights reserved. diff --git a/openbsd-compat/getgrouplist.c b/openbsd-compat/getgrouplist.c index 085cda8c3..59c164f44 100644 --- a/openbsd-compat/getgrouplist.c +++ b/openbsd-compat/getgrouplist.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/gen/getgrouplist.c */ + /* * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. diff --git a/openbsd-compat/getopt.c b/openbsd-compat/getopt.c index 2136fbfcc..f5ee6778d 100644 --- a/openbsd-compat/getopt.c +++ b/openbsd-compat/getopt.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/stdlib/getopt.c */ + /* * Copyright (c) 1987, 1993, 1994 * The Regents of the University of California. All rights reserved. diff --git a/openbsd-compat/getrrsetbyname.c b/openbsd-compat/getrrsetbyname.c index 2307337a7..bb5451cd2 100644 --- a/openbsd-compat/getrrsetbyname.c +++ b/openbsd-compat/getrrsetbyname.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/net/getrrsetbyname.c */ + /* $OpenBSD: getrrsetbyname.c,v 1.7 2003/03/07 07:34:14 itojun Exp $ */ /* diff --git a/openbsd-compat/getrrsetbyname.h b/openbsd-compat/getrrsetbyname.h index 0739972fe..67937ef5f 100644 --- a/openbsd-compat/getrrsetbyname.h +++ b/openbsd-compat/getrrsetbyname.h @@ -1,3 +1,5 @@ +/* OPENBSD BASED ON : include/netdb.h */ + /* $OpenBSD: getrrsetbyname.c,v 1.4 2001/08/16 18:16:43 ho Exp $ */ /* diff --git a/openbsd-compat/glob.c b/openbsd-compat/glob.c index 50f35c304..7fafc8c40 100644 --- a/openbsd-compat/glob.c +++ b/openbsd-compat/glob.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/gen/glob.c */ + /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. diff --git a/openbsd-compat/glob.h b/openbsd-compat/glob.h index aceddbc48..3428b2013 100644 --- a/openbsd-compat/glob.h +++ b/openbsd-compat/glob.h @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: include/glob.h */ + /* $OpenBSD: glob.h,v 1.8 2003/06/02 19:34:12 millert Exp $ */ /* $NetBSD: glob.h,v 1.5 1994/10/26 00:55:56 cgd Exp $ */ diff --git a/openbsd-compat/inet_aton.c b/openbsd-compat/inet_aton.c index 5de49868d..c141bcc68 100644 --- a/openbsd-compat/inet_aton.c +++ b/openbsd-compat/inet_aton.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/net/inet_addr.c */ + /* $OpenBSD: inet_addr.c,v 1.7 2003/06/02 20:18:35 millert Exp $ */ /* diff --git a/openbsd-compat/inet_ntoa.c b/openbsd-compat/inet_ntoa.c index f9fdc9ee5..dc010dc53 100644 --- a/openbsd-compat/inet_ntoa.c +++ b/openbsd-compat/inet_ntoa.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/net/inet_ntoa.c */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. diff --git a/openbsd-compat/inet_ntop.c b/openbsd-compat/inet_ntop.c index 075eac44f..7031625b4 100644 --- a/openbsd-compat/inet_ntop.c +++ b/openbsd-compat/inet_ntop.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/net/inet_ntop.c */ + /* $OpenBSD: inet_ntop.c,v 1.5 2002/08/23 16:27:31 itojun Exp $ */ /* Copyright (c) 1996 by Internet Software Consortium. diff --git a/openbsd-compat/mktemp.c b/openbsd-compat/mktemp.c index 2cd747835..aff8d2005 100644 --- a/openbsd-compat/mktemp.c +++ b/openbsd-compat/mktemp.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/stdio/mktemp.c */ + /* THIS FILE HAS BEEN MODIFIED FROM THE ORIGINAL OPENBSD SOURCE */ /* Changes: Removed mktemp */ diff --git a/openbsd-compat/readpassphrase.c b/openbsd-compat/readpassphrase.c index 0d0baf569..4ee1be5de 100644 --- a/openbsd-compat/readpassphrase.c +++ b/openbsd-compat/readpassphrase.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/gen/readpassphrase.c */ + /* $OpenBSD: readpassphrase.c,v 1.16 2003/06/17 21:56:23 millert Exp $ */ /* diff --git a/openbsd-compat/readpassphrase.h b/openbsd-compat/readpassphrase.h index 92908a489..178edf346 100644 --- a/openbsd-compat/readpassphrase.h +++ b/openbsd-compat/readpassphrase.h @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: include/readpassphrase.h */ + /* $OpenBSD: readpassphrase.h,v 1.3 2002/06/28 12:32:22 millert Exp $ */ /* diff --git a/openbsd-compat/realpath.c b/openbsd-compat/realpath.c index 922305ffd..218fbecb2 100644 --- a/openbsd-compat/realpath.c +++ b/openbsd-compat/realpath.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/stdlib/realpath.c */ + /* * Copyright (c) 1994 * The Regents of the University of California. All rights reserved. diff --git a/openbsd-compat/rresvport.c b/openbsd-compat/rresvport.c index 608a3b184..75167065c 100644 --- a/openbsd-compat/rresvport.c +++ b/openbsd-compat/rresvport.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/net/rresvport.c */ + /* * Copyright (c) 1995, 1996, 1998 Theo de Raadt. All rights reserved. * Copyright (c) 1983, 1993, 1994 diff --git a/openbsd-compat/setenv.c b/openbsd-compat/setenv.c index c9941c195..b7ba0ce83 100644 --- a/openbsd-compat/setenv.c +++ b/openbsd-compat/setenv.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/stdlib/setenv.c */ + /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. diff --git a/openbsd-compat/sigact.c b/openbsd-compat/sigact.c index 35fbab0eb..2772ac574 100644 --- a/openbsd-compat/sigact.c +++ b/openbsd-compat/sigact.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libcurses/base/sigaction.c */ + /* $OpenBSD: sigaction.c,v 1.3 1999/06/27 08:14:21 millert Exp $ */ /**************************************************************************** diff --git a/openbsd-compat/strlcat.c b/openbsd-compat/strlcat.c index cae16657c..70f01cb2a 100644 --- a/openbsd-compat/strlcat.c +++ b/openbsd-compat/strlcat.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/string/strlcat.c */ + /* $OpenBSD: strlcat.c,v 1.11 2003/06/17 21:56:24 millert Exp $ */ /* diff --git a/openbsd-compat/strlcpy.c b/openbsd-compat/strlcpy.c index c8fe29987..ccfa12a0a 100644 --- a/openbsd-compat/strlcpy.c +++ b/openbsd-compat/strlcpy.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/string/strlcpy.c */ + /* $OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $ */ /* diff --git a/openbsd-compat/strmode.c b/openbsd-compat/strmode.c index adf5e273e..ea8d515e3 100644 --- a/openbsd-compat/strmode.c +++ b/openbsd-compat/strmode.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/string/strmode.c */ + /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. diff --git a/openbsd-compat/strsep.c b/openbsd-compat/strsep.c index b13671343..330d84ce1 100644 --- a/openbsd-compat/strsep.c +++ b/openbsd-compat/strsep.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/string/strsep.c */ + /* $OpenBSD: strsep.c,v 1.5 2003/06/11 21:08:16 deraadt Exp $ */ /*- diff --git a/openbsd-compat/strtoul.c b/openbsd-compat/strtoul.c index 877e6a01f..24d0e253d 100644 --- a/openbsd-compat/strtoul.c +++ b/openbsd-compat/strtoul.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/stdlib/strtoul.c */ + /* * Copyright (c) 1990 Regents of the University of California. * All rights reserved. diff --git a/openbsd-compat/sys-queue.h b/openbsd-compat/sys-queue.h index dd5c47525..8ff19e452 100644 --- a/openbsd-compat/sys-queue.h +++ b/openbsd-compat/sys-queue.h @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: sys/sys/queue.h */ + /* $OpenBSD: queue.h,v 1.23 2003/06/02 23:28:21 millert Exp $ */ /* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */ diff --git a/openbsd-compat/sys-tree.h b/openbsd-compat/sys-tree.h index 927ca04cd..73cfbe72a 100644 --- a/openbsd-compat/sys-tree.h +++ b/openbsd-compat/sys-tree.h @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: sys/sys/tree.h */ + /* $OpenBSD: tree.h,v 1.7 2002/10/17 21:51:54 art Exp $ */ /* * Copyright 2002 Niels Provos diff --git a/openbsd-compat/vis.c b/openbsd-compat/vis.c index e6a2ce98d..1fb7a01e3 100644 --- a/openbsd-compat/vis.c +++ b/openbsd-compat/vis.c @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: lib/libc/gen/vis.c */ + /*- * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. diff --git a/openbsd-compat/vis.h b/openbsd-compat/vis.h index 1c131cc85..663355a24 100644 --- a/openbsd-compat/vis.h +++ b/openbsd-compat/vis.h @@ -1,3 +1,5 @@ +/* OPENBSD ORIGINAL: include/vis.h */ + /* $OpenBSD: vis.h,v 1.6 2003/06/02 19:34:12 millert Exp $ */ /* $NetBSD: vis.h,v 1.4 1994/10/26 00:56:41 cgd Exp $ */ -- cgit v1.2.3