| 1 |
207 |
jeremybenn |
/*
|
| 2 |
|
|
FUNCTION
|
| 3 |
|
|
<<wcstoull>>---wide string to unsigned long long
|
| 4 |
|
|
|
| 5 |
|
|
INDEX
|
| 6 |
|
|
wcstoull
|
| 7 |
|
|
INDEX
|
| 8 |
|
|
_wcstoull_r
|
| 9 |
|
|
|
| 10 |
|
|
ANSI_SYNOPSIS
|
| 11 |
|
|
#include <wchar.h>
|
| 12 |
|
|
unsigned long long wcstoull(const wchar_t *<[s]>, wchar_t **<[ptr]>,
|
| 13 |
|
|
int <[base]>);
|
| 14 |
|
|
|
| 15 |
|
|
unsigned long long _wcstoull_r(void *<[reent]>, const wchar_t *<[s]>,
|
| 16 |
|
|
wchar_t **<[ptr]>, int <[base]>);
|
| 17 |
|
|
|
| 18 |
|
|
TRAD_SYNOPSIS
|
| 19 |
|
|
#include <wchar.h>
|
| 20 |
|
|
unsigned long long wcstoull(<[s]>, <[ptr]>, <[base]>)
|
| 21 |
|
|
wchar_t *<[s]>;
|
| 22 |
|
|
wchar_t **<[ptr]>;
|
| 23 |
|
|
int <[base]>;
|
| 24 |
|
|
|
| 25 |
|
|
unsigned long long _wcstoull_r(<[reent]>, <[s]>, <[ptr]>, <[base]>)
|
| 26 |
|
|
wchar_t *<[reent]>;
|
| 27 |
|
|
wchar_t *<[s]>;
|
| 28 |
|
|
wchar_t **<[ptr]>;
|
| 29 |
|
|
int <[base]>;
|
| 30 |
|
|
|
| 31 |
|
|
DESCRIPTION
|
| 32 |
|
|
The function <<wcstoull>> converts the wide string <<*<[s]>>> to
|
| 33 |
|
|
an <<unsigned long long>>. First, it breaks down the string into three parts:
|
| 34 |
|
|
leading whitespace, which is ignored; a subject string consisting
|
| 35 |
|
|
of the digits meaningful in the radix specified by <[base]>
|
| 36 |
|
|
(for example, <<0>> through <<7>> if the value of <[base]> is 8);
|
| 37 |
|
|
and a trailing portion consisting of one or more unparseable characters,
|
| 38 |
|
|
which always includes the terminating null character. Then, it attempts
|
| 39 |
|
|
to convert the subject string into an unsigned long long integer, and returns the
|
| 40 |
|
|
result.
|
| 41 |
|
|
|
| 42 |
|
|
If the value of <[base]> is zero, the subject string is expected to look
|
| 43 |
|
|
like a normal C integer constant: an optional sign (<<+>> or <<->>),
|
| 44 |
|
|
a possible <<0x>> indicating hexadecimal radix or a possible <0> indicating
|
| 45 |
|
|
octal radix, and a number.
|
| 46 |
|
|
If <[base]> is between 2 and 36, the expected form of the subject is a
|
| 47 |
|
|
sequence of digits (which may include letters, depending on the
|
| 48 |
|
|
base) representing an integer in the radix specified by <[base]>.
|
| 49 |
|
|
The letters <<a>>--<<z>> (or <<A>>--<<Z>>) are used as digits valued from
|
| 50 |
|
|
10 to 35. If <[base]> is 16, a leading <<0x>> is permitted.
|
| 51 |
|
|
|
| 52 |
|
|
The subject sequence is the longest initial sequence of the input
|
| 53 |
|
|
string that has the expected form, starting with the first
|
| 54 |
|
|
non-whitespace character. If the string is empty or consists entirely
|
| 55 |
|
|
of whitespace, or if the first non-whitespace character is not a
|
| 56 |
|
|
permissible digit, the subject string is empty.
|
| 57 |
|
|
|
| 58 |
|
|
If the subject string is acceptable, and the value of <[base]> is zero,
|
| 59 |
|
|
<<wcstoull>> attempts to determine the radix from the input string. A
|
| 60 |
|
|
string with a leading <<0x>> is treated as a hexadecimal value; a string with
|
| 61 |
|
|
a leading <<0>> and no <<x>> is treated as octal; all other strings are
|
| 62 |
|
|
treated as decimal. If <[base]> is between 2 and 36, it is used as the
|
| 63 |
|
|
conversion radix, as described above. Finally, a pointer to the first
|
| 64 |
|
|
character past the converted subject string is stored in <[ptr]>, if
|
| 65 |
|
|
<[ptr]> is not <<NULL>>.
|
| 66 |
|
|
|
| 67 |
|
|
If the subject string is empty (that is, if <<*>><[s]> does not start
|
| 68 |
|
|
with a substring in acceptable form), no conversion
|
| 69 |
|
|
is performed and the value of <[s]> is stored in <[ptr]> (if <[ptr]> is
|
| 70 |
|
|
not <<NULL>>).
|
| 71 |
|
|
|
| 72 |
|
|
The alternate function <<_wcstoull_r>> is a reentrant version. The
|
| 73 |
|
|
extra argument <[reent]> is a pointer to a reentrancy structure.
|
| 74 |
|
|
|
| 75 |
|
|
|
| 76 |
|
|
RETURNS
|
| 77 |
|
|
<<wcstoull>> returns <<0>> and sets <<errno>> to <<EINVAL>> if the value of
|
| 78 |
|
|
<[base]> is not supported.
|
| 79 |
|
|
|
| 80 |
|
|
<<wcstoull>> returns the converted value, if any. If no conversion was
|
| 81 |
|
|
made, <<0>> is returned.
|
| 82 |
|
|
|
| 83 |
|
|
<<wcstoull>> returns <<ULLONG_MAX>> if the magnitude of the converted
|
| 84 |
|
|
value is too large, and sets <<errno>> to <<ERANGE>>.
|
| 85 |
|
|
|
| 86 |
|
|
PORTABILITY
|
| 87 |
|
|
<<wcstoull>> is ANSI.
|
| 88 |
|
|
|
| 89 |
|
|
<<wcstoull>> requires no supporting OS subroutines.
|
| 90 |
|
|
*/
|
| 91 |
|
|
|
| 92 |
|
|
/*
|
| 93 |
|
|
* Copyright (c) 1990 Regents of the University of California.
|
| 94 |
|
|
* All rights reserved.
|
| 95 |
|
|
*
|
| 96 |
|
|
* Redistribution and use in source and binary forms, with or without
|
| 97 |
|
|
* modification, are permitted provided that the following conditions
|
| 98 |
|
|
* are met:
|
| 99 |
|
|
* 1. Redistributions of source code must retain the above copyright
|
| 100 |
|
|
* notice, this list of conditions and the following disclaimer.
|
| 101 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
| 102 |
|
|
* notice, this list of conditions and the following disclaimer in the
|
| 103 |
|
|
* documentation and/or other materials provided with the distribution.
|
| 104 |
|
|
* 3. All advertising materials mentioning features or use of this software
|
| 105 |
|
|
* must display the following acknowledgement:
|
| 106 |
|
|
* This product includes software developed by the University of
|
| 107 |
|
|
* California, Berkeley and its contributors.
|
| 108 |
|
|
* 4. Neither the name of the University nor the names of its contributors
|
| 109 |
|
|
* may be used to endorse or promote products derived from this software
|
| 110 |
|
|
* without specific prior written permission.
|
| 111 |
|
|
*
|
| 112 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
| 113 |
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| 114 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
| 115 |
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
| 116 |
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 117 |
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
| 118 |
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
| 119 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
| 120 |
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
| 121 |
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
| 122 |
|
|
* SUCH DAMAGE.
|
| 123 |
|
|
*/
|
| 124 |
|
|
|
| 125 |
|
|
#include <_ansi.h>
|
| 126 |
|
|
#include <wchar.h>
|
| 127 |
|
|
#include <reent.h>
|
| 128 |
|
|
|
| 129 |
|
|
#ifndef _REENT_ONLY
|
| 130 |
|
|
|
| 131 |
|
|
unsigned long long
|
| 132 |
|
|
_DEFUN (wcstoull, (s, ptr, base),
|
| 133 |
|
|
_CONST wchar_t *s _AND
|
| 134 |
|
|
wchar_t **ptr _AND
|
| 135 |
|
|
int base)
|
| 136 |
|
|
{
|
| 137 |
|
|
return _wcstoull_r (_REENT, s, ptr, base);
|
| 138 |
|
|
}
|
| 139 |
|
|
|
| 140 |
|
|
#endif
|