]>
cvs.zerfleddert.de Git - micropolis/blob - src/tcl/compat/strtol.c
4 * Source code for the "strtol" library procedure.
6 * Copyright 1988 Regents of the University of California
7 * Permission to use, copy, modify, and distribute this
8 * software and its documentation for any purpose and without
9 * fee is hereby granted, provided that the above copyright
10 * notice appear in all copies. The University of California
11 * makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without
13 * express or implied warranty.
17 static char rcsid
[] = "$Header: /sprite/src/lib/tcl/compat/RCS/strtol.c,v 1.1 91/09/22 15:42:49 ouster Exp $ SPRITE (Berkeley)";
24 *----------------------------------------------------------------------
28 * Convert an ASCII string into an integer.
31 * The return value is the integer equivalent of string. If endPtr
32 * is non-NULL, then *endPtr is filled in with the character
33 * after the last one that was part of the integer. If string
34 * doesn't contain a valid integer value, then zero is returned
35 * and *endPtr is set to string.
40 *----------------------------------------------------------------------
44 strtol(string
, endPtr
, base
)
45 char *string
; /* String of ASCII digits, possibly
46 * preceded by white space. For bases
47 * greater than 10, either lower- or
48 * upper-case digits may be used.
50 char **endPtr
; /* Where to store address of terminating
51 * character, or NULL. */
52 int base
; /* Base for conversion. Must be less
53 * than 37. If 0, then the base is chosen
54 * from the leading characters of string:
55 * "0x" means hex, "0" means octal, anything
63 * Skip any leading blanks.
77 result
= -(strtoul(p
, endPtr
, base
));
82 result
= strtoul(p
, endPtr
, base
);
84 if ((result
== 0) && (endPtr
!= 0) && (*endPtr
== p
)) {