Mercurial > projects > ldc
comparison druntime/src/compiler/ldc/util/string.d @ 759:d3eb054172f9
Added copy of druntime from DMD 2.020 modified for LDC.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 11 Nov 2008 01:52:37 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
758:f04dde6e882c | 759:d3eb054172f9 |
---|---|
1 /** | |
2 * The exception module defines all system-level exceptions and provides a | |
3 * mechanism to alter system-level error handling. | |
4 * | |
5 * Copyright: Copyright (c) 2005-2008, The D Runtime Project | |
6 * License: BSD Style, see LICENSE | |
7 * Authors: Sean Kelly | |
8 */ | |
9 module rt.util.string; | |
10 | |
11 private import stdc.string; | |
12 | |
13 char[] intToString( char[] buf, uint val ) | |
14 { | |
15 assert( buf.length > 9 ); | |
16 auto p = buf.ptr + buf.length; | |
17 | |
18 do | |
19 { | |
20 *--p = cast(char)(val % 10 + '0'); | |
21 } while( val /= 10 ); | |
22 | |
23 return buf[p - buf.ptr .. $]; | |
24 } | |
25 | |
26 | |
27 int dstrcmp( in char[] s1, in char[] s2 ) | |
28 { | |
29 auto len = s1.length; | |
30 if( s2.length < len ) | |
31 len = s2.length; | |
32 if( memcmp( s1.ptr, s2.ptr, len ) == 0 ) | |
33 return 0; | |
34 return s1.length > s2.length ? 1 : -1; | |
35 } |