diff -uNr dmd-0.112/dmd/src/dmd/class.c dmd-0.113/dmd/src/dmd/class.c --- dmd-0.112/dmd/src/dmd/class.c 2004-12-30 00:19:38.000000000 +0100 +++ dmd-0.113/dmd/src/dmd/class.c 2005-02-12 02:38:22.000000000 +0100 @@ -124,7 +124,7 @@ handle = handle->semantic(loc, sc); } if (!members) // if forward reference - { printf("\tclass '%s' is forward referenced\n", toChars()); + { //printf("\tclass '%s' is forward referenced\n", toChars()); return; } if (symtab) @@ -481,7 +481,7 @@ if (!members || !symtab || scope) { error("is forward referenced when looking for '%s'", ident->toChars()); -*(char*)0=0; + //*(char*)0=0; return NULL; } diff -uNr dmd-0.112/dmd/src/dmd/enum.c dmd-0.113/dmd/src/dmd/enum.c --- dmd-0.112/dmd/src/dmd/enum.c 2004-12-30 00:16:08.000000000 +0100 +++ dmd-0.113/dmd/src/dmd/enum.c 2005-02-09 13:44:24.000000000 +0100 @@ -65,9 +65,10 @@ sce = sc->push(this); sce->parent = this; number = 0; + if (!members) // enum ident; + return; if (members->dim == 0) error("enum %s must have at least one member", toChars()); - for (i = 0; i < members->dim; i++) { EnumMember *em = ((Dsymbol *)members->data[i])->isEnumMember(); @@ -114,13 +115,14 @@ number++; } + sce->pop(); //members->print(); } Dsymbol *EnumDeclaration::oneMember() { - if (isAnonymous() && members->dim) + if (isAnonymous() && members && members->dim) { Dsymbol *s = (Dsymbol *)members->data[0]; s = s->oneMember(); @@ -153,6 +155,12 @@ buf->writestring(": "); memtype->toCBuffer(buf, NULL); } + if (!members) + { + buf->writeByte(';'); + buf->writenl(); + return; + } buf->writenl(); buf->writeByte('{'); buf->writenl(); diff -uNr dmd-0.112/dmd/src/dmd/expression.c dmd-0.113/dmd/src/dmd/expression.c --- dmd-0.112/dmd/src/dmd/expression.c 2005-01-15 02:30:30.000000000 +0100 +++ dmd-0.113/dmd/src/dmd/expression.c 2005-02-10 12:15:02.000000000 +0100 @@ -57,7 +57,7 @@ while (1) { if (!fd) - { printf("test1\n"); + { //printf("test1\n"); goto Lno; } if (!fd->isNested()) @@ -445,10 +445,13 @@ error("'%s' is not a scalar, it is a %s", toChars(), type->toChars()); } -void Expression::checkIntegral() +Expression *Expression::checkIntegral() { if (!type->isintegral()) - error("'%s' is not of integral type, it is a %s", toChars(), type->toChars()); + { error("'%s' is not of integral type, it is a %s", toChars(), type->toChars()); + return new IntegerExp(0); + } + return this; } void Expression::checkArithmetic() @@ -2905,7 +2908,10 @@ { f = cd->baseClass->ctor; if (!f) - error("no super class constructor for %s", cd->baseClass->toChars()); + { error("no super class constructor for %s", cd->baseClass->toChars()); + type = Type::terror; + return this; + } else { #if 0 @@ -3226,7 +3232,7 @@ if (e) return e; - e1->checkIntegral(); + e1 = e1->checkIntegral(); type = e1->type; } return this; @@ -4330,7 +4336,7 @@ type = e1->type; typeCombine(); e1->checkIntegral(); - e2->checkIntegral(); + e2 = e2->checkIntegral(); e2 = e2->castTo(Type::tshiftcnt); return this; } @@ -4357,7 +4363,7 @@ type = e1->type; typeCombine(); e1->checkIntegral(); - e2->checkIntegral(); + e2 = e2->checkIntegral(); e2 = e2->castTo(Type::tshiftcnt); return this; } @@ -4384,7 +4390,7 @@ type = e1->type; typeCombine(); e1->checkIntegral(); - e2->checkIntegral(); + e2 = e2->checkIntegral(); e2 = e2->castTo(Type::tshiftcnt); return this; } @@ -4806,8 +4812,8 @@ e = op_overload(sc); if (e) return e; - e1->checkIntegral(); - e2->checkIntegral(); + e1 = e1->checkIntegral(); + e2 = e2->checkIntegral(); e1 = e1->integralPromotions(); e2 = e2->castTo(Type::tshiftcnt); type = e1->type; @@ -4830,8 +4836,8 @@ e = op_overload(sc); if (e) return e; - e1->checkIntegral(); - e2->checkIntegral(); + e1 = e1->checkIntegral(); + e2 = e2->checkIntegral(); e1 = e1->integralPromotions(); e2 = e2->castTo(Type::tshiftcnt); type = e1->type; @@ -4854,8 +4860,8 @@ e = op_overload(sc); if (e) return e; - e1->checkIntegral(); - e2->checkIntegral(); + e1 = e1->checkIntegral(); + e2 = e2->checkIntegral(); e1 = e1->integralPromotions(); e2 = e2->castTo(Type::tshiftcnt); type = e1->type; diff -uNr dmd-0.112/dmd/src/dmd/expression.h dmd-0.113/dmd/src/dmd/expression.h --- dmd-0.112/dmd/src/dmd/expression.h 2005-01-16 01:55:38.000000000 +0100 +++ dmd-0.113/dmd/src/dmd/expression.h 2005-02-08 15:38:22.000000000 +0100 @@ -77,7 +77,7 @@ virtual int implicitConvTo(Type *t); virtual Expression *castTo(Type *t); void checkScalar(); - void checkIntegral(); + Expression *checkIntegral(); void checkArithmetic(); void checkDeprecated(Scope *sc, Dsymbol *s); virtual Expression *checkToBoolean(); diff -uNr dmd-0.112/dmd/src/dmd/init.c dmd-0.113/dmd/src/dmd/init.c --- dmd-0.112/dmd/src/dmd/init.c 2004-07-19 12:30:42.000000000 +0200 +++ dmd-0.113/dmd/src/dmd/init.c 2005-02-12 10:23:36.000000000 +0100 @@ -184,6 +184,7 @@ { dim = 0; type = NULL; + sem = 0; } Initializer *ArrayInitializer::syntaxCopy() @@ -220,6 +221,10 @@ { unsigned i; unsigned length; + //printf("ArrayInitializer::semantic(%s)\n", t->toChars()); + if (sem) // if semantic() already run + return this; + sem = 1; type = t; t = t->toBasetype(); switch (t->ty) diff -uNr dmd-0.112/dmd/src/dmd/init.h dmd-0.113/dmd/src/dmd/init.h --- dmd-0.112/dmd/src/dmd/init.h 2004-09-15 00:04:32.000000000 +0200 +++ dmd-0.113/dmd/src/dmd/init.h 2005-02-12 00:48:12.000000000 +0100 @@ -61,6 +61,7 @@ Array value; // of Initializer *'s unsigned dim; // length of array being initialized Type *type; // type that array will be used to initialize + int sem; // !=0 if semantic() is run ArrayInitializer(Loc loc); Initializer *syntaxCopy(); diff -uNr dmd-0.112/dmd/src/dmd/mars.c dmd-0.113/dmd/src/dmd/mars.c --- dmd-0.112/dmd/src/dmd/mars.c 2005-01-15 00:58:12.000000000 +0100 +++ dmd-0.113/dmd/src/dmd/mars.c 2005-02-08 00:05:06.000000000 +0100 @@ -49,7 +49,7 @@ copyright = "Copyright (c) 1999-2005 by Digital Mars"; written = "written by Walter Bright"; - version = "v0.111"; + version = "v0.113"; global.structalign = 8; memset(¶ms, 0, sizeof(Param)); @@ -371,6 +371,9 @@ global.params.useSwitchError = 0; } + if (global.params.useUnitTests) + global.params.useAssert = 1; + if (global.params.link) { global.params.exefile = global.params.objname; diff -uNr dmd-0.112/dmd/src/dmd/module.c dmd-0.113/dmd/src/dmd/module.c --- dmd-0.112/dmd/src/dmd/module.c 2005-01-12 02:45:36.000000000 +0100 +++ dmd-0.113/dmd/src/dmd/module.c 2005-02-10 13:46:24.000000000 +0100 @@ -467,7 +467,16 @@ void Module::semantic2() { int i; - assert(!deferred.dim); + if (deferred.dim) + { + for (int i = 0; i < deferred.dim; i++) + { + Dsymbol *sd = (Dsymbol *)deferred.data[i]; + + sd->error("unable to resolve forward reference"); + } + return; + } //printf("Module::semantic2('%s'): parent = %p\n", toChars(), parent); if (semanticdone >= 2) return; @@ -618,7 +627,7 @@ return; } -// printf("Module::addDeferredSemantic('%s')\n", s->toChars()); + //printf("Module::addDeferredSemantic('%s')\n", s->toChars()); deferred.push(s); } @@ -633,7 +642,7 @@ static int nested; if (nested) return; -// if (deferred.dim) printf("Module::runDeferredSemantic('%s'), len = %d\n", toChars(), deferred.dim); + //if (deferred.dim) printf("Module::runDeferredSemantic('%s'), len = %d\n", toChars(), deferred.dim); nested++; do diff -uNr dmd-0.112/dmd/src/dmd/mtype.c dmd-0.113/dmd/src/dmd/mtype.c --- dmd-0.112/dmd/src/dmd/mtype.c 2004-12-20 21:53:54.000000000 +0100 +++ dmd-0.113/dmd/src/dmd/mtype.c 2005-02-10 23:39:12.000000000 +0100 @@ -2684,6 +2684,15 @@ return t; } +void TypeIdentifier::toDecoBuffer(OutBuffer *buf) +{ unsigned len; + char *name; + + name = ident->toChars(); + //len = strlen(name); + //buf->printf("%c%d%s", mangleChar[ty], len, name); + buf->printf("%c%s", mangleChar[ty], name); +} void TypeIdentifier::toCBuffer2(OutBuffer *buf, Identifier *ident) { @@ -3017,7 +3026,11 @@ unsigned TypeEnum::alignsize() { - assert(sym->memtype); + if (!sym->memtype) + { + error(0, "enum %s is forward referenced", sym->toChars()); + return 4; + } return sym->memtype->alignsize(); } diff -uNr dmd-0.112/dmd/src/dmd/mtype.h dmd-0.113/dmd/src/dmd/mtype.h --- dmd-0.112/dmd/src/dmd/mtype.h 2004-12-15 15:19:38.000000000 +0100 +++ dmd-0.113/dmd/src/dmd/mtype.h 2005-01-29 22:06:16.000000000 +0100 @@ -418,6 +418,7 @@ TypeIdentifier(Loc loc, Identifier *ident); Type *syntaxCopy(); //char *toChars(); + void toDecoBuffer(OutBuffer *buf); void toCBuffer2(OutBuffer *buf, Identifier *ident); void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); Dsymbol *toDsymbol(Scope *sc); diff -uNr dmd-0.112/dmd/src/dmd/opover.c dmd-0.113/dmd/src/dmd/opover.c --- dmd-0.112/dmd/src/dmd/opover.c 2004-10-25 21:18:54.000000000 +0200 +++ dmd-0.113/dmd/src/dmd/opover.c 2005-02-10 01:10:42.000000000 +0100 @@ -188,6 +188,8 @@ Expression *BinExp::op_overload(Scope *sc) { + //printf("BinExp::op_overload() (%s)\n", toChars()); + AggregateDeclaration *ad; Type *t1 = e1->type->toBasetype(); Type *t2 = e2->type->toBasetype(); @@ -278,6 +280,8 @@ if (isCommutative()) { + fd = NULL; + fd_r = NULL; if (ad1 && id_r) { fd_r = search_function(ad1, id_r); @@ -323,7 +327,8 @@ m.lastf = m.anyf; } - if (lastf && m.lastf == lastf || m.last == MATCHnomatch) + if (lastf && m.lastf == lastf || + id_r && m.last == MATCHnomatch) // Rewrite (e1 op e2) as e1.opfunc_r(e2) e = build_overload(loc, sc, e1, e2, id_r); else diff -uNr dmd-0.112/dmd/src/dmd/statement.c dmd-0.113/dmd/src/dmd/statement.c --- dmd-0.112/dmd/src/dmd/statement.c 2004-12-29 14:28:20.000000000 +0100 +++ dmd-0.113/dmd/src/dmd/statement.c 2005-02-11 09:56:54.000000000 +0100 @@ -1440,6 +1440,19 @@ sc->fes->cases.push(this); s = new ReturnStatement(0, new IntegerExp(sc->fes->cases.dim + 1)); } + else if (fdx->type->next->toBasetype() == Type::tvoid) + { + Statement *s1; + Statement *s2; + + s = new ReturnStatement(0, NULL); + sc->fes->cases.push(s); + + // Construct: { exp; return cases.dim + 1; } + s1 = new ExpStatement(loc, exp); + s2 = new ReturnStatement(0, new IntegerExp(sc->fes->cases.dim + 1)); + s = new CompoundStatement(loc, s1, s2); + } else { VarExp *v; @@ -2098,6 +2111,10 @@ a = statement->flatten(); if (a) { + if (!a->dim) + { + a->push(new ExpStatement(loc, NULL)); + } Statement *s = (Statement *)a->data[0]; s = new LabelStatement(loc, ident, s); diff -uNr dmd-0.112/dmd/src/dmd/template.c dmd-0.113/dmd/src/dmd/template.c --- dmd-0.112/dmd/src/dmd/template.c 2004-10-26 11:31:30.000000000 +0200 +++ dmd-0.113/dmd/src/dmd/template.c 2005-01-29 22:10:08.000000000 +0100 @@ -1,5 +1,5 @@ -// Copyright (c) 1999-2004 by Digital Mars +// Copyright (c) 1999-2005 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com @@ -68,6 +68,18 @@ #if LOG printf("TemplateDeclaration(this = %p, id = '%s')\n", this, id->toChars()); #endif +#if 0 + if (parameters) + for (int i = 0; i < parameters->dim; i++) + { TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; + TemplateTypeParameter *ttp = tp->isTemplateTypeParameter(); + + if (ttp) + { + printf("\tparameter[%d] = %s : %s\n", i, tp->ident->toChars(), ttp->specType ? ttp->specType->toChars() : ""); + } + } +#endif this->loc = loc; this->parameters = parameters; this->members = decldefs; @@ -255,10 +267,18 @@ if (!oarg) goto Lnomatch; } +#if 0 + printf("\targument [%d] is %s\n", i, oarg->toChars()); + TemplateTypeParameter *ttp = tp->isTemplateTypeParameter(); + if (ttp) + printf("\tparameter[%d] is %s : %s\n", i, tp->ident->toChars(), ttp->specType ? ttp->specType->toChars() : ""); +#endif m2 = tp->matchArg(paramscope, oarg, i, parameters, dedtypes, &sparam); if (m2 == MATCHnomatch) + { //printf("\tmatchArg() failed\n"); goto Lnomatch; + } if (m2 < m) m = m2; @@ -674,14 +694,16 @@ void TemplateTypeParameter::semantic(Scope *sc) { - //printf("TemplateTypeParameter::semantic()\n"); + //printf("TemplateTypeParameter::semantic('%s')\n", ident->toChars()); TypeIdentifier *ti = new TypeIdentifier(loc, ident); Declaration *sparam = new AliasDeclaration(loc, ident, ti); if (!sc->insert(sparam)) error(loc, "parameter '%s' multiply defined", ident->toChars()); if (specType) + { specType = specType->semantic(loc, sc); + } #if 0 // Don't do semantic() until instantiation if (defaultType) { @@ -713,6 +735,8 @@ MATCH TemplateTypeParameter::matchArg(Scope *sc, Object *oarg, int i, Array *parameters, Array *dedtypes, Declaration **psparam) { + //printf("TemplateTypeParameter::matchArg()\n"); + Type *t; MATCH m = MATCHexact; Type *ta = isType(oarg); @@ -723,10 +747,12 @@ if (specType) { - //printf("calling deduceType()\n"); + //printf("\tcalling deduceType(), specType is %s\n", specType->toChars()); MATCH m2 = ta->deduceType(specType, parameters, dedtypes); if (m2 == MATCHnomatch) + { //printf("\tfailed deduceType\n"); goto Lnomatch; + } if (m2 < m) m = m2; diff -uNr dmd-0.112/dmd/src/dmd/tocsym.c dmd-0.113/dmd/src/dmd/tocsym.c --- dmd-0.112/dmd/src/dmd/tocsym.c 2004-11-28 02:07:28.000000000 +0100 +++ dmd-0.113/dmd/src/dmd/tocsym.c 2005-02-09 14:12:18.000000000 +0100 @@ -1,5 +1,5 @@ -// Copyright (c) 1999-2002 by Digital Mars +// Copyright (c) 1999-2005 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com @@ -136,6 +136,7 @@ Symbol *VarDeclaration::toSymbol() { //printf("VarDeclaration::toSymbol(%s)\n", toChars()); + //if (needThis()) *(char*)0=0; assert(!needThis()); if (!csym) { Symbol *s; diff -uNr dmd-0.112/dmd/src/dmd/todt.c dmd-0.113/dmd/src/dmd/todt.c --- dmd-0.112/dmd/src/dmd/todt.c 2004-12-03 01:56:20.000000000 +0100 +++ dmd-0.113/dmd/src/dmd/todt.c 2005-02-10 12:16:50.000000000 +0100 @@ -161,6 +161,7 @@ dt_t *d; dt_t **pdtend; + //printf("dim = %d\n", dim); dts.setDim(dim); dts.zero(); @@ -174,6 +175,7 @@ idx = (Expression *)index.data[i]; if (idx) length = idx->toInteger(); + //printf("index[%d] = %p, length = %d\n", i, idx, length); val = (Initializer *)value.data[i]; dt = val->toDt(); @@ -518,9 +520,11 @@ //printf("SymOffExp::toDt('%s')\n", var->toChars()); assert(var); + if (!(var->isDataseg() || var->isCodeseg()) || var->needThis()) + { error("non-constant expression %s", toChars()); + return pdt; + } s = var->toSymbol(); - if (!(var->isDataseg() || var->isCodeseg())) - error("non-constant expression %s", toChars()); return dtxoff(pdt, s, offset, TYnptr); } diff -uNr dmd-0.112/dmd/src/dmd/typinf.c dmd-0.113/dmd/src/dmd/typinf.c --- dmd-0.112/dmd/src/dmd/typinf.c 2004-12-15 17:02:42.000000000 +0100 +++ dmd-0.113/dmd/src/dmd/typinf.c 2005-02-12 00:45:56.000000000 +0100 @@ -387,6 +387,7 @@ sc = sc->push(); sc->linkage = LINKc; sc->stc = STCstatic | STCcomdat; + ai->semantic(sc, t); v->semantic(sc); v->parent = m; sc = sc->pop(); diff -uNr dmd-0.112/dmd/src/phobos/internal/arraycast.d dmd-0.113/dmd/src/phobos/internal/arraycast.d --- dmd-0.112/dmd/src/phobos/internal/arraycast.d 2005-01-27 01:05:36.000000000 +0100 +++ dmd-0.113/dmd/src/phobos/internal/arraycast.d 2005-02-13 10:33:28.000000000 +0100 @@ -1,3 +1,26 @@ +/* + * Copyright (C) 2004 by Digital Mars, www.digitalmars.com + * Written by Walter Bright + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, in both source and binary form, subject to the following + * restrictions: + * + * o The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * o Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * o This notice may not be removed or altered from any source + * distribution. + */ + /****************************************** diff -uNr dmd-0.112/dmd/src/phobos/internal/arraycat.d dmd-0.113/dmd/src/phobos/internal/arraycat.d --- dmd-0.112/dmd/src/phobos/internal/arraycat.d 2005-01-27 01:05:36.000000000 +0100 +++ dmd-0.113/dmd/src/phobos/internal/arraycat.d 2005-02-13 10:33:28.000000000 +0100 @@ -1,3 +1,26 @@ +/* + * Copyright (C) 2004 by Digital Mars, www.digitalmars.com + * Written by Walter Bright + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, in both source and binary form, subject to the following + * restrictions: + * + * o The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * o Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * o This notice may not be removed or altered from any source + * distribution. + */ + import object; import std.string; diff -uNr dmd-0.112/dmd/src/phobos/internal/cast.d dmd-0.113/dmd/src/phobos/internal/cast.d --- dmd-0.112/dmd/src/phobos/internal/cast.d 2005-01-27 01:05:36.000000000 +0100 +++ dmd-0.113/dmd/src/phobos/internal/cast.d 2005-02-13 10:33:28.000000000 +0100 @@ -1,3 +1,26 @@ +/* + * Copyright (C) 2004 by Digital Mars, www.digitalmars.com + * Written by Walter Bright + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, in both source and binary form, subject to the following + * restrictions: + * + * o The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * o Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * o This notice may not be removed or altered from any source + * distribution. + */ + import object; import std.c.stdio; diff -uNr dmd-0.112/dmd/src/phobos/internal/complex.c dmd-0.113/dmd/src/phobos/internal/complex.c --- dmd-0.112/dmd/src/phobos/internal/complex.c 2005-01-27 01:05:36.000000000 +0100 +++ dmd-0.113/dmd/src/phobos/internal/complex.c 2005-02-13 10:33:28.000000000 +0100 @@ -1,3 +1,9 @@ +/* + * Placed into the public domain. + * Written by Walter Bright + * www.digitalmars.com + */ + #include diff -uNr dmd-0.112/dmd/src/phobos/internal/dmain2.d dmd-0.113/dmd/src/phobos/internal/dmain2.d --- dmd-0.112/dmd/src/phobos/internal/dmain2.d 2005-01-27 01:05:36.000000000 +0100 +++ dmd-0.113/dmd/src/phobos/internal/dmain2.d 2005-02-13 10:33:28.000000000 +0100 @@ -1,3 +1,8 @@ +/* + * Placed into the Public Domain. + * written by Walter Bright + * www.digitalmars.com + */ import object; import std.c.stdio; diff -uNr dmd-0.112/dmd/src/phobos/internal/invariant.d dmd-0.113/dmd/src/phobos/internal/invariant.d --- dmd-0.112/dmd/src/phobos/internal/invariant.d 2005-01-27 01:05:36.000000000 +0100 +++ dmd-0.113/dmd/src/phobos/internal/invariant.d 2005-02-13 10:33:28.000000000 +0100 @@ -1,4 +1,10 @@ +/* + * Placed into the Public Domain + * written by Walter Bright + * www.digitalmars.com + */ + void _d_invariant(Object o) { ClassInfo c; diff -uNr dmd-0.112/dmd/src/phobos/internal/mars.h dmd-0.113/dmd/src/phobos/internal/mars.h --- dmd-0.112/dmd/src/phobos/internal/mars.h 2005-01-27 01:05:36.000000000 +0100 +++ dmd-0.113/dmd/src/phobos/internal/mars.h 2005-02-13 10:33:28.000000000 +0100 @@ -1,4 +1,10 @@ +/* + * Placed into the Public Domain + * written by Walter Bright + * www.digitalmars.com + */ + #if __cplusplus extern "C" { #endif diff -uNr dmd-0.112/dmd/src/phobos/internal/memset.d dmd-0.113/dmd/src/phobos/internal/memset.d --- dmd-0.112/dmd/src/phobos/internal/memset.d 2005-01-27 01:05:36.000000000 +0100 +++ dmd-0.113/dmd/src/phobos/internal/memset.d 2005-02-13 10:33:28.000000000 +0100 @@ -1,3 +1,26 @@ +/* + * Copyright (C) 2004 by Digital Mars, www.digitalmars.com + * Written by Walter Bright + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, in both source and binary form, subject to the following + * restrictions: + * + * o The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * o Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * o This notice may not be removed or altered from any source + * distribution. + */ + extern (C) { diff -uNr dmd-0.112/dmd/src/phobos/internal/object.d dmd-0.113/dmd/src/phobos/internal/object.d --- dmd-0.112/dmd/src/phobos/internal/object.d 2005-01-27 01:05:36.000000000 +0100 +++ dmd-0.113/dmd/src/phobos/internal/object.d 2005-02-13 10:33:28.000000000 +0100 @@ -1,3 +1,26 @@ +/* + * Copyright (C) 2004 by Digital Mars, www.digitalmars.com + * Written by Walter Bright + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, in both source and binary form, subject to the following + * restrictions: + * + * o The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * o Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * o This notice may not be removed or altered from any source + * distribution. + */ + module object; diff -uNr dmd-0.112/dmd/src/phobos/internal/qsort.d dmd-0.113/dmd/src/phobos/internal/qsort.d --- dmd-0.112/dmd/src/phobos/internal/qsort.d 2005-01-27 01:05:36.000000000 +0100 +++ dmd-0.113/dmd/src/phobos/internal/qsort.d 2005-02-13 10:33:28.000000000 +0100 @@ -1,4 +1,5 @@ /* + Portions of this file are: Copyright Prototronics, 1987 Totem Lake P.O. 8117 Kirkland, Washington 98034 @@ -7,6 +8,9 @@ June 11, 1987 from Ray Gardner's Denver, Colorado) public domain version + + Use qsort2.d instead of this file if a redistributable version of + _adSort() is required. */ diff -uNr dmd-0.112/dmd/src/phobos/internal/switch.d dmd-0.113/dmd/src/phobos/internal/switch.d --- dmd-0.112/dmd/src/phobos/internal/switch.d 2005-01-27 01:05:36.000000000 +0100 +++ dmd-0.113/dmd/src/phobos/internal/switch.d 2005-02-13 10:33:28.000000000 +0100 @@ -1,3 +1,26 @@ +/* + * Copyright (C) 2004 by Digital Mars, www.digitalmars.com + * Written by Walter Bright + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, in both source and binary form, subject to the following + * restrictions: + * + * o The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * o Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * o This notice may not be removed or altered from any source + * distribution. + */ + import std.c.stdio; import std.string; diff -uNr dmd-0.112/dmd/src/phobos/linux.mak dmd-0.113/dmd/src/phobos/linux.mak --- dmd-0.112/dmd/src/phobos/linux.mak 2005-01-27 01:05:32.000000000 +0100 +++ dmd-0.113/dmd/src/phobos/linux.mak 2005-02-13 10:33:26.000000000 +0100 @@ -52,7 +52,7 @@ cast.o path.o string.o memset.o math.o mmfile.o \ outbuffer.o ctype.o regexp.o random.o linux.o \ stream.o switcherr.o array.o gc.o \ - qsort.o thread.o obj.o utf.o uri.o \ + qsort.o qsort2.o thread.o obj.o utf.o uri.o \ crc32.o conv.o arraycast.o errno.o alloca.o cmath2.o \ process.o syserror.o \ socket.o socketstream.o stdarg.o stdio.o format.o \ @@ -700,9 +700,9 @@ ##########################################################333 -zip : $(ALLSRCS) linux.mak win32.mak +zip : $(ALLSRCS) linux.mak win32.mak phoboslicense.txt rm phobos.zip - zip phobos $(ALLSRCS) linux.mak win32.mak + zip phobos $(ALLSRCS) linux.mak win32.mak phoboslicense.txt clean: rm $(OBJS) unittest unittest.o diff -uNr dmd-0.112/dmd/src/phobos/phoboslicense.txt dmd-0.113/dmd/src/phobos/phoboslicense.txt --- dmd-0.112/dmd/src/phobos/phoboslicense.txt 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.113/dmd/src/phobos/phoboslicense.txt 2005-02-13 10:33:26.000000000 +0100 @@ -0,0 +1,31 @@ +Unless otherwise marked within the file, each file in the source +to the Phobos library is under the following license: + +/* + * Copyright (C) 2004 by Digital Mars, www.digitalmars.com + * Written by Walter Bright + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, in both source and binary form, subject to the following + * restrictions: + * + * o The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * o Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * o This notice may not be removed or altered from any source + * distribution. + */ + + +By plainly marking modifications, something along the lines of adding to each +file that has been changed a "Modified by Foo Bar" line +underneath the "Written by" line would be adequate. + diff -uNr dmd-0.112/dmd/src/phobos/std/file.d dmd-0.113/dmd/src/phobos/std/file.d --- dmd-0.112/dmd/src/phobos/std/file.d 2005-01-27 01:05:32.000000000 +0100 +++ dmd-0.113/dmd/src/phobos/std/file.d 2005-02-13 10:33:28.000000000 +0100 @@ -887,3 +887,22 @@ } } + +/*************************************************** + * Copy a file. + */ + +void copy(char[] from, char[] to) +{ + void[] buffer; + + /* If the file is very large, this won't work, but + * it's a good start. + */ + buffer = read(from); + write(to, buffer); + delete buffer; +} + + + diff -uNr dmd-0.112/dmd/src/phobos/std/process.d dmd-0.113/dmd/src/phobos/std/process.d --- dmd-0.112/dmd/src/phobos/std/process.d 2005-01-27 01:05:34.000000000 +0100 +++ dmd-0.113/dmd/src/phobos/std/process.d 2005-02-13 10:33:28.000000000 +0100 @@ -46,6 +46,20 @@ *az = null; } + +/* ========================================================== */ + +int spawnvp(int mode, char[] pathname, char[][] argv) +{ + char** argv_ = cast(char**)alloca((char*).sizeof * (1 + argv.length)); + + toAStringz(argv, argv_); + + return std.c.process.spawnvp(mode, toStringz(pathname), argv_); +} + +/* ========================================================== */ + int execv(char[] pathname, char[][] argv) { char** argv_ = cast(char**)alloca((char*).sizeof * (1 + argv.length)); diff -uNr dmd-0.112/dmd/src/phobos/std/string.d dmd-0.113/dmd/src/phobos/std/string.d --- dmd-0.112/dmd/src/phobos/std/string.d 2005-01-27 01:05:32.000000000 +0100 +++ dmd-0.113/dmd/src/phobos/std/string.d 2005-02-13 10:33:26.000000000 +0100 @@ -208,20 +208,25 @@ } body { - char* p; char[] copy; if (string.length == 0) return ""; - p = &string[0] + string.length; - - // Peek past end of string[], if it's 0, no conversion necessary. - // Note that the compiler will put a 0 past the end of static - // strings, and the storage allocator will put a 0 past the end - // of newly allocated char[]'s. - if (*p == 0) - return string; + /+ Unfortunately, this isn't reliable. + We could make this work if string literals are put + in read-only memory and we test if string[] is pointing into + that. + + /* Peek past end of string[], if it's 0, no conversion necessary. + * Note that the compiler will put a 0 past the end of static + * strings, and the storage allocator will put a 0 past the end + * of newly allocated char[]'s. + */ + char* p = &string[0] + string.length; + if (*p == 0) + return string; + +/ // Need to make a copy copy = new char[string.length + 1]; diff -uNr dmd-0.112/dmd/src/phobos/std/typeinfo/ti_C.d dmd-0.113/dmd/src/phobos/std/typeinfo/ti_C.d --- dmd-0.112/dmd/src/phobos/std/typeinfo/ti_C.d 2005-01-27 01:05:34.000000000 +0100 +++ dmd-0.113/dmd/src/phobos/std/typeinfo/ti_C.d 2005-02-13 10:33:28.000000000 +0100 @@ -1,3 +1,25 @@ +/* + * Copyright (C) 2004 by Digital Mars, www.digitalmars.com + * Written by Walter Bright + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, in both source and binary form, subject to the following + * restrictions: + * + * o The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * o Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * o This notice may not be removed or altered from any source + * distribution. + */ private import std.string; @@ -27,7 +49,7 @@ int c = 0; // Regard null references as always being "less than" - if (o1 != o2) + if (!(o1 is o2)) { if (o1) { if (!o2) diff -uNr dmd-0.112/dmd/src/phobos/unittest.d dmd-0.113/dmd/src/phobos/unittest.d --- dmd-0.112/dmd/src/phobos/unittest.d 2005-01-27 01:05:32.000000000 +0100 +++ dmd-0.113/dmd/src/phobos/unittest.d 2005-02-13 10:33:26.000000000 +0100 @@ -66,6 +66,13 @@ printf("args.length = %d\n", args.length); for (int i = 0; i < args.length; i++) printf("args[%d] = '%s'\n", i, cast(char *)args[i]); + + int[3] x; + x[0] = 3; + x[1] = 45; + x[2] = -1; + x.sort; + printf("Success\n!"); return 0; } diff -uNr dmd-0.112/dmd/src/phobos/win32.mak dmd-0.113/dmd/src/phobos/win32.mak --- dmd-0.112/dmd/src/phobos/win32.mak 2005-01-27 01:05:32.000000000 +0100 +++ dmd-0.113/dmd/src/phobos/win32.mak 2005-02-13 10:33:26.000000000 +0100 @@ -60,7 +60,7 @@ cast.obj syserror.obj path.obj string.obj memset.obj math.obj \ outbuffer.obj ctype.obj regexp.obj random.obj windows.obj \ stream.obj switcherr.obj com.obj array.obj gc.obj mmfile.obj \ - qsort.obj math2.obj date.obj dateparse.obj thread.obj obj.obj \ + qsort.obj qsort.2.d math2.obj date.obj dateparse.obj thread.obj obj.obj \ iunknown.obj crc32.obj conv.obj arraycast.obj utf.obj uri.obj \ Czlib.obj Dzlib.obj zip.obj process.obj registry.obj recls.obj \ socket.obj socketstream.obj loader.obj stdarg.obj format.obj stdio.obj \ @@ -334,7 +334,7 @@ phobos.lib : $(OBJS) minit.obj internal\gc\dmgc.lib etc\c\zlib\zlib.lib \ win32.mak etc\c\recls\recls.lib - lib -c phobos.lib $(OBJS) minit.obj internal\gc\dmgc.lib \ + lib -c -p32 phobos.lib $(OBJS) minit.obj internal\gc\dmgc.lib \ etc\c\recls\recls.lib etc\c\zlib\zlib.lib ###################################################### @@ -679,7 +679,7 @@ ###################################################### -zip : win32.mak linux.mak $(SRC) \ +zip : win32.mak linux.mak phoboslicense.txt $(SRC) \ $(SRC_STD) $(SRC_STD_C) $(SRC_TI) $(SRC_INT) $(SRC_STD_WIN) \ $(SRC_STDLINUX) $(SRC_ETC) $(SRC_ETC_C) $(SRC_ZLIB) $(SRC_GC) del phobos.zip @@ -704,7 +704,7 @@ install: $(CP) phobos.lib gcstub.obj \dmd\lib - $(CP) win32.mak linux.mak minit.obj \dmd\src\phobos + $(CP) win32.mak linux.mak phoboslicense.txt minit.obj \dmd\src\phobos $(CP) $(SRC) \dmd\src\phobos $(CP) $(SRC_STD) \dmd\src\phobos\std $(CP) $(SRC_STD_C) \dmd\src\phobos\std\c