Mercurial > projects > dang
annotate basic/conv.d @ 112:d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Sun, 25 May 2008 15:48:13 +0200 |
parents | |
children |
rev | line source |
---|---|
112
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
1 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
2 // Written in the D programming language. |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
3 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
4 /* |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
5 * Copyright (C) 2002-2006 by Digital Mars, www.digitalmars.com |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
6 * Written by Walter Bright |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
7 * Some parts contributed by David L. Davis |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
8 * |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
9 * This software is provided 'as-is', without any express or implied |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
10 * warranty. In no event will the authors be held liable for any damages |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
11 * arising from the use of this software. |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
12 * |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
13 * Permission is granted to anyone to use this software for any purpose, |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
14 * including commercial applications, and to alter it and redistribute it |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
15 * freely, subject to the following restrictions: |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
16 * |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
17 * o The origin of this software must not be misrepresented; you must not |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
18 * claim that you wrote the original software. If you use this software |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
19 * in a product, an acknowledgment in the product documentation would be |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
20 * appreciated but is not required. |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
21 * o Altered source versions must be plainly marked as such, and must not |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
22 * be misrepresented as being the original software. |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
23 * o This notice may not be removed or altered from any source |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
24 * distribution. |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
25 */ |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
26 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
27 /*********** |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
28 * Conversion building blocks. These differ from the C equivalents |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
29 * <tt>atoi()</tt> and <tt>atol()</tt> by |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
30 * checking for overflow and not allowing whitespace. |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
31 * |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
32 * For conversion to signed types, the grammar recognized is: |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
33 * <pre> |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
34 $(I Integer): |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
35 $(I Sign UnsignedInteger) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
36 $(I UnsignedInteger) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
37 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
38 $(I Sign): |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
39 $(B +) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
40 $(B -) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
41 * </pre> |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
42 * For conversion to signed types, the grammar recognized is: |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
43 * <pre> |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
44 $(I UnsignedInteger): |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
45 $(I DecimalDigit) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
46 $(I DecimalDigit) $(I UnsignedInteger) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
47 * </pre> |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
48 * Macros: |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
49 * WIKI=Phobos/StdConv |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
50 */ |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
51 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
52 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
53 /************************* |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
54 Changed to be used next to tango. |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
55 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
56 Unittests removed. |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
57 *************************/ |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
58 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
59 module basic.conv; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
60 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
61 private import tango.text.Util; // for atof(), toString() |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
62 private import tango.stdc.stringz; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
63 private import tango.stdc.ctype; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
64 private import tango.stdc.stdlib; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
65 private import tango.stdc.errno; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
66 //private import std.c.stdlib; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
67 //private import std.math; // for fabs(), isnan() |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
68 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
69 private |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
70 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
71 extern (C) int getErrno(); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
72 extern (C) int setErrno(int); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
73 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
74 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
75 //debug=conv; // uncomment to turn on debugging printf's |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
76 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
77 /* ************* Exceptions *************** */ |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
78 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
79 /** |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
80 * Thrown on conversion errors, which happens on deviation from the grammar. |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
81 */ |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
82 class ConvError : Exception |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
83 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
84 this(char[] s) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
85 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
86 super("conversion " ~ s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
87 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
88 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
89 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
90 private void conv_error(char[] s) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
91 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
92 throw new ConvError(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
93 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
94 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
95 /** |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
96 * Thrown on conversion overflow errors. |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
97 */ |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
98 class ConvOverflowError : Exception |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
99 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
100 this(char[] s) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
101 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
102 super("Error: overflow " ~ s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
103 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
104 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
105 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
106 private void conv_overflow(char[] s) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
107 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
108 throw new ConvOverflowError(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
109 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
110 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
111 /*************************************************************** |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
112 * Convert character string to the return type. |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
113 */ |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
114 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
115 int toInt(char[] s) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
116 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
117 int length = s.length; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
118 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
119 if (!length) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
120 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
121 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
122 int sign = 0; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
123 int v = 0; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
124 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
125 for (int i = 0; i < length; i++) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
126 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
127 char c = s[i]; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
128 if (c >= '0' && c <= '9') |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
129 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
130 if (v < int.max/10 || (v == int.max/10 && c + sign <= '7')) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
131 v = v * 10 + (c - '0'); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
132 else |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
133 goto Loverflow; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
134 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
135 else if (c == '-' && i == 0) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
136 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
137 sign = -1; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
138 if (length == 1) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
139 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
140 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
141 else if (c == '+' && i == 0) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
142 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
143 if (length == 1) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
144 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
145 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
146 else |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
147 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
148 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
149 if (sign == -1) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
150 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
151 if (cast(uint)v > 0x80000000) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
152 goto Loverflow; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
153 v = -v; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
154 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
155 else |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
156 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
157 if (cast(uint)v > 0x7FFFFFFF) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
158 goto Loverflow; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
159 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
160 return v; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
161 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
162 Loverflow: |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
163 conv_overflow(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
164 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
165 Lerr: |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
166 conv_error(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
167 return 0; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
168 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
169 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
170 /******************************************************* |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
171 * ditto |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
172 */ |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
173 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
174 uint toUint(char[] s) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
175 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
176 int length = s.length; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
177 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
178 if (!length) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
179 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
180 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
181 uint v = 0; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
182 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
183 for (int i = 0; i < length; i++) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
184 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
185 char c = s[i]; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
186 if (c >= '0' && c <= '9') |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
187 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
188 if (v < uint.max/10 || (v == uint.max/10 && c <= '5')) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
189 v = v * 10 + (c - '0'); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
190 else |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
191 goto Loverflow; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
192 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
193 else |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
194 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
195 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
196 return v; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
197 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
198 Loverflow: |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
199 conv_overflow(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
200 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
201 Lerr: |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
202 conv_error(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
203 return 0; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
204 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
205 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
206 /******************************************************* |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
207 * ditto |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
208 */ |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
209 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
210 long toLong(char[] s) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
211 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
212 int length = s.length; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
213 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
214 if (!length) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
215 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
216 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
217 int sign = 0; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
218 long v = 0; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
219 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
220 for (int i = 0; i < length; i++) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
221 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
222 char c = s[i]; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
223 if (c >= '0' && c <= '9') |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
224 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
225 if (v < long.max/10 || (v == long.max/10 && c + sign <= '7')) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
226 v = v * 10 + (c - '0'); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
227 else |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
228 goto Loverflow; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
229 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
230 else if (c == '-' && i == 0) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
231 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
232 sign = -1; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
233 if (length == 1) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
234 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
235 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
236 else if (c == '+' && i == 0) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
237 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
238 if (length == 1) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
239 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
240 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
241 else |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
242 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
243 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
244 if (sign == -1) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
245 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
246 if (cast(ulong)v > 0x8000000000000000) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
247 goto Loverflow; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
248 v = -v; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
249 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
250 else |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
251 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
252 if (cast(ulong)v > 0x7FFFFFFFFFFFFFFF) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
253 goto Loverflow; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
254 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
255 return v; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
256 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
257 Loverflow: |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
258 conv_overflow(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
259 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
260 Lerr: |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
261 conv_error(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
262 return 0; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
263 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
264 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
265 /******************************************************* |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
266 * ditto |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
267 */ |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
268 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
269 ulong toUlong(char[] s) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
270 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
271 int length = s.length; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
272 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
273 if (!length) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
274 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
275 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
276 ulong v = 0; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
277 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
278 for (int i = 0; i < length; i++) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
279 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
280 char c = s[i]; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
281 if (c >= '0' && c <= '9') |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
282 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
283 if (v < ulong.max/10 || (v == ulong.max/10 && c <= '5')) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
284 v = v * 10 + (c - '0'); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
285 else |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
286 goto Loverflow; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
287 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
288 else |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
289 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
290 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
291 return v; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
292 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
293 Loverflow: |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
294 conv_overflow(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
295 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
296 Lerr: |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
297 conv_error(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
298 return 0; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
299 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
300 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
301 /******************************************************* |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
302 * ditto |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
303 */ |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
304 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
305 short toShort(char[] s) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
306 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
307 int v = toInt(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
308 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
309 if (v != cast(short)v) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
310 goto Loverflow; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
311 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
312 return cast(short)v; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
313 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
314 Loverflow: |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
315 conv_overflow(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
316 return 0; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
317 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
318 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
319 /******************************************************* |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
320 * ditto |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
321 */ |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
322 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
323 ushort toUshort(char[] s) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
324 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
325 uint v = toUint(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
326 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
327 if (v != cast(ushort)v) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
328 goto Loverflow; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
329 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
330 return cast(ushort)v; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
331 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
332 Loverflow: |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
333 conv_overflow(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
334 return 0; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
335 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
336 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
337 /******************************************************* |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
338 * ditto |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
339 */ |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
340 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
341 byte toByte(char[] s) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
342 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
343 int v = toInt(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
344 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
345 if (v != cast(byte)v) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
346 goto Loverflow; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
347 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
348 return cast(byte)v; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
349 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
350 Loverflow: |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
351 conv_overflow(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
352 return 0; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
353 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
354 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
355 /******************************************************* |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
356 * ditto |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
357 */ |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
358 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
359 ubyte toUbyte(char[] s) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
360 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
361 uint v = toUint(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
362 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
363 if (v != cast(ubyte)v) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
364 goto Loverflow; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
365 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
366 return cast(ubyte)v; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
367 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
368 Loverflow: |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
369 conv_overflow(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
370 return 0; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
371 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
372 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
373 /******************************************************* |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
374 * ditto |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
375 */ |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
376 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
377 float toFloat(in char[] s) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
378 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
379 float f; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
380 char* endptr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
381 char* sz; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
382 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
383 //writefln("toFloat('%s')", s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
384 sz = toStringz(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
385 if (tango.stdc.ctype.isspace(*sz)) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
386 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
387 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
388 // BUG: should set __locale_decpoint to "." for DMC |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
389 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
390 setErrno(0); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
391 f = strtof(sz, &endptr); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
392 if (getErrno() == ERANGE) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
393 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
394 if (endptr && (endptr == sz || *endptr != 0)) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
395 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
396 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
397 return f; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
398 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
399 Lerr: |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
400 conv_error(s ~ " not representable as a float"); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
401 assert(0); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
402 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
403 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
404 /******************************************************* |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
405 * ditto |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
406 */ |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
407 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
408 double toDouble(in char[] s) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
409 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
410 double f; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
411 char* endptr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
412 char* sz; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
413 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
414 //writefln("toDouble('%s')", s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
415 sz = toStringz(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
416 if (tango.stdc.ctype.isspace(*sz)) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
417 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
418 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
419 // BUG: should set __locale_decpoint to "." for DMC |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
420 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
421 setErrno(0); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
422 f = strtod(sz, &endptr); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
423 if (getErrno() == ERANGE) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
424 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
425 if (endptr && (endptr == sz || *endptr != 0)) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
426 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
427 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
428 return f; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
429 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
430 Lerr: |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
431 conv_error(s ~ " not representable as a double"); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
432 assert(0); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
433 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
434 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
435 /******************************************************* |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
436 * ditto |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
437 */ |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
438 real toReal(in char[] s) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
439 { |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
440 real f; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
441 char* endptr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
442 char* sz; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
443 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
444 //writefln("toReal('%s')", s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
445 sz = toStringz(s); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
446 if (tango.stdc.ctype.isspace(*sz)) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
447 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
448 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
449 // BUG: should set __locale_decpoint to "." for DMC |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
450 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
451 setErrno(0); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
452 f = strtold(sz, &endptr); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
453 if (getErrno() == ERANGE) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
454 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
455 if (endptr && (endptr == sz || *endptr != 0)) |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
456 goto Lerr; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
457 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
458 return f; |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
459 |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
460 Lerr: |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
461 conv_error(s ~ " not representable as a real"); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
462 assert(0); |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
463 } |
d03b011c50e9
Added missing file. This file is from the phobos source, with some modifications so that it can run in tango. Also slimed out unittests.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
464 |