comparison druntime/src/compiler/ldc/util/string.d @ 1458:e0b2d67cfe7c

Added druntime (this should be removed once it works).
author Robert Clipsham <robert@octarineparrot.com>
date Tue, 02 Jun 2009 17:43:06 +0100
parents
children
comparison
equal deleted inserted replaced
1456:7b218ec1044f 1458:e0b2d67cfe7c
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 Sean Kelly 2005 - 2009.
6 * License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
7 * Authors: Sean Kelly
8 *
9 * Copyright Sean Kelly 2005 - 2009.
10 * Distributed under the Boost Software License, Version 1.0.
11 * (See accompanying file LICENSE_1_0.txt or copy at
12 * http://www.boost.org/LICENSE_1_0.txt)
13 */
14 module rt.util.string;
15
16 private import core.stdc.string;
17
18 char[] intToString( char[] buf, uint val )
19 {
20 assert( buf.length > 9 );
21 auto p = buf.ptr + buf.length;
22
23 do
24 {
25 *--p = cast(char)(val % 10 + '0');
26 } while( val /= 10 );
27
28 return buf[p - buf.ptr .. $];
29 }
30
31
32 int dstrcmp( in char[] s1, in char[] s2 )
33 {
34 auto len = s1.length;
35 if( s2.length < len )
36 len = s2.length;
37 if( memcmp( s1.ptr, s2.ptr, len ) == 0 )
38 return 0;
39 return s1.length > s2.length ? 1 : -1;
40 }