os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/compat/strtol.c
First public contribution.
4 * Source code for the "strtol" library procedure.
6 * Copyright (c) 1988 The Regents of the University of California.
7 * Copyright (c) 1994 Sun Microsystems, Inc.
9 * See the file "license.terms" for information on usage and redistribution
10 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12 * RCS: @(#) $Id: strtol.c,v 1.4 2002/02/25 16:23:26 dgp Exp $
21 *----------------------------------------------------------------------
25 * Convert an ASCII string into an integer.
28 * The return value is the integer equivalent of string. If endPtr
29 * is non-NULL, then *endPtr is filled in with the character
30 * after the last one that was part of the integer. If string
31 * doesn't contain a valid integer value, then zero is returned
32 * and *endPtr is set to string.
37 *----------------------------------------------------------------------
41 strtol(string, endPtr, base)
42 CONST char *string; /* String of ASCII digits, possibly
43 * preceded by white space. For bases
44 * greater than 10, either lower- or
45 * upper-case digits may be used.
47 char **endPtr; /* Where to store address of terminating
48 * character, or NULL. */
49 int base; /* Base for conversion. Must be less
50 * than 37. If 0, then the base is chosen
51 * from the leading characters of string:
52 * "0x" means hex, "0" means octal, anything
56 register CONST char *p;
60 * Skip any leading blanks.
64 while (isspace(UCHAR(*p))) {
74 result = -(strtoul(p, endPtr, base));
79 result = strtoul(p, endPtr, base);
81 if ((result == 0) && (endPtr != 0) && (*endPtr == p)) {
82 *endPtr = (char *) string;