diff -uNr dmd-0.160/dmd/src/dmd/cast.c dmd-0.161/dmd/src/dmd/cast.c --- dmd-0.160/dmd/src/dmd/cast.c 2006-04-06 02:01:46.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/cast.c 2006-06-18 12:43:58.000000000 +0200 @@ -54,13 +54,25 @@ type->print(); printf("to:\n"); t->print(); -printf("%p %p %s %s\n", type->deco, t->deco, type->deco, t->deco); +printf("%p %p type: %s to: %s\n", type->deco, t->deco, type->deco, t->deco); //printf("%p %p %p\n", type->next->arrayOf(), type, t); fflush(stdout); #endif //*(char*)0=0; - error("cannot implicitly convert expression (%s) of type %s to %s", - toChars(), type->toChars(), t->toChars()); + if (!t->deco) + { /* Can happen with: + * enum E { One } + * class A + * { static void fork(EDG dg) { dg(E.One); } + * alias void delegate(E) EDG; + * } + * Should eventually make it work. + */ + error("forward reference to type %s", t->toChars()); + } + else + error("cannot implicitly convert expression (%s) of type %s to %s", + toChars(), type->toChars(), t->toChars()); return castTo(t); } @@ -203,7 +215,6 @@ goto Lyes; case Tfloat32: - case Tcomplex32: { volatile float f; if (type->isunsigned()) @@ -222,7 +233,6 @@ } case Tfloat64: - case Tcomplex64: { volatile double f; if (type->isunsigned()) @@ -241,7 +251,6 @@ } case Tfloat80: - case Tcomplex80: { volatile long double f; if (type->isunsigned()) @@ -292,7 +301,7 @@ int StringExp::implicitConvTo(Type *t) { MATCH m; - //printf("StringExp::implicitConvTo(), committed = %d\n", committed); + //printf("StringExp::implicitConvTo(t = %s), '%s' committed = %d\n", t->toChars(), toChars(), committed); if (!committed) { if (!committed && t->ty == Tpointer && t->next->ty == Tvoid) @@ -527,8 +536,8 @@ Type *tb; int unique; - //printf("StringExp::castTo(%s) '%s'\n", t->toChars(), string); - //if (((char*)string)[0] == 'd') *(char*)0=0; + //printf("StringExp::castTo(t = %s), '%s' committed = %d\n", t->toChars(), toChars(), committed); + if (!committed && t->ty == Tpointer && t->next->ty == Tvoid) { error("cannot convert string literal to void*"); @@ -546,16 +555,26 @@ se = new StringExp(loc, s, len); se->type = type; se->sz = sz; - se->committed = 1; // it now has a firm type + se->committed = 0; unique = 1; // this is the only instance } tb = t->toBasetype(); se->type = type->toBasetype(); if (tb == se->type) { se->type = t; + se->committed = 1; return se; } + if (se->committed == 1) + { + if (se->type->next->size() == tb->next->size()) + { se->type = t; + return se; + } + goto Lcast; + } + se->committed = 1; if (tb->ty != Tsarray && tb->ty != Tarray && tb->ty != Tpointer) goto Lcast; if (se->type->ty != Tsarray && se->type->ty != Tarray && se->type->ty != Tpointer) diff -uNr dmd-0.160/dmd/src/dmd/class.c dmd-0.161/dmd/src/dmd/class.c --- dmd-0.160/dmd/src/dmd/class.c 2006-05-12 10:53:44.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/class.c 2006-06-19 11:59:58.000000000 +0200 @@ -400,24 +400,27 @@ } else if (!(storage_class & STCstatic)) { Dsymbol *s = toParent(); - ClassDeclaration *cd = s->isClassDeclaration(); - FuncDeclaration *fd = s->isFuncDeclaration(); + if (s) + { + ClassDeclaration *cd = s->isClassDeclaration(); + FuncDeclaration *fd = s->isFuncDeclaration(); - if (cd || fd) - { isnested = 1; - Type *t; - if (cd) - t = cd->type; - else if (fd) - { t = new TypePointer(Type::tvoid); - t = t->semantic(0, sc); + if (cd || fd) + { isnested = 1; + Type *t; + if (cd) + t = cd->type; + else if (fd) + { t = new TypePointer(Type::tvoid); + t = t->semantic(0, sc); + } + else + assert(0); + assert(!vthis); + vthis = new ThisDeclaration(t); + members->push(vthis); } - else - assert(0); - assert(!vthis); - vthis = new ThisDeclaration(t); - members->push(vthis); } } } diff -uNr dmd-0.160/dmd/src/dmd/declaration.c dmd-0.161/dmd/src/dmd/declaration.c --- dmd-0.160/dmd/src/dmd/declaration.c 2006-05-24 13:37:52.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/declaration.c 2006-06-07 16:58:16.000000000 +0200 @@ -541,6 +541,14 @@ type = Type::terror; tb = type; } + if (tb->ty == Tstruct) + { TypeStruct *ts = (TypeStruct *)tb; + + if (!ts->sym->members) + { + error("no definition of struct %s", ts->toChars()); + } + } if (storage_class & STCconst && !init && !fd) // Initialize by constructor only diff -uNr dmd-0.160/dmd/src/dmd/declaration.h dmd-0.161/dmd/src/dmd/declaration.h --- dmd-0.160/dmd/src/dmd/declaration.h 2006-03-12 14:36:32.000000000 +0100 +++ dmd-0.161/dmd/src/dmd/declaration.h 2006-06-09 23:36:12.000000000 +0200 @@ -373,9 +373,13 @@ Type *tintro; // if !=NULL, then this is the type // of the 'introducing' function // this one is overriding + int inferRetType; // !=0 if return type is to be inferred // Things that should really go into Scope - int hasReturnExp; // if there's a return exp; statement + int hasReturnExp; // 1 if there's a return exp; statement + // 2 if there's a throw statement + // 4 if there's an assert(0) + // 8 if there's inline asm FuncDeclaration(Loc loc, Loc endloc, Identifier *id, enum STC storage_class, Type *type); Dsymbol *syntaxCopy(Dsymbol *); diff -uNr dmd-0.160/dmd/src/dmd/dsymbol.c dmd-0.161/dmd/src/dmd/dsymbol.c --- dmd-0.160/dmd/src/dmd/dsymbol.c 2006-04-15 01:00:18.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/dsymbol.c 2006-06-19 18:08:36.000000000 +0200 @@ -557,8 +557,16 @@ s = s2; else if (s2 && s != s2) { - ss->multiplyDefined(s, s2); - break; + /* Two imports of the same module should be regarded as + * the same. + */ + Import *i1 = s->isImport(); + Import *i2 = s2->isImport(); + if (!(i1 && i2 && i1->mod == i2->mod)) + { + ss->multiplyDefined(s, s2); + break; + } } } if (s) @@ -616,8 +624,11 @@ void ScopeDsymbol::multiplyDefined(Dsymbol *s1, Dsymbol *s2) { - //printf("s1 = '%s'\n", s1->toChars()); - //printf("s2 = '%s', parent = %p\n", s2->toChars(), s2->parent); +#if 0 + printf("ScopeDsymbol::multiplyDefined()\n"); + printf("s1 = %p, '%s' kind = '%s', parent = %s\n", s1, s1->toChars(), s1->kind(), s1->parent ? s1->parent->toChars() : ""); + printf("s2 = %p, '%s' kind = '%s', parent = %s\n", s2, s2->toChars(), s2->kind(), s2->parent ? s2->parent->toChars() : ""); +#endif #if 1 s1->error("conflicts with %s at %s", s2->toPrettyChars(), @@ -628,6 +639,7 @@ s2->toPrettyChars(), s2->locToChars()); #endif +//*(char*)0=0; } Dsymbol *ScopeDsymbol::nameCollision(Dsymbol *s) diff -uNr dmd-0.160/dmd/src/dmd/expression.c dmd-0.161/dmd/src/dmd/expression.c --- dmd-0.160/dmd/src/dmd/expression.c 2006-06-02 17:51:30.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/expression.c 2006-06-16 13:24:46.000000000 +0200 @@ -1469,8 +1469,17 @@ if (withsym) { // Same as wthis.ident - e = new VarExp(loc, withsym->withstate->wthis); - e = new DotIdExp(loc, e, ident); + if (s->needThis()) + { + e = new VarExp(loc, withsym->withstate->wthis); + e = new DotIdExp(loc, e, ident); + } + else + { Type *t = withsym->withstate->wthis->type; + if (t->ty == Tpointer) + t = t->next; + e = new TypeDotIdExp(loc, t, ident); + } } else { @@ -1889,6 +1898,16 @@ /******************************** StringExp **************************/ +StringExp::StringExp(Loc loc, char *string) + : Expression(loc, TOKstring, sizeof(StringExp)) +{ + this->string = string; + this->len = strlen(string); + this->sz = 1; + this->committed = 0; + this->postfix = 0; +} + StringExp::StringExp(Loc loc, void *string, unsigned len) : Expression(loc, TOKstring, sizeof(StringExp)) { @@ -2924,10 +2943,28 @@ // Must be unique in both. if (s->ident) { - if (!sc->insert(s) || - (s->isFuncDeclaration() && !sc->func->localsymtab->insert(s))) - //error("declaration %s.%s is already defined", sc->func->toChars(), s->toChars()); + if (!sc->insert(s)) error("declaration %s is already defined", s->toPrettyChars()); + else if (sc->func) + { VarDeclaration *v = s->isVarDeclaration(); + if ((s->isFuncDeclaration() /*|| v && v->storage_class & STCstatic*/) && + !sc->func->localsymtab->insert(s)) + error("declaration %s is already defined in another scope in %s", s->toPrettyChars(), sc->func->toChars()); + else if (!global.params.useDeprecated) + { // Disallow shadowing + + for (Scope *scx = sc->enclosing; scx && scx->func == sc->func; scx = scx->enclosing) + { Dsymbol *s2; + + if (scx->scopesym && scx->scopesym->symtab && + (s2 = scx->scopesym->symtab->lookup(s->ident)) != NULL && + s != s2) + { + error("shadowing declaration %s is deprecated", s->toPrettyChars()); + } + } + } + } } if (!s->isVarDeclaration()) { @@ -3435,10 +3472,16 @@ msg = msg->implicitCastTo(Type::tchar->arrayOf()); msg = msg->optimize(WANTvalue); } - if (!global.params.useAssert && e1->isBool(FALSE)) - { Expression *e = new HaltExp(loc); - e = e->semantic(sc); - return e; + if (e1->isBool(FALSE)) + { + FuncDeclaration *fd = sc->parent->isFuncDeclaration(); + fd->hasReturnExp |= 4; + + if (!global.params.useAssert) + { Expression *e = new HaltExp(loc); + e = e->semantic(sc); + return e; + } } type = Type::tvoid; return this; @@ -6522,16 +6565,27 @@ // same as for AndAnd e1 = e1->semantic(sc); + e1 = resolveProperties(sc, e1); + e1 = e1->checkToPointer(); + e1 = e1->checkToBoolean(); cs1 = sc->callSuper; + + if (sc->flags & SCOPEstaticif) + { + /* If in static if, don't evaluate e2 if we don't have to. + */ + e1 = e1->optimize(WANTflags); + if (e1->isBool(TRUE)) + { + return new IntegerExp(loc, 1, Type::tboolean); + } + } + e2 = e2->semantic(sc); sc->mergeCallSuper(loc, cs1); - - e1 = resolveProperties(sc, e1); e2 = resolveProperties(sc, e2); - - e1 = e1->checkToPointer(); e2 = e2->checkToPointer(); - e1 = e1->checkToBoolean(); + type = Type::tboolean; if (e1->type->ty == Tvoid) type = Type::tvoid; @@ -6569,16 +6623,27 @@ // same as for OrOr e1 = e1->semantic(sc); + e1 = resolveProperties(sc, e1); + e1 = e1->checkToPointer(); + e1 = e1->checkToBoolean(); cs1 = sc->callSuper; + + if (sc->flags & SCOPEstaticif) + { + /* If in static if, don't evaluate e2 if we don't have to. + */ + e1 = e1->optimize(WANTflags); + if (e1->isBool(FALSE)) + { + return new IntegerExp(loc, 0, Type::tboolean); + } + } + e2 = e2->semantic(sc); sc->mergeCallSuper(loc, cs1); - - e1 = resolveProperties(sc, e1); e2 = resolveProperties(sc, e2); - - e1 = e1->checkToPointer(); e2 = e2->checkToPointer(); - e1 = e1->checkToBoolean(); + type = Type::tboolean; if (e1->type->ty == Tvoid) type = Type::tvoid; @@ -6863,6 +6928,31 @@ econd = econd->semantic(sc); econd = resolveProperties(sc, econd); + econd = econd->checkToPointer(); + econd = econd->checkToBoolean(); + +#if 0 /* this cannot work right because the types of e1 and e2 + * both contribute to the type of the result. + */ + if (sc->flags & SCOPEstaticif) + { + /* If in static if, don't evaluate what we don't have to. + */ + econd = econd->optimize(WANTflags); + if (econd->isBool(TRUE)) + { + e1 = e1->semantic(sc); + e1 = resolveProperties(sc, e1); + return e1; + } + else if (econd->isBool(FALSE)) + { + e2 = e2->semantic(sc); + e2 = resolveProperties(sc, e2); + return e2; + } + } +#endif cs0 = sc->callSuper; @@ -6875,8 +6965,6 @@ sc->mergeCallSuper(loc, cs1); - econd = econd->checkToPointer(); - econd = econd->checkToBoolean(); // If either operand is void, the result is void t1 = e1->type; t2 = e2->type; diff -uNr dmd-0.160/dmd/src/dmd/expression.h dmd-0.161/dmd/src/dmd/expression.h --- dmd-0.160/dmd/src/dmd/expression.h 2006-06-02 17:50:10.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/expression.h 2006-06-07 17:25:36.000000000 +0200 @@ -280,8 +280,9 @@ unsigned char committed; // !=0 if type is committed unsigned char postfix; // 'c', 'w', 'd' - StringExp(Loc loc, void *s, unsigned len, unsigned char postfix); + StringExp(Loc loc, char *s); StringExp(Loc loc, void *s, unsigned len); + StringExp(Loc loc, void *s, unsigned len, unsigned char postfix); int equals(Object *o); char *toChars(); Expression *semantic(Scope *sc); @@ -1194,6 +1195,7 @@ // For operator overloading Identifier *opId(); + Identifier *opId_r(); elem *toElem(IRState *irs); }; diff -uNr dmd-0.160/dmd/src/dmd/func.c dmd-0.161/dmd/src/dmd/func.c --- dmd-0.160/dmd/src/dmd/func.c 2006-05-14 14:54:36.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/func.c 2006-06-08 17:26:54.000000000 +0200 @@ -65,6 +65,7 @@ fes = NULL; introducing = 0; tintro = NULL; + inferRetType = (type && type->next == NULL); } Dsymbol *FuncDeclaration::syntaxCopy(Dsymbol *s) @@ -99,7 +100,8 @@ printf("\tFuncLiteralDeclaration()\n"); #endif - type = type->semantic(loc, sc); + if (type->next) + type = type->semantic(loc, sc); //type->print(); if (type->ty != Tfunction) { @@ -622,6 +624,7 @@ sym->parent = sc2->scopesym; sc2 = sc2->push(sym); + assert(type->next); if (type->next->ty == Tvoid) { if (outId) @@ -731,6 +734,17 @@ } fbody = fbody->semantic(sc2); + + if (inferRetType) + { // If no return type inferred yet, then infer a void + if (!type->next) + { + type->next = Type::tvoid; + type = type->semantic(loc, sc); + } + f = (TypeFunction *)type; + } + int offend = fbody ? fbody->fallOffEnd() : TRUE; if (isStaticCtorDeclaration()) @@ -789,8 +803,8 @@ fbody = new CompoundStatement(0, fbody, s); assert(!returnLabel); } -// else if (!hasReturnExp && type->next->ty != Tvoid) -// error("expected to return a value of type %s", type->next->toChars()); + else if (!hasReturnExp && type->next->ty != Tvoid) + error("expected to return a value of type %s", type->next->toChars()); else if (!inlineAsm) { if (type->next->ty == Tvoid) @@ -813,10 +827,14 @@ if (global.params.useAssert && !global.params.useInline) - { /* Add an assert(0); where the missing return + { /* Add an assert(0, msg); where the missing return * should be. */ - e = new AssertExp(endloc, new IntegerExp(0, 0, Type::tint32)); + e = new AssertExp( + endloc, + new IntegerExp(0), + new StringExp(0, "missing return expression") + ); } else e = new HaltExp(endloc); diff -uNr dmd-0.160/dmd/src/dmd/idgen.c dmd-0.161/dmd/src/dmd/idgen.c --- dmd-0.160/dmd/src/dmd/idgen.c 2006-06-02 17:47:30.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/idgen.c 2006-06-07 00:50:38.000000000 +0200 @@ -165,15 +165,16 @@ { "catass", "opCatAssign" }, { "postinc", "opPostInc" }, { "postdec", "opPostDec" }, - { "index", "opIndex" }, + { "index", "opIndex" }, { "indexass", "opIndexAssign" }, - { "slice", "opSlice" }, + { "slice", "opSlice" }, { "sliceass", "opSliceAssign" }, - { "call", "opCall" }, - { "cast", "opCast" }, - { "match", "opMatch" }, - { "next", "opNext" }, + { "call", "opCall" }, + { "cast", "opCast" }, + { "match", "opMatch" }, + { "next", "opNext" }, { "opIn" }, + { "opIn_r" }, { "classNew", "new" }, { "classDelete", "delete" }, diff -uNr dmd-0.160/dmd/src/dmd/import.h dmd-0.161/dmd/src/dmd/import.h --- dmd-0.160/dmd/src/dmd/import.h 2005-12-12 16:13:24.000000000 +0100 +++ dmd-0.161/dmd/src/dmd/import.h 2006-06-19 18:08:36.000000000 +0200 @@ -28,11 +28,12 @@ struct Import : Dsymbol { - Module *mod; - Package *pkg; // leftmost package/module Array *packages; // array of Identifier's representing packages Identifier *id; // module Identifier + Module *mod; + Package *pkg; // leftmost package/module + Import(Loc loc, Array *packages, Identifier *id); char *kind(); Dsymbol *syntaxCopy(Dsymbol *s); // copy only syntax trees diff -uNr dmd-0.160/dmd/src/dmd/inline.c dmd-0.161/dmd/src/dmd/inline.c --- dmd-0.160/dmd/src/dmd/inline.c 2006-06-02 14:17:46.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/inline.c 2006-06-17 00:48:44.000000000 +0200 @@ -70,6 +70,12 @@ { int cost; + /* Can't declare variables inside ?: expressions, so + * we cannot inline if a variable is declared. + */ + if (arg) + return COST_MAX; + cost = condition->inlineCost(ics); /* Specifically allow: @@ -293,6 +299,7 @@ Expression *e2; Expression *e; + assert(!arg); econd = condition->doInline(ids); assert(econd); if (ifbody) @@ -1007,6 +1014,14 @@ TypeFunction *tf = (TypeFunction *)(type); if (tf->varargs == 1) // no variadic parameter lists goto Lno; + + /* Don't inline a function that returns non-void, but has + * no return expression. + */ + if (type->next && type->next->ty != Tvoid && + !(hasReturnExp & 1) && + !hdrscan) + goto Lno; } else { CtorDeclaration *ctor = isCtorDeclaration(); diff -uNr dmd-0.160/dmd/src/dmd/lexer.c dmd-0.161/dmd/src/dmd/lexer.c --- dmd-0.160/dmd/src/dmd/lexer.c 2006-04-26 11:53:18.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/lexer.c 2006-06-10 00:01:32.000000000 +0200 @@ -392,6 +392,42 @@ return t; } +/********************************* + * tk is on the opening (. + * Look ahead and return token that is past the closing ). + */ + +Token *Lexer::peekPastParen(Token *tk) +{ + //printf("peekPastParen()\n"); + int parens = 1; + while (1) + { + tk = peek(tk); + //tk->print(); + switch (tk->value) + { + case TOKlparen: + parens++; + continue; + + case TOKrparen: + --parens; + if (parens) + continue; + tk = peek(tk); + break; + + case TOKeof: + break; + + default: + continue; + } + return tk; + } +} + /**************************** * Turn next token in buffer into a token. */ diff -uNr dmd-0.160/dmd/src/dmd/lexer.h dmd-0.161/dmd/src/dmd/lexer.h --- dmd-0.160/dmd/src/dmd/lexer.h 2006-03-03 23:16:18.000000000 +0100 +++ dmd-0.161/dmd/src/dmd/lexer.h 2006-06-08 18:32:14.000000000 +0200 @@ -254,6 +254,7 @@ TOK nextToken(); void scan(Token *t); Token *peek(Token *t); + Token *peekPastParen(Token *t); unsigned escapeSequence(); TOK wysiwygStringConstant(Token *t, int tc); TOK hexStringConstant(Token *t); diff -uNr dmd-0.160/dmd/src/dmd/mars.c dmd-0.161/dmd/src/dmd/mars.c --- dmd-0.160/dmd/src/dmd/mars.c 2006-06-04 11:12:10.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/mars.c 2006-06-18 00:20:24.000000000 +0200 @@ -58,7 +58,7 @@ copyright = "Copyright (c) 1999-2006 by Digital Mars"; written = "written by Walter Bright"; - version = "v0.160"; + version = "v0.161"; global.structalign = 8; memset(¶ms, 0, sizeof(Param)); diff -uNr dmd-0.160/dmd/src/dmd/mars.h dmd-0.161/dmd/src/dmd/mars.h --- dmd-0.160/dmd/src/dmd/mars.h 2006-04-06 21:15:40.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/mars.h 2006-06-15 01:17:38.000000000 +0200 @@ -124,14 +124,15 @@ #endif #ifdef __DMC__ -typedef _Complex long double complex_t; -#elif IN_GCC + typedef _Complex long double complex_t; #else -#include "complex_t.h" -#ifdef __APPLE__ -//#include "complex.h"//This causes problems with include the c++ and not the C "complex.h" -#define integer_t dmd_integer_t -#endif + #ifndef IN_GCC + #include "complex_t.h" + #endif + #ifdef __APPLE__ + //#include "complex.h"//This causes problems with include the c++ and not the C "complex.h" + #define integer_t dmd_integer_t + #endif #endif // Be careful not to care about sign with integer_t diff -uNr dmd-0.160/dmd/src/dmd/module.c dmd-0.161/dmd/src/dmd/module.c --- dmd-0.160/dmd/src/dmd/module.c 2006-06-01 12:21:42.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/module.c 2006-06-19 18:07:48.000000000 +0200 @@ -119,7 +119,9 @@ else argobj = FileName::name(filename); if (!FileName::absolute(argobj)) + { FileName::ensurePathExists(global.params.objdir); argobj = FileName::combine(global.params.objdir, argobj); + } if (global.params.objname) objfilename = new FileName(argobj, 0); else @@ -155,7 +157,9 @@ else argdoc = FileName::name((char *)arg); if (!FileName::absolute(argdoc)) + { FileName::ensurePathExists(global.params.docdir); argdoc = FileName::combine(global.params.docdir, argdoc); + } if (global.params.docname) docfilename = new FileName(argdoc, 0); else @@ -181,7 +185,9 @@ else arghdr = FileName::name((char *)arg); if (!FileName::absolute(arghdr)) + { FileName::ensurePathExists(global.params.hdrdir); arghdr = FileName::combine(global.params.hdrdir, arghdr); + } if (global.params.hdrname) hdrfilename = new FileName(arghdr, 0); else diff -uNr dmd-0.160/dmd/src/dmd/mtype.c dmd-0.161/dmd/src/dmd/mtype.c --- dmd-0.160/dmd/src/dmd/mtype.c 2006-06-01 14:33:54.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/mtype.c 2006-06-16 00:26:10.000000000 +0200 @@ -1326,7 +1326,7 @@ int TypeBasic::implicitConvTo(Type *to) { - //printf("TypeBasic::implicitConvTo(%s)\n", to->toChars()); + //printf("TypeBasic::implicitConvTo(%s) from %s\n", to->toChars(), toChars()); if (this == to) return MATCHexact; if (to->ty == Tvoid) @@ -1340,7 +1340,8 @@ TypeBasic *tob = (TypeBasic *)to; if (flags & TFLAGSintegral) { - if (tob->flags & TFLAGSimaginary) + // Disallow implicit conversion of integers to imaginary or complex + if (tob->flags & (TFLAGSimaginary | TFLAGScomplex)) return MATCHnomatch; } else if (flags & TFLAGSfloating) @@ -1809,8 +1810,10 @@ return MATCHconvert; } if (to->ty == Tarray) - { - if (to->next->isBaseOf(next, NULL) || to->next->ty == Tvoid) + { int offset = 0; + + if ((to->next->isBaseOf(next, &offset) && offset == 0) || + to->next->ty == Tvoid) return MATCHconvert; } return Type::implicitConvTo(to); @@ -2211,8 +2214,8 @@ TypeFunction::TypeFunction(Array *arguments, Type *treturn, int varargs, enum LINK linkage) : Type(Tfunction, treturn) { -if (!treturn) *(char*)0=0; - assert(treturn); +//if (!treturn) *(char*)0=0; +// assert(treturn); this->arguments = arguments; this->varargs = varargs; this->linkage = linkage; @@ -2221,7 +2224,7 @@ Type *TypeFunction::syntaxCopy() { assert(next); - Type *treturn = next->syntaxCopy(); + Type *treturn = next ? next->syntaxCopy() : NULL; Array *args = Argument::arraySyntaxCopy(arguments); Type *t = new TypeFunction(args, treturn, varargs, linkage); return t; @@ -2382,7 +2385,7 @@ } } Argument::argsToCBuffer(buf, hgs, arguments, varargs); - if (!ident || ident->toHChars2() == ident->toChars()) + if (next && (!ident || ident->toHChars2() == ident->toChars())) next->toCBuffer2(buf, NULL, hgs); } @@ -2394,6 +2397,11 @@ return this; } linkage = sc->linkage; + if (!next) + { + assert(global.errors); + next = tvoid; + } next = next->semantic(loc,sc); if (next->toBasetype()->ty == Tsarray) error(loc, "functions cannot return static array %s", next->toChars()); @@ -2993,7 +3001,9 @@ s = sm; if (!s) // failed to find a symbol + { //printf("\tdidn't find a symbol\n"); break; + } s = s->toAlias(); } } diff -uNr dmd-0.160/dmd/src/dmd/opover.c dmd-0.161/dmd/src/dmd/opover.c --- dmd-0.160/dmd/src/dmd/opover.c 2006-06-02 17:49:20.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/opover.c 2006-06-07 00:51:18.000000000 +0200 @@ -79,6 +79,7 @@ Identifier *CastExp::opId() { return Id::cast; } Identifier *InExp::opId() { return Id::opIn; } +Identifier *InExp::opId_r() { return Id::opIn_r; } Identifier *PostIncExp::opId() { return Id::postinc; } diff -uNr dmd-0.160/dmd/src/dmd/parse.c dmd-0.161/dmd/src/dmd/parse.c --- dmd-0.160/dmd/src/dmd/parse.c 2006-06-02 11:40:56.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/parse.c 2006-06-16 10:25:00.000000000 +0200 @@ -43,10 +43,6 @@ // (type)(expression) #define CCASTSYNTAX 1 -// Support D cast syntax: -// cast(type)(expression) -#define DCASTSYNTAX 1 - // Support C array declarations, such as // int a[3][4]; #define CARRAYDECL 1 @@ -1818,37 +1814,12 @@ /* Look ahead to see if this is (...)(...), * i.e. a function template declaration */ - Token *tk = &token; - int parens = 1; - while (1) - { - tk = peek(tk); - switch (tk->value) - { - case TOKlparen: - parens++; - continue; - - case TOKrparen: - --parens; - if (parens) - continue; - break; + if (peekPastParen(&token)->value == TOKlparen) + { // It's a function template declaration + //printf("function template declaration\n"); - case TOKeof: - break; - - default: - continue; - } - if (peek(tk)->value == TOKlparen) - { // It's a function template declaration - //printf("function template declaration\n"); - - // Gather template parameter list - *tpl = parseTemplateParameterList(); - } - break; + // Gather template parameter list + *tpl = parseTemplateParameterList(); } } @@ -2381,9 +2352,7 @@ case TOKfalse: case TOKstring: case TOKlparen: -#if DCASTSYNTAX case TOKcast: -#endif case TOKmul: case TOKmin: case TOKadd: @@ -3622,6 +3591,7 @@ { Expression *e; Type *t; Identifier *id; + enum TOK save; Loc loc = this->loc; switch (token.value) @@ -3879,8 +3849,28 @@ break; } + case TOKlparen: + if (peekPastParen(&token)->value == TOKlcurly) + { // (arguments) { statements... } + save = TOKdelegate; + goto case_delegate; + } + // ( expression ) + nextToken(); + e = parseExpression(); + check(TOKrparen); + break; + + case TOKlcurly: + // { statements... } + save = TOKdelegate; + goto case_delegate; + case TOKfunction: case TOKdelegate: + save = token.value; + nextToken(); + case_delegate: { /* function type(parameters) { body } * delegate type(parameters) { body } @@ -3889,19 +3879,17 @@ int varargs; FuncLiteralDeclaration *fd; Type *t; - enum TOK save = token.value; - nextToken(); if (token.value == TOKlcurly) - { // default to void() - t = Type::tvoid; + { + t = NULL; varargs = 0; arguments = new Array(); } else { if (token.value == TOKlparen) - t = Type::tvoid; // default to void return type + t = NULL; else { t = parseBasicType(); @@ -4096,7 +4084,6 @@ e = parseNewExp(NULL); break; -#if DCASTSYNTAX case TOKcast: // cast(type) expression { Type *t; @@ -4126,14 +4113,14 @@ break; } -#endif + case TOKlparen: { Token *tk; - nextToken(); + tk = peek(&token); #if CCASTSYNTAX // If cast - if (isDeclaration(&token, 0, TOKrparen, &tk)) + if (isDeclaration(tk, 0, TOKrparen, &tk)) { tk = peek(tk); // skip over right parenthesis switch (tk->value) @@ -4142,7 +4129,6 @@ case TOKplusplus: case TOKminusminus: case TOKnot: - case TOKtilde: case TOKdelete: case TOKnew: case TOKlparen: @@ -4166,10 +4152,13 @@ case TOKwcharv: case TOKdcharv: case TOKstring: +#if 0 + case TOKtilde: case TOKand: case TOKmul: case TOKmin: case TOKadd: +#endif case TOKfunction: case TOKdelegate: case TOKtypeof: @@ -4177,6 +4166,7 @@ { // (type) una_exp Type *t; + nextToken(); t = parseBasicType(); t = parseDeclarator(t,NULL); check(TOKrparen); @@ -4203,10 +4193,7 @@ } } #endif - // ( expression ) - e = parseExpression(); - check(TOKrparen); - e = parsePostExp(e); + e = parsePrimaryExp(); break; } default: diff -uNr dmd-0.160/dmd/src/dmd/root.c dmd-0.161/dmd/src/dmd/root.c --- dmd-0.160/dmd/src/dmd/root.c 2005-10-02 11:11:12.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/root.c 2006-06-17 22:23:36.000000000 +0200 @@ -19,6 +19,7 @@ #if _WIN32 #include +#include #endif #if linux @@ -783,6 +784,46 @@ #endif } +void FileName::ensurePathExists(const char *path) +{ + //printf("FileName::ensurePathExists(%s)\n", path ? path : ""); + if (path && *path) + { + if (!exists(path)) + { + char *p = FileName::path(path); + if (*p) + { +#if _WIN32 + size_t len = strlen(p); + if (len > 2 && p[-1] == ':') + { mem.free(p); + return; + } +#endif + ensurePathExists(p); + mem.free(p); + } +#if _WIN32 + if (path[strlen(path) - 1] != '\\') +#endif +#if linux + if (path[strlen(path) - 1] != '\\') +#endif + { + //printf("mkdir(%s)\n", path); +#if _WIN32 + if (mkdir(path)) +#endif +#if linux + if (mkdir(path, 0777)) +#endif + error("cannot create directory %s", path); + } + } + } +} + /****************************** File ********************************/ File::File(FileName *n) diff -uNr dmd-0.160/dmd/src/dmd/root.h dmd-0.161/dmd/src/dmd/root.h --- dmd-0.160/dmd/src/dmd/root.h 2006-04-05 09:36:48.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/root.h 2006-06-17 10:41:06.000000000 +0200 @@ -137,6 +137,7 @@ void CopyTo(FileName *to); static char *searchPath(Array *path, char *name, int cwd); static int exists(const char *name); + static void ensurePathExists(const char *path); }; struct File : Object diff -uNr dmd-0.160/dmd/src/dmd/statement.c dmd-0.161/dmd/src/dmd/statement.c --- dmd-0.160/dmd/src/dmd/statement.c 2006-06-01 18:41:02.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/statement.c 2006-06-16 09:47:54.000000000 +0200 @@ -205,10 +205,15 @@ int ExpStatement::fallOffEnd() { - if (exp && exp->op == TOKassert) - { AssertExp *a = (AssertExp *)exp; + if (exp) + { + if (exp->op == TOKassert) + { AssertExp *a = (AssertExp *)exp; - if (a->e1->isBool(FALSE)) // if it's an assert(0) + if (a->e1->isBool(FALSE)) // if it's an assert(0) + return FALSE; + } + else if (exp->op == TOKhalt) return FALSE; } return TRUE; @@ -346,12 +351,16 @@ } if (sexception) { - if (i + 1 == statements->dim) + if (i + 1 == statements->dim && !sfinally) { +#if 1 + sexception = sexception->semantic(sc); +#else statements->push(sexception); if (sfinally) // Assume sexception does not throw statements->push(sfinally); +#endif } else { @@ -389,14 +398,14 @@ if (sfinally) s = new TryFinallyStatement(0, s, sfinally); s = s->semantic(sc); - statements->data[i + 1] = s; - statements->setDim(i + 2); + statements->setDim(i + 1); + statements->push(s); break; } } else if (sfinally) { - if (i + 1 == statements->dim) + if (0 && i + 1 == statements->dim) { statements->push(sfinally); } @@ -417,8 +426,8 @@ body = new CompoundStatement(0, a); s = new TryFinallyStatement(0, body, sfinally); s = s->semantic(sc); - statements->data[i + 1] = s; - statements->setDim(i + 2); + statements->setDim(i + 1); + statements->push(s); break; } } @@ -2004,16 +2013,18 @@ Statement *ReturnStatement::semantic(Scope *sc) { - //printf("ReturnStatement::semantic()\n"); + //printf("ReturnStatement::semantic() %s\n", toChars()); FuncDeclaration *fd = sc->parent->isFuncDeclaration(); FuncDeclaration *fdx = fd; Type *tret = fd->type->next; if (fd->tintro) tret = fd->tintro->next; - Type *tbret = tret->toBasetype(); + Type *tbret = NULL; - if (!exp && tbret->ty == Tvoid && fd->isMain()) + if (tret) + tbret = tret->toBasetype(); + if (!exp && (!tbret || tbret->ty == Tvoid) && fd->isMain()) exp = new IntegerExp(0); Scope *scx = sc; @@ -2085,7 +2096,7 @@ if (sc->incontract) error("return statements cannot be in contracts"); if (sc->tf) - error("return statements cannot be in finally bodies"); + error("return statements cannot be in finally, scope(exit) or scope(success) bodies"); if (fd->isCtorDeclaration()) { @@ -2098,7 +2109,7 @@ if (exp) { - fd->hasReturnExp = 1; + fd->hasReturnExp |= 1; if (fd->returnLabel && tbret->ty != Tvoid) { @@ -2113,13 +2124,51 @@ { exp = exp->semantic(sc); exp = resolveProperties(sc, exp); - if (tbret->ty != Tvoid) + if (fd->inferRetType) + { + if (fd->type->next) + { + if (!exp->type->equals(fd->type->next)) + error("mismatched function return type inference of %s and %s", + exp->type->toChars(), fd->type->next->toChars()); + } + else + { + fd->type->next = exp->type; + fd->type = fd->type->semantic(loc, sc); + if (!fd->tintro) + { tret = fd->type->next; + tbret = tret->toBasetype(); + } + } + } + else if (tbret->ty != Tvoid) + { exp = exp->implicitCastTo(tret); + } } //exp->dump(0); //exp->print(); exp->checkEscape(); } + else if (fd->inferRetType) + { + if (fd->type->next) + { + if (fd->type->next->ty != Tvoid) + error("mismatched function return type inference of void and %s", + fd->type->next->toChars()); + } + else + { + fd->type->next = Type::tvoid; + fd->type = fd->type->semantic(loc, sc); + if (!fd->tintro) + { tret = Type::tvoid; + tbret = tret; + } + } + } else if (tbret->ty != Tvoid) // if non-void return error("return expression expected"); @@ -2708,6 +2757,7 @@ Statement *TryFinallyStatement::semantic(Scope *sc) { + //printf("TryFinallyStatement::semantic()\n"); body = body->semantic(sc); sc = sc->push(); sc->tf = this; @@ -2852,6 +2902,10 @@ Statement *ThrowStatement::semantic(Scope *sc) { //printf("ThrowStatement::semantic()\n"); + + FuncDeclaration *fd = sc->parent->isFuncDeclaration(); + fd->hasReturnExp |= 2; + if (sc->incontract) error("Throw statements cannot be in contracts"); exp = exp->semantic(sc); diff -uNr dmd-0.160/dmd/src/dmd/struct.c dmd-0.161/dmd/src/dmd/struct.c --- dmd-0.160/dmd/src/dmd/struct.c 2006-06-03 01:50:26.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/struct.c 2006-06-13 02:52:30.000000000 +0200 @@ -186,7 +186,7 @@ //printf("\talignsize = %d\n", alignsize); v->storage_class |= STCfield; - //printf(" addField '%s' to '%s' at offset %d\n", v->toChars(), toChars(), v->offset); + //printf(" addField '%s' to '%s' at offset %d, size = %d\n", v->toChars(), toChars(), v->offset, memsize); fields.push(v); } @@ -273,10 +273,12 @@ s->semantic(sc2); if (isUnionDeclaration()) sc2->offset = 0; +#if 0 if (sizeok == 2) { //printf("forward reference\n"); break; } +#endif } /* The TypeInfo_Struct is expecting an opEquals and opCmp with diff -uNr dmd-0.160/dmd/src/dmd/template.c dmd-0.161/dmd/src/dmd/template.c --- dmd-0.160/dmd/src/dmd/template.c 2006-05-24 13:38:20.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/template.c 2006-06-17 01:24:32.000000000 +0200 @@ -73,6 +73,7 @@ if (parameters) for (int i = 0; i < parameters->dim; i++) { TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; + //printf("\tparameter[%d] = %p\n", i, tp); TemplateTypeParameter *ttp = tp->isTemplateTypeParameter(); if (ttp) @@ -91,6 +92,7 @@ Dsymbol *TemplateDeclaration::syntaxCopy(Dsymbol *) { + //printf("TemplateDeclaration::syntaxCopy()\n"); TemplateDeclaration *td; TemplateParameters *p; Array *d; @@ -641,7 +643,7 @@ { if (!td->scope) { - error("forward reference to template"); + error("forward reference to template %s", td->toChars()); goto Lerror; } if (!td->onemember || !td->onemember->toAlias()->isFuncDeclaration()) @@ -2125,6 +2127,15 @@ { if (!s->parent && global.errors) return NULL; + if (!s->parent && s->getType()) + { Dsymbol *s2 = s->getType()->toDsymbol(sc); + if (!s2) + { + error("%s is not a template declaration, it is a %s", id->toChars(), s->kind()); + return NULL; + } + s = s2; + } assert(s->parent); TemplateInstance *ti = s->parent->isTemplateInstance(); if (ti && @@ -2172,7 +2183,7 @@ dedtypes.setDim(td->parameters->dim); if (!td->scope) { - error("forward reference to template"); + error("forward reference to template declaration %s", td->toChars()); return NULL; } m = td->matchWithInstance(this, &dedtypes, 0); @@ -2233,6 +2244,26 @@ /* The best match is td_best */ tempdecl = td_best; + +#if 0 + /* Cast any value arguments to be same type as value parameter + */ + for (size_t i = 0; i < tiargs->dim; i++) + { Object *o = (Object *)tiargs->data[i]; + Expression *ea = isExpression(o); // value argument + TemplateParameter *tp = (TemplateParameter *)tempdecl->parameters->data[i]; + assert(tp); + TemplateValueParameter *tvp = tp->isTemplateValueParameter(); + if (tvp) + { + assert(ea); + ea = ea->castTo(tvp->valType); + ea = ea->optimize(WANTvalue); + tiargs->data[i] = (Object *)ea; + } + } +#endif + #if LOG printf("\tIt's a match with template declaration '%s'\n", tempdecl->toChars()); #endif @@ -2269,7 +2300,6 @@ else if (ea) { sinteger_t v; real_t r; - int i; unsigned char *p; if (ea->op == TOKvar) @@ -2285,7 +2315,16 @@ goto Lsa; } buf.writeByte('V'); +#if 1 buf.writestring(ea->type->deco); +#else + // Use type of parameter, not type of argument + TemplateParameter *tp = (TemplateParameter *)tempdecl->parameters->data[i]; + assert(tp); + TemplateValueParameter *tvp = tp->isTemplateValueParameter(); + assert(tvp); + buf.writestring(tvp->valType->deco); +#endif ea->toMangleBuffer(&buf); } else if (sa) @@ -2532,6 +2571,7 @@ this->tqual = tqual; this->idents = idents; this->tiargs = tiargs ? tiargs : new Array(); + this->scope = NULL; } Dsymbol *TemplateMixin::syntaxCopy(Dsymbol *s) @@ -2571,10 +2611,15 @@ printf("\tdo semantic\n"); #endif - // Run semantic on each argument, place results in tiargs[] - semanticTiargs(sc); + Scope *scx = NULL; + if (scope) + { sc = scope; + scx = scope; // save so we don't make redundant copies + scope = NULL; + } // Follow qualifications to find the TemplateDeclaration + if (!tempdecl) { Dsymbol *s; int i; Identifier *id; @@ -2651,6 +2696,37 @@ } } + // Look for forward reference + assert(tempdecl); + for (TemplateDeclaration *td = tempdecl; td; td = td->overnext) + { + if (!td->scope) + { + /* Cannot handle forward references if mixin is a struct member, + * because addField must happen during struct's semantic, not + * during the mixin semantic. + * runDeferred will re-run mixin's semantic outside of the struct's + * semantic. + */ + semanticdone = 0; + AggregateDeclaration *ad = toParent()->isAggregateDeclaration(); + if (ad) + ad->sizeok = 2; + else + { + // Forward reference + //printf("forward reference - deferring\n"); + scope = scx ? scx : new Scope(*sc); + scope->setNoFree(); + scope->module->addDeferredSemantic(this); + } + return; + } + } + + // Run semantic on each argument, place results in tiargs[] + semanticTiargs(sc); + tempdecl = findTemplateDeclaration(sc); if (!tempdecl) { inst = this; @@ -2722,13 +2798,13 @@ #if LOG printf("\tcreate scope for template parameters '%s'\n", toChars()); #endif - Scope *scx = sc; - scx = sc->push(this); - scx->parent = this; + Scope *scy = sc; + scy = sc->push(this); + scy->parent = this; argsym = new ScopeDsymbol(); - argsym->parent = scx->parent; - Scope *scope = scx->push(argsym); + argsym->parent = scy->parent; + Scope *scope = scy->push(argsym); // Declare each template parameter as an alias for the argument type declareParameters(scope); @@ -2777,7 +2853,7 @@ // if (!isAnonymous()) { - scx->pop(); + scy->pop(); } #if LOG printf("-TemplateMixin::semantic('%s', this=%p)\n", toChars(), this); diff -uNr dmd-0.160/dmd/src/dmd/template.h dmd-0.161/dmd/src/dmd/template.h --- dmd-0.160/dmd/src/dmd/template.h 2006-03-07 19:02:42.000000000 +0100 +++ dmd-0.161/dmd/src/dmd/template.h 2006-06-13 01:58:12.000000000 +0200 @@ -242,6 +242,8 @@ Array *idents; TypeTypeof *tqual; + Scope *scope; // for forward referencing + TemplateMixin(Loc loc, Identifier *ident, TypeTypeof *tqual, Array *idents, Array *tiargs); Dsymbol *syntaxCopy(Dsymbol *s); void semantic(Scope *sc); diff -uNr dmd-0.160/dmd/src/dmd/toobj.c dmd-0.161/dmd/src/dmd/toobj.c --- dmd-0.160/dmd/src/dmd/toobj.c 2006-05-14 16:19:44.000000000 +0200 +++ dmd-0.161/dmd/src/dmd/toobj.c 2006-06-17 01:08:08.000000000 +0200 @@ -800,14 +800,26 @@ s->Sclass = SCstatic; else #endif - if (parent->isTemplateInstance() || - storage_class & STCcomdat) - // Global template data members need to be in comdat's - // in case multiple .obj files instantiate the same - // template with the same types. - s->Sclass = SCcomdat; - else - s->Sclass = SCglobal; + { + if (storage_class & STCcomdat) + s->Sclass = SCcomdat; + else + s->Sclass = SCglobal; + + do + { + /* Global template data members need to be in comdat's + * in case multiple .obj files instantiate the same + * template with the same types. + */ + if (parent->isTemplateInstance()) + { + s->Sclass = SCcomdat; + break; + } + parent = parent->toParent(); + } while (parent); + } s->Sfl = FLdata; if (init) diff -uNr dmd-0.160/dmd/src/phobos/etc/gamma.d dmd-0.161/dmd/src/phobos/etc/gamma.d --- dmd-0.160/dmd/src/phobos/etc/gamma.d 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.161/dmd/src/phobos/etc/gamma.d 2006-06-19 21:09:18.000000000 +0200 @@ -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 π) xx-0.5 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) =$(INTEGRAL)0&infintz-1e-tdt + * + * This function is equivalent to tgamma() in the C programming language. + * + * + * + *
Special Values
x $(GAMMA)(x) invalid? + *
NAN NAN yes + *
±0.0 ±∞ yes + *
integer > 0 (x-1)! no + *
integer < 0 NAN yes + *
+∞ +∞ no + *
-∞ NAN yes + *
+ * + * 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)). + * + * + * + *
Special Values
x log$(GAMMA)(x) invalid? + *
NaN NaN yes + *
integer <= 0 +∞ yes + *
1, 2 +0.0 no + *
±∞ +∞ no + *
+ * + */ +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 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); +} + + diff -uNr dmd-0.160/dmd/src/phobos/internal/adi.d dmd-0.161/dmd/src/phobos/internal/adi.d --- dmd-0.160/dmd/src/phobos/internal/adi.d 2006-06-04 11:50:08.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/internal/adi.d 2006-06-19 21:09:16.000000000 +0200 @@ -173,13 +173,13 @@ break; if (stridelo == stridehi) - { int tmp; + { int stmp; assert(stridelo == 2); - assert(tmp.sizeof == 2 * (*lo).sizeof); - tmp = *cast(int*)lo; + assert(stmp.sizeof == 2 * (*lo).sizeof); + stmp = *cast(int*)lo; *cast(int*)lo = *cast(int*)hi; - *cast(int*)hi = tmp; + *cast(int*)hi = stmp; lo += stridelo; hi--; continue; @@ -546,7 +546,7 @@ ubyte mask; 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]); return (mask == 0) || (p1[i] & mask) == (p2[i] & mask); } @@ -785,7 +785,7 @@ break; // not equal } for (uint j = i * 8; j < len; j++) - { ubyte mask = 1 << j; + { ubyte mask = cast(ubyte)(1 << j); int c; c = cast(int)(p1[i] & mask) - cast(int)(p2[i] & mask); diff -uNr dmd-0.160/dmd/src/phobos/internal/cast.d dmd-0.161/dmd/src/phobos/internal/cast.d --- dmd-0.160/dmd/src/phobos/internal/cast.d 2006-06-04 11:50:08.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/internal/cast.d 2006-06-19 21:09:16.000000000 +0200 @@ -148,5 +148,4 @@ } } assert(0); - return null; } diff -uNr dmd-0.160/dmd/src/phobos/internal/qsort.d dmd-0.161/dmd/src/phobos/internal/qsort.d --- dmd-0.160/dmd/src/phobos/internal/qsort.d 2006-06-04 11:50:08.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/internal/qsort.d 2006-06-19 21:09:16.000000000 +0200 @@ -129,6 +129,7 @@ else // else stack empty, all done return *cast(long*)(&a); } + assert(0); } diff -uNr dmd-0.160/dmd/src/phobos/internal/trace.d dmd-0.161/dmd/src/phobos/internal/trace.d --- dmd-0.160/dmd/src/phobos/internal/trace.d 2006-06-04 11:50:08.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/internal/trace.d 2006-06-19 21:09:16.000000000 +0200 @@ -749,9 +749,9 @@ p++; count = strtoul(p,&p,10); - t = strtoull(p,&p,10); + t = cast(long)strtoull(p,&p,10); s.totaltime += t; - t = strtoull(p,&p,10); + t = cast(long)strtoull(p,&p,10); s.functime += t; } break; diff -uNr dmd-0.160/dmd/src/phobos/linux.mak dmd-0.161/dmd/src/phobos/linux.mak --- dmd-0.160/dmd/src/phobos/linux.mak 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/linux.mak 2006-06-19 21:09:16.000000000 +0200 @@ -12,8 +12,8 @@ CFLAGS=-O #CFLAGS=-g -DFLAGS=-O -release -#DFLAGS=-unittest +DFLAGS=-O -release -w +#DFLAGS=-unittest -w CC=gcc #DMD=/dmd/bin/dmd @@ -140,7 +140,7 @@ SRC_STD_C_LINUX= std/c/linux/linux.d std/c/linux/linuxextern.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 diff -uNr dmd-0.160/dmd/src/phobos/std/asserterror.d dmd-0.161/dmd/src/phobos/std/asserterror.d --- dmd-0.160/dmd/src/phobos/std/asserterror.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/asserterror.d 2006-06-19 21:09:16.000000000 +0200 @@ -6,8 +6,6 @@ class AssertError : Error { - private: - uint linnum; char[] filename; diff -uNr dmd-0.160/dmd/src/phobos/std/base64.d dmd-0.161/dmd/src/phobos/std/base64.d --- dmd-0.160/dmd/src/phobos/std/base64.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/base64.d 2006-06-19 21:09:16.000000000 +0200 @@ -133,6 +133,9 @@ case 0: break; + + default: + assert(0); } return buf[0 .. (bp - &buf[0])]; @@ -211,6 +214,7 @@ if(ch == '/') return 'Z' - 'A' + 1 + 'z' - 'a' + 1 + '9' - '0' + 1 + 1; badc(ch); + assert(0); } diff -uNr dmd-0.160/dmd/src/phobos/std/bitarray.d dmd-0.161/dmd/src/phobos/std/bitarray.d --- dmd-0.160/dmd/src/phobos/std/bitarray.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/bitarray.d 2006-06-19 21:09:16.000000000 +0200 @@ -157,6 +157,7 @@ { case 0: assert(b == true); break; case 1: assert(b == false); break; case 2: assert(b == true); break; + default: assert(0); } i++; } @@ -167,6 +168,7 @@ { case 0: assert(b == true); break; case 1: assert(b == false); break; case 2: assert(b == true); break; + default: assert(0); } } } @@ -301,7 +303,7 @@ ubyte mask; 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]); return (mask == 0) || (p1[i] & mask) == (p2[i] & mask); } @@ -349,7 +351,7 @@ break; // not equal } for (uint j = i * 8; j < len; j++) - { ubyte mask = 1 << j; + { ubyte mask = cast(ubyte)(1 << j); int c; c = cast(int)(p1[i] & mask) - cast(int)(p2[i] & mask); diff -uNr dmd-0.160/dmd/src/phobos/std/boxer.d dmd-0.161/dmd/src/phobos/std/boxer.d --- dmd-0.160/dmd/src/phobos/std/boxer.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/boxer.d 2006-06-19 21:09:16.000000000 +0200 @@ -189,6 +189,7 @@ default: return TypeClass.Other; } } + assert(0); } /** Return whether this value could be unboxed as the given type without throwing. */ diff -uNr dmd-0.160/dmd/src/phobos/std/c/linux/socket.d dmd-0.161/dmd/src/phobos/std/c/linux/socket.d --- dmd-0.160/dmd/src/phobos/std/c/linux/socket.d 2006-06-04 11:50:08.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/c/linux/socket.d 2006-06-19 21:09:18.000000000 +0200 @@ -173,7 +173,7 @@ uint16_t htons(uint16_t x) { - return (x >> 8) | (x << 8); + return cast(uint16_t)((x >> 8) | (x << 8)); } diff -uNr dmd-0.160/dmd/src/phobos/std/c/windows/windows.d dmd-0.161/dmd/src/phobos/std/c/windows/windows.d --- dmd-0.160/dmd/src/phobos/std/c/windows/windows.d 2006-06-04 11:50:08.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/c/windows/windows.d 2006-06-19 21:09:16.000000000 +0200 @@ -968,8 +968,8 @@ // int MAKELANGID(int p, int s) { return ((cast(WORD)s) << 10) | cast(WORD)p; } -WORD PRIMARYLANGID(int lgid) { return cast(WORD)lgid & 0x3ff; } -WORD SUBLANGID(int lgid) { return cast(WORD)lgid >> 10; } +WORD PRIMARYLANGID(int lgid) { return cast(WORD)(lgid & 0x3ff); } +WORD SUBLANGID(int lgid) { return cast(WORD)(lgid >> 10); } struct FLOATING_SAVE_AREA { diff -uNr dmd-0.160/dmd/src/phobos/std/c/windows/winsock.d dmd-0.161/dmd/src/phobos/std/c/windows/winsock.d --- dmd-0.160/dmd/src/phobos/std/c/windows/winsock.d 2006-06-04 11:50:08.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/c/windows/winsock.d 2006-06-19 21:09:16.000000000 +0200 @@ -321,7 +321,7 @@ uint16_t htons(uint16_t x) { - return (x >> 8) | (x << 8); + return cast(uint16_t)((x >> 8) | (x << 8)); } diff -uNr dmd-0.160/dmd/src/phobos/std/conv.d dmd-0.161/dmd/src/phobos/std/conv.d --- dmd-0.160/dmd/src/phobos/std/conv.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/conv.d 2006-06-19 21:09:16.000000000 +0200 @@ -329,7 +329,7 @@ char c = s[i]; if (c >= '0' && c <= '9') { - ulong v1 = v; + ulong v1 = cast(ulong)v; v = v * 10 + (c - '0'); if (cast(ulong)v < v1) goto Loverflow; @@ -893,6 +893,7 @@ Lerr: conv_error(s ~ " not representable as a float"); + assert(0); } unittest @@ -956,6 +957,7 @@ Lerr: conv_error(s ~ " not representable as a double"); + assert(0); } unittest @@ -1021,6 +1023,7 @@ Lerr: conv_error(s ~ " not representable as a real"); + assert(0); } unittest diff -uNr dmd-0.160/dmd/src/phobos/std/cstream.d dmd-0.161/dmd/src/phobos/std/cstream.d --- dmd-0.160/dmd/src/phobos/std/cstream.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/cstream.d 2006-06-19 21:09:16.000000000 +0200 @@ -193,7 +193,7 @@ file.position = 0; lines = new char[][5]; 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[1] == "Another line"); diff -uNr dmd-0.160/dmd/src/phobos/std/date.d dmd-0.161/dmd/src/phobos/std/date.d --- dmd-0.160/dmd/src/phobos/std/date.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/date.d 2006-06-19 21:09:16.000000000 +0200 @@ -198,7 +198,7 @@ int Day(d_time t) { - return floor(t, msPerDay); + return cast(int)floor(t, msPerDay); } int LeapYear(int y) @@ -810,6 +810,9 @@ case TIME_ZONE_ID_UNKNOWN: // Daylight savings time not used in this time zone break; + + default: + assert(0); } return t; } @@ -869,7 +872,7 @@ dt -= LocalTZA; 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)); d_time start = TimeFromYear(year); // Jan 1 diff -uNr dmd-0.160/dmd/src/phobos/std/dateparse.d dmd-0.161/dmd/src/phobos/std/dateparse.d --- dmd-0.160/dmd/src/phobos/std/dateparse.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/dateparse.d 2006-06-19 21:09:16.000000000 +0200 @@ -528,6 +528,7 @@ } dp = nextToken(); } + assert(0); } int parseCalendarDate(int n1) diff -uNr dmd-0.160/dmd/src/phobos/std/demangle.d dmd-0.161/dmd/src/phobos/std/demangle.d --- dmd-0.160/dmd/src/phobos/std/demangle.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/demangle.d 2006-06-19 21:09:16.000000000 +0200 @@ -87,9 +87,11 @@ { if (!isxdigit(c)) error(); - return (c >= 'a') ? c - 'a' + 10 : - (c >= 'A') ? c - 'A' + 10 : - c - '0'; + return cast(ubyte) + ( (c >= 'a') ? c - 'a' + 10 : + (c >= 'A') ? c - 'A' + 10 : + c - '0' + ); } size_t parseNumber() @@ -265,6 +267,7 @@ case 'U': p = "extern (C) "; break; // C function case 'W': p = "extern (Windows) "; break; // Windows function case 'V': p = "extern (Pascal) "; break; // Pascal function + default: assert(0); } p ~= parseType() ~ " " ~ identifier ~ "(" ~ args ~ ")"; return p; @@ -298,6 +301,7 @@ p = name[i .. length]; goto L1; } + assert(0); } char[] parseTemplateInstanceName() @@ -330,8 +334,11 @@ for (i = 0; i < 10; i++) { ubyte b; - b = (ascii2hex(name[ni + i * 2]) << 4) + - ascii2hex(name[ni + i * 2 + 1]); + b = cast(ubyte) + ( + (ascii2hex(name[ni + i * 2]) << 4) + + ascii2hex(name[ni + i * 2 + 1]) + ); p[i] = b; } result ~= format(r); diff -uNr dmd-0.160/dmd/src/phobos/std/file.d dmd-0.161/dmd/src/phobos/std/file.d --- dmd-0.160/dmd/src/phobos/std/file.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/file.d 2006-06-19 21:09:16.000000000 +0200 @@ -531,9 +531,9 @@ * * 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); * } * ---- @@ -572,9 +572,9 @@ * * 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); * } * ---- @@ -587,9 +587,9 @@ * * 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); * } * ---- @@ -650,7 +650,7 @@ * * void main(char[][] args) * { - * char[] pathname = args[1]; + * auto pathname = args[1]; * char[][] result; * * bool listing(char[] filename) @@ -661,7 +661,7 @@ * * listdir(pathname, &listing); * - * foreach (char[] name; result) + * foreach (name; result) * writefln("%s", name); * } * ---- @@ -1222,9 +1222,10 @@ return; } _size = statbuf.st_size; - _creationTime = statbuf.st_ctime * std.date.TicksPerSecond; - _lastAccessTime = statbuf.st_atime * std.date.TicksPerSecond; - _lastWriteTime = statbuf.st_mtime * std.date.TicksPerSecond; + _creationTime = cast(d_time)statbuf.st_ctime * std.date.TicksPerSecond; + _lastAccessTime = cast(d_time)statbuf.st_atime * std.date.TicksPerSecond; + _lastWriteTime = cast(d_time)statbuf.st_mtime * std.date.TicksPerSecond; + didstat = 1; } } @@ -1328,6 +1329,7 @@ } } + /*************************************************** * Copy a file. * Bugs: @@ -1348,3 +1350,17 @@ } +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; + } + ); +} + + diff -uNr dmd-0.160/dmd/src/phobos/std/format.d dmd-0.161/dmd/src/phobos/std/format.d --- dmd-0.160/dmd/src/phobos/std/format.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/format.d 2006-06-19 21:09:16.000000000 +0200 @@ -686,7 +686,7 @@ case Mangle.Tlong: signed = 1; - vnumber = va_arg!(long)(argptr); + vnumber = cast(ulong)va_arg!(long)(argptr); goto Lnumber; case Mangle.Tulong: @@ -873,6 +873,10 @@ } if (precision == 0 || !(flags & FLprecision)) { vchar = '0' + vnumber; + if (vnumber < 10) + vchar = '0' + vnumber; + else + vchar = (uc ? 'A' - 10 : 'a' - 10) + vnumber; goto L2; } } @@ -1343,5 +1347,14 @@ assert(r == "80000000"); r = std.string.format("%x", ++i); 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"); } diff -uNr dmd-0.160/dmd/src/phobos/std/math2.d dmd-0.161/dmd/src/phobos/std/math2.d --- dmd-0.160/dmd/src/phobos/std/math2.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/math2.d 2006-06-19 21:09:16.000000000 +0200 @@ -259,9 +259,9 @@ int sum(int[] n) { long result = 0; - for (uint i = 0; i < n.length; i++) - result += n[i]; - return result; + for (size_t i = 0; i < n.length; i++) + result += n[i]; + return cast(int)result; } unittest diff -uNr dmd-0.160/dmd/src/phobos/std/math.d dmd-0.161/dmd/src/phobos/std/math.d --- dmd-0.160/dmd/src/phobos/std/math.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/math.d 2006-06-19 21:09:16.000000000 +0200 @@ -539,7 +539,7 @@ if (z == 0) { - c = 0; + c = 0 + 0i; } else { real z_re = z.re; @@ -659,7 +659,7 @@ else { exp = ex - 0x3FFE; - vu[4] = (0x8000 & vu[4]) | 0x3FFE; + vu[4] = cast(ushort)((0x8000 & vu[4]) | 0x3FFE); } } else if (!*vl) @@ -677,7 +677,7 @@ *vl <<= 1; } while (*vl > 0); exp = i; - vu[4] = (0x8000 & vu[4]) | 0x3FFE; + vu[4] = cast(ushort)((0x8000 & vu[4]) | 0x3FFE); } return value; } diff -uNr dmd-0.160/dmd/src/phobos/std/mmfile.d dmd-0.161/dmd/src/phobos/std/mmfile.d --- dmd-0.160/dmd/src/phobos/std/mmfile.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/mmfile.d 2006-06-19 21:09:16.000000000 +0200 @@ -103,49 +103,52 @@ if (dwVersion & 0x80000000 && (dwVersion & 0xFF) == 3) { - throw new FileException(filename, - "Win32s does not implement mm files"); + throw new FileException(filename, + "Win32s does not implement mm files"); } switch (mode) { - case Mode.Read: - dwDesiredAccess2 = GENERIC_READ; - dwShareMode = FILE_SHARE_READ; - dwCreationDisposition = OPEN_EXISTING; - flProtect = PAGE_READONLY; - dwDesiredAccess = FILE_MAP_READ; - break; - - case Mode.ReadWriteNew: - assert(size != 0); - dwDesiredAccess2 = GENERIC_READ | GENERIC_WRITE; - dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; - dwCreationDisposition = CREATE_ALWAYS; - flProtect = PAGE_READWRITE; - dwDesiredAccess = FILE_MAP_WRITE; - break; - - case Mode.ReadWrite: - dwDesiredAccess2 = GENERIC_READ | GENERIC_WRITE; - dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; - dwCreationDisposition = OPEN_ALWAYS; - flProtect = PAGE_READWRITE; - dwDesiredAccess = FILE_MAP_WRITE; - break; - - case Mode.ReadCopyOnWrite: - if (dwVersion & 0x80000000) - { - throw new FileException(filename, - "Win9x does not implement copy on write"); - } - dwDesiredAccess2 = GENERIC_READ | GENERIC_WRITE; - dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; - dwCreationDisposition = OPEN_EXISTING; - flProtect = PAGE_WRITECOPY; - dwDesiredAccess = FILE_MAP_COPY; - break; + case Mode.Read: + dwDesiredAccess2 = GENERIC_READ; + dwShareMode = FILE_SHARE_READ; + dwCreationDisposition = OPEN_EXISTING; + flProtect = PAGE_READONLY; + dwDesiredAccess = FILE_MAP_READ; + break; + + case Mode.ReadWriteNew: + assert(size != 0); + dwDesiredAccess2 = GENERIC_READ | GENERIC_WRITE; + dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; + dwCreationDisposition = CREATE_ALWAYS; + flProtect = PAGE_READWRITE; + dwDesiredAccess = FILE_MAP_WRITE; + break; + + case Mode.ReadWrite: + dwDesiredAccess2 = GENERIC_READ | GENERIC_WRITE; + dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; + dwCreationDisposition = OPEN_ALWAYS; + flProtect = PAGE_READWRITE; + dwDesiredAccess = FILE_MAP_WRITE; + break; + + case Mode.ReadCopyOnWrite: + if (dwVersion & 0x80000000) + { + throw new FileException(filename, + "Win9x does not implement copy on write"); + } + dwDesiredAccess2 = GENERIC_READ | GENERIC_WRITE; + dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; + dwCreationDisposition = OPEN_EXISTING; + flProtect = PAGE_WRITECOPY; + dwDesiredAccess = FILE_MAP_COPY; + break; + + default: + assert(0); } if (useWfuncs) @@ -242,6 +245,9 @@ oflag = O_RDWR; fmode = 0; break; + + default: + assert(0); } if (filename.length) @@ -265,7 +271,7 @@ if (prot & PROT_WRITE && size > statbuf.st_size) { // 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; std.c.linux.linux.write(fd, &c, 1); } @@ -447,7 +453,7 @@ p = MapViewOfFileEx(hFileMap, dwDesiredAccess, hi, cast(uint)start, len, address); if (!p) errNo(); } else { - p = mmap(address, len, prot, flags, fd, start); + p = mmap(address, len, prot, flags, fd, cast(int)start); if (p == MAP_FAILED) errNo(); } data = p[0 .. len]; diff -uNr dmd-0.160/dmd/src/phobos/std/random.d dmd-0.161/dmd/src/phobos/std/random.d --- dmd-0.160/dmd/src/phobos/std/random.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/random.d 2006-06-19 21:09:16.000000000 +0200 @@ -108,7 +108,7 @@ } 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)); diff -uNr dmd-0.160/dmd/src/phobos/std/regexp.d dmd-0.161/dmd/src/phobos/std/regexp.d --- dmd-0.160/dmd/src/phobos/std/regexp.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/regexp.d 2006-06-19 21:09:16.000000000 +0200 @@ -39,24 +39,61 @@ of the following characters: - + $(TR $(TH Attribute) $(TH Action)) - - -
Attribute - Action +
Attribute Characters
$(B g) - global; repeat over the whole input string + $(TD $(B g)) + $(TD global; repeat over the whole input string)
$(B i) - case insensitive + $(TD $(B i)) + $(TD case insensitive)
$(B m) - treat as multiple lines separated by newlines + $(TD $(B m)) + $(TD treat as multiple lines separated by newlines)
+ * + * The $(I format)[] string has the formatting characters: + * + * + + $(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.) + ) +
Formatting Characters
+ * Any other $ are left as is. + * + * References: + * $(LINK2 http://en.wikipedia.org/wiki/Regular_expressions, Wikipedia) * Macros: * WIKI = StdRegexp + * DOLLAR = $ */ /* @@ -98,6 +135,7 @@ import std.c.stdio; import std.c.stdlib; import std.c.string; + import std.stdio; import std.string; import std.ctype; import std.outbuffer; @@ -140,7 +178,20 @@ * pattern = Regular expression pattern. * format = Replacement string format. * 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) @@ -170,6 +221,17 @@ * dg = Delegate * attributes = Regular expression attributes. * 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) @@ -194,11 +256,10 @@ if (r.attributes & RegExp.REA.global && // global, so replace all !(r.attributes & RegExp.REA.ignoreCase) && // not ignoring case !(r.attributes & RegExp.REA.multiline) && // not multiline - pattern == slice && // simple pattern (exact match, no special characters) - format == replacement) // simple format, not $ formats + pattern == slice) // simple pattern (exact match, no special characters) { 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); break; } @@ -230,6 +291,18 @@ char[] r = sub("hello", "ll", delegate char[](RegExp r) { return "ss"; }); 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 @@ * attributes = Regular expression attributes. * Returns: * 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) @@ -277,6 +356,12 @@ * attributes = Regular expression attributes. * Returns: * 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) @@ -318,11 +403,23 @@ /******************************************** * Split string[] into an array of strings, using the regular * expression pattern[] with attributes[] as the separator. + * Params: * string = String to search. * pattern = Regular expression pattern. * attributes = Regular expression attributes. * Returns: * 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) @@ -342,6 +439,15 @@ assert(result.length == 2); assert(result[0] == ""); 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 @@ * * 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); * } @@ -383,6 +489,27 @@ 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 ******************************** */ /***************************** @@ -401,6 +528,12 @@ * pattern = regular expression * attributes = _attributes * 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) { @@ -414,12 +547,36 @@ * pattern = regular expression * attributes = _attributes * 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) { 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. * Returns: @@ -467,6 +624,23 @@ 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. * @@ -908,6 +1082,11 @@ result = r.replace("1ab2ac3", "x$&y"); i = std.string.cmp(result, "1xaby2xacy3"); 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 @@ break; } } + assert(0); } int parsePiece() @@ -1947,6 +2127,7 @@ Lerr: error("badly formed {n,m}"); + assert(0); } int parseAtom() @@ -2165,11 +2346,11 @@ maxc = u; b = u / 8; 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); - base = &buf.data[u]; + base = &buf.data[u2]; maxb = b + 1; //bits = (cast(bit*)this.base)[0 .. maxc + 1]; bits.ptr = cast(uint*)this.base; @@ -2245,6 +2426,8 @@ break; case RS.start: break; + default: + assert(0); } p++; break; @@ -2348,6 +2531,9 @@ r.bits[c] = 1; rs = RS.start; break; + + default: + assert(0); } continue; } @@ -2752,6 +2938,9 @@ case REbackref: return 0; + + default: + assert(0); } } return 1; @@ -2763,34 +2952,6 @@ * After a match is found with test(), this function * will take the match results and, using the format * string, generate and return a new string. - * The format string has the formatting characters: - * - $(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.) - ) -
- Any other $ are left as is. */ public rchar[] replace(rchar[] format) @@ -2936,11 +3097,11 @@ { c = format[++i]; if (c >= '1' && c <= '9') - { uint i; + { uint j; - i = c - '0'; - if (i <= re_nsub && pmatch[i].rm_so != pmatch[i].rm_eo) - result ~= input[pmatch[i].rm_so .. pmatch[i].rm_eo]; + j = c - '0'; + if (j <= re_nsub && pmatch[j].rm_so != pmatch[j].rm_eo) + result ~= input[pmatch[j].rm_so .. pmatch[j].rm_eo]; break; } } diff -uNr dmd-0.160/dmd/src/phobos/std/socket.d dmd-0.161/dmd/src/phobos/std/socket.d --- dmd-0.160/dmd/src/phobos/std/socket.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/socket.d 2006-06-19 21:09:16.000000000 +0200 @@ -269,7 +269,7 @@ void populate(servent* serv) { 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; int i; diff -uNr dmd-0.160/dmd/src/phobos/std/socketstream.d dmd-0.161/dmd/src/phobos/std/socketstream.d --- dmd-0.160/dmd/src/phobos/std/socketstream.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/socketstream.d 2006-06-19 21:09:16.000000000 +0200 @@ -123,7 +123,6 @@ override ulong seek(long offset, SeekPos whence) { throw new SeekException("Cannot seek a socket."); - return 0; } /** diff -uNr dmd-0.160/dmd/src/phobos/std/stream.d dmd-0.161/dmd/src/phobos/std/stream.d --- dmd-0.160/dmd/src/phobos/std/stream.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/stream.d 2006-06-19 21:09:16.000000000 +0200 @@ -771,65 +771,69 @@ ifmt = 'd'; } long n = 0; - switch (ifmt) { - case 'd': // decimal - case 'u': { - while (isdigit(c) && width) { - n = n * 10 + (c - '0'); - width--; - c = getc(); - count++; - } - } break; - - case 'o': { // octal - while (isoctdigit(c) && width) { - n = n * 010 + (c - '0'); - width--; - c = getc(); - count++; - } - } break; + switch (ifmt) + { + case 'd': // decimal + case 'u': { + while (isdigit(c) && width) { + n = n * 10 + (c - '0'); + width--; + c = getc(); + count++; + } + } break; + + case 'o': { // octal + while (isoctdigit(c) && width) { + n = n * 010 + (c - '0'); + width--; + c = getc(); + count++; + } + } break; + + case 'x': { // hexadecimal + while (ishexdigit(c) && width) { + n *= 0x10; + if (isdigit(c)) + n += c - '0'; + else + n += 0xA + (c | 0x20) - 'a'; + width--; + c = getc(); + count++; + } + } break; - case 'x': { // hexadecimal - while (ishexdigit(c) && width) { - n *= 0x10; - if (isdigit(c)) - n += c - '0'; - else - n += 0xA + (c | 0x20) - 'a'; - width--; - c = getc(); - count++; - } - } break; + default: + assert(0); } if (neg) n = -n; if (arguments[j] is typeid(int*)) { int* p = va_arg!(int*)(args); - *p = n; + *p = cast(int)n; } else if (arguments[j] is typeid(short*)) { short* p = va_arg!(short*)(args); - *p = n; + *p = cast(short)n; } else if (arguments[j] is typeid(byte*)) { byte* p = va_arg!(byte*)(args); - *p = n; + *p = cast(byte)n; } else if (arguments[j] is typeid(long*)) { long* p = va_arg!(long*)(args); *p = n; } else if (arguments[j] is typeid(uint*)) { uint* p = va_arg!(uint*)(args); - *p = n; + *p = cast(uint)n; } else if (arguments[j] is typeid(ushort*)) { ushort* p = va_arg!(ushort*)(args); - *p = n; + *p = cast(ushort)n; } else if (arguments[j] is typeid(ubyte*)) { ubyte* p = va_arg!(ubyte*)(args); - *p = n; + *p = cast(ubyte)n; } else if (arguments[j] is typeid(ulong*)) { ulong* p = va_arg!(ulong*)(args); - *p = n; + *p = cast(ulong)n; } j++; i++; @@ -951,14 +955,14 @@ *p = s; } else if (arguments[j] is typeid(char*)) { s ~= 0; - char* p = va_arg!(char*)(args); - p[0 .. s.length] = s[]; + char* q = va_arg!(char*)(args); + q[0 .. s.length] = s[]; } else if (arguments[j] is typeid(wchar[]*)) { - wchar[]* p = va_arg!(wchar[]*)(args); - *p = toUTF16(s); + wchar[]* q = va_arg!(wchar[]*)(args); + *q = toUTF16(s); } else if (arguments[j] is typeid(dchar[]*)) { - dchar[]* p = va_arg!(dchar[]*)(args); - *p = toUTF32(s); + dchar[]* q = va_arg!(dchar[]*)(args); + *q = toUTF32(s); } j++; i++; @@ -1203,7 +1207,7 @@ void copyFrom(Stream s, ulong count) { ubyte[128] buf; while (count > 0) { - size_t n = count 0) { rdlen = readBlock(&result[pos], blockSize); @@ -1960,12 +1964,12 @@ assertSeekable(); version (Win32) { 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)) throw new SeekException("unable to move file pointer"); ulong result = (cast(ulong)hi << 32) + low; } else version (linux) { - ulong result = lseek(hFile, offset, rel); + ulong result = lseek(hFile, cast(int)offset, rel); if (result == 0xFFFFFFFF) throw new SeekException("unable to move file pointer"); } @@ -2055,7 +2059,7 @@ file.position = 0; lines = new char[][4]; 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[1] == "Another line"); @@ -2125,7 +2129,7 @@ assert(file.position() == 18 + 13 + 4); // we must be at the end of file assert(file.eof()); - long oldsize = file.size(); + long oldsize = cast(long)file.size(); file.close(); // no operations are allowed when file is closed assert(!file.readable && !file.writeable && !file.seekable); @@ -2508,8 +2512,8 @@ assertReadable(); ubyte* cbuf = cast(ubyte*) buffer; if (len - cur < size) - size = len - cur; - ubyte[] ubuf = cast(ubyte[])buf[cur .. cur + size]; + size = cast(size_t)(len - cur); + ubyte[] ubuf = cast(ubyte[])buf[cast(size_t)cur .. cast(size_t)(cur + size)]; cbuf[0 .. size] = ubuf[]; cur += size; return size; @@ -2520,8 +2524,8 @@ ubyte* cbuf = cast(ubyte*) buffer; ulong blen = buf.length; if (cur + size > blen) - size = blen - cur; - ubyte[] ubuf = cast(ubyte[])buf[cur .. cur + size]; + size = cast(size_t)(blen - cur); + ubyte[] ubuf = cast(ubyte[])buf[cast(size_t)cur .. cast(size_t)(cur + size)]; ubuf[] = cbuf[0 .. size]; cur += size; if (cur > len) @@ -2535,8 +2539,10 @@ switch (rel) { case SeekPos.Set: scur = offset; break; - case SeekPos.Current: scur = cur + offset; break; - case SeekPos.End: scur = len + offset; break; + case SeekPos.Current: scur = cast(long)(cur + offset); break; + case SeekPos.End: scur = cast(long)(len + offset); break; + default: + assert(0); } if (scur < 0) @@ -2544,18 +2550,18 @@ else if (scur > len) cur = len; else - cur = scur; + cur = cast(ulong)scur; 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. ubyte[] data() { if (len > size_t.max) throw new StreamException("Stream too big"); - void[] res = buf[0 .. len]; + void[] res = buf[0 .. cast(size_t)len]; return cast(ubyte[])res; } @@ -2608,7 +2614,7 @@ /// Ensure the stream can hold count bytes. void reserve(size_t count) { 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) { @@ -2787,7 +2793,7 @@ override size_t readBlock (void *buffer, size_t size) { assertReadable(); if (bounded && size > high - low - pos) - size = high - low - pos; + size = cast(size_t)(high - low - pos); ulong bp = s.position; if (seekable) s.position = low + pos; @@ -2802,7 +2808,7 @@ override size_t writeBlock (void *buffer, size_t size) { assertWriteable(); if (bounded && size > high - low - pos) - size = high - low - pos; + size = cast(size_t)(high - low - pos); ulong bp = s.position; if (seekable) s.position = low + pos; @@ -2823,14 +2829,16 @@ spos = offset; break; case SeekPos.Current: - spos = pos + offset; + spos = cast(long)(pos + offset); break; case SeekPos.End: if (bounded) - spos = high - low + offset; + spos = cast(long)(high - low + offset); else - spos = s.size - low + offset; + spos = cast(long)(s.size - low + offset); break; + default: + assert(0); } if (spos < 0) @@ -2840,7 +2848,7 @@ else if (!bounded && spos > s.size - low) pos = s.size - low; else - pos = spos; + pos = cast(ulong)spos; readEOF = false; return pos; @@ -2851,9 +2859,9 @@ ulong bp = s.position; if (bp <= pos+low && pos+low <= bp+res) { if (!bounded || bp+res <= high) - return bp + res - pos - low; + return cast(size_t)(bp + res - pos - low); else if (high <= bp+res) - return high - pos - low; + return cast(size_t)(high - pos - low); } return 0; } diff -uNr dmd-0.160/dmd/src/phobos/std/string.d dmd-0.161/dmd/src/phobos/std/string.d --- dmd-0.160/dmd/src/phobos/std/string.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/string.d 2006-06-19 21:09:16.000000000 +0200 @@ -2394,7 +2394,7 @@ if (cast(int)i == i) return toString(cast(int)i); - ulong u = -i; + ulong u = cast(ulong)(-i); int ndigits = 1; while (u) { @@ -2536,12 +2536,12 @@ uint i = buffer.length; if (value < radix && value < hexdigits.length) - return hexdigits[value .. value + 1]; + return hexdigits[cast(size_t)value .. cast(size_t)value + 1]; do { ubyte c; - c = value % radix; + c = cast(ubyte)(value % radix); value = value / radix; i--; buffer[i] = (c < 10) ? c + '0' : c + 'A' - 10; @@ -3069,6 +3069,7 @@ case 'c': mod_c = 1; break; // complement case 'd': mod_d = 1; break; // delete unreplaced chars case 's': mod_s = 1; break; // squeeze duplicated replaced chars + default: assert(0); } } diff -uNr dmd-0.160/dmd/src/phobos/std/thread.d dmd-0.161/dmd/src/phobos/std/thread.d --- dmd-0.160/dmd/src/phobos/std/thread.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/thread.d 2006-06-19 21:09:16.000000000 +0200 @@ -159,6 +159,7 @@ return fp(arg); else if (dg) return dg(); + assert(0); } /***************************** @@ -247,6 +248,8 @@ case PRIORITY.CRITICAL: nPriority = THREAD_PRIORITY_TIME_CRITICAL; break; + default: + assert(0); } if (SetThreadPriority(hdl, nPriority) == THREAD_PRIORITY_ERROR_RETURN) @@ -654,6 +657,7 @@ return fp(arg); else if (dg) return dg(); + assert(0); } void wait() diff -uNr dmd-0.160/dmd/src/phobos/std/typeinfo/ti_Along.d dmd-0.161/dmd/src/phobos/std/typeinfo/ti_Along.d --- dmd-0.160/dmd/src/phobos/std/typeinfo/ti_Along.d 2006-06-04 11:50:08.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/typeinfo/ti_Along.d 2006-06-19 21:09:16.000000000 +0200 @@ -45,9 +45,10 @@ len = s2.length; for (size_t u = 0; u < len; u++) { - int result = s1[u] - s2[u]; - if (result) - return result; + if (s1[u] < s2[u]) + return -1; + else if (s1[u] > s2[u]) + return 1; } return cast(int)s1.length - cast(int)s2.length; } diff -uNr dmd-0.160/dmd/src/phobos/std/typeinfo/ti_Aulong.d dmd-0.161/dmd/src/phobos/std/typeinfo/ti_Aulong.d --- dmd-0.160/dmd/src/phobos/std/typeinfo/ti_Aulong.d 2006-06-04 11:50:08.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/typeinfo/ti_Aulong.d 2006-06-19 21:09:16.000000000 +0200 @@ -45,9 +45,10 @@ len = s2.length; for (size_t u = 0; u < len; u++) { - int result = s1[u] - s2[u]; - if (result) - return result; + if (s1[u] < s2[u]) + return -1; + else if (s1[u] > s2[u]) + return 1; } return cast(int)s1.length - cast(int)s2.length; } diff -uNr dmd-0.160/dmd/src/phobos/std/typeinfo/ti_void.d dmd-0.161/dmd/src/phobos/std/typeinfo/ti_void.d --- dmd-0.160/dmd/src/phobos/std/typeinfo/ti_void.d 2006-06-04 11:50:08.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/typeinfo/ti_void.d 2006-06-19 21:09:16.000000000 +0200 @@ -10,7 +10,6 @@ hash_t getHash(void *p) { assert(0); - return *cast(byte *)p; } int equals(void *p1, void *p2) diff -uNr dmd-0.160/dmd/src/phobos/std/uni.d dmd-0.161/dmd/src/phobos/std/uni.d --- dmd-0.160/dmd/src/phobos/std/uni.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/uni.d 2006-06-19 21:09:16.000000000 +0200 @@ -464,7 +464,7 @@ low = 0; high = table.length - 1; - while (low <= high) + while (cast(int)low <= cast(int)high) { mid = (low + high) >> 1; if (u < table[mid][0]) @@ -498,4 +498,15 @@ 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)); + } +} diff -uNr dmd-0.160/dmd/src/phobos/std/uri.d dmd-0.161/dmd/src/phobos/std/uri.d --- dmd-0.160/dmd/src/phobos/std/uri.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/uri.d 2006-06-19 21:09:16.000000000 +0200 @@ -223,7 +223,6 @@ LthrowURIerror: throw new URIerror(); - return null; } uint ascii2hex(dchar c) @@ -344,7 +343,6 @@ LthrowURIerror: throw new URIerror(); - return null; } /************************************* diff -uNr dmd-0.160/dmd/src/phobos/std/utf.d dmd-0.161/dmd/src/phobos/std/utf.d --- dmd-0.160/dmd/src/phobos/std/utf.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/utf.d 2006-06-19 21:09:16.000000000 +0200 @@ -667,10 +667,7 @@ buf[3] = cast(char)(0x80 | (c & 0x3F)); return buf[0 .. 4]; } - else - { - assert(0); - } + assert(0); } /******************* diff -uNr dmd-0.160/dmd/src/phobos/std/windows/registry.d dmd-0.161/dmd/src/phobos/std/windows/registry.d --- dmd-0.160/dmd/src/phobos/std/windows/registry.d 2006-06-04 11:50:08.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/windows/registry.d 2006-06-19 21:09:16.000000000 +0200 @@ -384,13 +384,14 @@ { case Endian.Big: return REG_VALUE_TYPE.REG_DWORD_BIG_ENDIAN; - break; + case Endian.Little: return REG_VALUE_TYPE.REG_DWORD_LITTLE_ENDIAN; - break; + default: throw new RegistryException("Invalid Endian specified"); } + assert(0); } private uint swap(in uint i) @@ -711,7 +712,7 @@ case REG_VALUE_TYPE.REG_BINARY: case REG_VALUE_TYPE.REG_MULTI_SZ: throw new RegistryException("Cannot read the given value as a string"); - break; + case REG_VALUE_TYPE.REG_SZ: case REG_VALUE_TYPE.REG_EXPAND_SZ: value = std.string.toString(cast(char*)data); @@ -775,7 +776,7 @@ { default: throw new RegistryException("Cannot read the given value as a string"); - break; + case REG_VALUE_TYPE.REG_MULTI_SZ: break; } @@ -807,7 +808,7 @@ { default: throw new RegistryException("Cannot read the given value as a 32-bit integer"); - break; + version(LittleEndian) { case REG_VALUE_TYPE.REG_DWORD_LITTLE_ENDIAN: @@ -850,7 +851,7 @@ { default: throw new RegistryException("Cannot read the given value as a 64-bit integer"); - break; + case REG_VALUE_TYPE.REG_QWORD_LITTLE_ENDIAN: break; } @@ -887,7 +888,7 @@ { default: throw new RegistryException("Cannot read the given value as a string"); - break; + case REG_VALUE_TYPE.REG_BINARY: data.length = cbData; value = data; @@ -1748,8 +1749,8 @@ for(DWORD index = 0; 0 == result; ++index) { DWORD cchName; - LONG res = Reg_EnumKeyName_(hkey, index, sName, cchName); + res = Reg_EnumKeyName_(hkey, index, sName, cchName); assert(ERROR_MORE_DATA != res); if(ERROR_NO_MORE_ITEMS == res) @@ -1881,8 +1882,8 @@ for(DWORD index = 0; 0 == result; ++index) { DWORD cchName; - LONG res = Reg_EnumKeyName_(hkey, index, sName, cchName); + res = Reg_EnumKeyName_(hkey, index, sName, cchName); assert(ERROR_MORE_DATA != res); if(ERROR_NO_MORE_ITEMS == res) @@ -2025,8 +2026,8 @@ for(DWORD index = 0; 0 == result; ++index) { 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) { // Enumeration complete @@ -2152,8 +2153,8 @@ for(DWORD index = 0; 0 == result; ++index) { 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) { // Enumeration complete diff -uNr dmd-0.160/dmd/src/phobos/std/zip.d dmd-0.161/dmd/src/phobos/std/zip.d --- dmd-0.160/dmd/src/phobos/std/zip.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/zip.d 2006-06-19 21:09:16.000000000 +0200 @@ -212,8 +212,8 @@ putUint (i + 14, de.crc32); putUint (i + 18, de.compressedSize); putUint (i + 22, de.expandedData.length); - putUshort(i + 26, de.name.length); - putUshort(i + 28, de.extra.length); + putUshort(i + 26, cast(ushort)de.name.length); + putUshort(i + 28, cast(ushort)de.extra.length); i += 30; data[i .. i + de.name.length] = cast(ubyte[])de.name[]; @@ -238,9 +238,9 @@ putUint (i + 16, de.crc32); putUint (i + 20, de.compressedSize); putUint (i + 24, de.expandedSize); - putUshort(i + 28, de.name.length); - putUshort(i + 30, de.extra.length); - putUshort(i + 32, de.comment.length); + putUshort(i + 28, cast(ushort)de.name.length); + putUshort(i + 30, cast(ushort)de.extra.length); + putUshort(i + 32, cast(ushort)de.comment.length); putUshort(i + 34, de.diskNumber); putUshort(i + 36, de.internalAttributes); putUint (i + 38, de.externalAttributes); @@ -260,13 +260,13 @@ // Write end record endrecOffset = i; data[i .. i + 4] = cast(ubyte[])"PK\x05\x06"; - putUshort(i + 4, diskNumber); - putUshort(i + 6, diskStartDir); - putUshort(i + 8, numEntries); - putUshort(i + 10, totalEntries); + putUshort(i + 4, cast(ushort)diskNumber); + putUshort(i + 6, cast(ushort)diskStartDir); + putUshort(i + 8, cast(ushort)numEntries); + putUshort(i + 10, cast(ushort)totalEntries); putUint (i + 12, directorySize); putUint (i + 16, directoryOffset); - putUshort(i + 20, comment.length); + putUshort(i + 20, cast(ushort)comment.length); i += 22; // Write archive comment @@ -450,6 +450,7 @@ default: throw new ZipException("unsupported compression method"); } + assert(0); } /* ============ Utility =================== */ @@ -488,8 +489,8 @@ } else { - data[0] = cast(ubyte)us; - data[1] = cast(ubyte)(us >> 8); + data[i] = cast(ubyte)us; + data[i + 1] = cast(ubyte)(us >> 8); } } diff -uNr dmd-0.160/dmd/src/phobos/std/zlib.d dmd-0.161/dmd/src/phobos/std/zlib.d --- dmd-0.160/dmd/src/phobos/std/zlib.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std/zlib.d 2006-06-19 21:09:16.000000000 +0200 @@ -191,6 +191,7 @@ throw new ZlibException(err); } } + assert(0); } unittest diff -uNr dmd-0.160/dmd/src/phobos/std.ddoc dmd-0.161/dmd/src/phobos/std.ddoc --- dmd-0.160/dmd/src/phobos/std.ddoc 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/std.ddoc 2006-06-19 21:09:16.000000000 +0200 @@ -170,12 +170,11 @@ BLACK = $0 WHITE = $0 -RPAREN = ) -LPAREN = ( - D_COMMENT = $0 D_STRING = $0 D_KEYWORD = $0 D_PSYMBOL = $0 D_PARAM = $0 - +RPAREN = ) +LPAREN = ( +FOO=$0 diff -uNr dmd-0.160/dmd/src/phobos/unittest.d dmd-0.161/dmd/src/phobos/unittest.d --- dmd-0.160/dmd/src/phobos/unittest.d 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/unittest.d 2006-06-19 21:09:16.000000000 +0200 @@ -48,6 +48,7 @@ import std.conv; import std.boxer; import std.bitarray; +import std.uni; int main(char[][] args) { @@ -108,6 +109,8 @@ ba.length = 3; ba[0] = true; + std.uni.isUniAlpha('A'); + printf("Success\n!"); return 0; } diff -uNr dmd-0.160/dmd/src/phobos/win32.mak dmd-0.161/dmd/src/phobos/win32.mak --- dmd-0.160/dmd/src/phobos/win32.mak 2006-06-04 11:50:06.000000000 +0200 +++ dmd-0.161/dmd/src/phobos/win32.mak 2006-06-19 21:09:16.000000000 +0200 @@ -19,8 +19,8 @@ CFLAGS=-mn -6 -r #CFLAGS=-g -mn -6 -r -DFLAGS=-O -release -nofloat -#DFLAGS=-unittest -g +DFLAGS=-O -release -nofloat -w +#DFLAGS=-unittest -g -w #DFLAGS=-unittest -cov -g CC=dmc @@ -73,7 +73,7 @@ socket.obj socketstream.obj loader.obj stdarg.obj format.obj stdio.obj \ perf.obj openrj.obj uni.obj winsock.obj oldsyserror.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_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 \ @@ -190,7 +190,7 @@ SRC_STD_C_LINUX= std\c\linux\linux.d std\c\linux\linuxextern.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 @@ -478,9 +478,6 @@ gamma.obj : etc\gamma.d $(DMD) -c $(DFLAGS) etc\gamma.d -realtest.obj : etc\realtest.d - $(DMD) -c $(DFLAGS) etc\realtest.d - ### etc\c Czlib.obj : etc\c\zlib.d @@ -820,7 +817,7 @@ $(CP) $(SRC_STD_WIN) \dmd\src\phobos\std\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_ETC) \dmd\src\phobos\etc + $(CP) $(SRC_ETC) \dmd\src\phobos\etc $(CP) $(SRC_ETC_C) \dmd\src\phobos\etc\c $(CP) $(SRC_ZLIB) \dmd\src\phobos\etc\c\zlib $(CP) $(SRC_GC) \dmd\src\phobos\internal\gc