Mercurial > projects > ldc
view runtime/internal/util/string.d @ 715:30b42a283c8e
Removed TypeOpaque from DMD.
Changed runtime functions taking opaque[] to void[].
Implemented proper type painting, to avoid "resizing" array casts in runtime calls that previously took opaque[].
Implemented dynamic arrays as first class types, this implements proper ABI for these types on x86.
Added dwarf region end after call to assert function, fixes some problems with llvm not allowing this to be missing.
Reverted change to WithStatement from rev [704] it breaks MiniD, mini/with2.d needs to be fixed some other way...
Fixed tango bug 1339 in runtime, problem with _adReverseChar on invalid UTF-8.
Disabled .bc generation in the compiler runtime part, genobj.d triggers some llvm bug when using debug info. the .o seems to work fine.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Wed, 22 Oct 2008 14:55:33 +0200 |
parents | 44f08170f4ef |
children | ecb429ee0648 |
line wrap: on
line source
/******************************************************************************* copyright: Copyright (c) 2004 Tango group. All rights reserved license: BSD style: $(LICENSE) version: Initial release: July 2006 Various char[] utilities *******************************************************************************/ module util.string; private import tango.stdc.string; // convert uint to char[], within the given buffer // Returns a valid slice of the populated buffer char[] intToUtf8 (char[] tmp, size_t val) in { assert (tmp.length > 20, "atoi buffer should be 20 or more chars wide"); } body { char* p = tmp.ptr + tmp.length; do { *--p = (val % 10) + '0'; } while (val /= 10); return tmp [cast(size_t)(p - tmp.ptr) .. $]; } // function to compare two strings int stringCompare (char[] s1, char[] s2) { auto len = s1.length; if (s2.length < len) len = s2.length; int result = memcmp(s1.ptr, s2.ptr, len); if (result == 0) result = cast(int)s1.length - cast(int)s2.length; return result; }