Mercurial > projects > ldc
annotate dmd/lstring.c @ 1138:4c8bb03e4fbc
Update DtoConstFP() to be correct after LLVM r67562, which changed the way the
APFloat constructor expects its i80 APInts to be formatted. (They're now
actually consistent with the x87 format)
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Tue, 24 Mar 2009 15:24:59 +0100 |
parents | eeb8b95ea92e |
children |
rev | line source |
---|---|
1 | 1 // lstring.c |
2 | |
3 // Copyright (c) 1999-2002 by Digital Mars | |
4 // All Rights Reserved | |
5 // written by Walter Bright | |
6 // www.digitalmars.com | |
7 // License for redistribution is by either the Artistic License | |
8 // in artistic.txt, or the GNU General Public License in gnu.txt. | |
9 // See the included readme.txt for details. | |
10 | |
11 #include <stdlib.h> | |
12 | |
13 #include "dchar.h" | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1
diff
changeset
|
14 #include "rmem.h" |
1 | 15 #include "lstring.h" |
16 | |
1133
eeb8b95ea92e
Cleanup DMD 1.041 merge.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
17 #ifdef _MSC_VER // prevent compiler internal crash |
eeb8b95ea92e
Cleanup DMD 1.041 merge.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
18 Lstring Lstring::zero; |
eeb8b95ea92e
Cleanup DMD 1.041 merge.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
19 #else |
1 | 20 Lstring Lstring::zero = LSTRING_EMPTY(); |
1133
eeb8b95ea92e
Cleanup DMD 1.041 merge.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
21 #endif |
1 | 22 |
23 Lstring *Lstring::ctor(const dchar *p, unsigned length) | |
24 { | |
25 Lstring *s; | |
26 | |
27 s = alloc(length); | |
28 memcpy(s->string, p, length * sizeof(dchar)); | |
29 return s; | |
30 } | |
31 | |
32 Lstring *Lstring::alloc(unsigned length) | |
33 { | |
34 Lstring *s; | |
35 | |
36 s = (Lstring *)mem.malloc(size(length)); | |
37 s->length = length; | |
38 s->string[length] = 0; | |
39 return s; | |
40 } | |
41 | |
42 Lstring *Lstring::append(const Lstring *s) | |
43 { | |
44 Lstring *t; | |
45 | |
46 if (!s->length) | |
47 return this; | |
48 t = alloc(length + s->length); | |
49 memcpy(t->string, string, length * sizeof(dchar)); | |
50 memcpy(t->string + length, s->string, s->length * sizeof(dchar)); | |
51 return t; | |
52 } | |
53 | |
54 Lstring *Lstring::substring(int start, int end) | |
55 { | |
56 Lstring *t; | |
57 | |
58 if (start == end) | |
59 return &zero; | |
60 t = alloc(end - start); | |
61 memcpy(t->string, string + start, (end - start) * sizeof(dchar)); | |
62 return t; | |
63 } |