mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 14:40:30 +03:00
phobos 0.161
This commit is contained in:
parent
6ca2e50261
commit
b76c21ccf9
42 changed files with 973 additions and 260 deletions
477
etc/gamma.d
Normal file
477
etc/gamma.d
Normal file
|
@ -0,0 +1,477 @@
|
||||||
|
/*
|
||||||
|
* Cephes code Copyright 1994 by Stephen L. Moshier
|
||||||
|
* Converted to D by Don Clugston.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
Macros:
|
||||||
|
GAMMA = Γ
|
||||||
|
INTEGRAL = ∫
|
||||||
|
*/
|
||||||
|
module etc.gamma;
|
||||||
|
|
||||||
|
import std.math;
|
||||||
|
private import std.stdio;
|
||||||
|
import etc.realtest;
|
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
const real SQRT2PI = 2.50662827463100050242E0L; // sqrt(2pi)
|
||||||
|
const real MAXGAMMA = 1755.455L; // exp(tgamma(x)) == inf if x>MAXGAMMA
|
||||||
|
|
||||||
|
// Polynomial approximations for gamma and loggamma.
|
||||||
|
|
||||||
|
static real GammaNumeratorCoeffs[] = [
|
||||||
|
0x1p+0, // 1
|
||||||
|
0x1.acf42d903366539ep-1, // 0.83780043015731267283
|
||||||
|
0x1.73a991c8475f1aeap-2, // 0.36295154366402391688
|
||||||
|
0x1.c7e918751d6b2a92p-4, // 0.1113062816019361559
|
||||||
|
0x1.86d162cca32cfe86p-6, // 0.023853632434611082525
|
||||||
|
0x1.0c378e2e6eaf7cd8p-8, // 0.0040926668283940355009
|
||||||
|
0x1.dc5c66b7d05feb54p-12, // 0.00045429319606080091555
|
||||||
|
0x1.616457b47e448694p-15 // 4.2127604874716220134e-05
|
||||||
|
];
|
||||||
|
|
||||||
|
static real GammaDenominatorCoeffs[] = [
|
||||||
|
0x1p+0, // 1
|
||||||
|
0x1.a8f9faae5d8fc8b0p-2, // 0.41501609505884554346
|
||||||
|
-0x1.cb7895a6756eebdep-3, // -0.22435109056703291645
|
||||||
|
-0x1.7b9bab006d30652ap-5, // -0.046338876712445342138
|
||||||
|
0x1.c671af78f312082ep-6, // 0.027737065658400729792
|
||||||
|
-0x1.a11ebbfaf96252dcp-11, // -0.00079559336824947383209
|
||||||
|
-0x1.447b4d2230a77ddap-10, // -0.0012377992466531522311
|
||||||
|
0x1.ec1d45bb85e06696p-13, // 0.00023465840591606352443
|
||||||
|
-0x1.d4ce24d05bd0a8e6p-17 // -1.3971485174761704409e-05
|
||||||
|
];
|
||||||
|
|
||||||
|
static real GammaSmallCoeffs[] = [
|
||||||
|
0x1p+0, // 1
|
||||||
|
0x1.2788cfc6fb618f52p-1, // 0.57721566490153286082
|
||||||
|
-0x1.4fcf4026afa2f7ecp-1, // -0.65587807152025406846
|
||||||
|
-0x1.5815e8fa24d7e306p-5, // -0.042002635034033440541
|
||||||
|
0x1.5512320aea2ad71ap-3, // 0.16653861137208052067
|
||||||
|
-0x1.59af0fb9d82e2160p-5, // -0.042197733607059154702
|
||||||
|
-0x1.3b4b61d3bfdf244ap-7, // -0.0096220233604062716456
|
||||||
|
0x1.d9358e9d9d69fd34p-8, // 0.0072205994780369096722
|
||||||
|
-0x1.38fc4bcbada775d6p-10 // -0.0011939450513815100956
|
||||||
|
];
|
||||||
|
|
||||||
|
static real GammaSmallNegCoeffs[] = [
|
||||||
|
-0x1p+0, // -1
|
||||||
|
0x1.2788cfc6fb618f54p-1, // 0.57721566490153286086
|
||||||
|
0x1.4fcf4026afa2bc4cp-1, // 0.65587807152025365473
|
||||||
|
-0x1.5815e8fa2468fec8p-5, // -0.042002635034021129105
|
||||||
|
-0x1.5512320baedaf4b6p-3, // -0.16653861139444135193
|
||||||
|
-0x1.59af0fa283baf07ep-5, // -0.042197733437311917216
|
||||||
|
0x1.3b4a70de31e05942p-7, // 0.0096219111550359767339
|
||||||
|
0x1.d9398be3bad13136p-8, // 0.0072208372618931703258
|
||||||
|
0x1.291b73ee05bcbba2p-10 // 0.001133374167243894382
|
||||||
|
];
|
||||||
|
|
||||||
|
static real logGammaStirlingCoeffs[] = [
|
||||||
|
0x1.5555555555553f98p-4, // 0.083333333333333314473
|
||||||
|
-0x1.6c16c16c07509b10p-9, // -0.0027777777777503496034
|
||||||
|
0x1.a01a012461cbf1e4p-11, // 0.00079365077958550707556
|
||||||
|
-0x1.3813089d3f9d1640p-11, // -0.00059523458517656885149
|
||||||
|
0x1.b911a92555a277b8p-11, // 0.00084127232973224980805
|
||||||
|
-0x1.ed0a7b4206087b22p-10, // -0.0018808019381193769072
|
||||||
|
0x1.402523859811b308p-8 // 0.0048850261424322707812
|
||||||
|
];
|
||||||
|
|
||||||
|
static real logGammaNumerator[] = [
|
||||||
|
-0x1.0edd25913aaa40a2p+23, // -8875666.7836507038022
|
||||||
|
-0x1.31c6ce2e58842d1ep+24, // -20039374.181038151756
|
||||||
|
-0x1.f015814039477c3p+23, // -16255680.62543700591
|
||||||
|
-0x1.74ffe40c4b184b34p+22, // -6111225.0120052143001
|
||||||
|
-0x1.0d9c6d08f9eab55p+20, // -1104326.8146914642612
|
||||||
|
-0x1.54c6b71935f1fc88p+16, // -87238.715228435114593
|
||||||
|
-0x1.0e761b42932b2aaep+11 // -2163.6908276438128575
|
||||||
|
];
|
||||||
|
|
||||||
|
static real logGammaDenominator[] = [
|
||||||
|
-0x1.4055572d75d08c56p+24, // -20993367.177578958762
|
||||||
|
-0x1.deeb6013998e4d76p+24, // -31386464.076561826621
|
||||||
|
-0x1.106f7cded5dcc79ep+24, // -17854332.870450781569
|
||||||
|
-0x1.25e17184848c66d2p+22, // -4814940.3794118821866
|
||||||
|
-0x1.301303b99a614a0ap+19, // -622744.11640662195015
|
||||||
|
-0x1.09e76ab41ae965p+15, // -34035.708405343046707
|
||||||
|
-0x1.00f95ced9e5f54eep+9, // -513.94814844353701437
|
||||||
|
0x1p+0 // 1
|
||||||
|
];
|
||||||
|
|
||||||
|
/* ****************************************************
|
||||||
|
* Helper function: Gamma function computed by Stirling's formula.
|
||||||
|
*
|
||||||
|
* Stirling's formula for the gamma function is:
|
||||||
|
*
|
||||||
|
* $(GAMMA)(x) = sqrt(2 π) x<sup>x-0.5</sup> exp(-x) (1 + 1/x P(1/x))
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private real gammaStirling(real x)
|
||||||
|
{
|
||||||
|
static real SmallStirlingCoeffs[] = [
|
||||||
|
0x1.55555555555543aap-4, // 0.083333333333333318004
|
||||||
|
0x1.c71c71c720dd8792p-9, // 0.0034722222222300753277
|
||||||
|
-0x1.5f7268f0b5907438p-9, // -0.0026813271618763044182
|
||||||
|
-0x1.e13cd410e0477de6p-13, // -0.00022947197478731854057
|
||||||
|
0x1.9b0f31643442616ep-11, // 0.00078403348427447530038
|
||||||
|
0x1.2527623a3472ae08p-14, // 6.9893322606231931717e-05
|
||||||
|
-0x1.37f6bc8ef8b374dep-11, // -0.00059502375540563301557
|
||||||
|
-0x1.8c968886052b872ap-16, // -2.3638488095017590616e-05
|
||||||
|
0x1.76baa9c6d3eeddbcp-11 // 0.0007147391378143610789
|
||||||
|
];
|
||||||
|
|
||||||
|
static real LargeStirlingCoeffs[] = [
|
||||||
|
1.0L,
|
||||||
|
8.33333333333333333333E-2L,
|
||||||
|
3.47222222222222222222E-3L,
|
||||||
|
-2.68132716049382716049E-3L,
|
||||||
|
-2.29472093621399176955E-4L,
|
||||||
|
7.84039221720066627474E-4L,
|
||||||
|
6.97281375836585777429E-5L
|
||||||
|
];
|
||||||
|
|
||||||
|
real w = 1.0L / x;
|
||||||
|
real y = exp(x);
|
||||||
|
if (x > 1024.0L)
|
||||||
|
{
|
||||||
|
// For large x, use rational coefficients from the analytical expansion.
|
||||||
|
w = poly(w, LargeStirlingCoeffs);
|
||||||
|
// Avoid overflow in pow()
|
||||||
|
real v = pow( x, 0.5L * x - 0.25L );
|
||||||
|
y = v * (v / y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
w = 1.0L + w * poly(w, SmallStirlingCoeffs);
|
||||||
|
y = pow( x, x - 0.5L ) / y;
|
||||||
|
}
|
||||||
|
y = SQRT2PI * y * w;
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************
|
||||||
|
* The Gamma function, $(GAMMA)(x)
|
||||||
|
*
|
||||||
|
* Generalizes the factorial function to real and complex numbers.
|
||||||
|
* Like x!, $(GAMMA)(x+1) = x*$(GAMMA)(x).
|
||||||
|
*
|
||||||
|
* Mathematically, if z.re > 0 then
|
||||||
|
* $(GAMMA)(z) =<big>$(INTEGRAL)<sub>0</sub><sup>&infin</sup></big>t<sup>z-1</sup>e<sup>-t</sup>dt
|
||||||
|
*
|
||||||
|
* This function is equivalent to tgamma() in the C programming language.
|
||||||
|
*
|
||||||
|
* <table border=1 cellpadding=4 cellspacing=0>
|
||||||
|
* <caption>Special Values</caption>
|
||||||
|
* <tr> <th> x <th> $(GAMMA)(x) <th>invalid?
|
||||||
|
* <tr> <td> NAN <td> NAN <td> yes
|
||||||
|
* <tr> <td> ±0.0 <td> ±∞ <td> yes
|
||||||
|
* <tr> <td> integer > 0 <td> (x-1)! <td> no
|
||||||
|
* <tr> <td> integer < 0 <td> NAN <td> yes
|
||||||
|
* <tr> <td> +∞ <td> +∞ <td> no
|
||||||
|
* <tr> <td> -∞ <td> NAN <td> yes
|
||||||
|
* </table>
|
||||||
|
*
|
||||||
|
* References:
|
||||||
|
* cephes, http://en.wikipedia.org/wiki/Gamma_function
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
real tgamma(real x)
|
||||||
|
{
|
||||||
|
/* Author: Don Clugston. Based on code from the CEPHES library.
|
||||||
|
*
|
||||||
|
* Arguments |x| <= 13 are reduced by recurrence and the function
|
||||||
|
* approximated by a rational function of degree 7/8 in the
|
||||||
|
* interval (2,3). Large arguments are handled by Stirling's
|
||||||
|
* formula. Large negative arguments are made positive using
|
||||||
|
* a reflection formula.
|
||||||
|
*/
|
||||||
|
|
||||||
|
real q, z;
|
||||||
|
|
||||||
|
if (isnan(x))
|
||||||
|
return x;
|
||||||
|
if (x == -x.infinity)
|
||||||
|
return real.nan;
|
||||||
|
if ( fabs(x) > MAXGAMMA )
|
||||||
|
return real.infinity;
|
||||||
|
if (x == 0)
|
||||||
|
return 1.0 / x; // +- infinity depending on sign of x, create an exception.
|
||||||
|
|
||||||
|
q = fabs(x);
|
||||||
|
|
||||||
|
if ( q > 13.0L )
|
||||||
|
{
|
||||||
|
// Large arguments are handled by Stirling's
|
||||||
|
// formula. Large negative arguments are made positive using
|
||||||
|
// the reflection formula.
|
||||||
|
|
||||||
|
if ( x < 0.0L )
|
||||||
|
{
|
||||||
|
int sgngam = 1; // sign of gamma.
|
||||||
|
real p = floor(q);
|
||||||
|
if ( p == q )
|
||||||
|
return real.nan; // poles for all integers <0.
|
||||||
|
int intpart = cast(int)(p);
|
||||||
|
if ( (intpart & 1) == 0 )
|
||||||
|
sgngam = -1;
|
||||||
|
z = q - p;
|
||||||
|
if ( z > 0.5L )
|
||||||
|
{
|
||||||
|
p += 1.0L;
|
||||||
|
z = q - p;
|
||||||
|
}
|
||||||
|
z = q * sin( PI * z );
|
||||||
|
z = fabs(z) * gammaStirling(q);
|
||||||
|
if ( z <= PI / real.max )
|
||||||
|
return sgngam * real.infinity;
|
||||||
|
return sgngam * PI / z;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return gammaStirling(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Arguments |x| <= 13 are reduced by recurrence and the function
|
||||||
|
// approximated by a rational function of degree 7/8 in the
|
||||||
|
// interval (2,3).
|
||||||
|
|
||||||
|
z = 1.0L;
|
||||||
|
while ( x >= 3.0L )
|
||||||
|
{
|
||||||
|
x -= 1.0L;
|
||||||
|
z *= x;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ( x < -0.03125L )
|
||||||
|
{
|
||||||
|
z /= x;
|
||||||
|
x += 1.0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( x <= 0.03125L )
|
||||||
|
{
|
||||||
|
if ( x == 0.0L )
|
||||||
|
return real.nan;
|
||||||
|
else if ( x < 0.0L )
|
||||||
|
{
|
||||||
|
x = -x;
|
||||||
|
return z / (x * poly( x, GammaSmallNegCoeffs ));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return z / (x * poly( x, GammaSmallCoeffs ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while ( x < 2.0L )
|
||||||
|
{
|
||||||
|
z /= x;
|
||||||
|
x += 1.0L;
|
||||||
|
}
|
||||||
|
if ( x == 2.0L )
|
||||||
|
return z;
|
||||||
|
|
||||||
|
x -= 2.0L;
|
||||||
|
return z * poly( x, GammaNumeratorCoeffs ) / poly( x, GammaDenominatorCoeffs );
|
||||||
|
}
|
||||||
|
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
// gamma(n) = factorial(n-1) if n is an integer.
|
||||||
|
double fact = 1.0L;
|
||||||
|
for (int i = 1; fact < real.max; ++i)
|
||||||
|
{
|
||||||
|
// Require exact equality for small factorials
|
||||||
|
if (i < 14)
|
||||||
|
assert(tgamma(i * 1.0L)==fact);
|
||||||
|
assert(feqrel(tgamma(i * 1.0L), fact) > real.mant_dig - 15);
|
||||||
|
//writefln(i, " %a ---> %a %a ", i*1.0L, tgamma(i * 1.0L), fact, feqrel(tgamma(i*1.0L), fact));
|
||||||
|
fact *= (i * 1.0L);
|
||||||
|
}
|
||||||
|
assert(tgamma(0.0) == real.infinity);
|
||||||
|
assert(tgamma(-0.0) == -real.infinity);
|
||||||
|
assert(isnan(tgamma(-1.0)));
|
||||||
|
assert(isnan(tgamma(real.nan)));
|
||||||
|
assert(tgamma(real.infinity) == real.infinity);
|
||||||
|
assert(isnan(tgamma(-real.infinity)));
|
||||||
|
assert(tgamma(real.min * real.epsilon) == real.infinity);
|
||||||
|
|
||||||
|
assert(feqrel(tgamma(0.5), sqrt(PI)) > real.mant_dig - 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************
|
||||||
|
* Natural logarithm of gamma function.
|
||||||
|
*
|
||||||
|
* Returns the base e (2.718...) logarithm of the absolute
|
||||||
|
* value of the gamma function of the argument.
|
||||||
|
*
|
||||||
|
* For reals, lgamma is equivalent to log(fabs(tgamma(x)).
|
||||||
|
*
|
||||||
|
* <table border=1 cellpadding=4 cellspacing=0>
|
||||||
|
* <caption>Special Values</caption>
|
||||||
|
* <tr> <th> x <th> log$(GAMMA)(x) <th>invalid?
|
||||||
|
* <tr> <td> NaN <td> NaN <td> yes
|
||||||
|
* <tr> <td> integer <= 0 <td> +∞ <td> yes
|
||||||
|
* <tr> <td> 1, 2 <td> +0.0 <td> no
|
||||||
|
* <tr> <td> ±∞ <td> +∞ <td> no
|
||||||
|
* </table>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
real lgamma(real x)
|
||||||
|
{
|
||||||
|
/* Author: Don Clugston. Based on code from the CEPHES library.
|
||||||
|
*
|
||||||
|
* For arguments greater than 33, the logarithm of the gamma
|
||||||
|
* function is approximated by the logarithmic version of
|
||||||
|
* Stirling's formula using a polynomial approximation of
|
||||||
|
* degree 4. Arguments between -33 and +33 are reduced by
|
||||||
|
* recurrence to the interval [2,3] of a rational approximation.
|
||||||
|
* The cosecant reflection formula is employed for arguments
|
||||||
|
* less than -33.
|
||||||
|
*/
|
||||||
|
real q, w, z, f, nx;
|
||||||
|
|
||||||
|
if (isnan(x))
|
||||||
|
return x;
|
||||||
|
if (fabs(x) == x.infinity)
|
||||||
|
return x.infinity;
|
||||||
|
|
||||||
|
if ( x < -34.0L )
|
||||||
|
{
|
||||||
|
q = -x;
|
||||||
|
w = lgamma(q);
|
||||||
|
real p = floor(q);
|
||||||
|
if ( p == q )
|
||||||
|
return real.infinity;
|
||||||
|
int intpart = cast(int)(p);
|
||||||
|
real sgngam = 1;
|
||||||
|
if ( (intpart & 1) == 0 )
|
||||||
|
sgngam = -1;
|
||||||
|
z = q - p;
|
||||||
|
if ( z > 0.5L )
|
||||||
|
{
|
||||||
|
p += 1.0L;
|
||||||
|
z = p - q;
|
||||||
|
}
|
||||||
|
z = q * sin( PI * z );
|
||||||
|
if ( z == 0.0L )
|
||||||
|
return sgngam * real.infinity;
|
||||||
|
/* z = LOGPI - logl( z ) - w; */
|
||||||
|
z = log( PI / z ) - w;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( x < 13.0L )
|
||||||
|
{
|
||||||
|
z = 1.0L;
|
||||||
|
nx = floor( x + 0.5L );
|
||||||
|
f = x - nx;
|
||||||
|
while ( x >= 3.0L )
|
||||||
|
{
|
||||||
|
nx -= 1.0L;
|
||||||
|
x = nx + f;
|
||||||
|
z *= x;
|
||||||
|
}
|
||||||
|
while ( x < 2.0L )
|
||||||
|
{
|
||||||
|
if( fabs(x) <= 0.03125 )
|
||||||
|
{
|
||||||
|
if ( x == 0.0L )
|
||||||
|
return real.infinity;
|
||||||
|
if ( x < 0.0L )
|
||||||
|
{
|
||||||
|
x = -x;
|
||||||
|
q = z / (x * poly( x, GammaSmallNegCoeffs));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
q = z / (x * poly( x, GammaSmallCoeffs));
|
||||||
|
return log( fabs(q) );
|
||||||
|
}
|
||||||
|
z /= nx + f;
|
||||||
|
nx += 1.0L;
|
||||||
|
x = nx + f;
|
||||||
|
}
|
||||||
|
z = fabs(z);
|
||||||
|
if ( x == 2.0L )
|
||||||
|
return log(z);
|
||||||
|
x = (nx - 2.0L) + f;
|
||||||
|
real p = x * poly( x, logGammaNumerator ) / poly( x, logGammaDenominator);
|
||||||
|
return ( log(z) + p );
|
||||||
|
}
|
||||||
|
|
||||||
|
//const real MAXLGM = 1.04848146839019521116e+4928L;
|
||||||
|
//if ( x > MAXLGM ) return sgngaml * real.infinity;
|
||||||
|
|
||||||
|
/* log( sqrt( 2*pi ) ) */
|
||||||
|
const real LOGSQRT2PI = 0.91893853320467274178L;
|
||||||
|
|
||||||
|
q = ( x - 0.5L ) * log(x) - x + LOGSQRT2PI;
|
||||||
|
if (x > 1.0e10L) return q;
|
||||||
|
real p = 1.0L/(x*x);
|
||||||
|
q += poly( p, logGammaStirlingCoeffs ) / x;
|
||||||
|
return q ;
|
||||||
|
}
|
||||||
|
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
assert(isnan(lgamma(real.nan)));
|
||||||
|
assert(lgamma(real.infinity) == real.infinity);
|
||||||
|
assert(lgamma(-1.0) == real.infinity);
|
||||||
|
assert(lgamma(0.0) == real.infinity);
|
||||||
|
assert(std.math.isPosZero(lgamma(1.0L)));
|
||||||
|
assert(std.math.isPosZero(lgamma(2.0L)));
|
||||||
|
|
||||||
|
// x, correct loggamma(x), correct d/dx loggamma(x).
|
||||||
|
static real[] testpoints =
|
||||||
|
[
|
||||||
|
8.0L, 8.525146484375L + 1.48766904143001655310E-5, 2.01564147795560999654E0L,
|
||||||
|
8.99993896484375e-1L, 6.6375732421875e-2L + 5.11505711292524166220E-6L, -7.54938684259372234258E-1,
|
||||||
|
7.31597900390625e-1L, 2.2369384765625e-1 + 5.21506341809849792422E-6L, -1.13355566660398608343E0L,
|
||||||
|
2.31639862060546875e-1L, 1.3686676025390625L + 1.12609441752996145670E-5L, -4.56670961813812679012E0,
|
||||||
|
1.73162841796875L, -8.88214111328125e-2L + 3.36207740803753034508E-6L, 2.33339034686200586920E-1L,
|
||||||
|
1.23162841796875L, -9.3902587890625e-2L + 1.28765089229009648104E-5L, -2.49677345775751390414E-1L,
|
||||||
|
7.3786976294838206464e19L, 3.301798506038663053312e21L - 1.656137564136932662487046269677E5L,
|
||||||
|
4.57477139169563904215E1L,
|
||||||
|
1.08420217248550443401E-19L, 4.36682586669921875e1L + 1.37082843669932230418E-5L,
|
||||||
|
-9.22337203685477580858E18L,
|
||||||
|
// 1.0L, 0.0L, -5.77215664901532860607E-1L,
|
||||||
|
// 2.0L, 0.0L, 4.22784335098467139393E-1L,
|
||||||
|
-0.5L, 1.2655029296875L + 9.19379714539648894580E-6L, 3.64899739785765205590E-2L,
|
||||||
|
-1.5L, 8.6004638671875e-1L + 6.28657731014510932682E-7L, 7.03156640645243187226E-1L,
|
||||||
|
-2.5L, -5.6243896484375E-2L + 1.79986700949327405470E-7, 1.10315664064524318723E0L,
|
||||||
|
-3.5L, -1.30902099609375L + 1.43111007079536392848E-5L, 1.38887092635952890151E0L
|
||||||
|
];
|
||||||
|
|
||||||
|
// TODO: test derivatives as well.
|
||||||
|
|
||||||
|
for (int i=0; i<testpoints.length; i+=3)
|
||||||
|
{
|
||||||
|
//writefln("%a %a ", lgamma(testpoints[i]), testpoints[i+1], feqrel(lgamma(testpoints[i]), testpoints[i+1]));
|
||||||
|
assert( feqrel(lgamma(testpoints[i]), testpoints[i+1]) > real.mant_dig-5);
|
||||||
|
}
|
||||||
|
|
||||||
|
static real logabsgamma(real x)
|
||||||
|
{
|
||||||
|
// For poles, tgamma(x) returns nan, but lgamma() returns infinity.
|
||||||
|
if (x < 0 && x == floor(x))
|
||||||
|
return real.infinity;
|
||||||
|
return log(fabs(tgamma(x)));
|
||||||
|
}
|
||||||
|
|
||||||
|
static real exploggamma(real x)
|
||||||
|
{
|
||||||
|
return exp(lgamma(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
static real absgamma(real x)
|
||||||
|
{
|
||||||
|
if (x < 0 && x == floor(x))
|
||||||
|
return real.infinity;
|
||||||
|
return fabs(tgamma(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that loggamma(x) = log(gamma(x)) provided x is not -1, -2, -3, ...
|
||||||
|
assert(consistencyTwoFuncs(&lgamma, &logabsgamma, -1000, 1700) > real.mant_dig-7);
|
||||||
|
assert(consistencyTwoFuncs(&exploggamma, &absgamma, -2000, real.infinity) > real.mant_dig-16);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,13 +173,13 @@ extern (C) long _adReverseWchar(wchar[] a)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (stridelo == stridehi)
|
if (stridelo == stridehi)
|
||||||
{ int tmp;
|
{ int stmp;
|
||||||
|
|
||||||
assert(stridelo == 2);
|
assert(stridelo == 2);
|
||||||
assert(tmp.sizeof == 2 * (*lo).sizeof);
|
assert(stmp.sizeof == 2 * (*lo).sizeof);
|
||||||
tmp = *cast(int*)lo;
|
stmp = *cast(int*)lo;
|
||||||
*cast(int*)lo = *cast(int*)hi;
|
*cast(int*)lo = *cast(int*)hi;
|
||||||
*cast(int*)hi = tmp;
|
*cast(int*)hi = stmp;
|
||||||
lo += stridelo;
|
lo += stridelo;
|
||||||
hi--;
|
hi--;
|
||||||
continue;
|
continue;
|
||||||
|
@ -546,7 +546,7 @@ extern (C) int _adEqBit(Array a1, Array a2)
|
||||||
ubyte mask;
|
ubyte mask;
|
||||||
|
|
||||||
n = a1.length & 7;
|
n = a1.length & 7;
|
||||||
mask = (1 << n) - 1;
|
mask = cast(ubyte)((1 << n) - 1);
|
||||||
//printf("i = %d, n = %d, mask = %x, %x, %x\n", i, n, mask, p1[i], p2[i]);
|
//printf("i = %d, n = %d, mask = %x, %x, %x\n", i, n, mask, p1[i], p2[i]);
|
||||||
return (mask == 0) || (p1[i] & mask) == (p2[i] & mask);
|
return (mask == 0) || (p1[i] & mask) == (p2[i] & mask);
|
||||||
}
|
}
|
||||||
|
@ -785,7 +785,7 @@ extern (C) int _adCmpBit(Array a1, Array a2)
|
||||||
break; // not equal
|
break; // not equal
|
||||||
}
|
}
|
||||||
for (uint j = i * 8; j < len; j++)
|
for (uint j = i * 8; j < len; j++)
|
||||||
{ ubyte mask = 1 << j;
|
{ ubyte mask = cast(ubyte)(1 << j);
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
c = cast(int)(p1[i] & mask) - cast(int)(p2[i] & mask);
|
c = cast(int)(p1[i] & mask) - cast(int)(p2[i] & mask);
|
||||||
|
|
|
@ -148,5 +148,4 @@ void *_d_interface_vtbl(ClassInfo ic, Object o)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(0);
|
assert(0);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,6 +129,7 @@ extern (C) long _adSort(Array a, TypeInfo ti)
|
||||||
else // else stack empty, all done
|
else // else stack empty, all done
|
||||||
return *cast(long*)(&a);
|
return *cast(long*)(&a);
|
||||||
}
|
}
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -749,9 +749,9 @@ static void trace_merge()
|
||||||
|
|
||||||
p++;
|
p++;
|
||||||
count = strtoul(p,&p,10);
|
count = strtoul(p,&p,10);
|
||||||
t = strtoull(p,&p,10);
|
t = cast(long)strtoull(p,&p,10);
|
||||||
s.totaltime += t;
|
s.totaltime += t;
|
||||||
t = strtoull(p,&p,10);
|
t = cast(long)strtoull(p,&p,10);
|
||||||
s.functime += t;
|
s.functime += t;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
CFLAGS=-O
|
CFLAGS=-O
|
||||||
#CFLAGS=-g
|
#CFLAGS=-g
|
||||||
|
|
||||||
DFLAGS=-O -release
|
DFLAGS=-O -release -w
|
||||||
#DFLAGS=-unittest
|
#DFLAGS=-unittest -w
|
||||||
|
|
||||||
CC=gcc
|
CC=gcc
|
||||||
#DMD=/dmd/bin/dmd
|
#DMD=/dmd/bin/dmd
|
||||||
|
@ -140,7 +140,7 @@ SRC_STD_C_WIN= std/c/windows/windows.d std/c/windows/com.d \
|
||||||
SRC_STD_C_LINUX= std/c/linux/linux.d std/c/linux/linuxextern.d \
|
SRC_STD_C_LINUX= std/c/linux/linux.d std/c/linux/linuxextern.d \
|
||||||
std/c/linux/socket.d
|
std/c/linux/socket.d
|
||||||
|
|
||||||
SRC_ETC= etc/gamma.d etc/realtest.d
|
SRC_ETC= etc/gamma.d
|
||||||
|
|
||||||
SRC_ETC_C= etc/c/zlib.d
|
SRC_ETC_C= etc/c/zlib.d
|
||||||
|
|
||||||
|
|
7
std.ddoc
7
std.ddoc
|
@ -170,12 +170,11 @@ YELLOW = <span style="color:yellow">$0</span>
|
||||||
BLACK = <span style="color:black">$0</span>
|
BLACK = <span style="color:black">$0</span>
|
||||||
WHITE = <span style="color:white">$0</span>
|
WHITE = <span style="color:white">$0</span>
|
||||||
|
|
||||||
RPAREN = )
|
|
||||||
LPAREN = (
|
|
||||||
|
|
||||||
D_COMMENT = <span class="d_comment">$0</span>
|
D_COMMENT = <span class="d_comment">$0</span>
|
||||||
D_STRING = <span class="d_string">$0</span>
|
D_STRING = <span class="d_string">$0</span>
|
||||||
D_KEYWORD = <span class="d_keyword">$0</span>
|
D_KEYWORD = <span class="d_keyword">$0</span>
|
||||||
D_PSYMBOL = <span class="d_psymbol">$0</span>
|
D_PSYMBOL = <span class="d_psymbol">$0</span>
|
||||||
D_PARAM = <span class="d_param">$0</span>
|
D_PARAM = <span class="d_param">$0</span>
|
||||||
|
RPAREN = )
|
||||||
|
LPAREN = (
|
||||||
|
FOO=$0
|
||||||
|
|
|
@ -6,8 +6,6 @@ import std.c.stdlib;
|
||||||
|
|
||||||
class AssertError : Error
|
class AssertError : Error
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
|
|
||||||
uint linnum;
|
uint linnum;
|
||||||
char[] filename;
|
char[] filename;
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,9 @@ body
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf[0 .. (bp - &buf[0])];
|
return buf[0 .. (bp - &buf[0])];
|
||||||
|
@ -211,6 +214,7 @@ body
|
||||||
if(ch == '/')
|
if(ch == '/')
|
||||||
return 'Z' - 'A' + 1 + 'z' - 'a' + 1 + '9' - '0' + 1 + 1;
|
return 'Z' - 'A' + 1 + 'z' - 'a' + 1 + '9' - '0' + 1 + 1;
|
||||||
badc(ch);
|
badc(ch);
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -157,6 +157,7 @@ struct BitArray
|
||||||
{ case 0: assert(b == true); break;
|
{ case 0: assert(b == true); break;
|
||||||
case 1: assert(b == false); break;
|
case 1: assert(b == false); break;
|
||||||
case 2: assert(b == true); break;
|
case 2: assert(b == true); break;
|
||||||
|
default: assert(0);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -167,6 +168,7 @@ struct BitArray
|
||||||
{ case 0: assert(b == true); break;
|
{ case 0: assert(b == true); break;
|
||||||
case 1: assert(b == false); break;
|
case 1: assert(b == false); break;
|
||||||
case 2: assert(b == true); break;
|
case 2: assert(b == true); break;
|
||||||
|
default: assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,7 +303,7 @@ struct BitArray
|
||||||
ubyte mask;
|
ubyte mask;
|
||||||
|
|
||||||
n = this.length & 7;
|
n = this.length & 7;
|
||||||
mask = (1 << n) - 1;
|
mask = cast(ubyte)((1 << n) - 1);
|
||||||
//printf("i = %d, n = %d, mask = %x, %x, %x\n", i, n, mask, p1[i], p2[i]);
|
//printf("i = %d, n = %d, mask = %x, %x, %x\n", i, n, mask, p1[i], p2[i]);
|
||||||
return (mask == 0) || (p1[i] & mask) == (p2[i] & mask);
|
return (mask == 0) || (p1[i] & mask) == (p2[i] & mask);
|
||||||
}
|
}
|
||||||
|
@ -349,7 +351,7 @@ struct BitArray
|
||||||
break; // not equal
|
break; // not equal
|
||||||
}
|
}
|
||||||
for (uint j = i * 8; j < len; j++)
|
for (uint j = i * 8; j < len; j++)
|
||||||
{ ubyte mask = 1 << j;
|
{ ubyte mask = cast(ubyte)(1 << j);
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
c = cast(int)(p1[i] & mask) - cast(int)(p2[i] & mask);
|
c = cast(int)(p1[i] & mask) - cast(int)(p2[i] & mask);
|
||||||
|
|
|
@ -189,6 +189,7 @@ struct Box
|
||||||
default: return TypeClass.Other;
|
default: return TypeClass.Other;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return whether this value could be unboxed as the given type without throwing. */
|
/** Return whether this value could be unboxed as the given type without throwing. */
|
||||||
|
|
|
@ -173,7 +173,7 @@ else version(LittleEndian)
|
||||||
|
|
||||||
uint16_t htons(uint16_t x)
|
uint16_t htons(uint16_t x)
|
||||||
{
|
{
|
||||||
return (x >> 8) | (x << 8);
|
return cast(uint16_t)((x >> 8) | (x << 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -968,8 +968,8 @@ enum
|
||||||
//
|
//
|
||||||
|
|
||||||
int MAKELANGID(int p, int s) { return ((cast(WORD)s) << 10) | cast(WORD)p; }
|
int MAKELANGID(int p, int s) { return ((cast(WORD)s) << 10) | cast(WORD)p; }
|
||||||
WORD PRIMARYLANGID(int lgid) { return cast(WORD)lgid & 0x3ff; }
|
WORD PRIMARYLANGID(int lgid) { return cast(WORD)(lgid & 0x3ff); }
|
||||||
WORD SUBLANGID(int lgid) { return cast(WORD)lgid >> 10; }
|
WORD SUBLANGID(int lgid) { return cast(WORD)(lgid >> 10); }
|
||||||
|
|
||||||
|
|
||||||
struct FLOATING_SAVE_AREA {
|
struct FLOATING_SAVE_AREA {
|
||||||
|
|
|
@ -321,7 +321,7 @@ else version(LittleEndian)
|
||||||
|
|
||||||
uint16_t htons(uint16_t x)
|
uint16_t htons(uint16_t x)
|
||||||
{
|
{
|
||||||
return (x >> 8) | (x << 8);
|
return cast(uint16_t)((x >> 8) | (x << 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -329,7 +329,7 @@ long toLong(char[] s)
|
||||||
char c = s[i];
|
char c = s[i];
|
||||||
if (c >= '0' && c <= '9')
|
if (c >= '0' && c <= '9')
|
||||||
{
|
{
|
||||||
ulong v1 = v;
|
ulong v1 = cast(ulong)v;
|
||||||
v = v * 10 + (c - '0');
|
v = v * 10 + (c - '0');
|
||||||
if (cast(ulong)v < v1)
|
if (cast(ulong)v < v1)
|
||||||
goto Loverflow;
|
goto Loverflow;
|
||||||
|
@ -893,6 +893,7 @@ float toFloat(in char[] s)
|
||||||
|
|
||||||
Lerr:
|
Lerr:
|
||||||
conv_error(s ~ " not representable as a float");
|
conv_error(s ~ " not representable as a float");
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
|
@ -956,6 +957,7 @@ double toDouble(in char[] s)
|
||||||
|
|
||||||
Lerr:
|
Lerr:
|
||||||
conv_error(s ~ " not representable as a double");
|
conv_error(s ~ " not representable as a double");
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
|
@ -1021,6 +1023,7 @@ real toReal(in char[] s)
|
||||||
|
|
||||||
Lerr:
|
Lerr:
|
||||||
conv_error(s ~ " not representable as a real");
|
conv_error(s ~ " not representable as a real");
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
|
|
|
@ -193,7 +193,7 @@ class CFile : Stream {
|
||||||
file.position = 0;
|
file.position = 0;
|
||||||
lines = new char[][5];
|
lines = new char[][5];
|
||||||
foreach(ulong n, char[] line; file) {
|
foreach(ulong n, char[] line; file) {
|
||||||
lines[n-1] = line.dup;
|
lines[cast(size_t)(n-1)] = line.dup;
|
||||||
}
|
}
|
||||||
assert( lines[0] == "Testing stream.d:");
|
assert( lines[0] == "Testing stream.d:");
|
||||||
assert( lines[1] == "Another line");
|
assert( lines[1] == "Another line");
|
||||||
|
|
|
@ -198,7 +198,7 @@ d_time toInteger(d_time n)
|
||||||
|
|
||||||
int Day(d_time t)
|
int Day(d_time t)
|
||||||
{
|
{
|
||||||
return floor(t, msPerDay);
|
return cast(int)floor(t, msPerDay);
|
||||||
}
|
}
|
||||||
|
|
||||||
int LeapYear(int y)
|
int LeapYear(int y)
|
||||||
|
@ -810,6 +810,9 @@ version (Win32)
|
||||||
case TIME_ZONE_ID_UNKNOWN:
|
case TIME_ZONE_ID_UNKNOWN:
|
||||||
// Daylight savings time not used in this time zone
|
// Daylight savings time not used in this time zone
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
@ -869,7 +872,7 @@ version (linux)
|
||||||
dt -= LocalTZA;
|
dt -= LocalTZA;
|
||||||
|
|
||||||
int year = YearFromTime(dt);
|
int year = YearFromTime(dt);
|
||||||
int leap = LeapYear(dt);
|
int leap = LeapYear(cast(int)dt);
|
||||||
//writefln("year = %s, leap = %s, month = %s", year, leap, MonthFromTime(dt));
|
//writefln("year = %s, leap = %s, month = %s", year, leap, MonthFromTime(dt));
|
||||||
|
|
||||||
d_time start = TimeFromYear(year); // Jan 1
|
d_time start = TimeFromYear(year); // Jan 1
|
||||||
|
|
|
@ -528,6 +528,7 @@ private:
|
||||||
}
|
}
|
||||||
dp = nextToken();
|
dp = nextToken();
|
||||||
}
|
}
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int parseCalendarDate(int n1)
|
int parseCalendarDate(int n1)
|
||||||
|
|
|
@ -87,9 +87,11 @@ char[] demangle(char[] name)
|
||||||
{
|
{
|
||||||
if (!isxdigit(c))
|
if (!isxdigit(c))
|
||||||
error();
|
error();
|
||||||
return (c >= 'a') ? c - 'a' + 10 :
|
return cast(ubyte)
|
||||||
|
( (c >= 'a') ? c - 'a' + 10 :
|
||||||
(c >= 'A') ? c - 'A' + 10 :
|
(c >= 'A') ? c - 'A' + 10 :
|
||||||
c - '0';
|
c - '0'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t parseNumber()
|
size_t parseNumber()
|
||||||
|
@ -265,6 +267,7 @@ char[] demangle(char[] name)
|
||||||
case 'U': p = "extern (C) "; break; // C function
|
case 'U': p = "extern (C) "; break; // C function
|
||||||
case 'W': p = "extern (Windows) "; break; // Windows function
|
case 'W': p = "extern (Windows) "; break; // Windows function
|
||||||
case 'V': p = "extern (Pascal) "; break; // Pascal function
|
case 'V': p = "extern (Pascal) "; break; // Pascal function
|
||||||
|
default: assert(0);
|
||||||
}
|
}
|
||||||
p ~= parseType() ~ " " ~ identifier ~ "(" ~ args ~ ")";
|
p ~= parseType() ~ " " ~ identifier ~ "(" ~ args ~ ")";
|
||||||
return p;
|
return p;
|
||||||
|
@ -298,6 +301,7 @@ char[] demangle(char[] name)
|
||||||
p = name[i .. length];
|
p = name[i .. length];
|
||||||
goto L1;
|
goto L1;
|
||||||
}
|
}
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
char[] parseTemplateInstanceName()
|
char[] parseTemplateInstanceName()
|
||||||
|
@ -330,8 +334,11 @@ char[] demangle(char[] name)
|
||||||
for (i = 0; i < 10; i++)
|
for (i = 0; i < 10; i++)
|
||||||
{ ubyte b;
|
{ ubyte b;
|
||||||
|
|
||||||
b = (ascii2hex(name[ni + i * 2]) << 4) +
|
b = cast(ubyte)
|
||||||
ascii2hex(name[ni + i * 2 + 1]);
|
(
|
||||||
|
(ascii2hex(name[ni + i * 2]) << 4) +
|
||||||
|
ascii2hex(name[ni + i * 2 + 1])
|
||||||
|
);
|
||||||
p[i] = b;
|
p[i] = b;
|
||||||
}
|
}
|
||||||
result ~= format(r);
|
result ~= format(r);
|
||||||
|
|
38
std/file.d
38
std/file.d
|
@ -531,9 +531,9 @@ struct DirEntry
|
||||||
*
|
*
|
||||||
* void main(char[][] args)
|
* void main(char[][] args)
|
||||||
* {
|
* {
|
||||||
* char[][] dirs = std.file.listdir(args[1]);
|
* auto dirs = std.file.listdir(args[1]);
|
||||||
*
|
*
|
||||||
* foreach (char[] d; dirs)
|
* foreach (d; dirs)
|
||||||
* writefln(d);
|
* writefln(d);
|
||||||
* }
|
* }
|
||||||
* ----
|
* ----
|
||||||
|
@ -572,9 +572,9 @@ char[][] listdir(char[] pathname)
|
||||||
*
|
*
|
||||||
* void main(char[][] args)
|
* void main(char[][] args)
|
||||||
* {
|
* {
|
||||||
* char[][] d_source_files = std.file.listdir(args[1], "*.d");
|
* auto d_source_files = std.file.listdir(args[1], "*.d");
|
||||||
*
|
*
|
||||||
* foreach (char[] d; d_source_files)
|
* foreach (d; d_source_files)
|
||||||
* writefln(d);
|
* writefln(d);
|
||||||
* }
|
* }
|
||||||
* ----
|
* ----
|
||||||
|
@ -587,9 +587,9 @@ char[][] listdir(char[] pathname)
|
||||||
*
|
*
|
||||||
* void main(char[][] args)
|
* void main(char[][] args)
|
||||||
* {
|
* {
|
||||||
* char[][] d_source_files = std.file.listdir(args[1], RegExp(r"\.(d|obj)$"));
|
* auto d_source_files = std.file.listdir(args[1], RegExp(r"\.(d|obj)$"));
|
||||||
*
|
*
|
||||||
* foreach (char[] d; d_source_files)
|
* foreach (d; d_source_files)
|
||||||
* writefln(d);
|
* writefln(d);
|
||||||
* }
|
* }
|
||||||
* ----
|
* ----
|
||||||
|
@ -650,7 +650,7 @@ char[][] listdir(char[] pathname, RegExp r)
|
||||||
*
|
*
|
||||||
* void main(char[][] args)
|
* void main(char[][] args)
|
||||||
* {
|
* {
|
||||||
* char[] pathname = args[1];
|
* auto pathname = args[1];
|
||||||
* char[][] result;
|
* char[][] result;
|
||||||
*
|
*
|
||||||
* bool listing(char[] filename)
|
* bool listing(char[] filename)
|
||||||
|
@ -661,7 +661,7 @@ char[][] listdir(char[] pathname, RegExp r)
|
||||||
*
|
*
|
||||||
* listdir(pathname, &listing);
|
* listdir(pathname, &listing);
|
||||||
*
|
*
|
||||||
* foreach (char[] name; result)
|
* foreach (name; result)
|
||||||
* writefln("%s", name);
|
* writefln("%s", name);
|
||||||
* }
|
* }
|
||||||
* ----
|
* ----
|
||||||
|
@ -1222,9 +1222,10 @@ struct DirEntry
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_size = statbuf.st_size;
|
_size = statbuf.st_size;
|
||||||
_creationTime = statbuf.st_ctime * std.date.TicksPerSecond;
|
_creationTime = cast(d_time)statbuf.st_ctime * std.date.TicksPerSecond;
|
||||||
_lastAccessTime = statbuf.st_atime * std.date.TicksPerSecond;
|
_lastAccessTime = cast(d_time)statbuf.st_atime * std.date.TicksPerSecond;
|
||||||
_lastWriteTime = statbuf.st_mtime * std.date.TicksPerSecond;
|
_lastWriteTime = cast(d_time)statbuf.st_mtime * std.date.TicksPerSecond;
|
||||||
|
|
||||||
didstat = 1;
|
didstat = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1328,6 +1329,7 @@ void listdir(char[] pathname, bool delegate(DirEntry* de) callback)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************
|
/***************************************************
|
||||||
* Copy a file.
|
* Copy a file.
|
||||||
* Bugs:
|
* Bugs:
|
||||||
|
@ -1348,3 +1350,17 @@ void copy(char[] from, char[] to)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
listdir (".", delegate bool (DirEntry * de)
|
||||||
|
{
|
||||||
|
auto s = std.string.format("%s : c %s, w %s, a %s", de.name,
|
||||||
|
toUTCString (de.creationTime),
|
||||||
|
toUTCString (de.lastWriteTime),
|
||||||
|
toUTCString (de.lastAccessTime));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
15
std/format.d
15
std/format.d
|
@ -686,7 +686,7 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr)
|
||||||
|
|
||||||
case Mangle.Tlong:
|
case Mangle.Tlong:
|
||||||
signed = 1;
|
signed = 1;
|
||||||
vnumber = va_arg!(long)(argptr);
|
vnumber = cast(ulong)va_arg!(long)(argptr);
|
||||||
goto Lnumber;
|
goto Lnumber;
|
||||||
|
|
||||||
case Mangle.Tulong:
|
case Mangle.Tulong:
|
||||||
|
@ -873,6 +873,10 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr)
|
||||||
}
|
}
|
||||||
if (precision == 0 || !(flags & FLprecision))
|
if (precision == 0 || !(flags & FLprecision))
|
||||||
{ vchar = '0' + vnumber;
|
{ vchar = '0' + vnumber;
|
||||||
|
if (vnumber < 10)
|
||||||
|
vchar = '0' + vnumber;
|
||||||
|
else
|
||||||
|
vchar = (uc ? 'A' - 10 : 'a' - 10) + vnumber;
|
||||||
goto L2;
|
goto L2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1343,5 +1347,14 @@ unittest
|
||||||
assert(r == "80000000");
|
assert(r == "80000000");
|
||||||
r = std.string.format("%x", ++i);
|
r = std.string.format("%x", ++i);
|
||||||
assert(r == "80000001");
|
assert(r == "80000001");
|
||||||
|
|
||||||
|
r = std.string.format("%x", 10);
|
||||||
|
assert(r == "a");
|
||||||
|
r = std.string.format("%X", 10);
|
||||||
|
assert(r == "A");
|
||||||
|
r = std.string.format("%x", 15);
|
||||||
|
assert(r == "f");
|
||||||
|
r = std.string.format("%X", 15);
|
||||||
|
assert(r == "F");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -539,7 +539,7 @@ creal sqrt(creal z)
|
||||||
|
|
||||||
if (z == 0)
|
if (z == 0)
|
||||||
{
|
{
|
||||||
c = 0;
|
c = 0 + 0i;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ real z_re = z.re;
|
{ real z_re = z.re;
|
||||||
|
@ -659,7 +659,7 @@ real frexp(real value, out int exp)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
exp = ex - 0x3FFE;
|
exp = ex - 0x3FFE;
|
||||||
vu[4] = (0x8000 & vu[4]) | 0x3FFE;
|
vu[4] = cast(ushort)((0x8000 & vu[4]) | 0x3FFE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!*vl)
|
else if (!*vl)
|
||||||
|
@ -677,7 +677,7 @@ real frexp(real value, out int exp)
|
||||||
*vl <<= 1;
|
*vl <<= 1;
|
||||||
} while (*vl > 0);
|
} while (*vl > 0);
|
||||||
exp = i;
|
exp = i;
|
||||||
vu[4] = (0x8000 & vu[4]) | 0x3FFE;
|
vu[4] = cast(ushort)((0x8000 & vu[4]) | 0x3FFE);
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,9 +259,9 @@ unittest
|
||||||
int sum(int[] n)
|
int sum(int[] n)
|
||||||
{
|
{
|
||||||
long result = 0;
|
long result = 0;
|
||||||
for (uint i = 0; i < n.length; i++)
|
for (size_t i = 0; i < n.length; i++)
|
||||||
result += n[i];
|
result += n[i];
|
||||||
return result;
|
return cast(int)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
|
|
10
std/mmfile.d
10
std/mmfile.d
|
@ -146,6 +146,9 @@ class MmFile
|
||||||
flProtect = PAGE_WRITECOPY;
|
flProtect = PAGE_WRITECOPY;
|
||||||
dwDesiredAccess = FILE_MAP_COPY;
|
dwDesiredAccess = FILE_MAP_COPY;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useWfuncs)
|
if (useWfuncs)
|
||||||
|
@ -242,6 +245,9 @@ class MmFile
|
||||||
oflag = O_RDWR;
|
oflag = O_RDWR;
|
||||||
fmode = 0;
|
fmode = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filename.length)
|
if (filename.length)
|
||||||
|
@ -265,7 +271,7 @@ class MmFile
|
||||||
if (prot & PROT_WRITE && size > statbuf.st_size)
|
if (prot & PROT_WRITE && size > statbuf.st_size)
|
||||||
{
|
{
|
||||||
// Need to make the file size bytes big
|
// Need to make the file size bytes big
|
||||||
std.c.linux.linux.lseek(fd, size - 1, SEEK_SET);
|
std.c.linux.linux.lseek(fd, cast(int)(size - 1), SEEK_SET);
|
||||||
char c = 0;
|
char c = 0;
|
||||||
std.c.linux.linux.write(fd, &c, 1);
|
std.c.linux.linux.write(fd, &c, 1);
|
||||||
}
|
}
|
||||||
|
@ -447,7 +453,7 @@ class MmFile
|
||||||
p = MapViewOfFileEx(hFileMap, dwDesiredAccess, hi, cast(uint)start, len, address);
|
p = MapViewOfFileEx(hFileMap, dwDesiredAccess, hi, cast(uint)start, len, address);
|
||||||
if (!p) errNo();
|
if (!p) errNo();
|
||||||
} else {
|
} else {
|
||||||
p = mmap(address, len, prot, flags, fd, start);
|
p = mmap(address, len, prot, flags, fd, cast(int)start);
|
||||||
if (p == MAP_FAILED) errNo();
|
if (p == MAP_FAILED) errNo();
|
||||||
}
|
}
|
||||||
data = p[0 .. len];
|
data = p[0 .. len];
|
||||||
|
|
|
@ -108,7 +108,7 @@ static this()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s = (cast(long)tv.tv_sec << 32) + tv.tv_usec;
|
s = cast(ulong)((cast(long)tv.tv_sec << 32) + tv.tv_usec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rand_seed(cast(uint) s, cast(uint)(s >> 32));
|
rand_seed(cast(uint) s, cast(uint)(s >> 32));
|
||||||
|
|
257
std/regexp.d
257
std/regexp.d
|
@ -39,24 +39,61 @@
|
||||||
of the following characters:
|
of the following characters:
|
||||||
|
|
||||||
<table border=1 cellspacing=0 cellpadding=5>
|
<table border=1 cellspacing=0 cellpadding=5>
|
||||||
<th>Attribute
|
<caption>Attribute Characters</caption>
|
||||||
<th>Action
|
$(TR $(TH Attribute) $(TH Action))
|
||||||
<tr>
|
<tr>
|
||||||
<td> $(B g)
|
$(TD $(B g))
|
||||||
<td>global; repeat over the whole input string
|
$(TD global; repeat over the whole input string)
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td> $(B i)
|
$(TD $(B i))
|
||||||
<td> case insensitive
|
$(TD case insensitive)
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td> $(B m)
|
$(TD $(B m))
|
||||||
<td> treat as multiple lines separated by newlines
|
$(TD treat as multiple lines separated by newlines)
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
*
|
||||||
|
* The $(I format)[] string has the formatting characters:
|
||||||
|
*
|
||||||
|
* <table border=1 cellspacing=0 cellpadding=5>
|
||||||
|
<caption>Formatting Characters</caption>
|
||||||
|
$(TR $(TH Format) $(TH Replaced With))
|
||||||
|
$(TR
|
||||||
|
$(TD $(B $$)) $(TD $)
|
||||||
|
)
|
||||||
|
$(TR
|
||||||
|
$(TD $(B $&)) $(TD The matched substring.)
|
||||||
|
)
|
||||||
|
$(TR
|
||||||
|
$(TD $(B $`)) $(TD The portion of string that precedes the matched substring.)
|
||||||
|
)
|
||||||
|
$(TR
|
||||||
|
$(TD $(B $')) $(TD The portion of string that follows the matched substring.)
|
||||||
|
)
|
||||||
|
$(TR
|
||||||
|
$(TD $(B $(DOLLAR))$(I n)) $(TD The $(I n)th capture, where $(I n)
|
||||||
|
is a single digit 1-9
|
||||||
|
and $$(I n) is not followed by a decimal digit.)
|
||||||
|
)
|
||||||
|
$(TR
|
||||||
|
$(TD $(B $(DOLLAR))$(I nn)) $(TD The $(I nn)th capture, where $(I nn)
|
||||||
|
is a two-digit decimal
|
||||||
|
number 01-99.
|
||||||
|
If $(I nn)th capture is undefined or more than the number
|
||||||
|
of parenthesized subexpressions, use the empty
|
||||||
|
string instead.)
|
||||||
|
)
|
||||||
|
</table>
|
||||||
|
|
||||||
|
* Any other $ are left as is.
|
||||||
|
*
|
||||||
|
* References:
|
||||||
|
* $(LINK2 http://en.wikipedia.org/wiki/Regular_expressions, Wikipedia)
|
||||||
* Macros:
|
* Macros:
|
||||||
* WIKI = StdRegexp
|
* WIKI = StdRegexp
|
||||||
|
* DOLLAR = $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -98,6 +135,7 @@ private
|
||||||
import std.c.stdio;
|
import std.c.stdio;
|
||||||
import std.c.stdlib;
|
import std.c.stdlib;
|
||||||
import std.c.string;
|
import std.c.string;
|
||||||
|
import std.stdio;
|
||||||
import std.string;
|
import std.string;
|
||||||
import std.ctype;
|
import std.ctype;
|
||||||
import std.outbuffer;
|
import std.outbuffer;
|
||||||
|
@ -140,7 +178,20 @@ private alias char rchar; // so we can make a wchar version
|
||||||
* pattern = Regular expression pattern.
|
* pattern = Regular expression pattern.
|
||||||
* format = Replacement string format.
|
* format = Replacement string format.
|
||||||
* attributes = Regular expression attributes.
|
* attributes = Regular expression attributes.
|
||||||
* Returns: the resulting string.
|
* Returns:
|
||||||
|
* the resulting string
|
||||||
|
* Example:
|
||||||
|
* Replace the letters 'a' with the letters 'ZZ'.
|
||||||
|
* ---
|
||||||
|
* s = "Strap a rocket engine on a chicken."
|
||||||
|
* sub(s, "a", "ZZ") // result: StrZZp a rocket engine on a chicken.
|
||||||
|
* sub(s, "a", "ZZ", "g") // result: StrZZp ZZ rocket engine on ZZ chicken.
|
||||||
|
* ---
|
||||||
|
* The replacement format can reference the matches using
|
||||||
|
* the $&, $$, $', $`, $0 .. $99 notation:
|
||||||
|
* ---
|
||||||
|
* sub(s, "[ar]", "[$&]", "g") // result: St[r][a]p [a] [r]ocket engine on [a] chi
|
||||||
|
* ---
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char[] sub(char[] string, char[] pattern, char[] format, char[] attributes = null)
|
char[] sub(char[] string, char[] pattern, char[] format, char[] attributes = null)
|
||||||
|
@ -170,6 +221,17 @@ unittest
|
||||||
* dg = Delegate
|
* dg = Delegate
|
||||||
* attributes = Regular expression attributes.
|
* attributes = Regular expression attributes.
|
||||||
* Returns: the resulting string.
|
* Returns: the resulting string.
|
||||||
|
* Example:
|
||||||
|
* Capitalize the letters 'a' and 'r':
|
||||||
|
* ---
|
||||||
|
* s = "Strap a rocket engine on a chicken.";
|
||||||
|
* sub(s, "[ar]",
|
||||||
|
* delegate char[] (RegExp m)
|
||||||
|
* {
|
||||||
|
* return toupper(m.match(0));
|
||||||
|
* },
|
||||||
|
* "g"); // result: StRAp A Rocket engine on A chicken.
|
||||||
|
* ---
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char[] sub(char[] string, char[] pattern, char[] delegate(RegExp) dg, char[] attributes = null)
|
char[] sub(char[] string, char[] pattern, char[] delegate(RegExp) dg, char[] attributes = null)
|
||||||
|
@ -194,11 +256,10 @@ char[] sub(char[] string, char[] pattern, char[] delegate(RegExp) dg, char[] att
|
||||||
if (r.attributes & RegExp.REA.global && // global, so replace all
|
if (r.attributes & RegExp.REA.global && // global, so replace all
|
||||||
!(r.attributes & RegExp.REA.ignoreCase) && // not ignoring case
|
!(r.attributes & RegExp.REA.ignoreCase) && // not ignoring case
|
||||||
!(r.attributes & RegExp.REA.multiline) && // not multiline
|
!(r.attributes & RegExp.REA.multiline) && // not multiline
|
||||||
pattern == slice && // simple pattern (exact match, no special characters)
|
pattern == slice) // simple pattern (exact match, no special characters)
|
||||||
format == replacement) // simple format, not $ formats
|
|
||||||
{
|
{
|
||||||
debug(regexp)
|
debug(regexp)
|
||||||
printf("pattern: %.*s, slice: %.*s, format: %.*s, replacement: %.*s\n",pattern,result[offset + so .. offset + eo],format,replacement);
|
printf("pattern: %.*s, slice: %.*s, replacement: %.*s\n",pattern,result[offset + so .. offset + eo],replacement);
|
||||||
result = std.string.replace(result,slice,replacement);
|
result = std.string.replace(result,slice,replacement);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -230,6 +291,18 @@ unittest
|
||||||
|
|
||||||
char[] r = sub("hello", "ll", delegate char[](RegExp r) { return "ss"; });
|
char[] r = sub("hello", "ll", delegate char[](RegExp r) { return "ss"; });
|
||||||
assert(r == "hesso");
|
assert(r == "hesso");
|
||||||
|
|
||||||
|
r = sub("hello", "l", delegate char[](RegExp r) { return "l"; }, "g");
|
||||||
|
assert(r == "hello");
|
||||||
|
|
||||||
|
auto s = sub("Strap a rocket engine on a chicken.",
|
||||||
|
"[ar]",
|
||||||
|
delegate char[] (RegExp m)
|
||||||
|
{
|
||||||
|
return std.string.toupper(m.match(0));
|
||||||
|
},
|
||||||
|
"g");
|
||||||
|
assert(s == "StRAp A Rocket engine on A chicken.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -241,6 +314,12 @@ unittest
|
||||||
* attributes = Regular expression attributes.
|
* attributes = Regular expression attributes.
|
||||||
* Returns:
|
* Returns:
|
||||||
* index into string[] of match if found, -1 if no match.
|
* index into string[] of match if found, -1 if no match.
|
||||||
|
* Example:
|
||||||
|
* ---
|
||||||
|
* auto s = "abcabcabab";
|
||||||
|
* std.regexp.find(s, "b"); // match, returns 1
|
||||||
|
* std.regexp.find(s, "f"); // no match, returns -1
|
||||||
|
* ---
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int find(rchar[] string, char[] pattern, char[] attributes = null)
|
int find(rchar[] string, char[] pattern, char[] attributes = null)
|
||||||
|
@ -277,6 +356,12 @@ unittest
|
||||||
* attributes = Regular expression attributes.
|
* attributes = Regular expression attributes.
|
||||||
* Returns:
|
* Returns:
|
||||||
* index into string[] of match if found, -1 if no match.
|
* index into string[] of match if found, -1 if no match.
|
||||||
|
* Example:
|
||||||
|
* ---
|
||||||
|
* auto s = "abcabcabab";
|
||||||
|
* std.regexp.find(s, "b"); // match, returns 9
|
||||||
|
* std.regexp.find(s, "f"); // no match, returns -1
|
||||||
|
* ---
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int rfind(rchar[] string, char[] pattern, char[] attributes = null)
|
int rfind(rchar[] string, char[] pattern, char[] attributes = null)
|
||||||
|
@ -318,11 +403,23 @@ unittest
|
||||||
/********************************************
|
/********************************************
|
||||||
* Split string[] into an array of strings, using the regular
|
* Split string[] into an array of strings, using the regular
|
||||||
* expression pattern[] with attributes[] as the separator.
|
* expression pattern[] with attributes[] as the separator.
|
||||||
|
* Params:
|
||||||
* string = String to search.
|
* string = String to search.
|
||||||
* pattern = Regular expression pattern.
|
* pattern = Regular expression pattern.
|
||||||
* attributes = Regular expression attributes.
|
* attributes = Regular expression attributes.
|
||||||
* Returns:
|
* Returns:
|
||||||
* array of slices into string[]
|
* array of slices into string[]
|
||||||
|
* Example:
|
||||||
|
* ---
|
||||||
|
* foreach (s; split("abcabcabab", "C.", "i"))
|
||||||
|
* {
|
||||||
|
* writefln("s = '%s'", s);
|
||||||
|
* }
|
||||||
|
* // Prints:
|
||||||
|
* // s = 'ab'
|
||||||
|
* // s = 'b'
|
||||||
|
* // s = 'bab'
|
||||||
|
* ---
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char[][] split(char[] string, char[] pattern, char[] attributes = null)
|
char[][] split(char[] string, char[] pattern, char[] attributes = null)
|
||||||
|
@ -342,6 +439,15 @@ unittest
|
||||||
assert(result.length == 2);
|
assert(result.length == 2);
|
||||||
assert(result[0] == "");
|
assert(result[0] == "");
|
||||||
assert(result[1] == "b");
|
assert(result[1] == "b");
|
||||||
|
|
||||||
|
foreach (i, s; split("abcabcabab", "C.", "i"))
|
||||||
|
{
|
||||||
|
writefln("s[%d] = '%s'", i, s);
|
||||||
|
if (i == 0) assert(s == "ab");
|
||||||
|
else if (i == 1) assert(s == "b");
|
||||||
|
else if (i == 2) assert(s == "bab");
|
||||||
|
else assert(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************
|
/****************************************************
|
||||||
|
@ -359,7 +465,7 @@ unittest
|
||||||
*
|
*
|
||||||
* void main()
|
* void main()
|
||||||
* {
|
* {
|
||||||
* if (m; std.regexp.search("abcdef", "c"))
|
* if (auto m = std.regexp.search("abcdef", "c"))
|
||||||
* {
|
* {
|
||||||
* writefln("%s[%s]%s", m.pre, m.match(0), m.post);
|
* writefln("%s[%s]%s", m.pre, m.match(0), m.post);
|
||||||
* }
|
* }
|
||||||
|
@ -383,6 +489,27 @@ RegExp search(char[] string, char[] pattern, char[] attributes = null)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
debug(regexp) printf("regexp.string.unittest()\n");
|
||||||
|
|
||||||
|
if (auto m = std.regexp.search("abcdef", "c()"))
|
||||||
|
{
|
||||||
|
auto result = std.string.format("%s[%s]%s", m.pre, m.match(0), m.post);
|
||||||
|
assert(result == "ab[c]def");
|
||||||
|
assert(m.match(1) == null);
|
||||||
|
assert(m.match(2) == null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
assert(0);
|
||||||
|
|
||||||
|
if (auto n = std.regexp.search("abcdef", "g"))
|
||||||
|
{
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ********************************* RegExp ******************************** */
|
/* ********************************* RegExp ******************************** */
|
||||||
|
|
||||||
/*****************************
|
/*****************************
|
||||||
|
@ -401,6 +528,12 @@ class RegExp
|
||||||
* pattern = regular expression
|
* pattern = regular expression
|
||||||
* attributes = _attributes
|
* attributes = _attributes
|
||||||
* Throws: RegExpException if there are any compilation errors.
|
* Throws: RegExpException if there are any compilation errors.
|
||||||
|
* Example:
|
||||||
|
* Declare two variables and assign to them a RegExp object:
|
||||||
|
* ---
|
||||||
|
* auto r = new RegExp("pattern");
|
||||||
|
* auto s = new RegExp(r"p[1-5]\s*");
|
||||||
|
* ---
|
||||||
*/
|
*/
|
||||||
public this(rchar[] pattern, rchar[] attributes = null)
|
public this(rchar[] pattern, rchar[] attributes = null)
|
||||||
{
|
{
|
||||||
|
@ -414,12 +547,36 @@ class RegExp
|
||||||
* pattern = regular expression
|
* pattern = regular expression
|
||||||
* attributes = _attributes
|
* attributes = _attributes
|
||||||
* Throws: RegExpException if there are any compilation errors.
|
* Throws: RegExpException if there are any compilation errors.
|
||||||
|
* Example:
|
||||||
|
* Declare two variables and assign to them a RegExp object:
|
||||||
|
* ---
|
||||||
|
* auto r = RegExp("pattern");
|
||||||
|
* auto s = RegExp(r"p[1-5]\s*");
|
||||||
|
* ---
|
||||||
*/
|
*/
|
||||||
public static RegExp opCall(rchar[] pattern, rchar[] attributes = null)
|
public static RegExp opCall(rchar[] pattern, rchar[] attributes = null)
|
||||||
{
|
{
|
||||||
return new RegExp(pattern, attributes);
|
return new RegExp(pattern, attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
debug(regexp) printf("regexp.opCall.unittest()\n");
|
||||||
|
auto r1 = RegExp("hello", "m");
|
||||||
|
char[] msg;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
auto r2 = RegExp("hello", "q");
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
catch (RegExpException ree)
|
||||||
|
{
|
||||||
|
msg = ree.toString();
|
||||||
|
//writefln("message: %s", ree);
|
||||||
|
}
|
||||||
|
assert(msg == "unrecognized attribute");
|
||||||
|
}
|
||||||
|
|
||||||
/************************************
|
/************************************
|
||||||
* Set up for start of foreach loop.
|
* Set up for start of foreach loop.
|
||||||
* Returns:
|
* Returns:
|
||||||
|
@ -467,6 +624,23 @@ class RegExp
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
debug(regexp) printf("regexp.search.unittest()\n");
|
||||||
|
|
||||||
|
int i;
|
||||||
|
foreach(m; RegExp("ab").search("abcabcabab"))
|
||||||
|
{
|
||||||
|
auto s = std.string.format("%s[%s]%s", m.pre, m.match(0), m.post);
|
||||||
|
if (i == 0) assert(s == "[ab]cabcabab");
|
||||||
|
else if (i == 1) assert(s == "abc[ab]cabab");
|
||||||
|
else if (i == 2) assert(s == "abcabc[ab]ab");
|
||||||
|
else if (i == 3) assert(s == "abcabcab[ab]");
|
||||||
|
else assert(0);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/******************
|
/******************
|
||||||
* Retrieve match n.
|
* Retrieve match n.
|
||||||
*
|
*
|
||||||
|
@ -908,6 +1082,11 @@ unittest
|
||||||
result = r.replace("1ab2ac3", "x$&y");
|
result = r.replace("1ab2ac3", "x$&y");
|
||||||
i = std.string.cmp(result, "1xaby2xacy3");
|
i = std.string.cmp(result, "1xaby2xacy3");
|
||||||
assert(i == 0);
|
assert(i == 0);
|
||||||
|
|
||||||
|
r = new RegExp("ab", "g");
|
||||||
|
result = r.replace("1ab2ac3", "xy");
|
||||||
|
i = std.string.cmp(result, "1xy2ac3");
|
||||||
|
assert(i == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1840,6 +2019,7 @@ int parseRegexp()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int parsePiece()
|
int parsePiece()
|
||||||
|
@ -1947,6 +2127,7 @@ int parsePiece()
|
||||||
|
|
||||||
Lerr:
|
Lerr:
|
||||||
error("badly formed {n,m}");
|
error("badly formed {n,m}");
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int parseAtom()
|
int parseAtom()
|
||||||
|
@ -2165,11 +2346,11 @@ class Range
|
||||||
maxc = u;
|
maxc = u;
|
||||||
b = u / 8;
|
b = u / 8;
|
||||||
if (b >= maxb)
|
if (b >= maxb)
|
||||||
{ uint u;
|
{ uint u2;
|
||||||
|
|
||||||
u = base ? base - &buf.data[0] : 0;
|
u2 = base ? base - &buf.data[0] : 0;
|
||||||
buf.fill0(b - maxb + 1);
|
buf.fill0(b - maxb + 1);
|
||||||
base = &buf.data[u];
|
base = &buf.data[u2];
|
||||||
maxb = b + 1;
|
maxb = b + 1;
|
||||||
//bits = (cast(bit*)this.base)[0 .. maxc + 1];
|
//bits = (cast(bit*)this.base)[0 .. maxc + 1];
|
||||||
bits.ptr = cast(uint*)this.base;
|
bits.ptr = cast(uint*)this.base;
|
||||||
|
@ -2245,6 +2426,8 @@ int parseRange()
|
||||||
break;
|
break;
|
||||||
case RS.start:
|
case RS.start:
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
p++;
|
p++;
|
||||||
break;
|
break;
|
||||||
|
@ -2348,6 +2531,9 @@ int parseRange()
|
||||||
r.bits[c] = 1;
|
r.bits[c] = 1;
|
||||||
rs = RS.start;
|
rs = RS.start;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2752,6 +2938,9 @@ int starrchars(Range r, ubyte[] prog)
|
||||||
|
|
||||||
case REbackref:
|
case REbackref:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -2763,34 +2952,6 @@ int starrchars(Range r, ubyte[] prog)
|
||||||
* After a match is found with test(), this function
|
* After a match is found with test(), this function
|
||||||
* will take the match results and, using the format
|
* will take the match results and, using the format
|
||||||
* string, generate and return a new string.
|
* string, generate and return a new string.
|
||||||
* The format string has the formatting characters:
|
|
||||||
* <table border=1 cellspacing=0 cellpadding=5>
|
|
||||||
$(TR $(TH Format) $(TH Replaced With))
|
|
||||||
$(TR
|
|
||||||
$(TD $(B $$)) $(TD $)
|
|
||||||
)
|
|
||||||
$(TR
|
|
||||||
$(TD $(B $&)) $(TD The matched substring.)
|
|
||||||
)
|
|
||||||
$(TR
|
|
||||||
$(TD $(B $`)) $(TD The portion of string that precedes the matched substring.)
|
|
||||||
)
|
|
||||||
$(TR
|
|
||||||
$(TD $(B $')) $(TD The portion of string that follows the matched substring.)
|
|
||||||
)
|
|
||||||
$(TR
|
|
||||||
$(TD $(B $n)) $(TD The nth capture, where n is a single digit 1-9
|
|
||||||
and $n is not followed by a decimal digit.)
|
|
||||||
)
|
|
||||||
$(TR
|
|
||||||
$(TD $(B $nn)) $(TD The nnth capture, where nn is a two-digit decimal
|
|
||||||
number 01-99.
|
|
||||||
If nnth capture is undefined or more than the number
|
|
||||||
of parenthesized subexpressions, use the empty
|
|
||||||
string instead.)
|
|
||||||
)
|
|
||||||
</table>
|
|
||||||
Any other $ are left as is.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public rchar[] replace(rchar[] format)
|
public rchar[] replace(rchar[] format)
|
||||||
|
@ -2936,11 +3097,11 @@ public rchar[] replaceOld(rchar[] format)
|
||||||
{
|
{
|
||||||
c = format[++i];
|
c = format[++i];
|
||||||
if (c >= '1' && c <= '9')
|
if (c >= '1' && c <= '9')
|
||||||
{ uint i;
|
{ uint j;
|
||||||
|
|
||||||
i = c - '0';
|
j = c - '0';
|
||||||
if (i <= re_nsub && pmatch[i].rm_so != pmatch[i].rm_eo)
|
if (j <= re_nsub && pmatch[j].rm_so != pmatch[j].rm_eo)
|
||||||
result ~= input[pmatch[i].rm_so .. pmatch[i].rm_eo];
|
result ~= input[pmatch[j].rm_so .. pmatch[j].rm_eo];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,7 +269,7 @@ class Service
|
||||||
void populate(servent* serv)
|
void populate(servent* serv)
|
||||||
{
|
{
|
||||||
name = std.string.toString(serv.s_name).dup;
|
name = std.string.toString(serv.s_name).dup;
|
||||||
port = ntohs(serv.s_port);
|
port = ntohs(cast(ushort)serv.s_port);
|
||||||
protocolName = std.string.toString(serv.s_proto).dup;
|
protocolName = std.string.toString(serv.s_proto).dup;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -123,7 +123,6 @@ class SocketStream: Stream
|
||||||
override ulong seek(long offset, SeekPos whence)
|
override ulong seek(long offset, SeekPos whence)
|
||||||
{
|
{
|
||||||
throw new SeekException("Cannot seek a socket.");
|
throw new SeekException("Cannot seek a socket.");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
86
std/stream.d
86
std/stream.d
|
@ -771,7 +771,8 @@ class Stream : InputStream, OutputStream {
|
||||||
ifmt = 'd';
|
ifmt = 'd';
|
||||||
}
|
}
|
||||||
long n = 0;
|
long n = 0;
|
||||||
switch (ifmt) {
|
switch (ifmt)
|
||||||
|
{
|
||||||
case 'd': // decimal
|
case 'd': // decimal
|
||||||
case 'u': {
|
case 'u': {
|
||||||
while (isdigit(c) && width) {
|
while (isdigit(c) && width) {
|
||||||
|
@ -803,33 +804,36 @@ class Stream : InputStream, OutputStream {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
if (neg)
|
if (neg)
|
||||||
n = -n;
|
n = -n;
|
||||||
if (arguments[j] is typeid(int*)) {
|
if (arguments[j] is typeid(int*)) {
|
||||||
int* p = va_arg!(int*)(args);
|
int* p = va_arg!(int*)(args);
|
||||||
*p = n;
|
*p = cast(int)n;
|
||||||
} else if (arguments[j] is typeid(short*)) {
|
} else if (arguments[j] is typeid(short*)) {
|
||||||
short* p = va_arg!(short*)(args);
|
short* p = va_arg!(short*)(args);
|
||||||
*p = n;
|
*p = cast(short)n;
|
||||||
} else if (arguments[j] is typeid(byte*)) {
|
} else if (arguments[j] is typeid(byte*)) {
|
||||||
byte* p = va_arg!(byte*)(args);
|
byte* p = va_arg!(byte*)(args);
|
||||||
*p = n;
|
*p = cast(byte)n;
|
||||||
} else if (arguments[j] is typeid(long*)) {
|
} else if (arguments[j] is typeid(long*)) {
|
||||||
long* p = va_arg!(long*)(args);
|
long* p = va_arg!(long*)(args);
|
||||||
*p = n;
|
*p = n;
|
||||||
} else if (arguments[j] is typeid(uint*)) {
|
} else if (arguments[j] is typeid(uint*)) {
|
||||||
uint* p = va_arg!(uint*)(args);
|
uint* p = va_arg!(uint*)(args);
|
||||||
*p = n;
|
*p = cast(uint)n;
|
||||||
} else if (arguments[j] is typeid(ushort*)) {
|
} else if (arguments[j] is typeid(ushort*)) {
|
||||||
ushort* p = va_arg!(ushort*)(args);
|
ushort* p = va_arg!(ushort*)(args);
|
||||||
*p = n;
|
*p = cast(ushort)n;
|
||||||
} else if (arguments[j] is typeid(ubyte*)) {
|
} else if (arguments[j] is typeid(ubyte*)) {
|
||||||
ubyte* p = va_arg!(ubyte*)(args);
|
ubyte* p = va_arg!(ubyte*)(args);
|
||||||
*p = n;
|
*p = cast(ubyte)n;
|
||||||
} else if (arguments[j] is typeid(ulong*)) {
|
} else if (arguments[j] is typeid(ulong*)) {
|
||||||
ulong* p = va_arg!(ulong*)(args);
|
ulong* p = va_arg!(ulong*)(args);
|
||||||
*p = n;
|
*p = cast(ulong)n;
|
||||||
}
|
}
|
||||||
j++;
|
j++;
|
||||||
i++;
|
i++;
|
||||||
|
@ -951,14 +955,14 @@ class Stream : InputStream, OutputStream {
|
||||||
*p = s;
|
*p = s;
|
||||||
} else if (arguments[j] is typeid(char*)) {
|
} else if (arguments[j] is typeid(char*)) {
|
||||||
s ~= 0;
|
s ~= 0;
|
||||||
char* p = va_arg!(char*)(args);
|
char* q = va_arg!(char*)(args);
|
||||||
p[0 .. s.length] = s[];
|
q[0 .. s.length] = s[];
|
||||||
} else if (arguments[j] is typeid(wchar[]*)) {
|
} else if (arguments[j] is typeid(wchar[]*)) {
|
||||||
wchar[]* p = va_arg!(wchar[]*)(args);
|
wchar[]* q = va_arg!(wchar[]*)(args);
|
||||||
*p = toUTF16(s);
|
*q = toUTF16(s);
|
||||||
} else if (arguments[j] is typeid(dchar[]*)) {
|
} else if (arguments[j] is typeid(dchar[]*)) {
|
||||||
dchar[]* p = va_arg!(dchar[]*)(args);
|
dchar[]* q = va_arg!(dchar[]*)(args);
|
||||||
*p = toUTF32(s);
|
*q = toUTF32(s);
|
||||||
}
|
}
|
||||||
j++;
|
j++;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1203,7 +1207,7 @@ class Stream : InputStream, OutputStream {
|
||||||
void copyFrom(Stream s, ulong count) {
|
void copyFrom(Stream s, ulong count) {
|
||||||
ubyte[128] buf;
|
ubyte[128] buf;
|
||||||
while (count > 0) {
|
while (count > 0) {
|
||||||
size_t n = count<buf.length ? count : buf.length;
|
size_t n = cast(size_t)(count<buf.length ? count : buf.length);
|
||||||
s.readExact(buf, n);
|
s.readExact(buf, n);
|
||||||
writeExact(buf, n);
|
writeExact(buf, n);
|
||||||
count -= n;
|
count -= n;
|
||||||
|
@ -1230,7 +1234,7 @@ class Stream : InputStream, OutputStream {
|
||||||
/***
|
/***
|
||||||
* Sets file position. Equivalent to calling seek(pos, SeekPos.Set).
|
* Sets file position. Equivalent to calling seek(pos, SeekPos.Set).
|
||||||
*/
|
*/
|
||||||
void position(ulong pos) { seek(pos, SeekPos.Set); }
|
void position(ulong pos) { seek(cast(long)pos, SeekPos.Set); }
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Returns current file position. Equivalent to seek(0, SeekPos.Current).
|
* Returns current file position. Equivalent to seek(0, SeekPos.Current).
|
||||||
|
@ -1290,7 +1294,7 @@ class Stream : InputStream, OutputStream {
|
||||||
if (seekable) {
|
if (seekable) {
|
||||||
ulong orig_pos = position();
|
ulong orig_pos = position();
|
||||||
position(0);
|
position(0);
|
||||||
blockSize = size();
|
blockSize = cast(size_t)size();
|
||||||
result = new char[blockSize];
|
result = new char[blockSize];
|
||||||
while (blockSize > 0) {
|
while (blockSize > 0) {
|
||||||
rdlen = readBlock(&result[pos], blockSize);
|
rdlen = readBlock(&result[pos], blockSize);
|
||||||
|
@ -1960,12 +1964,12 @@ class File: Stream {
|
||||||
assertSeekable();
|
assertSeekable();
|
||||||
version (Win32) {
|
version (Win32) {
|
||||||
int hi = cast(int)(offset>>32);
|
int hi = cast(int)(offset>>32);
|
||||||
uint low = SetFilePointer(hFile, offset, &hi, rel);
|
uint low = SetFilePointer(hFile, cast(int)offset, &hi, rel);
|
||||||
if ((low == INVALID_SET_FILE_POINTER) && (GetLastError() != 0))
|
if ((low == INVALID_SET_FILE_POINTER) && (GetLastError() != 0))
|
||||||
throw new SeekException("unable to move file pointer");
|
throw new SeekException("unable to move file pointer");
|
||||||
ulong result = (cast(ulong)hi << 32) + low;
|
ulong result = (cast(ulong)hi << 32) + low;
|
||||||
} else version (linux) {
|
} else version (linux) {
|
||||||
ulong result = lseek(hFile, offset, rel);
|
ulong result = lseek(hFile, cast(int)offset, rel);
|
||||||
if (result == 0xFFFFFFFF)
|
if (result == 0xFFFFFFFF)
|
||||||
throw new SeekException("unable to move file pointer");
|
throw new SeekException("unable to move file pointer");
|
||||||
}
|
}
|
||||||
|
@ -2055,7 +2059,7 @@ class File: Stream {
|
||||||
file.position = 0;
|
file.position = 0;
|
||||||
lines = new char[][4];
|
lines = new char[][4];
|
||||||
foreach(ulong n, char[] line; file) {
|
foreach(ulong n, char[] line; file) {
|
||||||
lines[n-1] = line.dup;
|
lines[cast(size_t)(n-1)] = line.dup;
|
||||||
}
|
}
|
||||||
assert( lines[0] == "Testing stream.d:");
|
assert( lines[0] == "Testing stream.d:");
|
||||||
assert( lines[1] == "Another line");
|
assert( lines[1] == "Another line");
|
||||||
|
@ -2125,7 +2129,7 @@ class BufferedFile: BufferedStream {
|
||||||
assert(file.position() == 18 + 13 + 4);
|
assert(file.position() == 18 + 13 + 4);
|
||||||
// we must be at the end of file
|
// we must be at the end of file
|
||||||
assert(file.eof());
|
assert(file.eof());
|
||||||
long oldsize = file.size();
|
long oldsize = cast(long)file.size();
|
||||||
file.close();
|
file.close();
|
||||||
// no operations are allowed when file is closed
|
// no operations are allowed when file is closed
|
||||||
assert(!file.readable && !file.writeable && !file.seekable);
|
assert(!file.readable && !file.writeable && !file.seekable);
|
||||||
|
@ -2508,8 +2512,8 @@ class TArrayStream(Buffer): Stream {
|
||||||
assertReadable();
|
assertReadable();
|
||||||
ubyte* cbuf = cast(ubyte*) buffer;
|
ubyte* cbuf = cast(ubyte*) buffer;
|
||||||
if (len - cur < size)
|
if (len - cur < size)
|
||||||
size = len - cur;
|
size = cast(size_t)(len - cur);
|
||||||
ubyte[] ubuf = cast(ubyte[])buf[cur .. cur + size];
|
ubyte[] ubuf = cast(ubyte[])buf[cast(size_t)cur .. cast(size_t)(cur + size)];
|
||||||
cbuf[0 .. size] = ubuf[];
|
cbuf[0 .. size] = ubuf[];
|
||||||
cur += size;
|
cur += size;
|
||||||
return size;
|
return size;
|
||||||
|
@ -2520,8 +2524,8 @@ class TArrayStream(Buffer): Stream {
|
||||||
ubyte* cbuf = cast(ubyte*) buffer;
|
ubyte* cbuf = cast(ubyte*) buffer;
|
||||||
ulong blen = buf.length;
|
ulong blen = buf.length;
|
||||||
if (cur + size > blen)
|
if (cur + size > blen)
|
||||||
size = blen - cur;
|
size = cast(size_t)(blen - cur);
|
||||||
ubyte[] ubuf = cast(ubyte[])buf[cur .. cur + size];
|
ubyte[] ubuf = cast(ubyte[])buf[cast(size_t)cur .. cast(size_t)(cur + size)];
|
||||||
ubuf[] = cbuf[0 .. size];
|
ubuf[] = cbuf[0 .. size];
|
||||||
cur += size;
|
cur += size;
|
||||||
if (cur > len)
|
if (cur > len)
|
||||||
|
@ -2535,8 +2539,10 @@ class TArrayStream(Buffer): Stream {
|
||||||
|
|
||||||
switch (rel) {
|
switch (rel) {
|
||||||
case SeekPos.Set: scur = offset; break;
|
case SeekPos.Set: scur = offset; break;
|
||||||
case SeekPos.Current: scur = cur + offset; break;
|
case SeekPos.Current: scur = cast(long)(cur + offset); break;
|
||||||
case SeekPos.End: scur = len + offset; break;
|
case SeekPos.End: scur = cast(long)(len + offset); break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scur < 0)
|
if (scur < 0)
|
||||||
|
@ -2544,18 +2550,18 @@ class TArrayStream(Buffer): Stream {
|
||||||
else if (scur > len)
|
else if (scur > len)
|
||||||
cur = len;
|
cur = len;
|
||||||
else
|
else
|
||||||
cur = scur;
|
cur = cast(ulong)scur;
|
||||||
|
|
||||||
return cur;
|
return cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
override size_t available () { return len - cur; }
|
override size_t available () { return cast(size_t)(len - cur); }
|
||||||
|
|
||||||
/// Get the current memory data in total.
|
/// Get the current memory data in total.
|
||||||
ubyte[] data() {
|
ubyte[] data() {
|
||||||
if (len > size_t.max)
|
if (len > size_t.max)
|
||||||
throw new StreamException("Stream too big");
|
throw new StreamException("Stream too big");
|
||||||
void[] res = buf[0 .. len];
|
void[] res = buf[0 .. cast(size_t)len];
|
||||||
return cast(ubyte[])res;
|
return cast(ubyte[])res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2608,7 +2614,7 @@ class MemoryStream: TArrayStream!(ubyte[]) {
|
||||||
/// Ensure the stream can hold count bytes.
|
/// Ensure the stream can hold count bytes.
|
||||||
void reserve(size_t count) {
|
void reserve(size_t count) {
|
||||||
if (cur + count > buf.length)
|
if (cur + count > buf.length)
|
||||||
buf.length = (cur + count) * 2;
|
buf.length = cast(uint)((cur + count) * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
override size_t writeBlock(void* buffer, size_t size) {
|
override size_t writeBlock(void* buffer, size_t size) {
|
||||||
|
@ -2787,7 +2793,7 @@ class SliceStream : FilterStream {
|
||||||
override size_t readBlock (void *buffer, size_t size) {
|
override size_t readBlock (void *buffer, size_t size) {
|
||||||
assertReadable();
|
assertReadable();
|
||||||
if (bounded && size > high - low - pos)
|
if (bounded && size > high - low - pos)
|
||||||
size = high - low - pos;
|
size = cast(size_t)(high - low - pos);
|
||||||
ulong bp = s.position;
|
ulong bp = s.position;
|
||||||
if (seekable)
|
if (seekable)
|
||||||
s.position = low + pos;
|
s.position = low + pos;
|
||||||
|
@ -2802,7 +2808,7 @@ class SliceStream : FilterStream {
|
||||||
override size_t writeBlock (void *buffer, size_t size) {
|
override size_t writeBlock (void *buffer, size_t size) {
|
||||||
assertWriteable();
|
assertWriteable();
|
||||||
if (bounded && size > high - low - pos)
|
if (bounded && size > high - low - pos)
|
||||||
size = high - low - pos;
|
size = cast(size_t)(high - low - pos);
|
||||||
ulong bp = s.position;
|
ulong bp = s.position;
|
||||||
if (seekable)
|
if (seekable)
|
||||||
s.position = low + pos;
|
s.position = low + pos;
|
||||||
|
@ -2823,14 +2829,16 @@ class SliceStream : FilterStream {
|
||||||
spos = offset;
|
spos = offset;
|
||||||
break;
|
break;
|
||||||
case SeekPos.Current:
|
case SeekPos.Current:
|
||||||
spos = pos + offset;
|
spos = cast(long)(pos + offset);
|
||||||
break;
|
break;
|
||||||
case SeekPos.End:
|
case SeekPos.End:
|
||||||
if (bounded)
|
if (bounded)
|
||||||
spos = high - low + offset;
|
spos = cast(long)(high - low + offset);
|
||||||
else
|
else
|
||||||
spos = s.size - low + offset;
|
spos = cast(long)(s.size - low + offset);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spos < 0)
|
if (spos < 0)
|
||||||
|
@ -2840,7 +2848,7 @@ class SliceStream : FilterStream {
|
||||||
else if (!bounded && spos > s.size - low)
|
else if (!bounded && spos > s.size - low)
|
||||||
pos = s.size - low;
|
pos = s.size - low;
|
||||||
else
|
else
|
||||||
pos = spos;
|
pos = cast(ulong)spos;
|
||||||
|
|
||||||
readEOF = false;
|
readEOF = false;
|
||||||
return pos;
|
return pos;
|
||||||
|
@ -2851,9 +2859,9 @@ class SliceStream : FilterStream {
|
||||||
ulong bp = s.position;
|
ulong bp = s.position;
|
||||||
if (bp <= pos+low && pos+low <= bp+res) {
|
if (bp <= pos+low && pos+low <= bp+res) {
|
||||||
if (!bounded || bp+res <= high)
|
if (!bounded || bp+res <= high)
|
||||||
return bp + res - pos - low;
|
return cast(size_t)(bp + res - pos - low);
|
||||||
else if (high <= bp+res)
|
else if (high <= bp+res)
|
||||||
return high - pos - low;
|
return cast(size_t)(high - pos - low);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2394,7 +2394,7 @@ char[] toString(long i)
|
||||||
if (cast(int)i == i)
|
if (cast(int)i == i)
|
||||||
return toString(cast(int)i);
|
return toString(cast(int)i);
|
||||||
|
|
||||||
ulong u = -i;
|
ulong u = cast(ulong)(-i);
|
||||||
int ndigits = 1;
|
int ndigits = 1;
|
||||||
while (u)
|
while (u)
|
||||||
{
|
{
|
||||||
|
@ -2536,12 +2536,12 @@ body
|
||||||
uint i = buffer.length;
|
uint i = buffer.length;
|
||||||
|
|
||||||
if (value < radix && value < hexdigits.length)
|
if (value < radix && value < hexdigits.length)
|
||||||
return hexdigits[value .. value + 1];
|
return hexdigits[cast(size_t)value .. cast(size_t)value + 1];
|
||||||
|
|
||||||
do
|
do
|
||||||
{ ubyte c;
|
{ ubyte c;
|
||||||
|
|
||||||
c = value % radix;
|
c = cast(ubyte)(value % radix);
|
||||||
value = value / radix;
|
value = value / radix;
|
||||||
i--;
|
i--;
|
||||||
buffer[i] = (c < 10) ? c + '0' : c + 'A' - 10;
|
buffer[i] = (c < 10) ? c + '0' : c + 'A' - 10;
|
||||||
|
@ -3069,6 +3069,7 @@ char[] tr(char[] str, char[] from, char[] to, char[] modifiers = null)
|
||||||
case 'c': mod_c = 1; break; // complement
|
case 'c': mod_c = 1; break; // complement
|
||||||
case 'd': mod_d = 1; break; // delete unreplaced chars
|
case 'd': mod_d = 1; break; // delete unreplaced chars
|
||||||
case 's': mod_s = 1; break; // squeeze duplicated replaced chars
|
case 's': mod_s = 1; break; // squeeze duplicated replaced chars
|
||||||
|
default: assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -159,6 +159,7 @@ class Thread
|
||||||
return fp(arg);
|
return fp(arg);
|
||||||
else if (dg)
|
else if (dg)
|
||||||
return dg();
|
return dg();
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************
|
/*****************************
|
||||||
|
@ -247,6 +248,8 @@ class Thread
|
||||||
case PRIORITY.CRITICAL:
|
case PRIORITY.CRITICAL:
|
||||||
nPriority = THREAD_PRIORITY_TIME_CRITICAL;
|
nPriority = THREAD_PRIORITY_TIME_CRITICAL;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SetThreadPriority(hdl, nPriority) == THREAD_PRIORITY_ERROR_RETURN)
|
if (SetThreadPriority(hdl, nPriority) == THREAD_PRIORITY_ERROR_RETURN)
|
||||||
|
@ -654,6 +657,7 @@ class Thread
|
||||||
return fp(arg);
|
return fp(arg);
|
||||||
else if (dg)
|
else if (dg)
|
||||||
return dg();
|
return dg();
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wait()
|
void wait()
|
||||||
|
|
|
@ -45,9 +45,10 @@ class TypeInfo_Al : TypeInfo
|
||||||
len = s2.length;
|
len = s2.length;
|
||||||
for (size_t u = 0; u < len; u++)
|
for (size_t u = 0; u < len; u++)
|
||||||
{
|
{
|
||||||
int result = s1[u] - s2[u];
|
if (s1[u] < s2[u])
|
||||||
if (result)
|
return -1;
|
||||||
return result;
|
else if (s1[u] > s2[u])
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
return cast(int)s1.length - cast(int)s2.length;
|
return cast(int)s1.length - cast(int)s2.length;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,10 @@ class TypeInfo_Am : TypeInfo
|
||||||
len = s2.length;
|
len = s2.length;
|
||||||
for (size_t u = 0; u < len; u++)
|
for (size_t u = 0; u < len; u++)
|
||||||
{
|
{
|
||||||
int result = s1[u] - s2[u];
|
if (s1[u] < s2[u])
|
||||||
if (result)
|
return -1;
|
||||||
return result;
|
else if (s1[u] > s2[u])
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
return cast(int)s1.length - cast(int)s2.length;
|
return cast(int)s1.length - cast(int)s2.length;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ class TypeInfo_v : TypeInfo
|
||||||
hash_t getHash(void *p)
|
hash_t getHash(void *p)
|
||||||
{
|
{
|
||||||
assert(0);
|
assert(0);
|
||||||
return *cast(byte *)p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int equals(void *p1, void *p2)
|
int equals(void *p1, void *p2)
|
||||||
|
|
15
std/uni.d
15
std/uni.d
|
@ -464,7 +464,7 @@ int isUniAlpha(dchar u)
|
||||||
|
|
||||||
low = 0;
|
low = 0;
|
||||||
high = table.length - 1;
|
high = table.length - 1;
|
||||||
while (low <= high)
|
while (cast(int)low <= cast(int)high)
|
||||||
{
|
{
|
||||||
mid = (low + high) >> 1;
|
mid = (low + high) >> 1;
|
||||||
if (u < table[mid][0])
|
if (u < table[mid][0])
|
||||||
|
@ -498,4 +498,15 @@ Lis:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
for (uint i = 0; i < 0x80; i++)
|
||||||
|
{
|
||||||
|
if (i >= 'A' && i <= 'Z')
|
||||||
|
assert(isUniAlpha(i));
|
||||||
|
else if (i >= 'a' && i <= 'z')
|
||||||
|
assert(isUniAlpha(i));
|
||||||
|
else
|
||||||
|
assert(!isUniAlpha(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -223,7 +223,6 @@ private char[] URI_Encode(dchar[] string, uint unescapedSet)
|
||||||
|
|
||||||
LthrowURIerror:
|
LthrowURIerror:
|
||||||
throw new URIerror();
|
throw new URIerror();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint ascii2hex(dchar c)
|
uint ascii2hex(dchar c)
|
||||||
|
@ -344,7 +343,6 @@ private dchar[] URI_Decode(char[] string, uint reservedSet)
|
||||||
|
|
||||||
LthrowURIerror:
|
LthrowURIerror:
|
||||||
throw new URIerror();
|
throw new URIerror();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************
|
/*************************************
|
||||||
|
|
|
@ -667,11 +667,8 @@ char[] toUTF8(char[4] buf, dchar c)
|
||||||
buf[3] = cast(char)(0x80 | (c & 0x3F));
|
buf[3] = cast(char)(0x80 | (c & 0x3F));
|
||||||
return buf[0 .. 4];
|
return buf[0 .. 4];
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*******************
|
/*******************
|
||||||
* Encodes string s into UTF-8 and returns the encoded string.
|
* Encodes string s into UTF-8 and returns the encoded string.
|
||||||
|
|
|
@ -384,13 +384,14 @@ private REG_VALUE_TYPE _RVT_from_Endian(Endian endian)
|
||||||
{
|
{
|
||||||
case Endian.Big:
|
case Endian.Big:
|
||||||
return REG_VALUE_TYPE.REG_DWORD_BIG_ENDIAN;
|
return REG_VALUE_TYPE.REG_DWORD_BIG_ENDIAN;
|
||||||
break;
|
|
||||||
case Endian.Little:
|
case Endian.Little:
|
||||||
return REG_VALUE_TYPE.REG_DWORD_LITTLE_ENDIAN;
|
return REG_VALUE_TYPE.REG_DWORD_LITTLE_ENDIAN;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw new RegistryException("Invalid Endian specified");
|
throw new RegistryException("Invalid Endian specified");
|
||||||
}
|
}
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private uint swap(in uint i)
|
private uint swap(in uint i)
|
||||||
|
@ -711,7 +712,7 @@ body
|
||||||
case REG_VALUE_TYPE.REG_BINARY:
|
case REG_VALUE_TYPE.REG_BINARY:
|
||||||
case REG_VALUE_TYPE.REG_MULTI_SZ:
|
case REG_VALUE_TYPE.REG_MULTI_SZ:
|
||||||
throw new RegistryException("Cannot read the given value as a string");
|
throw new RegistryException("Cannot read the given value as a string");
|
||||||
break;
|
|
||||||
case REG_VALUE_TYPE.REG_SZ:
|
case REG_VALUE_TYPE.REG_SZ:
|
||||||
case REG_VALUE_TYPE.REG_EXPAND_SZ:
|
case REG_VALUE_TYPE.REG_EXPAND_SZ:
|
||||||
value = std.string.toString(cast(char*)data);
|
value = std.string.toString(cast(char*)data);
|
||||||
|
@ -775,7 +776,7 @@ body
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
throw new RegistryException("Cannot read the given value as a string");
|
throw new RegistryException("Cannot read the given value as a string");
|
||||||
break;
|
|
||||||
case REG_VALUE_TYPE.REG_MULTI_SZ:
|
case REG_VALUE_TYPE.REG_MULTI_SZ:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -807,7 +808,7 @@ body
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
throw new RegistryException("Cannot read the given value as a 32-bit integer");
|
throw new RegistryException("Cannot read the given value as a 32-bit integer");
|
||||||
break;
|
|
||||||
version(LittleEndian)
|
version(LittleEndian)
|
||||||
{
|
{
|
||||||
case REG_VALUE_TYPE.REG_DWORD_LITTLE_ENDIAN:
|
case REG_VALUE_TYPE.REG_DWORD_LITTLE_ENDIAN:
|
||||||
|
@ -850,7 +851,7 @@ body
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
throw new RegistryException("Cannot read the given value as a 64-bit integer");
|
throw new RegistryException("Cannot read the given value as a 64-bit integer");
|
||||||
break;
|
|
||||||
case REG_VALUE_TYPE.REG_QWORD_LITTLE_ENDIAN:
|
case REG_VALUE_TYPE.REG_QWORD_LITTLE_ENDIAN:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -887,7 +888,7 @@ body
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
throw new RegistryException("Cannot read the given value as a string");
|
throw new RegistryException("Cannot read the given value as a string");
|
||||||
break;
|
|
||||||
case REG_VALUE_TYPE.REG_BINARY:
|
case REG_VALUE_TYPE.REG_BINARY:
|
||||||
data.length = cbData;
|
data.length = cbData;
|
||||||
value = data;
|
value = data;
|
||||||
|
@ -1748,8 +1749,8 @@ public:
|
||||||
for(DWORD index = 0; 0 == result; ++index)
|
for(DWORD index = 0; 0 == result; ++index)
|
||||||
{
|
{
|
||||||
DWORD cchName;
|
DWORD cchName;
|
||||||
LONG res = Reg_EnumKeyName_(hkey, index, sName, cchName);
|
|
||||||
|
|
||||||
|
res = Reg_EnumKeyName_(hkey, index, sName, cchName);
|
||||||
assert(ERROR_MORE_DATA != res);
|
assert(ERROR_MORE_DATA != res);
|
||||||
|
|
||||||
if(ERROR_NO_MORE_ITEMS == res)
|
if(ERROR_NO_MORE_ITEMS == res)
|
||||||
|
@ -1881,8 +1882,8 @@ public:
|
||||||
for(DWORD index = 0; 0 == result; ++index)
|
for(DWORD index = 0; 0 == result; ++index)
|
||||||
{
|
{
|
||||||
DWORD cchName;
|
DWORD cchName;
|
||||||
LONG res = Reg_EnumKeyName_(hkey, index, sName, cchName);
|
|
||||||
|
|
||||||
|
res = Reg_EnumKeyName_(hkey, index, sName, cchName);
|
||||||
assert(ERROR_MORE_DATA != res);
|
assert(ERROR_MORE_DATA != res);
|
||||||
|
|
||||||
if(ERROR_NO_MORE_ITEMS == res)
|
if(ERROR_NO_MORE_ITEMS == res)
|
||||||
|
@ -2025,8 +2026,8 @@ public:
|
||||||
for(DWORD index = 0; 0 == result; ++index)
|
for(DWORD index = 0; 0 == result; ++index)
|
||||||
{
|
{
|
||||||
DWORD cchName = 1 + cchValueMaxLen;
|
DWORD cchName = 1 + cchValueMaxLen;
|
||||||
LONG res = Reg_EnumValueName_(hkey, index, sName, cchName);
|
|
||||||
|
|
||||||
|
res = Reg_EnumValueName_(hkey, index, sName, cchName);
|
||||||
if(ERROR_NO_MORE_ITEMS == res)
|
if(ERROR_NO_MORE_ITEMS == res)
|
||||||
{
|
{
|
||||||
// Enumeration complete
|
// Enumeration complete
|
||||||
|
@ -2152,8 +2153,8 @@ public:
|
||||||
for(DWORD index = 0; 0 == result; ++index)
|
for(DWORD index = 0; 0 == result; ++index)
|
||||||
{
|
{
|
||||||
DWORD cchName = 1 + cchValueMaxLen;
|
DWORD cchName = 1 + cchValueMaxLen;
|
||||||
LONG res = Reg_EnumValueName_(hkey, index, sName, cchName);
|
|
||||||
|
|
||||||
|
res = Reg_EnumValueName_(hkey, index, sName, cchName);
|
||||||
if(ERROR_NO_MORE_ITEMS == res)
|
if(ERROR_NO_MORE_ITEMS == res)
|
||||||
{
|
{
|
||||||
// Enumeration complete
|
// Enumeration complete
|
||||||
|
|
25
std/zip.d
25
std/zip.d
|
@ -212,8 +212,8 @@ class ZipArchive
|
||||||
putUint (i + 14, de.crc32);
|
putUint (i + 14, de.crc32);
|
||||||
putUint (i + 18, de.compressedSize);
|
putUint (i + 18, de.compressedSize);
|
||||||
putUint (i + 22, de.expandedData.length);
|
putUint (i + 22, de.expandedData.length);
|
||||||
putUshort(i + 26, de.name.length);
|
putUshort(i + 26, cast(ushort)de.name.length);
|
||||||
putUshort(i + 28, de.extra.length);
|
putUshort(i + 28, cast(ushort)de.extra.length);
|
||||||
i += 30;
|
i += 30;
|
||||||
|
|
||||||
data[i .. i + de.name.length] = cast(ubyte[])de.name[];
|
data[i .. i + de.name.length] = cast(ubyte[])de.name[];
|
||||||
|
@ -238,9 +238,9 @@ class ZipArchive
|
||||||
putUint (i + 16, de.crc32);
|
putUint (i + 16, de.crc32);
|
||||||
putUint (i + 20, de.compressedSize);
|
putUint (i + 20, de.compressedSize);
|
||||||
putUint (i + 24, de.expandedSize);
|
putUint (i + 24, de.expandedSize);
|
||||||
putUshort(i + 28, de.name.length);
|
putUshort(i + 28, cast(ushort)de.name.length);
|
||||||
putUshort(i + 30, de.extra.length);
|
putUshort(i + 30, cast(ushort)de.extra.length);
|
||||||
putUshort(i + 32, de.comment.length);
|
putUshort(i + 32, cast(ushort)de.comment.length);
|
||||||
putUshort(i + 34, de.diskNumber);
|
putUshort(i + 34, de.diskNumber);
|
||||||
putUshort(i + 36, de.internalAttributes);
|
putUshort(i + 36, de.internalAttributes);
|
||||||
putUint (i + 38, de.externalAttributes);
|
putUint (i + 38, de.externalAttributes);
|
||||||
|
@ -260,13 +260,13 @@ class ZipArchive
|
||||||
// Write end record
|
// Write end record
|
||||||
endrecOffset = i;
|
endrecOffset = i;
|
||||||
data[i .. i + 4] = cast(ubyte[])"PK\x05\x06";
|
data[i .. i + 4] = cast(ubyte[])"PK\x05\x06";
|
||||||
putUshort(i + 4, diskNumber);
|
putUshort(i + 4, cast(ushort)diskNumber);
|
||||||
putUshort(i + 6, diskStartDir);
|
putUshort(i + 6, cast(ushort)diskStartDir);
|
||||||
putUshort(i + 8, numEntries);
|
putUshort(i + 8, cast(ushort)numEntries);
|
||||||
putUshort(i + 10, totalEntries);
|
putUshort(i + 10, cast(ushort)totalEntries);
|
||||||
putUint (i + 12, directorySize);
|
putUint (i + 12, directorySize);
|
||||||
putUint (i + 16, directoryOffset);
|
putUint (i + 16, directoryOffset);
|
||||||
putUshort(i + 20, comment.length);
|
putUshort(i + 20, cast(ushort)comment.length);
|
||||||
i += 22;
|
i += 22;
|
||||||
|
|
||||||
// Write archive comment
|
// Write archive comment
|
||||||
|
@ -450,6 +450,7 @@ class ZipArchive
|
||||||
default:
|
default:
|
||||||
throw new ZipException("unsupported compression method");
|
throw new ZipException("unsupported compression method");
|
||||||
}
|
}
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ============ Utility =================== */
|
/* ============ Utility =================== */
|
||||||
|
@ -488,8 +489,8 @@ class ZipArchive
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data[0] = cast(ubyte)us;
|
data[i] = cast(ubyte)us;
|
||||||
data[1] = cast(ubyte)(us >> 8);
|
data[i + 1] = cast(ubyte)(us >> 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -191,6 +191,7 @@ void[] uncompress(void[] srcbuf, uint destlen = 0u, int winbits = 15)
|
||||||
throw new ZlibException(err);
|
throw new ZlibException(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
|
|
|
@ -48,6 +48,7 @@ import std.stdio;
|
||||||
import std.conv;
|
import std.conv;
|
||||||
import std.boxer;
|
import std.boxer;
|
||||||
import std.bitarray;
|
import std.bitarray;
|
||||||
|
import std.uni;
|
||||||
|
|
||||||
int main(char[][] args)
|
int main(char[][] args)
|
||||||
{
|
{
|
||||||
|
@ -108,6 +109,8 @@ printf("test2\n");
|
||||||
ba.length = 3;
|
ba.length = 3;
|
||||||
ba[0] = true;
|
ba[0] = true;
|
||||||
|
|
||||||
|
std.uni.isUniAlpha('A');
|
||||||
|
|
||||||
printf("Success\n!");
|
printf("Success\n!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
13
win32.mak
13
win32.mak
|
@ -19,8 +19,8 @@ CP=cp
|
||||||
CFLAGS=-mn -6 -r
|
CFLAGS=-mn -6 -r
|
||||||
#CFLAGS=-g -mn -6 -r
|
#CFLAGS=-g -mn -6 -r
|
||||||
|
|
||||||
DFLAGS=-O -release -nofloat
|
DFLAGS=-O -release -nofloat -w
|
||||||
#DFLAGS=-unittest -g
|
#DFLAGS=-unittest -g -w
|
||||||
#DFLAGS=-unittest -cov -g
|
#DFLAGS=-unittest -cov -g
|
||||||
|
|
||||||
CC=dmc
|
CC=dmc
|
||||||
|
@ -73,7 +73,7 @@ OBJS= asserterror.obj deh.obj switch.obj complex.obj gcstats.obj \
|
||||||
socket.obj socketstream.obj loader.obj stdarg.obj format.obj stdio.obj \
|
socket.obj socketstream.obj loader.obj stdarg.obj format.obj stdio.obj \
|
||||||
perf.obj openrj.obj uni.obj winsock.obj oldsyserror.obj \
|
perf.obj openrj.obj uni.obj winsock.obj oldsyserror.obj \
|
||||||
errno.obj boxer.obj cstream.obj charset.obj \
|
errno.obj boxer.obj cstream.obj charset.obj \
|
||||||
realtest.obj gamma.obj demangle.obj cover.obj bitarray.obj \
|
gamma.obj demangle.obj cover.obj bitarray.obj \
|
||||||
ti_Aa.obj ti_Ag.obj ti_C.obj ti_int.obj ti_char.obj \
|
ti_Aa.obj ti_Ag.obj ti_C.obj ti_int.obj ti_char.obj \
|
||||||
ti_wchar.obj ti_uint.obj ti_short.obj ti_ushort.obj \
|
ti_wchar.obj ti_uint.obj ti_short.obj ti_ushort.obj \
|
||||||
ti_byte.obj ti_ubyte.obj ti_long.obj ti_ulong.obj ti_ptr.obj \
|
ti_byte.obj ti_ubyte.obj ti_long.obj ti_ulong.obj ti_ptr.obj \
|
||||||
|
@ -190,7 +190,7 @@ SRC_STD_C_WIN= std\c\windows\windows.d std\c\windows\com.d \
|
||||||
SRC_STD_C_LINUX= std\c\linux\linux.d std\c\linux\linuxextern.d \
|
SRC_STD_C_LINUX= std\c\linux\linux.d std\c\linux\linuxextern.d \
|
||||||
std\c\linux\socket.d
|
std\c\linux\socket.d
|
||||||
|
|
||||||
SRC_ETC= etc\gamma.d etc\realtest.d
|
SRC_ETC= etc\gamma.d
|
||||||
|
|
||||||
SRC_ETC_C= etc\c\zlib.d
|
SRC_ETC_C= etc\c\zlib.d
|
||||||
|
|
||||||
|
@ -478,9 +478,6 @@ stdarg.obj : std\c\stdarg.d
|
||||||
gamma.obj : etc\gamma.d
|
gamma.obj : etc\gamma.d
|
||||||
$(DMD) -c $(DFLAGS) etc\gamma.d
|
$(DMD) -c $(DFLAGS) etc\gamma.d
|
||||||
|
|
||||||
realtest.obj : etc\realtest.d
|
|
||||||
$(DMD) -c $(DFLAGS) etc\realtest.d
|
|
||||||
|
|
||||||
### etc\c
|
### etc\c
|
||||||
|
|
||||||
Czlib.obj : etc\c\zlib.d
|
Czlib.obj : etc\c\zlib.d
|
||||||
|
@ -820,7 +817,7 @@ install:
|
||||||
$(CP) $(SRC_STD_WIN) \dmd\src\phobos\std\windows
|
$(CP) $(SRC_STD_WIN) \dmd\src\phobos\std\windows
|
||||||
$(CP) $(SRC_STD_C_WIN) \dmd\src\phobos\std\c\windows
|
$(CP) $(SRC_STD_C_WIN) \dmd\src\phobos\std\c\windows
|
||||||
$(CP) $(SRC_STD_C_LINUX) \dmd\src\phobos\std\c\linux
|
$(CP) $(SRC_STD_C_LINUX) \dmd\src\phobos\std\c\linux
|
||||||
#$(CP) $(SRC_ETC) \dmd\src\phobos\etc
|
$(CP) $(SRC_ETC) \dmd\src\phobos\etc
|
||||||
$(CP) $(SRC_ETC_C) \dmd\src\phobos\etc\c
|
$(CP) $(SRC_ETC_C) \dmd\src\phobos\etc\c
|
||||||
$(CP) $(SRC_ZLIB) \dmd\src\phobos\etc\c\zlib
|
$(CP) $(SRC_ZLIB) \dmd\src\phobos\etc\c\zlib
|
||||||
$(CP) $(SRC_GC) \dmd\src\phobos\internal\gc
|
$(CP) $(SRC_GC) \dmd\src\phobos\internal\gc
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue