+ *
+ * NAN = NAN
*/
/*
@@ -44,8 +48,17 @@
//debug=math; // uncomment to turn on debugging printf's
private import std.c.stdio;
+private import std.string;
private import std.c.math;
+class NotImplemented : Error
+{
+ this(char[] msg)
+ {
+ super(msg ~ "not implemented");
+ }
+}
+
const real E = 2.7182818284590452354L; /** e */
const real LOG2T = 0x1.a934f0979a3715fcp+1; /** log210 */ // 3.32193 fldl2t
const real LOG2E = 0x1.71547652b82fe178p+0; /** log2e */ // 1.4427 fldl2e
@@ -80,12 +93,11 @@
/***********************************
* Returns cosine of x. x is in radians.
*
- *
- *
Special Values
- *
x
cos(x)
invalid?
- *
NAN
NAN
yes
- *
±∞
NAN
yes
- *
+ * $(TABLE_SV
+ * $(TR $(TH x) $(TH cos(x)) $(TH invalid?) )
+ * $(TR $(TD $(NAN)) $(TD $(NAN)) $(TD yes) )
+ * $(TR $(TD ±∞) $(TD $(NAN)) $(TD yes) )
+ * )
*/
real cos(real x); /* intrinsic */
@@ -93,13 +105,12 @@
/***********************************
* Returns sine of x. x is in radians.
*
- *
- *
Special Values
+ * $(TABLE_SV
*
x
sin(x)
invalid?
- *
NAN
NAN
yes
+ *
$(NAN)
$(NAN)
yes
*
±0.0
±0.0
no
- *
±∞
NAN
yes
- *
+ *
±∞
$(NAN)
yes
+ * )
*/
real sin(real x); /* intrinsic */
@@ -108,13 +119,12 @@
/****************************************************************************
* Returns tangent of x. x is in radians.
*
- *
- *
Special Values
+ * $(TABLE_SV
*
x
tan(x)
invalid?
- *
NAN
NAN
yes
+ *
$(NAN)
$(NAN)
yes
*
±0.0
±0.0
no
- *
±∞
NAN
yes
- *
+ *
±∞
$(NAN)
yes
+ * )
*/
real tan(real x)
@@ -206,45 +216,129 @@
}
}
-
+/***************
+ * Calculates the arc cosine of x,
+ * returning a value ranging from -π/2 to π/2.
+ *
+ * $(TABLE_SV
+ *
x
acos(x)
invalid?
+ *
>1.0
$(NAN)
yes
+ *
<-1.0
$(NAN)
yes
+ *
$(NAN)
$(NAN)
yes
+ * )
+ */
real acos(real x) { return std.c.math.acosl(x); }
+/***************
+ * Calculates the arc sine of x,
+ * returning a value ranging from -π/2 to π/2.
+ *
+ * $(TABLE_SV
+ *
x
asin(x)
invalid?
+ *
±0.0
±0.0
no
+ *
>1.0
$(NAN)
yes
+ *
<-1.0
$(NAN)
yes
+ * )
+ */
real asin(real x) { return std.c.math.asinl(x); }
+
+/***************
+ * Calculates the arc tangent of x,
+ * returning a value ranging from -π/2 to π/2.
+ *
+ * $(TABLE_SV
+ *
x
atan(x)
invalid?
+ *
±0.0
±0.0
no
+ *
±∞
$(NAN)
yes
+ * )
+ */
real atan(real x) { return std.c.math.atanl(x); }
+
+/***************
+ * Calculates the arc tangent of y / x,
+ * returning a value ranging from -π/2 to π/2.
+ *
+ * $(TABLE_SV
+ *
x
y
atan(x, y)
+ *
$(NAN)
anything
$(NAN)
+ *
anything
$(NAN)
$(NAN)
+ *
±0.0
> 0.0
±0.0
+ *
±0.0
±0.0
±0.0
+ *
±0.0
< 0.0
±π
+ *
±0.0
-0.0
±π
+ *
> 0.0
±0.0
π/2
+ *
< 0.0
±0.0
π/2
+ *
> 0.0
∞
±0.0
+ *
±∞
anything
±π/2
+ *
> 0.0
-∞
±π
+ *
±∞
∞
±π/4
+ *
±∞
-∞
±3π/4
+ * )
+ */
real atan2(real x, real y) { return std.c.math.atan2l(x,y); }
+
+/***********************************
+ * Calculates the hyperbolic cosine of x.
+ *
+ * $(TABLE_SV
+ *
x
cosh(x)
invalid?
+ *
±∞
±0.0
no
+ * )
+ */
real cosh(real x) { return std.c.math.coshl(x); }
+
+/***********************************
+ * Calculates the hyperbolic sine of x.
+ *
+ * $(TABLE_SV
+ *
x
sinh(x)
invalid?
+ *
±0.0
±0.0
no
+ *
±∞
±∞
no
+ * )
+ */
real sinh(real x) { return std.c.math.sinhl(x); }
+
+/***********************************
+ * Calculates the hyperbolic tangent of x.
+ *
+ * $(TABLE_SV
+ *
x
tanh(x)
invalid?
+ *
±0.0
±0.0
no
+ *
±∞
±1.0
no
+ * )
+ */
real tanh(real x) { return std.c.math.tanhl(x); }
//real acosh(real x) { return std.c.math.acoshl(x); }
//real asinh(real x) { return std.c.math.asinhl(x); }
//real atanh(real x) { return std.c.math.atanhl(x); }
-real fabs(real x); /* intrinsic */
-real rint(real x); /* intrinsic */
+/*****************************************
+ * Returns x rounded to a long value using the current rounding mode.
+ * If the integer value of x is
+ * greater than long.max, the result is
+ * indeterminate.
+ */
long rndtol(real x); /* intrinsic */
-/*******************************************
- * Compute n * 2exp
- * References: frexp
- */
-real ldexp(real n, int exp); /* intrinsic */
+/*****************************************
+ * Returns x rounded to a long value using the FE_TONEAREST rounding mode.
+ * If the integer value of x is
+ * greater than long.max, the result is
+ * indeterminate.
+ */
+extern (C) real rndtonl(real x);
/***************************************
* Compute square root of x.
*
- *
+0.0
+ * )
+ */
real exp2(real x) { return std.c.math.exp2l(x); }
/******************************************
@@ -307,88 +414,548 @@
* For very small x, expm1(x) is more accurate
* than exp(x)-1.
*
- *
- *
Special Values
+ * $(TABLE_SV
*
x
ex-1
*
±0.0
±0.0
*
+∞
+∞
*
-∞
-1.0
- *
+ * )
*/
real expm1(real x) { return std.c.math.expm1l(x); }
-int ilogb(real x) { return std.c.math.ilogbl(x); }
+
+/*********************************************************************
+ * Separate floating point value into significand and exponent.
+ *
+ * Returns:
+ *
Calculate and return x and exp such that
+ * value =x*2exp and
+ * .5 <= |x| < 1.0
+ * x has same sign as value.
+ *
+ * $(TABLE_SV
+ *
value
returns
exp
+ *
±0.0
±0.0
0
+ *
+∞
+∞
int.max
+ *
-∞
-∞
int.min
+ *
±$(NAN)
±$(NAN)
int.min
+ * )
+ */
+
+
+real frexp(real value, out int exp)
+{
+ ushort* vu = cast(ushort*)&value;
+ long* vl = cast(long*)&value;
+ uint ex;
+
+ // If exponent is non-zero
+ ex = vu[4] & 0x7FFF;
+ if (ex)
+ {
+ if (ex == 0x7FFF)
+ { // infinity or NaN
+ if (*vl & 0x7FFFFFFFFFFFFFFF) // if NaN
+ { *vl |= 0xC000000000000000; // convert $(NAN)S to $(NAN)Q
+ exp = int.min;
+ }
+ else if (vu[4] & 0x8000)
+ { // negative infinity
+ exp = int.min;
+ }
+ else
+ { // positive infinity
+ exp = int.max;
+ }
+ }
+ else
+ {
+ exp = ex - 0x3FFE;
+ vu[4] = (0x8000 & vu[4]) | 0x3FFE;
+ }
+ }
+ else if (!*vl)
+ {
+ // value is +-0.0
+ exp = 0;
+ }
+ else
+ { // denormal
+ int i = -0x3FFD;
+
+ do
+ {
+ i--;
+ *vl <<= 1;
+ } while (*vl > 0);
+ exp = i;
+ vu[4] = (0x8000 & vu[4]) | 0x3FFE;
+ }
+ return value;
+}
+
+
+unittest
+{
+ static real vals[][3] = // x,frexp,exp
+ [
+ [0.0, 0.0, 0],
+ [-0.0, -0.0, 0],
+ [1.0, .5, 1],
+ [-1.0, -.5, 1],
+ [2.0, .5, 2],
+ [155.67e20, 0x1.A5F1C2EB3FE4Fp-1, 74], // normal
+ [1.0e-320, 0.98829225, -1063],
+ [real.min, .5, -16381],
+ [real.min/2.0L, .5, -16382], // denormal
+
+ [real.infinity,real.infinity,int.max],
+ [-real.infinity,-real.infinity,int.min],
+ [real.nan,real.nan,int.min],
+ [-real.nan,-real.nan,int.min],
+
+ // Don't really support signalling nan's in D
+ //[real.nans,real.nan,int.min],
+ //[-real.nans,-real.nan,int.min],
+ ];
+ int i;
+
+ for (i = 0; i < vals.length; i++)
+ {
+ real x = vals[i][0];
+ real e = vals[i][1];
+ int exp = cast(int)vals[i][2];
+ int eptr;
+ real v = frexp(x, eptr);
+
+ //printf("frexp(%Lg) = %.8Lg, should be %.8Lg, eptr = %d, should be %d\n", x, v, e, eptr, exp);
+ assert(mfeq(e, v, .0000001));
+ assert(exp == eptr);
+ }
+}
+
+
+/******************************************
+ * Extracts the exponent of x as a signed integral value.
+ *
+ * If x is not a special value, the result is the same as
+ * cast(int)logb(x).
+ *
+ * $(TABLE_SV
+ *
x
ilogb(x)
Range error?
+ *
0
FP_ILOGB0
yes
+ *
±∞
+∞
no
+ *
$(NAN)
FP_ILOGBNAN
no
+ * )
+ */
+int ilogb(real x) { return std.c.math.ilogbl(x); }
+
+alias std.c.math.FP_ILOGB0 FP_ILOGB0;
+alias std.c.math.FP_ILOGBNAN FP_ILOGBNAN;
+
+
+/*******************************************
+ * Compute n * 2exp
+ * References: frexp
+ */
+
+real ldexp(real n, int exp); /* intrinsic */
/**************************************
* Calculate the natural logarithm of x.
*
- *
no
+ * )
+ */
+
+real log10(real x) { return std.c.math.log10l(x); }
+
+/******************************************
+ * Calculates the natural logarithm of 1 + x.
+ *
+ * For very small x, log1p(x) will be more accurate than
+ * log(1 + x).
+ *
+ * $(TABLE_SV
+ *
no
+ * )
+ */
+real log2(real x) { return std.c.math.log2l(x); }
+
+/*****************************************
+ * Extracts the exponent of x as a signed integral value.
+ *
+ * If x is subnormal, it is treated as if it were normalized.
+ * For a positive, finite x:
+ *
+ *
+ * 1 <= x * FLT_RADIX-logb(x) < FLT_RADIX
+ *
+ *
+ * $(TABLE_SV
+ *
x
logb(x)
Divide by 0?
+ *
±∞
+∞
no
+ *
±0.0
-∞
yes
+ * )
+ */
+real logb(real x) { return std.c.math.logbl(x); }
+
+/************************************
+ * Calculates the remainder from the calculation x/y.
+ * Returns:
+ * The value of x - i * y, where i is the number of times that y can
+ * be completely subtracted from x. The result has the same sign as x.
+ *
+ * $(TABLE_SV
+ *
x
y
modf(x, y)
invalid?
+ *
±0.0
not 0.0
±0.0
no
+ *
±∞
anything
$(NAN)
yes
+ *
anything
±0.0
$(NAN)
yes
+ *
!=±∞
±∞
x
no
+ * )
+ */
+real modf(real x, inout real y) { return std.c.math.modfl(x,&y); }
+
+/*************************************
+ * Efficiently calculates x * 2n.
+ *
+ * scalbn handles underflow and overflow in
+ * the same fashion as the basic arithmetic operators.
+ *
+ * $(TABLE_SV
+ *
+∞
+ * )
+ */
+real fabs(real x); /* intrinsic */
+
+
+/***********************************************************************
+ * Calculates the length of the
+ * hypotenuse of a right-angled triangle with sides of length x and y.
+ * The hypotenuse is the value of the square root of
+ * the sums of the squares of x and y:
+ *
+ * sqrt(x² + y²)
+ *
+ * Note that hypot(x, y), hypot(y, x) and
+ * hypot(x, -y) are equivalent.
+ *
+ * $(TABLE_SV
+ *
x
y
hypot(x, y)
invalid?
+ *
x
±0.0
|x|
no
+ *
±∞
y
+∞
no
+ *
±∞
$(NAN)
+∞
no
+ * )
+ */
+
+real hypot(real x, real y)
+{
+ /*
+ * This is based on code from:
+ * Cephes Math Library Release 2.1: January, 1989
+ * Copyright 1984, 1987, 1989 by Stephen L. Moshier
+ * Direct inquiries to 30 Frost Street, Cambridge, MA 02140
+ */
+
+ const int PRECL = 32;
+ const int MAXEXPL = real.max_exp; //16384;
+ const int MINEXPL = real.min_exp; //-16384;
+
+ real xx, yy, b, re, im;
+ int ex, ey, e;
+
+ // Note, hypot(INFINITY, NAN) = INFINITY.
+ if (isinf(x) || isinf(y))
+ return real.infinity;
+
+ if (isnan(x))
+ return x;
+ if (isnan(y))
+ return y;
+
+ re = fabs(x);
+ im = fabs(y);
+
+ if (re == 0.0)
+ return im;
+ if (im == 0.0)
+ return re;
+
+ // Get the exponents of the numbers
+ xx = frexp(re, ex);
+ yy = frexp(im, ey);
+
+ // Check if one number is tiny compared to the other
+ e = ex - ey;
+ if (e > PRECL)
+ return re;
+ if (e < -PRECL)
+ return im;
+
+ // Find approximate exponent e of the geometric mean.
+ e = (ex + ey) >> 1;
+
+ // Rescale so mean is about 1
+ xx = ldexp(re, -e);
+ yy = ldexp(im, -e);
+
+ // Hypotenuse of the right triangle
+ b = sqrt(xx * xx + yy * yy);
+
+ // Compute the exponent of the answer.
+ yy = frexp(b, ey);
+ ey = e + ey;
+
+ // Check it for overflow and underflow.
+ if (ey > MAXEXPL + 2)
+ {
+ //return __matherr(_OVERFLOW, INFINITY, x, y, "hypotl");
+ return real.infinity;
+ }
+ if (ey < MINEXPL - 2)
+ return 0.0;
+
+ // Undo the scaling
+ b = ldexp(b, e);
+ return b;
+}
+
+unittest
+{
+ static real vals[][3] = // x,y,hypot
+ [
+ [ 0, 0, 0],
+ [ 0, -0, 0],
+ [ 3, 4, 5],
+ [ -300, -400, 500],
+ [ real.min, real.min, 4.75473e-4932L],
+ [ real.max/2, real.max/2, 0x1.6a09e667f3bcc908p+16383L /*8.41267e+4931L*/],
+ [ real.infinity, real.nan, real.infinity],
+ [ real.nan, real.nan, real.nan],
+ ];
+ int i;
+
+ for (i = 0; i < vals.length; i++)
+ {
+ real x = vals[i][0];
+ real y = vals[i][1];
+ real z = vals[i][2];
+ real h = hypot(x, y);
+
+ //printf("hypot(%Lg, %Lg) = %Lg, should be %Lg\n", x, y, h, z);
+ //if (!mfeq(z, h, .0000001))
+ //printf("%La\n", h);
+ assert(mfeq(z, h, .0000001));
+ }
+}
+
+/**********************************
+ * Returns the error function of x.
+ *
+ *
+ */
+real erf(real x) { return std.c.math.erfl(x); }
+
+/**********************************
+ * Returns the complementary error function of x, which is 1 - erf(x).
+ *
+ *
+ */
+real erfc(real x) { return std.c.math.erfcl(x); }
+
+/***********************************
+ * Calculates ln |Γ(x)|
+ */
+real lgamma(real x)
+{
+ version (linux)
+ return std.c.math.lgammal(x);
+ else
+ throw new NotImplemented("lgamma");
+}
+
+/***********************************
+ * Calculates the gamma function Γ(x)
*/
+real tgamma(real x)
+{
+ version (linux)
+ return std.c.math.tgammal(x);
+ else
+ throw new NotImplemented("tgamma");
+}
+
+/**************************************
+ * Returns the value of x rounded upward to the next integer
+ * (toward positive infinity).
+ */
+real ceil(real x) { return std.c.math.ceill(x); }
+
+/**************************************
+ * Returns the value of x rounded downward to the next integer
+ * (toward negative infinity).
+ */
+real floor(real x) { return std.c.math.floorl(x); }
+
+/******************************************
+ * Rounds x to the nearest integer value, using the current rounding
+ * mode.
+ *
+ * Unlike the rint functions, nearbyint does not raise the
+ * FE_INEXACT exception.
+ */
+real nearbyint(real x) { return std.c.math.nearbyintl(x); }
+
+/**********************************
+ * Rounds x to the nearest integer value, using the current rounding
+ * mode.
+ * If the return value is not equal to x, the FE_INEXACT
+ * exception is raised.
+ * nearbyint performs
+ * the same operation, but does not set the FE_INEXACT exception.
+ */
+real rint(real x); /* intrinsic */
+
+/***************************************
+ * Rounds x to the nearest integer value, using the current rounding
+ * mode.
+ */
+long lrint(real x)
+{
+ version (linux)
+ return std.c.math.llrintl(x);
+ else
+ throw new NotImplemented("lrint");
+}
-real log(real x) { return std.c.math.logl(x); }
+/*******************************************
+ * Return the value of x rounded to the nearest integer.
+ * If the fractional part of x is exactly 0.5, the return value is rounded to
+ * the even integer.
+ */
+real round(real x) { return std.c.math.roundl(x); }
-/**************************************
- * Calculate the base-10 logarithm of x.
+/**********************************************
+ * Return the value of x rounded to the nearest integer.
*
- *
- *
Special Values
- *
- *
x
log10(x)
divide by 0?
invalid?
- *
- *
±0.0
-∞
yes
no
- *
- *
< 0.0
NAN
no
yes
- *
- *
+∞
+∞
no
no
- *
+ * If the fractional part of x is exactly 0.5, the return value is rounded
+ * away from zero.
*/
+long lround(real x)
+{
+ version (linux)
+ return std.c.math.llroundl(x);
+ else
+ throw new NotImplemented("lround");
+}
-real log10(real x) { return std.c.math.log10l(x); }
+/****************************************************
+ * Returns the integer portion of x, dropping the fractional portion.
+ *
+ * This is also know as "chop" rounding.
+ */
+real trunc(real x) { return std.c.math.truncl(x); }
-/******************************************
- * Calculates the natural logarithm of 1 + x.
+/****************************************************
+ * Calculate the remainder x REM y, following IEC 60559.
*
- * For very small x, log1p(x) will be more accurate than
- * log(1 + x).
+ * REM is the value of x - y * n, where n is the integer nearest the exact
+ * value of x / y.
+ * If |n - x / y| == 0.5, n is even.
+ * If the result is zero, it has the same sign as x.
+ * Otherwise, the sign of the result is the sign of x / y.
+ * Precision mode has no affect on the remainder functions.
*
- *
- *
Special Values
- *
- *
x
log1p(x)
divide by 0?
invalid?
- *
- *
±0.0
±0.0
no
no
- *
- *
-1.0
-∞
yes
no
- *
- *
<-1.0
NAN
no
yes
- *
- *
+∞
-∞
no
no
- *
+ * remquo returns n in the parameter n.
+ *
+ * $(TABLE_SV
+ *
x
y
remainder(x, y)
n
invalid?
+ *
±0.0
not 0.0
±0.0
0.0
no
+ *
±∞
anything
$(NAN)
?
yes
+ *
anything
±0.0
$(NAN)
?
yes
+ *
!= ±∞
±∞
x
?
no
+ * )
*/
+real remainder(real x, real y) { return std.c.math.remainderl(x, y); }
-real log1p(real x) { return std.c.math.log1pl(x); }
-
-real log2(real x) { return std.c.math.log2l(x); }
-real logb(real x) { return std.c.math.logbl(x); }
-real modf(real x, inout real y) { return std.c.math.modfl(x,&y); }
-real erf(real x) { return std.c.math.erfl(x); }
-real erfc(real x) { return std.c.math.erfcl(x); }
-real ceil(real x) { return std.c.math.ceill(x); }
-real floor(real x) { return std.c.math.floorl(x); }
+real remquo(real x, real y, out int n) /// ditto
+{
+ version (linux)
+ return std.c.math.remquol(x, y, &n);
+ else
+ throw new NotImplemented("remquo");
+}
/*********************************
- * Is number a nan?
+ * Returns !=0 if e is a NaN.
*/
int isnan(real e)
@@ -411,7 +978,7 @@
}
/*********************************
- * Is number finite?
+ * Returns !=0 if e is finite.
*/
int isfinite(real e)
@@ -430,16 +997,16 @@
/*********************************
- * Is number normalized?
+ * Returns !=0 if x is normalized.
*/
/* Need one for each format because subnormal floats might
* be converted to normal reals.
*/
-int isnormal(float f)
+int isnormal(float x)
{
- uint *p = cast(uint *)&f;
+ uint *p = cast(uint *)&x;
uint e;
e = *p & 0x7F800000;
@@ -540,7 +1107,7 @@
}
/*********************************
- * Is number infinity?
+ * Return !=0 if e is ±∞.
*/
int isinf(real e)
@@ -563,7 +1130,7 @@
}
/*********************************
- * Get sign bit.
+ * Return 1 if sign bit of e is set, 0 if not.
*/
int signbit(real e)
@@ -586,7 +1153,7 @@
}
/*********************************
- * Copy sign.
+ * Return a value composed of to with from's sign bit.
*/
real copysign(real to, real from)
@@ -620,246 +1187,58 @@
assert(isnan(e) && signbit(e));
}
-/***********************************************************************
- * Calculates the length of the
- * hypotenuse of a right-angled triangle with sides of length x and y.
- * The hypotenuse is the value of the square root of
- * the sums of the squares of x and y:
- *
- * sqrt(x² + y²)
- *
- * Note that hypot(x, y), hypot(y, x) and
- * hypot(x, -y) are equivalent.
- *
- *
- *
Special Values
- *
- *
x
y
hypot(x, y)
invalid?
- *
- *
x
±0.0
|x|
no
- *
- *
±∞
y
+∞
no
- *
- *
±∞
NAN
+∞
no
- *
+/******************************************
+ * Creates a quiet NAN with the information from tagp[] embedded in it.
*/
+real nan(char[] tagp) { return std.c.math.nanl(toStringz(tagp)); }
-real hypot(real x, real y)
+/******************************************
+ * Calculates the next representable value after x in the direction of y.
+ *
+ * If y > x, the result will be the next largest floating-point value;
+ * if y < x, the result will be the next smallest value.
+ * If x == y, the result is y.
+ * The FE_INEXACT and FE_OVERFLOW exceptions will be raised if x is finite and
+ * the function result is infinite. The FE_INEXACT and FE_UNDERFLOW
+ * exceptions will be raised if the function value is subnormal, and x is
+ * not equal to y.
+ */
+real nextafter(real x, real y)
{
- /*
- * This is based on code from:
- * Cephes Math Library Release 2.1: January, 1989
- * Copyright 1984, 1987, 1989 by Stephen L. Moshier
- * Direct inquiries to 30 Frost Street, Cambridge, MA 02140
- */
-
- const int PRECL = 32;
- const int MAXEXPL = real.max_exp; //16384;
- const int MINEXPL = real.min_exp; //-16384;
-
- real xx, yy, b, re, im;
- int ex, ey, e;
-
- // Note, hypot(INFINITY,NAN) = INFINITY.
- if (isinf(x) || isinf(y))
- return real.infinity;
-
- if (isnan(x))
- return x;
- if (isnan(y))
- return y;
-
- re = fabs(x);
- im = fabs(y);
-
- if (re == 0.0)
- return im;
- if (im == 0.0)
- return re;
-
- // Get the exponents of the numbers
- xx = frexp(re, ex);
- yy = frexp(im, ey);
-
- // Check if one number is tiny compared to the other
- e = ex - ey;
- if (e > PRECL)
- return re;
- if (e < -PRECL)
- return im;
-
- // Find approximate exponent e of the geometric mean.
- e = (ex + ey) >> 1;
-
- // Rescale so mean is about 1
- xx = ldexp(re, -e);
- yy = ldexp(im, -e);
-
- // Hypotenuse of the right triangle
- b = sqrt(xx * xx + yy * yy);
-
- // Compute the exponent of the answer.
- yy = frexp(b, ey);
- ey = e + ey;
-
- // Check it for overflow and underflow.
- if (ey > MAXEXPL + 2)
- {
- //return __matherr(_OVERFLOW, INFINITY, x, y, "hypotl");
- return real.infinity;
- }
- if (ey < MINEXPL - 2)
- return 0.0;
-
- // Undo the scaling
- b = ldexp(b, e);
- return b;
+ version (linux)
+ return std.c.math.nextafterl(x, y);
+ else
+ throw new NotImplemented("nextafter");
}
-unittest
-{
- static real vals[][3] = // x,y,hypot
- [
- [ 0, 0, 0],
- [ 0, -0, 0],
- [ 3, 4, 5],
- [ -300, -400, 500],
- [ real.min, real.min, 4.75473e-4932L],
- [ real.max/2, real.max/2, 0x1.6a09e667f3bcc908p+16383L /*8.41267e+4931L*/],
- [ real.infinity, real.nan, real.infinity],
- [ real.nan, real.nan, real.nan],
- ];
- int i;
-
- for (i = 0; i < vals.length; i++)
- {
- real x = vals[i][0];
- real y = vals[i][1];
- real z = vals[i][2];
- real h = hypot(x, y);
-
- //printf("hypot(%Lg, %Lg) = %Lg, should be %Lg\n", x, y, h, z);
- //if (!mfeq(z, h, .0000001))
- //printf("%La\n", h);
- assert(mfeq(z, h, .0000001));
- }
-}
+//real nexttoward(real x, real y) { return std.c.math.nexttowardl(x, y); }
-/*********************************************************************
- * Separate floating point value into significand and exponent.
- *
+/*******************************************
+ * Returns the positive difference between x and y.
* Returns:
- *
Calculate and return x and exp such that
- * value =x*2exp and
- * .5 <= |x| < 1.0
- * x has same sign as value.
- *
*
- *
Special values
- *
- *
value
returns
exp
- *
- *
±0.0
±0.0
0
- *
- *
+∞
+∞
int.max
- *
- *
-∞
-∞
int.min
- *
- *
±NAN
±NAN
int.min
+ *
x, y
fdim(x, y)
+ *
x > y
x - y
+ *
x <= y
+0.0
*
*/
+real fdim(real x, real y) { return (x > y) ? x - y : +0.0; }
+/****************************************
+ * Returns the larger of x and y.
+ */
+real fmax(real x, real y) { return x > y ? x : y; }
-real frexp(real value, out int exp)
-{
- ushort* vu = cast(ushort*)&value;
- long* vl = cast(long*)&value;
- uint ex;
-
- // If exponent is non-zero
- ex = vu[4] & 0x7FFF;
- if (ex)
- {
- if (ex == 0x7FFF)
- { // infinity or NaN
- if (*vl & 0x7FFFFFFFFFFFFFFF) // if NaN
- { *vl |= 0xC000000000000000; // convert NANS to NANQ
- exp = int.min;
- }
- else if (vu[4] & 0x8000)
- { // negative infinity
- exp = int.min;
- }
- else
- { // positive infinity
- exp = int.max;
- }
- }
- else
- {
- exp = ex - 0x3FFE;
- vu[4] = (0x8000 & vu[4]) | 0x3FFE;
- }
- }
- else if (!*vl)
- {
- // value is +-0.0
- exp = 0;
- }
- else
- { // denormal
- int i = -0x3FFD;
-
- do
- {
- i--;
- *vl <<= 1;
- } while (*vl > 0);
- exp = i;
- vu[4] = (0x8000 & vu[4]) | 0x3FFE;
- }
- return value;
-}
-
-
-unittest
-{
- static real vals[][3] = // x,frexp,exp
- [
- [0.0, 0.0, 0],
- [-0.0, -0.0, 0],
- [1.0, .5, 1],
- [-1.0, -.5, 1],
- [2.0, .5, 2],
- [155.67e20, 0x1.A5F1C2EB3FE4Fp-1, 74], // normal
- [1.0e-320, 0.98829225, -1063],
- [real.min, .5, -16381],
- [real.min/2.0L, .5, -16382], // denormal
-
- [real.infinity,real.infinity,int.max],
- [-real.infinity,-real.infinity,int.min],
- [real.nan,real.nan,int.min],
- [-real.nan,-real.nan,int.min],
-
- // Don't really support signalling nan's in D
- //[real.nans,real.nan,int.min],
- //[-real.nans,-real.nan,int.min],
- ];
- int i;
-
- for (i = 0; i < vals.length; i++)
- {
- real x = vals[i][0];
- real e = vals[i][1];
- int exp = cast(int)vals[i][2];
- int eptr;
- real v = frexp(x, eptr);
+/****************************************
+ * Returns the smaller of x and y.
+ */
+real fmin(real x, real y) { return x < y ? x : y; }
- //printf("frexp(%Lg) = %.8Lg, should be %.8Lg, eptr = %d, should be %d\n", x, v, e, eptr, exp);
- assert(mfeq(e, v, .0000001));
- assert(exp == eptr);
- }
-}
+/**************************************
+ * Returns (x * y) + z, rounding only once according to the
+ * current rounding mode.
+ */
+real fma(real x, real y, real z) { return (x * y) + z; }
/*******************************************************************
* Fast integral powers.
@@ -909,6 +1288,49 @@
return pow(x, cast(uint)n);
}
+/*********************************************
+ * Calculates xy.
+ *
+ * $(TABLE_SV
+ *
+ *
x
y
pow(x, y)
div 0
invalid?
+ *
+ *
anything
±0.0
1.0
no
no
+ *
+ *
|x| > 1
+∞
+∞
no
no
+ *
+ *
|x| < 1
+∞
+0.0
no
no
+ *
+ *
|x| > 1
-∞
+0.0
no
no
+ *
+ *
|x| < 1
-∞
+∞
no
no
+ *
+ *
+∞
> 0.0
+∞
no
no
+ *
+ *
+∞
< 0.0
+0.0
no
no
+ *
+ *
-∞
odd integer > 0.0
-∞
no
no
+ *
+ *
-∞
> 0.0, not odd integer
+∞
no
no
+ *
+ *
-∞
odd integer < 0.0
-0.0
no
no
+ *
+ *
-∞
< 0.0, not odd integer
+0.0
no
no
+ *
+ *
±1.0
±∞
$(NAN)
no
yes
+ *
+ *
< 0.0
finite, nonintegral
$(NAN)
no
yes
+ *
+ *
±0.0
odd integer < 0.0
±∞
yes
no
+ *
+ *
±0.0
< 0.0, not odd integer
+∞
yes
no
+ *
+ *
±0.0
odd integer > 0.0
±0.0
no
no
+ *
+ *
±0.0
> 0.0, not odd integer
+0.0
no
no
+ * )
+ */
+
real pow(real x, real y)
{
version (linux) // C pow() often does not handle special values correctly
@@ -917,7 +1339,7 @@
return real.nan;
if (y == 0)
- return 1; // even if x is NAN
+ return 1; // even if x is $(NAN)
if (isnan(x) && y != 0)
return real.nan;
if (isinf(y))
@@ -1046,21 +1468,14 @@
* Returns: the number of mantissa bits which are equal in x and y.
* eg, 0x1.F8p+60 and 0x1.F1p+60 are equal to 5 bits of precision.
*
- *
- *
Special values
- *
- *
x
y
feqrel(x, y)
- *
- *
x
x
real.mant_dig
- *
- *
x
>= 2*x
0
- *
- *
x
<= x/2
0
- *
- *
NAN
any
0
- *
- *
any
NAN
0
- *
+ * $(TABLE_SV
+ *
x
y
feqrel(x, y)
+ *
x
x
real.mant_dig
+ *
x
>= 2*x
0
+ *
x
<= x/2
0
+ *
$(NAN)
any
0
+ *
any
$(NAN)
0
+ * )
*/
int feqrel(real x, real y)
diff -uNr dmd-0.132/dmd/src/phobos/std/path.d dmd-0.133/dmd/src/phobos/std/path.d
--- dmd-0.132/dmd/src/phobos/std/path.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/path.d 2005-09-24 17:25:30.000000000 +0200
@@ -1,7 +1,5 @@
/**
- * Boilerplate:
- * $(std_boilerplate.html)
* Macros:
* WIKI = StdPath
* Copyright:
diff -uNr dmd-0.132/dmd/src/phobos/std/stream.d dmd-0.133/dmd/src/phobos/std/stream.d
--- dmd-0.132/dmd/src/phobos/std/stream.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/stream.d 2005-09-24 17:25:30.000000000 +0200
@@ -1,6 +1,4 @@
/**
- * Boilerplate:
- * $(std_boilerplate.html)
* Macros:
* WIKI = StdStream
*/
diff -uNr dmd-0.132/dmd/src/phobos/std/string.d dmd-0.133/dmd/src/phobos/std/string.d
--- dmd-0.132/dmd/src/phobos/std/string.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/string.d 2005-09-24 17:25:30.000000000 +0200
@@ -1,21 +1,25 @@
-/*
- * Written by Walter Bright
- * Digital Mars
- * www.digitalmars.com
- * Placed into Public Domain.
- */
-
-// String handling functions.
-//
-// To copy or not to copy?
-//
-// When a function takes a string as a parameter, and returns a string,
-// is that string the same as the input string, modified in place, or
-// is it a modified copy of the input string? The D array convention is
-// "copy-on-write". This means that if no modifications are done, the
-// original string (or slices of it) can be returned. If any modifications
-// are done, the returned string is a copy.
-//
+
+/**
+ * String handling functions.
+ *
+ * To copy or not to copy?
+ * When a function takes a string as a parameter, and returns a string,
+ * is that string the same as the input string, modified in place, or
+ * is it a modified copy of the input string? The D array convention is
+ * "copy-on-write". This means that if no modifications are done, the
+ * original string (or slices of it) can be returned. If any modifications
+ * are done, the returned string is a copy.
+ *
+ * Macros:
+ * WIKI = StdString
+ * Copyright:
+ * Public Domain
+ */
+
+/* Author:
+ * Walter Bright, Digital Mars, www.digitalmars.com
+ */
+
// The code is not optimized for speed, that will have to wait
// until the design is solidified.
@@ -55,26 +59,27 @@
int wcscmp(wchar *, wchar *);
}
-/************** Exceptions ****************/
+/* ************* Exceptions *************** */
+/// Thrown on errors in string functions.
class StringException : Exception
{
- this(char[] msg)
+ this(char[] msg) /// Constructor
{
super(msg);
}
}
-/************** Constants ****************/
+/* ************* Constants *************** */
-const char[16] hexdigits = "0123456789ABCDEF";
-const char[10] digits = "0123456789";
-const char[8] octdigits = "01234567";
-const char[26] lowercase = "abcdefghijklmnopqrstuvwxyz";
-const char[26] uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+const char[16] hexdigits = "0123456789ABCDEF"; /// 0..9A..F
+const char[10] digits = "0123456789"; /// 0..9
+const char[8] octdigits = "01234567"; /// 0..7
+const char[26] lowercase = "abcdefghijklmnopqrstuvwxyz"; /// a..z
+const char[26] uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; /// A..Z
const char[52] letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz";
-const char[6] whitespace = " \t\v\r\n\f";
+ "abcdefghijklmnopqrstuvwxyz"; /// A..Za..z
+const char[6] whitespace = " \t\v\r\n\f"; /// ASCII whitespace
/**********************************
* Returns !=0 if c is whitespace
@@ -86,7 +91,7 @@
}
/*********************************
- * Convert string to integer / real.
+ * Convert string to integer.
*/
long atoi(char[] s)
@@ -95,7 +100,7 @@
}
/*************************************
- * Convert string to float
+ * Convert string to real.
*/
real atof(char[] s)
@@ -107,16 +112,18 @@
}
/**********************************
- * Compare two strings.
+ * Compare two strings. cmp is case sensitive, icmp is case insensitive.
* Returns:
- * <0 s1 < s2
- * =0 s1 == s2
- * >0 s1 > s2
+ *
+ *
< 0
s1 < s2
+ *
= 0
s1 == s2
+ *
> 0
s1 > s2
+ *
*/
int cmp(char[] s1, char[] s2)
{
- uint len = s1.length;
+ size_t len = s1.length;
int result;
//printf("cmp('%.*s', '%.*s')\n", s1, s2);
@@ -129,12 +136,12 @@
}
/*********************************
- * Same as cmp() but case insensitive.
+ * ditto
*/
int icmp(char[] s1, char[] s2)
{
- uint len = s1.length;
+ size_t len = s1.length;
int result;
if (s2.length < len)
@@ -145,7 +152,7 @@
}
version (linux)
{
- for (int i = 0; i < len; i++)
+ for (size_t i = 0; i < len; i++)
{
if (s1[i] != s2[i])
{
@@ -188,52 +195,57 @@
assert(result > 0);
}
-/*********************************
+/* ********************************
* Converts a D array of chars to a C-style 0 terminated string.
+ * Deprecated: replaced with toStringz().
*/
-deprecated char* toCharz(char[] string)
+deprecated char* toCharz(char[] s)
{
- return toStringz(string);
+ return toStringz(s);
}
-char* toStringz(char[] string)
+/*********************************
+ * Convert array of chars s[] to a C-style 0 terminated string.
+ */
+
+char* toStringz(char[] s)
in
{
}
out (result)
{
if (result)
- { assert(strlen(result) == string.length);
- assert(memcmp(result, string, string.length) == 0);
+ { assert(strlen(result) == s.length);
+ assert(memcmp(result, s, s.length) == 0);
}
}
body
{
char[] copy;
- if (string.length == 0)
+ if (s.length == 0)
return "";
/+ Unfortunately, this isn't reliable.
We could make this work if string literals are put
- in read-only memory and we test if string[] is pointing into
+ in read-only memory and we test if s[] is pointing into
that.
- /* Peek past end of string[], if it's 0, no conversion necessary.
+ /* Peek past end of s[], if it's 0, no conversion necessary.
* Note that the compiler will put a 0 past the end of static
* strings, and the storage allocator will put a 0 past the end
* of newly allocated char[]'s.
*/
- char* p = &string[0] + string.length;
+ char* p = &s[0] + s.length;
if (*p == 0)
- return string;
+ return s;
+/
// Need to make a copy
- copy = new char[string.length + 1];
- copy[0..string.length] = string;
- copy[string.length] = 0;
+ copy = new char[s.length + 1];
+ copy[0..s.length] = s;
+ copy[s.length] = 0;
return copy;
}
@@ -253,9 +265,12 @@
}
/******************************************
- * Find first occurrance of c in string s.
- * Return index in s where it is found.
- * Return -1 if not found.
+ * find, ifind _find first occurrance of c in string s.
+ * rfind, irfind _find last occurrance of c in string s.
+ *
+ * find, rfind are case sensitive; ifind, irfind are case insensitive.
+ * Returns:
+ * Index in s where c is found, -1 if not found.
*/
int find(char[] s, dchar c)
@@ -298,7 +313,7 @@
/******************************************
- * Case insensitive version of find().
+ * ditto
*/
int ifind(char[] s, dchar c)
@@ -358,18 +373,16 @@
/******************************************
- * Find last occurrance of c in string s.
- * Return index in s where it is found.
- * Return -1 if not found.
+ * ditto
*/
int rfind(char[] s, dchar c)
{
- int i;
+ size_t i;
if (c <= 0x7F)
{ // Plain old ASCII
- for (i = s.length; i-- > 0;)
+ for (i = s.length; i-- != 0;)
{
if (s[i] == c)
break;
@@ -401,7 +414,7 @@
}
/******************************************
- * Case insensitive version of rfind().
+ * ditto
*/
int irfind(char[] s, dchar c)
@@ -412,7 +425,7 @@
{ // Plain old ASCII
char c1 = std.ctype.tolower(c);
- for (i = s.length; i-- > 0;)
+ for (i = s.length; i-- != 0;)
{ char c2 = s[i];
c2 = std.ctype.tolower(c2);
@@ -424,7 +437,7 @@
{ // c is a universal character
dchar c1 = std.uni.toUniLower(c);
- for (i = s.length; i-- > 0;)
+ for (i = s.length; i-- != 0;)
{ char cx = s[i];
if (cx <= 0x7F)
@@ -469,10 +482,13 @@
}
-/*************************************
- * Find first occurrance of sub[] in string s[].
- * Return index in s[] where it is found.
- * Return -1 if not found.
+/******************************************
+ * find, ifind _find first occurrance of sub[] in string s[].
+ * rfind, irfind _find last occurrance of sub[] in string s[].
+ *
+ * find, rfind are case sensitive; ifind, irfind are case insensitive.
+ * Returns:
+ * Index in s where c is found, -1 if not found.
*/
int find(char[] s, char[] sub)
@@ -489,7 +505,7 @@
}
body
{
- int sublength = sub.length;
+ size_t sublength = sub.length;
if (sublength == 0)
return 0;
@@ -503,13 +519,13 @@
}
else
{
- int imax = s.length - sublength + 1;
+ size_t imax = s.length - sublength + 1;
// Remainder of sub[]
char *q = &sub[1];
sublength--;
- for (int i = 0; i < imax; i++)
+ for (size_t i = 0; i < imax; i++)
{
char *p = memchr(&s[i], c, imax - i);
if (!p)
@@ -543,8 +559,8 @@
assert(i == 6);
}
-/*************************************
- * Case insensitive version of find().
+/******************************************
+ * ditto
*/
int ifind(char[] s, char[] sub)
@@ -561,7 +577,7 @@
}
body
{
- int sublength = sub.length;
+ size_t sublength = sub.length;
int i;
if (sublength == 0)
@@ -577,7 +593,7 @@
}
else if (c <= 0x7F)
{
- int imax = s.length - sublength + 1;
+ size_t imax = s.length - sublength + 1;
// Remainder of sub[]
char[] subn = sub[1 .. sublength];
@@ -595,7 +611,7 @@
}
else
{
- int imax = s.length - sublength;
+ size_t imax = s.length - sublength;
for (i = 0; i < imax; i++)
{
@@ -649,10 +665,8 @@
assert(i == -1);
}
-/*************************************
- * Find last occurrance of sub in string s.
- * Return index in s where it is found.
- * Return -1 if not found.
+/******************************************
+ * ditto
*/
int rfind(char[] s, char[] sub)
@@ -705,8 +719,8 @@
}
-/*************************************
- * Case insensitive version of rfind().
+/******************************************
+ * ditto
*/
int irfind(char[] s, char[] sub)
@@ -791,7 +805,7 @@
/************************************
- * Convert string to lower case.
+ * Convert string s[] to lower case.
*/
char[] tolower(char[] s)
@@ -846,7 +860,7 @@
}
/************************************
- * Convert string to upper case.
+ * Convert string s[] to upper case.
*/
char[] toupper(char[] s)
@@ -902,7 +916,7 @@
/********************************************
- * Capitalize first character of string, convert rest of string
+ * Capitalize first character of string s[], convert rest of string s[]
* to lower case.
*/
@@ -967,7 +981,7 @@
/********************************************
- * Capitalize all words in string.
+ * Capitalize all words in string s[].
* Remove leading and trailing whitespace.
* Replace all sequences of whitespace with a single space.
*/
@@ -1075,13 +1089,13 @@
/********************************************
- * Concatenate all the strings together into one
+ * Concatenate all the strings in words[] together into one
* string; use sep[] as the separator.
*/
char[] join(char[][] words, char[] sep)
{
- uint len;
+ size_t len;
uint seplen;
uint i;
uint j;
@@ -1613,7 +1627,7 @@
/*******************************************
- * Left justify, right justify, or center string
+ * Left justify, right justify, or center string s[]
* in field width chars wide.
*/
@@ -1627,6 +1641,7 @@
return r;
}
+/// ditto
char[] rjustify(char[] s, int width)
{
if (s.length >= width)
@@ -1637,6 +1652,7 @@
return r;
}
+/// ditto
char[] center(char[] s, int width)
{
if (s.length >= width)
@@ -1676,7 +1692,7 @@
/*****************************************
- * Same as rjustify(), but fill with '0's
+ * Same as rjustify(), but fill with '0's.
*/
char[] zfill(char[] s, int width)
@@ -1731,8 +1747,9 @@
assert(i == 0);
}
-////////////////////////////////////////////////////////
-// Return a string that is string[] with slice[] replaced by replacement[].
+/*****************************
+ * Return a _string that is string[] with slice[] replaced by replacement[].
+ */
char[] replaceSlice(char[] string, char[] slice, char[] replacement)
in
@@ -1774,7 +1791,7 @@
* Insert sub[] into s[] at location index.
*/
-char[] insert(char[] s, int index, char[] sub)
+char[] insert(char[] s, size_t index, char[] sub)
in
{
assert(0 <= index && index <= s.length);
@@ -2021,6 +2038,7 @@
return b ? "true" : "false";
}
+/// ditto
char[] toString(char c)
{
char[] result = new char[2];
@@ -2043,9 +2061,10 @@
assert(s2 == "foo");
}
-char[] toString(ubyte ub) { return toString(cast(uint) ub); }
-char[] toString(ushort us) { return toString(cast(uint) us); }
+char[] toString(ubyte ub) { return toString(cast(uint) ub); } /// ditto
+char[] toString(ushort us) { return toString(cast(uint) us); } /// ditto
+/// ditto
char[] toString(uint u)
{ char[uint.sizeof * 3] buffer = void;
int ndigits;
@@ -2091,6 +2110,7 @@
assert(i == 0);
}
+/// ditto
char[] toString(ulong u)
{ char[ulong.sizeof * 3] buffer;
int ndigits;
@@ -2132,9 +2152,10 @@
assert(i == 0);
}
-char[] toString(byte b) { return toString(cast(int) b); }
-char[] toString(short s) { return toString(cast(int) s); }
+char[] toString(byte b) { return toString(cast(int) b); } /// ditto
+char[] toString(short s) { return toString(cast(int) s); } /// ditto
+/// ditto
char[] toString(int i)
{ char[1 + int.sizeof * 3] buffer;
char c;
@@ -2190,6 +2211,7 @@
assert(i == 0);
}
+/// ditto
char[] toString(long i)
{ char[1 + long.sizeof * 3] buffer;
char c;
@@ -2247,8 +2269,10 @@
assert(i == 0);
}
+/// ditto
char[] toString(float f) { return toString(cast(double) f); }
+/// ditto
char[] toString(double d)
{
char[20] buffer;
@@ -2257,6 +2281,7 @@
return toString(buffer).dup;
}
+/// ditto
char[] toString(real r)
{
char[20] buffer;
@@ -2265,8 +2290,10 @@
return toString(buffer).dup;
}
+/// ditto
char[] toString(ifloat f) { return toString(cast(idouble) f); }
+/// ditto
char[] toString(idouble d)
{
char[21] buffer;
@@ -2275,6 +2302,7 @@
return toString(buffer).dup;
}
+/// ditto
char[] toString(ireal r)
{
char[21] buffer;
@@ -2283,8 +2311,10 @@
return toString(buffer).dup;
}
+/// ditto
char[] toString(cfloat f) { return toString(cast(cdouble) f); }
+/// ditto
char[] toString(cdouble d)
{
char[20 + 1 + 20 + 1] buffer;
@@ -2293,6 +2323,7 @@
return toString(buffer).dup;
}
+/// ditto
char[] toString(creal r)
{
char[20 + 1 + 20 + 1] buffer;
@@ -2301,6 +2332,13 @@
return toString(buffer).dup;
}
+/******************************************
+ * Convert value to string in _radix radix.
+ *
+ * radix must be a value from 2 to 36.
+ * value is treated as a signed value only if radix is 10.
+ * The characters A through Z are used to represent values 10 through 36.
+ */
char[] toString(long value, uint radix)
in
{
@@ -2313,6 +2351,7 @@
return toString(cast(ulong)value, radix);
}
+/// ditto
char[] toString(ulong value, uint radix)
in
{
@@ -2361,7 +2400,7 @@
}
/*************************************************
- * Convert to char[].
+ * Convert C-style 0 terminated string s to char[] string.
*/
char[] toString(char *s)
@@ -2387,6 +2426,7 @@
/*****************************************************
+ * Format arguments into a string.
*/
@@ -2404,6 +2444,11 @@
}
+/*****************************************************
+ * Format arguments into string s which must be large
+ * enough to hold the result. Throws ArrayBoundsError if it is not.
+ * Returns: s
+ */
char[] sformat(char[] s, ...)
{ size_t i;
@@ -2476,6 +2521,21 @@
/***********************************************
* See if character c is in the pattern.
+ * Patterns:
+ *
+ * A pattern is an array of characters much like a character
+ * class in regular expressions. A sequence of characters
+ * can be given, such as "abcde". The '-' can represent a range
+ * of characters, as "a-e" represents the same pattern as "abcde".
+ * "a-fA-F0-9" represents all the hex characters.
+ * If the first character of a pattern is '^', then the pattern
+ * is negated, i.e. "^0-9" means any character except a digit.
+ * The functions inPattern, countchars, removeschars,
+ * and squeeze
+ * use patterns.
+ *
+ * Note: In the future, the pattern syntax may be improved
+ * to be more like regular expression character classes.
*/
int inPattern(dchar c, char[] pattern)
@@ -2653,7 +2713,7 @@
/***************************************************
- * Return string where sequences of a character from pattern
+ * Return string where sequences of a character in s[] from pattern[]
* are replaced with a single instance of that character.
* If pattern is null, it defaults to all characters.
*/
@@ -2723,7 +2783,7 @@
/**********************************************
- * Return string that is the 'successor' to s.
+ * Return string that is the 'successor' to s[].
* If the rightmost character is a-zA-Z0-9, it is incremented within
* its case or digits. If it generates a carry, the process is
* repeated with the one to its immediate left.
@@ -2794,7 +2854,33 @@
/***********************************************
- * Translate characters in from[] to characters in to[].
+ * Replaces characters in str[] that are in from[]
+ * with corresponding characters in to[] and returns the resulting
+ * string.
+ * Params:
+ * modifiers = a string of modifier characters
+ * Modifiers:
+
+
Modifier
Description
+
c
Complement the list of characters in from[]
+
d
Removes matching characters with no corresponding replacement in to[]
+
s
Removes adjacent duplicates in the replaced characters
+
+
+ If modifier d is present, then the number of characters
+ in to[] may be only 0 or 1.
+
+ If modifier d is not present and to[] is null,
+ then to[] is taken _to be the same as from[].
+
+ If modifier d is not present and to[] is shorter
+ than from[], then to[] is extended by replicating the
+ last character in to[].
+
+ Both from[] and to[] may contain ranges using the -
+ character, for example a-d is synonymous with abcd.
+ Neither accept a leading ^ as meaning the complement of
+ the string (use the c modifier for that).
*/
char[] tr(char[] str, char[] from, char[] to, char[] modifiers = null)
@@ -2949,7 +3035,7 @@
}
-/*************************************************
+/* ************************************************
* Version : v0.3
* Author : David L. 'SpottedTiger' Davis
* Date Created : 31.May.05 Compiled and Tested with dmd v0.125
@@ -2960,43 +3046,41 @@
* Licence : Public Domain / Contributed to Digital Mars
*/
-/+
- ' final bool isNumeric(in char[], in bool = false)
- ' ---------------------------------------------------------------
- ' [in] char[] s can be formatted in the following ways:
- '
- ' Integer Whole Number:
- ' (for byte, ubyte, short, ushort, int, uint, long, and ulong)
- ' ['+'|'-']digit(s)[U|L|UL]
- '
- ' examples: 123, 123UL, 123L, +123U, -123L
- '
- ' Floating-Point Number:
- ' (for float, double, real, ifloat, idouble, and ireal)
- ' ['+'|'-']digit(s)[.][digit(s)][[e-|e+]digit(s)][i|f|L|Li|fi]]
- ' or [nan|nani|inf|-inf]
- '
- ' examples: +123., -123.01, 123.3e-10f, 123.3e-10fi, 123.3e-10L
- '
- ' (for cfloat, cdouble, and creal)
- ' ['+'|'-']digit(s)[.][digit(s)][[e-|e+]digit(s)][+]
- ' [digit(s)[.][digit(s)][[e-|e+]digit(s)][i|f|L|Li|fi]]
- ' or [nan|nani|nan+nani|inf|-inf]
- '
- ' examples: nan, -123e-1+456.9e-10Li, +123e+10+456i, 123+456
- '
- ' [in] bool bAllowSep
- ' False by default, but when set to true it will accept the
- ' separator characters "," and "_" within the string, but these
- ' characters should be stripped from the string before using any
- ' of the conversion functions like toInt(), toFloat(), and etc
- ' else an error will occur.
- '
- ' Also please note, that no spaces are allowed within the string
- ' anywhere whether it's a leading, trailing, or embedded space(s),
- ' thus they too must be stripped from the string before using this
- ' function, or any of the conversion functions.
- +/
+/**
+ * [in] char[] s can be formatted in the following ways:
+ *
+ * Integer Whole Number:
+ * (for byte, ubyte, short, ushort, int, uint, long, and ulong)
+ * ['+'|'-']digit(s)[U|L|UL]
+ *
+ * examples: 123, 123UL, 123L, +123U, -123L
+ *
+ * Floating-Point Number:
+ * (for float, double, real, ifloat, idouble, and ireal)
+ * ['+'|'-']digit(s)[.][digit(s)][[e-|e+]digit(s)][i|f|L|Li|fi]]
+ * or [nan|nani|inf|-inf]
+ *
+ * examples: +123., -123.01, 123.3e-10f, 123.3e-10fi, 123.3e-10L
+ *
+ * (for cfloat, cdouble, and creal)
+ * ['+'|'-']digit(s)[.][digit(s)][[e-|e+]digit(s)][+]
+ * [digit(s)[.][digit(s)][[e-|e+]digit(s)][i|f|L|Li|fi]]
+ * or [nan|nani|nan+nani|inf|-inf]
+ *
+ * examples: nan, -123e-1+456.9e-10Li, +123e+10+456i, 123+456
+ *
+ * [in] bool bAllowSep
+ * False by default, but when set to true it will accept the
+ * separator characters "," and "_" within the string, but these
+ * characters should be stripped from the string before using any
+ * of the conversion functions like toInt(), toFloat(), and etc
+ * else an error will occur.
+ *
+ * Also please note, that no spaces are allowed within the string
+ * anywhere whether it's a leading, trailing, or embedded space(s),
+ * thus they too must be stripped from the string before using this
+ * function, or any of the conversion functions.
+ */
final bool isNumeric(in char[] s, in bool bAllowSep = false)
{
@@ -3140,13 +3224,13 @@
return true;
}
-// Allow any object as a parameter
+/// Allow any object as a parameter
bool isNumeric(...)
{
return isNumeric(_arguments, _argptr);
}
-// Check only the first parameter, all others will be ignored.
+/// Check only the first parameter, all others will be ignored.
bool isNumeric(TypeInfo[] _arguments, va_list _argptr)
{
char[] s = "";
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Aa.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Aa.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Aa.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Aa.d 2005-09-24 17:25:30.000000000 +0200
@@ -18,7 +18,7 @@
}
else
{
- uint len = s.length;
+ size_t len = s.length;
char *str = s;
while (1)
@@ -73,7 +73,7 @@
return std.string.cmp(s1, s2);
}
- int tsize()
+ size_t tsize()
{
return (char[]).sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Abit.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Abit.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Abit.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Abit.d 2005-09-24 17:25:30.000000000 +0200
@@ -9,7 +9,7 @@
uint getHash(void *p)
{ ubyte[] s = *cast(ubyte[]*)p;
- uint len = (s.length + 7) / 8;
+ size_t len = (s.length + 7) / 8;
ubyte *str = s;
uint hash = 0;
@@ -53,13 +53,13 @@
bit[] s1 = *cast(bit[]*)p1;
bit[] s2 = *cast(bit[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (s2.length != len)
return 0;;
// Woefully inefficient bit-by-bit comparison
- for (uint u = 0; u < len; u++)
+ for (size_t u = 0; u < len; u++)
{
if (s1[u] != s2[u])
return 0;
@@ -72,13 +72,13 @@
bit[] s1 = *cast(bit[]*)p1;
bit[] s2 = *cast(bit[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (s2.length < len)
len = s2.length;
// Woefully inefficient bit-by-bit comparison
- for (uint u = 0; u < len; u++)
+ for (size_t u = 0; u < len; u++)
{
int result = s1[u] - s2[u];
if (result)
@@ -87,7 +87,7 @@
return cast(int)s1.length - cast(int)s2.length;
}
- int tsize()
+ size_t tsize()
{
return (bit[]).sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_AC.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_AC.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_AC.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_AC.d 2005-09-24 17:25:30.000000000 +0200
@@ -75,7 +75,7 @@
return c;
}
- int tsize()
+ size_t tsize()
{
return (Object[]).sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Acdouble.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Acdouble.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Acdouble.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Acdouble.d 2005-09-24 17:25:30.000000000 +0200
@@ -32,7 +32,7 @@
uint getHash(void *p)
{ cdouble[] s = *cast(cdouble[]*)p;
- uint len = s.length;
+ size_t len = s.length;
cdouble *str = s;
uint hash = 0;
@@ -54,7 +54,7 @@
{
cdouble[] s1 = *cast(cdouble[]*)p1;
cdouble[] s2 = *cast(cdouble[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (len != s2.length)
return 0;
@@ -71,7 +71,7 @@
{
cdouble[] s1 = *cast(cdouble[]*)p1;
cdouble[] s2 = *cast(cdouble[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (s2.length < len)
len = s2.length;
@@ -84,7 +84,7 @@
return cast(int)s1.length - cast(int)s2.length;
}
- int tsize()
+ size_t tsize()
{
return (cdouble[]).sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Acfloat.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Acfloat.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Acfloat.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Acfloat.d 2005-09-24 17:25:30.000000000 +0200
@@ -32,7 +32,7 @@
uint getHash(void *p)
{ cfloat[] s = *cast(cfloat[]*)p;
- uint len = s.length;
+ size_t len = s.length;
cfloat *str = s;
uint hash = 0;
@@ -52,7 +52,7 @@
{
cfloat[] s1 = *cast(cfloat[]*)p1;
cfloat[] s2 = *cast(cfloat[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (len != s2.length)
return 0;
@@ -69,7 +69,7 @@
{
cfloat[] s1 = *cast(cfloat[]*)p1;
cfloat[] s2 = *cast(cfloat[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (s2.length < len)
len = s2.length;
@@ -82,7 +82,7 @@
return cast(int)s1.length - cast(int)s2.length;
}
- int tsize()
+ size_t tsize()
{
return (cfloat[]).sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Acreal.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Acreal.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Acreal.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Acreal.d 2005-09-24 17:25:30.000000000 +0200
@@ -32,7 +32,7 @@
uint getHash(void *p)
{ creal[] s = *cast(creal[]*)p;
- uint len = s.length;
+ size_t len = s.length;
creal *str = s;
uint hash = 0;
@@ -55,7 +55,7 @@
{
creal[] s1 = *cast(creal[]*)p1;
creal[] s2 = *cast(creal[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (len != s2.length)
return 0;
@@ -72,7 +72,7 @@
{
creal[] s1 = *cast(creal[]*)p1;
creal[] s2 = *cast(creal[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (s2.length < len)
len = s2.length;
@@ -85,7 +85,7 @@
return cast(int)s1.length - cast(int)s2.length;
}
- int tsize()
+ size_t tsize()
{
return (creal[]).sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Adchar.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Adchar.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Adchar.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Adchar.d 2005-09-24 17:25:30.000000000 +0200
@@ -9,7 +9,7 @@
uint getHash(void *p)
{ dchar[] s = *cast(dchar[]*)p;
- uint len = s.length;
+ size_t len = s.length;
dchar *str = s;
uint hash = 0;
@@ -37,11 +37,11 @@
{
dchar[] s1 = *cast(dchar[]*)p1;
dchar[] s2 = *cast(dchar[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (s2.length < len)
len = s2.length;
- for (uint u = 0; u < len; u++)
+ for (size_t u = 0; u < len; u++)
{
int result = s1[u] - s2[u];
if (result)
@@ -50,7 +50,7 @@
return cast(int)s1.length - cast(int)s2.length;
}
- int tsize()
+ size_t tsize()
{
return (dchar[]).sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Adouble.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Adouble.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Adouble.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Adouble.d 2005-09-24 17:25:30.000000000 +0200
@@ -32,7 +32,7 @@
uint getHash(void *p)
{ double[] s = *cast(double[]*)p;
- uint len = s.length;
+ size_t len = s.length;
double *str = s;
uint hash = 0;
@@ -52,7 +52,7 @@
{
double[] s1 = *cast(double[]*)p1;
double[] s2 = *cast(double[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (len != s2.length)
return 0;
@@ -69,7 +69,7 @@
{
double[] s1 = *cast(double[]*)p1;
double[] s2 = *cast(double[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (s2.length < len)
len = s2.length;
@@ -82,7 +82,7 @@
return cast(int)s1.length - cast(int)s2.length;
}
- int tsize()
+ size_t tsize()
{
return (double[]).sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Afloat.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Afloat.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Afloat.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Afloat.d 2005-09-24 17:25:30.000000000 +0200
@@ -32,7 +32,7 @@
uint getHash(void *p)
{ float[] s = *cast(float[]*)p;
- uint len = s.length;
+ size_t len = s.length;
float *str = s;
uint hash = 0;
@@ -51,7 +51,7 @@
{
float[] s1 = *cast(float[]*)p1;
float[] s2 = *cast(float[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (len != s2.length)
return 0;
@@ -68,7 +68,7 @@
{
float[] s1 = *cast(float[]*)p1;
float[] s2 = *cast(float[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (s2.length < len)
len = s2.length;
@@ -81,7 +81,7 @@
return cast(int)s1.length - cast(int)s2.length;
}
- int tsize()
+ size_t tsize()
{
return (float[]).sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Ag.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Ag.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Ag.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Ag.d 2005-09-24 17:25:30.000000000 +0200
@@ -9,7 +9,7 @@
uint getHash(void *p)
{ byte[] s = *cast(byte[]*)p;
- uint len = s.length;
+ size_t len = s.length;
byte *str = s;
uint hash = 0;
@@ -61,11 +61,11 @@
{
byte[] s1 = *cast(byte[]*)p1;
byte[] s2 = *cast(byte[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (s2.length < len)
len = s2.length;
- for (uint u = 0; u < len; u++)
+ for (size_t u = 0; u < len; u++)
{
int result = s1[u] - s2[u];
if (result)
@@ -74,7 +74,7 @@
return cast(int)s1.length - cast(int)s2.length;
}
- int tsize()
+ size_t tsize()
{
return (byte[]).sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Aint.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Aint.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Aint.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Aint.d 2005-09-24 17:25:30.000000000 +0200
@@ -9,7 +9,7 @@
uint getHash(void *p)
{ int[] s = *cast(int[]*)p;
- uint len = s.length;
+ size_t len = s.length;
int *str = s;
uint hash = 0;
@@ -37,11 +37,11 @@
{
int[] s1 = *cast(int[]*)p1;
int[] s2 = *cast(int[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (s2.length < len)
len = s2.length;
- for (uint u = 0; u < len; u++)
+ for (size_t u = 0; u < len; u++)
{
int result = s1[u] - s2[u];
if (result)
@@ -50,7 +50,7 @@
return cast(int)s1.length - cast(int)s2.length;
}
- int tsize()
+ size_t tsize()
{
return (int[]).sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Along.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Along.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Along.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Along.d 2005-09-24 17:25:30.000000000 +0200
@@ -9,7 +9,7 @@
uint getHash(void *p)
{ long[] s = *cast(long[]*)p;
- uint len = s.length;
+ size_t len = s.length;
long *str = s;
uint hash = 0;
@@ -37,11 +37,11 @@
{
long[] s1 = *cast(long[]*)p1;
long[] s2 = *cast(long[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (s2.length < len)
len = s2.length;
- for (uint u = 0; u < len; u++)
+ for (size_t u = 0; u < len; u++)
{
int result = s1[u] - s2[u];
if (result)
@@ -50,7 +50,7 @@
return cast(int)s1.length - cast(int)s2.length;
}
- int tsize()
+ size_t tsize()
{
return (long[]).sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Areal.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Areal.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Areal.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Areal.d 2005-09-24 17:25:30.000000000 +0200
@@ -32,7 +32,7 @@
uint getHash(void *p)
{ real[] s = *cast(real[]*)p;
- uint len = s.length;
+ size_t len = s.length;
real *str = s;
uint hash = 0;
@@ -53,7 +53,7 @@
{
real[] s1 = *cast(real[]*)p1;
real[] s2 = *cast(real[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (len != s2.length)
return 0;
@@ -70,7 +70,7 @@
{
real[] s1 = *cast(real[]*)p1;
real[] s2 = *cast(real[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (s2.length < len)
len = s2.length;
@@ -83,7 +83,7 @@
return cast(int)s1.length - cast(int)s2.length;
}
- int tsize()
+ size_t tsize()
{
return (real[]).sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Ashort.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Ashort.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Ashort.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Ashort.d 2005-09-24 17:25:30.000000000 +0200
@@ -9,7 +9,7 @@
uint getHash(void *p)
{ short[] s = *cast(short[]*)p;
- uint len = s.length;
+ size_t len = s.length;
short *str = s;
uint hash = 0;
@@ -50,11 +50,11 @@
{
short[] s1 = *cast(short[]*)p1;
short[] s2 = *cast(short[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (s2.length < len)
len = s2.length;
- for (uint u = 0; u < len; u++)
+ for (size_t u = 0; u < len; u++)
{
int result = s1[u] - s2[u];
if (result)
@@ -63,7 +63,7 @@
return cast(int)s1.length - cast(int)s2.length;
}
- int tsize()
+ size_t tsize()
{
return (short[]).sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Aubyte.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Aubyte.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Aubyte.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Aubyte.d 2005-09-24 17:25:30.000000000 +0200
@@ -9,7 +9,7 @@
uint getHash(void *p)
{ ubyte[] s = *cast(ubyte[]*)p;
- uint len = s.length;
+ size_t len = s.length;
ubyte *str = s;
uint hash = 0;
@@ -65,7 +65,7 @@
return std.string.cmp(s1, s2);
}
- int tsize()
+ size_t tsize()
{
return (ubyte[]).sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Auint.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Auint.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Auint.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Auint.d 2005-09-24 17:25:30.000000000 +0200
@@ -9,7 +9,7 @@
uint getHash(void *p)
{ uint[] s = *cast(uint[]*)p;
- uint len = s.length;
+ size_t len = s.length;
uint *str = s;
uint hash = 0;
@@ -37,11 +37,11 @@
{
uint[] s1 = *cast(uint[]*)p1;
uint[] s2 = *cast(uint[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (s2.length < len)
len = s2.length;
- for (uint u = 0; u < len; u++)
+ for (size_t u = 0; u < len; u++)
{
int result = s1[u] - s2[u];
if (result)
@@ -50,7 +50,7 @@
return cast(int)s1.length - cast(int)s2.length;
}
- int tsize()
+ size_t tsize()
{
return (uint[]).sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Aulong.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Aulong.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Aulong.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Aulong.d 2005-09-24 17:25:30.000000000 +0200
@@ -9,7 +9,7 @@
uint getHash(void *p)
{ ulong[] s = *cast(ulong[]*)p;
- uint len = s.length;
+ size_t len = s.length;
ulong *str = s;
uint hash = 0;
@@ -37,11 +37,11 @@
{
ulong[] s1 = *cast(ulong[]*)p1;
ulong[] s2 = *cast(ulong[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (s2.length < len)
len = s2.length;
- for (uint u = 0; u < len; u++)
+ for (size_t u = 0; u < len; u++)
{
int result = s1[u] - s2[u];
if (result)
@@ -50,7 +50,7 @@
return cast(int)s1.length - cast(int)s2.length;
}
- int tsize()
+ size_t tsize()
{
return (ulong[]).sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Aushort.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Aushort.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Aushort.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Aushort.d 2005-09-24 17:25:30.000000000 +0200
@@ -9,7 +9,7 @@
uint getHash(void *p)
{ ushort[] s = *cast(ushort[]*)p;
- uint len = s.length;
+ size_t len = s.length;
ushort *str = s;
uint hash = 0;
@@ -50,11 +50,11 @@
{
ushort[] s1 = *cast(ushort[]*)p1;
ushort[] s2 = *cast(ushort[]*)p2;
- uint len = s1.length;
+ size_t len = s1.length;
if (s2.length < len)
len = s2.length;
- for (uint u = 0; u < len; u++)
+ for (size_t u = 0; u < len; u++)
{
int result = s1[u] - s2[u];
if (result)
@@ -63,7 +63,7 @@
return cast(int)s1.length - cast(int)s2.length;
}
- int tsize()
+ size_t tsize()
{
return (ushort[]).sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Awchar.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Awchar.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_Awchar.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_Awchar.d 2005-09-24 17:25:30.000000000 +0200
@@ -9,7 +9,7 @@
uint getHash(void *p)
{ wchar[] s = *cast(wchar[]*)p;
- uint len = s.length;
+ size_t len = s.length;
wchar *str = s;
uint hash = 0;
@@ -63,7 +63,7 @@
return cast(int)s1.length - cast(int)s2.length;
}
- int tsize()
+ size_t tsize()
{
return (wchar[]).sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_bit.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_bit.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_bit.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_bit.d 2005-09-24 17:25:30.000000000 +0200
@@ -24,7 +24,7 @@
return 0;
}
- int tsize()
+ size_t tsize()
{
return bit.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_byte.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_byte.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_byte.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_byte.d 2005-09-24 17:25:30.000000000 +0200
@@ -20,7 +20,7 @@
return *cast(byte *)p1 - *cast(byte *)p2;
}
- int tsize()
+ size_t tsize()
{
return byte.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_C.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_C.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_C.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_C.d 2005-09-24 17:25:30.000000000 +0200
@@ -63,7 +63,7 @@
return c;
}
- int tsize()
+ size_t tsize()
{
return Object.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_cdouble.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_cdouble.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_cdouble.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_cdouble.d 2005-09-24 17:25:30.000000000 +0200
@@ -42,7 +42,7 @@
return _compare(*cast(cdouble *)p1, *cast(cdouble *)p2);
}
- int tsize()
+ size_t tsize()
{
return cdouble.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_cfloat.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_cfloat.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_cfloat.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_cfloat.d 2005-09-24 17:25:30.000000000 +0200
@@ -41,7 +41,7 @@
return _compare(*cast(cfloat *)p1, *cast(cfloat *)p2);
}
- int tsize()
+ size_t tsize()
{
return cfloat.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_char.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_char.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_char.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_char.d 2005-09-24 17:25:30.000000000 +0200
@@ -19,7 +19,7 @@
return *cast(char *)p1 - *cast(char *)p2;
}
- int tsize()
+ size_t tsize()
{
return char.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_creal.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_creal.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_creal.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_creal.d 2005-09-24 17:25:30.000000000 +0200
@@ -43,7 +43,7 @@
return _compare(*cast(creal *)p1, *cast(creal *)p2);
}
- int tsize()
+ size_t tsize()
{
return creal.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_dchar.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_dchar.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_dchar.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_dchar.d 2005-09-24 17:25:30.000000000 +0200
@@ -20,7 +20,7 @@
return *cast(dchar *)p1 - *cast(dchar *)p2;
}
- int tsize()
+ size_t tsize()
{
return dchar.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_delegate.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_delegate.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_delegate.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_delegate.d 2005-09-24 17:25:30.000000000 +0200
@@ -16,7 +16,7 @@
return *cast(dg *)p1 == *cast(dg *)p2;
}
- int tsize()
+ size_t tsize()
{
return dg.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_double.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_double.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_double.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_double.d 2005-09-24 17:25:30.000000000 +0200
@@ -42,7 +42,7 @@
return _compare(*cast(double *)p1, *cast(double *)p2);
}
- int tsize()
+ size_t tsize()
{
return double.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_float.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_float.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_float.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_float.d 2005-09-24 17:25:30.000000000 +0200
@@ -42,7 +42,7 @@
return _compare(*cast(float *)p1, *cast(float *)p2);
}
- int tsize()
+ size_t tsize()
{
return float.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_int.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_int.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_int.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_int.d 2005-09-24 17:25:30.000000000 +0200
@@ -24,7 +24,7 @@
return 0;
}
- int tsize()
+ size_t tsize()
{
return int.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_long.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_long.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_long.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_long.d 2005-09-24 17:25:30.000000000 +0200
@@ -24,7 +24,7 @@
return 0;
}
- int tsize()
+ size_t tsize()
{
return long.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_ptr.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_ptr.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_ptr.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_ptr.d 2005-09-24 17:25:30.000000000 +0200
@@ -18,7 +18,7 @@
return *cast(void* *)p1 - *cast(void* *)p2;
}
- int tsize()
+ size_t tsize()
{
return (void*).sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_real.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_real.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_real.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_real.d 2005-09-24 17:25:30.000000000 +0200
@@ -42,7 +42,7 @@
return _compare(*cast(real *)p1, *cast(real *)p2);
}
- int tsize()
+ size_t tsize()
{
return real.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_short.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_short.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_short.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_short.d 2005-09-24 17:25:30.000000000 +0200
@@ -20,7 +20,7 @@
return *cast(short *)p1 - *cast(short *)p2;
}
- int tsize()
+ size_t tsize()
{
return short.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_ubyte.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_ubyte.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_ubyte.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_ubyte.d 2005-09-24 17:25:30.000000000 +0200
@@ -20,7 +20,7 @@
return *cast(ubyte *)p1 - *cast(ubyte *)p2;
}
- int tsize()
+ size_t tsize()
{
return ubyte.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_uint.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_uint.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_uint.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_uint.d 2005-09-24 17:25:30.000000000 +0200
@@ -24,7 +24,7 @@
return 0;
}
- int tsize()
+ size_t tsize()
{
return uint.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_ulong.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_ulong.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_ulong.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_ulong.d 2005-09-24 17:25:30.000000000 +0200
@@ -24,7 +24,7 @@
return 0;
}
- int tsize()
+ size_t tsize()
{
return ulong.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_ushort.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_ushort.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_ushort.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_ushort.d 2005-09-24 17:25:30.000000000 +0200
@@ -20,7 +20,7 @@
return *cast(ushort *)p1 - *cast(ushort *)p2;
}
- int tsize()
+ size_t tsize()
{
return ushort.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_wchar.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_wchar.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_wchar.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_wchar.d 2005-09-24 17:25:30.000000000 +0200
@@ -19,7 +19,7 @@
return *cast(wchar *)p1 - *cast(wchar *)p2;
}
- int tsize()
+ size_t tsize()
{
return wchar.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std/typeinfo/ti_void.d dmd-0.133/dmd/src/phobos/std/typeinfo/ti_void.d
--- dmd-0.132/dmd/src/phobos/std/typeinfo/ti_void.d 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std/typeinfo/ti_void.d 2005-09-24 17:25:30.000000000 +0200
@@ -21,7 +21,7 @@
return *cast(byte *)p1 - *cast(byte *)p2;
}
- int tsize()
+ size_t tsize()
{
return void.sizeof;
}
diff -uNr dmd-0.132/dmd/src/phobos/std_boilerplate.html dmd-0.133/dmd/src/phobos/std_boilerplate.html
--- dmd-0.132/dmd/src/phobos/std_boilerplate.html 2005-09-19 17:54:38.000000000 +0200
+++ dmd-0.133/dmd/src/phobos/std_boilerplate.html 1970-01-01 01:00:00.000000000 +0100
@@ -1,137 +0,0 @@
-
-
-
-
-
-
-
-Digital Mars - The D Programming Language - $(TITLE)
-
-
-
-
-
-
-Home
-| Search
-| D
-| Comments
-
-
-Last update $(DATETIME)
-
-