/usr/lib/gcc/x86_64-linux-gnu/5/include/d/rt/util/string.d is in libphobos-5-dev 5.5.0-12ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | /**
* String manipulation and comparison utilities.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Sean Kelly
*/
/* Copyright Sean Kelly 2005 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module rt.util.string;
private import core.stdc.string;
@trusted:
pure:
nothrow:
alias UintStringBuff = char[10];
alias UlongStringBuff = char[20];
version(D_LP64)
alias SizeStringBuff = UlongStringBuff;
else
alias SizeStringBuff = UintStringBuff;
char[] uintToTempString(in uint val, char[] buff)
{ return val._unsignedToTempString(buff); }
char[] ulongToTempString(in ulong val, char[] buff)
{ return val._unsignedToTempString(buff); }
char[] sizeToTempString(in size_t val, char[] buff)
{ return val._unsignedToTempString(buff); }
private char[] _unsignedToTempString(T)(in T val, char[] buff)
if(is(T == uint) || is(T == ulong))
{
assert(buff.length >= (is(T == uint) ? 10 : 20), "Buffer is too small for `" ~ T.stringof ~ "`.");
char* p = buff.ptr + buff.length;
T k = val;
do
*--p = cast(char) (k % 10 + '0');
while(k /= 10);
return buff[p - buff.ptr .. $];
}
unittest
{
UlongStringBuff buff;
assert(1.uintToTempString(buff) == "1");
assert(12.ulongToTempString(buff) == "12");
assert(long.sizeof.sizeToTempString(buff) == "8");
assert(uint.max.uintToTempString(buff) == "4294967295");
assert(ulong.max.ulongToTempString(buff) == "18446744073709551615");
}
int dstrcmp( in char[] s1, in char[] s2 )
{
int ret = 0;
auto len = s1.length;
if( s2.length < len )
len = s2.length;
if( 0 != (ret = memcmp( s1.ptr, s2.ptr, len )) )
return ret;
return s1.length > s2.length ? 1 :
s1.length == s2.length ? 0 : -1;
}
|