diff -uNr dmd-0.105/dmd/src/dmd/access.c dmd-0.106/dmd/src/dmd/access.c --- dmd-0.105/dmd/src/dmd/access.c 2004-06-07 02:21:12.000000000 +0200 +++ dmd-0.106/dmd/src/dmd/access.c 2004-11-05 01:17:28.000000000 +0100 @@ -314,6 +314,13 @@ } // If both are members of the same module, grant access + while (1) + { Dsymbol *sp = smember->toParent(); + if (sp->isFuncDeclaration() && smember->isFuncDeclaration()) + smember = sp; + else + break; + } if (!cd && toParent() == smember->toParent()) { #if LOG diff -uNr dmd-0.105/dmd/src/dmd/aggregate.h dmd-0.106/dmd/src/dmd/aggregate.h --- dmd-0.105/dmd/src/dmd/aggregate.h 2004-10-04 16:26:16.000000000 +0200 +++ dmd-0.106/dmd/src/dmd/aggregate.h 2004-11-04 21:26:12.000000000 +0100 @@ -162,6 +162,7 @@ void accessCheck(Loc loc, Scope *sc, Dsymbol *smember); int isFriendOf(ClassDeclaration *cd); int hasPackageAccess(Scope *sc); + void addLocalClass(Array *); // Back end void toObjFile(); // compile to .obj file diff -uNr dmd-0.105/dmd/src/dmd/attrib.c dmd-0.106/dmd/src/dmd/attrib.c --- dmd-0.105/dmd/src/dmd/attrib.c 2004-10-21 19:32:42.000000000 +0200 +++ dmd-0.106/dmd/src/dmd/attrib.c 2004-11-04 21:31:20.000000000 +0100 @@ -168,6 +168,25 @@ return NULL; } +/**************************************** + */ + +void AttribDeclaration::addLocalClass(Array *aclasses) +{ unsigned i; + Array *d = include(); + + if (d) + { + for (i = 0; i < d->dim; i++) + { Dsymbol *s; + + s = (Dsymbol *)d->data[i]; + s->addLocalClass(aclasses); + } + } +} + + void AttribDeclaration::toCBuffer(OutBuffer *buf) { if (decl) diff -uNr dmd-0.105/dmd/src/dmd/attrib.h dmd-0.106/dmd/src/dmd/attrib.h --- dmd-0.105/dmd/src/dmd/attrib.h 2004-10-02 09:36:14.000000000 +0200 +++ dmd-0.106/dmd/src/dmd/attrib.h 2004-11-04 21:31:20.000000000 +0100 @@ -38,6 +38,7 @@ void inlineScan(); char *kind(); Dsymbol *oneMember(); + void addLocalClass(Array *); void toCBuffer(OutBuffer *buf); void toObjFile(); // compile to .obj file diff -uNr dmd-0.105/dmd/src/dmd/class.c dmd-0.106/dmd/src/dmd/class.c --- dmd-0.105/dmd/src/dmd/class.c 2004-08-16 12:18:16.000000000 +0200 +++ dmd-0.106/dmd/src/dmd/class.c 2004-11-05 01:26:32.000000000 +0100 @@ -69,10 +69,10 @@ if (!Type::typeinfo && id == Id::TypeInfo) Type::typeinfo = this; - if (!Type::typeinfoclass && id == Id::TypeInfoClass) + if (!Type::typeinfoclass && id == Id::TypeInfo_Class) Type::typeinfoclass = this; - if (!Type::typeinfotypedef && id == Id::TypeInfoTypedef) + if (!Type::typeinfotypedef && id == Id::TypeInfo_Typedef) Type::typeinfotypedef = this; com = 0; @@ -564,6 +564,14 @@ return "class"; } +/**************************************** + */ + +void ClassDeclaration::addLocalClass(Array *aclasses) +{ + aclasses->push(this); +} + /********************************* InterfaceDeclaration ****************************/ InterfaceDeclaration::InterfaceDeclaration(Loc loc, Identifier *id, Array *baseclasses) diff -uNr dmd-0.105/dmd/src/dmd/constfold.c dmd-0.106/dmd/src/dmd/constfold.c --- dmd-0.105/dmd/src/dmd/constfold.c 2004-06-20 16:42:40.000000000 +0200 +++ dmd-0.106/dmd/src/dmd/constfold.c 2004-11-04 00:45:08.000000000 +0100 @@ -111,6 +111,8 @@ return e1; } + if (type->toBasetype()->ty == Tbit) + return new IntegerExp(loc, e1->toInteger() != 0, type); if (type->isintegral()) return new IntegerExp(loc, e1->toInteger(), type); if (type->isreal()) diff -uNr dmd-0.105/dmd/src/dmd/debcond.c dmd-0.106/dmd/src/dmd/debcond.c --- dmd-0.105/dmd/src/dmd/debcond.c 2004-10-27 21:01:34.000000000 +0200 +++ dmd-0.106/dmd/src/dmd/debcond.c 2004-11-03 15:44:36.000000000 +0100 @@ -110,6 +110,33 @@ void VersionCondition::addGlobalIdent(char *ident) { + static char* reserved[] = + { + "DigitalMars", "X86", "AMD64", + "Windows", "Win32", "Win64", + "linux", + "LittleEndian", "BigEndian", + "none", + }; + + for (unsigned i = 0; i < sizeof(reserved) / sizeof(reserved[0]); i++) + { + if (strcmp(ident, reserved[i]) == 0) + goto Lerror; + } + + if (ident[0] == 'D' && ident[1] == '_') + goto Lerror; + + addPredefinedGlobalIdent(ident); + return; + + Lerror: + error("version identifier '%s' is reserved and cannot be set", ident); +} + +void VersionCondition::addPredefinedGlobalIdent(char *ident) +{ if (!global.params.versionids) global.params.versionids = new Array(); global.params.versionids->push(ident); diff -uNr dmd-0.105/dmd/src/dmd/debcond.h dmd-0.106/dmd/src/dmd/debcond.h --- dmd-0.105/dmd/src/dmd/debcond.h 2004-08-30 02:09:22.000000000 +0200 +++ dmd-0.106/dmd/src/dmd/debcond.h 2004-11-03 15:44:36.000000000 +0100 @@ -33,6 +33,7 @@ { static void setGlobalLevel(unsigned level); static void addGlobalIdent(char *ident); + static void addPredefinedGlobalIdent(char *ident); DebugCondition(Module *mod, unsigned level, Identifier *ident); @@ -43,6 +44,7 @@ { static void setGlobalLevel(unsigned level); static void addGlobalIdent(char *ident); + static void addPredefinedGlobalIdent(char *ident); VersionCondition(Module *mod, unsigned level, Identifier *ident); diff -uNr dmd-0.105/dmd/src/dmd/declaration.c dmd-0.106/dmd/src/dmd/declaration.c --- dmd-0.105/dmd/src/dmd/declaration.c 2004-10-25 18:30:14.000000000 +0200 +++ dmd-0.106/dmd/src/dmd/declaration.c 2004-11-04 21:01:42.000000000 +0100 @@ -245,6 +245,8 @@ } } L1: + if (overnext) + ScopeDsymbol::multiplyDefined(this, overnext); type = type->semantic(loc, sc); this->inSemantic = 0; return; @@ -422,7 +424,7 @@ sd->alignsize = memalignsize; storage_class |= STCfield; - //printf("1 Adding '%s' to '%s'\n", this->toChars(), sd->toChars()); + //printf("1 Adding '%s' to '%s', offset %d\n", this->toChars(), sd->toChars(), offset); sd->fields.push(this); } diff -uNr dmd-0.105/dmd/src/dmd/dsymbol.h dmd-0.106/dmd/src/dmd/dsymbol.h --- dmd-0.105/dmd/src/dmd/dsymbol.h 2004-10-27 20:14:04.000000000 +0200 +++ dmd-0.106/dmd/src/dmd/dsymbol.h 2004-11-04 21:30:36.000000000 +0100 @@ -123,6 +123,7 @@ virtual enum PROT prot(); virtual Dsymbol *syntaxCopy(Dsymbol *s); // copy only syntax trees virtual Dsymbol *oneMember() { return this; } + virtual void addLocalClass(Array *) { } // Backend diff -uNr dmd-0.105/dmd/src/dmd/expression.c dmd-0.106/dmd/src/dmd/expression.c --- dmd-0.105/dmd/src/dmd/expression.c 2004-10-28 15:06:28.000000000 +0200 +++ dmd-0.106/dmd/src/dmd/expression.c 2004-11-04 01:05:14.000000000 +0100 @@ -1608,6 +1608,8 @@ member = f->isCtorDeclaration(); assert(member); + cd->accessCheck(loc, sc, member); + tf = (TypeFunction *)f->type; type = tf->next; diff -uNr dmd-0.105/dmd/src/dmd/idgen.c dmd-0.106/dmd/src/dmd/idgen.c --- dmd-0.105/dmd/src/dmd/idgen.c 2004-10-28 13:52:24.000000000 +0200 +++ dmd-0.106/dmd/src/dmd/idgen.c 2004-11-05 01:25:56.000000000 +0100 @@ -58,8 +58,8 @@ { "empty", "" }, { "TypeInfo" }, - { "TypeInfoClass" }, - { "TypeInfoTypedef" }, + { "TypeInfo_Class" }, + { "TypeInfo_Typedef" }, { "_arguments" }, { "_argptr" }, diff -uNr dmd-0.105/dmd/src/dmd/mangle.c dmd-0.106/dmd/src/dmd/mangle.c --- dmd-0.105/dmd/src/dmd/mangle.c 2004-07-05 21:23:32.000000000 +0200 +++ dmd-0.106/dmd/src/dmd/mangle.c 2004-11-05 01:27:06.000000000 +0100 @@ -133,8 +133,8 @@ * names for them. */ if (ident == Id::TypeInfo || - ident == Id::TypeInfoClass || - ident == Id::TypeInfoTypedef || + ident == Id::TypeInfo_Class || + ident == Id::TypeInfo_Typedef || ident == Id::Exception || ident == Id::Object || ident == Id::ClassInfo || diff -uNr dmd-0.105/dmd/src/dmd/mars.c dmd-0.106/dmd/src/dmd/mars.c --- dmd-0.105/dmd/src/dmd/mars.c 2004-10-29 12:06:58.000000000 +0200 +++ dmd-0.106/dmd/src/dmd/mars.c 2004-11-03 15:47:38.000000000 +0100 @@ -49,7 +49,7 @@ copyright = "Copyright (c) 1999-2004 by Digital Mars"; written = "written by Walter Bright"; - version = "v0.105"; + version = "v0.106"; global.structalign = 8; memset(¶ms, 0, sizeof(Param)); @@ -186,18 +186,19 @@ global.params.objfiles = new Array(); // Predefine version identifiers - VersionCondition::addGlobalIdent("DigitalMars"); + VersionCondition::addPredefinedGlobalIdent("DigitalMars"); #if _WIN32 - VersionCondition::addGlobalIdent("Windows"); - VersionCondition::addGlobalIdent("Win32"); + VersionCondition::addPredefinedGlobalIdent("Windows"); + VersionCondition::addPredefinedGlobalIdent("Win32"); #endif #if linux - VersionCondition::addGlobalIdent("linux"); + VersionCondition::addPredefinedGlobalIdent("linux"); global.params.isLinux = 1; #endif /* linux */ - VersionCondition::addGlobalIdent("X86"); - VersionCondition::addGlobalIdent("LittleEndian"); - VersionCondition::addGlobalIdent("D_InlineAsm"); + VersionCondition::addPredefinedGlobalIdent("X86"); + VersionCondition::addPredefinedGlobalIdent("LittleEndian"); + VersionCondition::addPredefinedGlobalIdent("D_InlineAsm"); + VersionCondition::addPredefinedGlobalIdent("all"); #if _WIN32 inifile(argv[0], "sc.ini"); @@ -288,7 +289,7 @@ goto Lerror; DebugCondition::setGlobalLevel((int)level); } - else if (isalpha(p[7])) + else if (isalpha(p[7]) || p[7] == '_') DebugCondition::addGlobalIdent(p + 7); else goto Lerror; @@ -306,8 +307,15 @@ if (p[8] == '=') { if (isdigit(p[9])) - VersionCondition::setGlobalLevel(atoi(p + 9)); - else if (isalpha(p[9])) + { long level; + + errno = 0; + level = strtol(p + 9, &p, 10); + if (*p || errno || level > INT_MAX) + goto Lerror; + VersionCondition::setGlobalLevel((int)level); + } + else if (isalpha(p[9]) || p[9] == '_') VersionCondition::addGlobalIdent(p + 9); else goto Lerror; diff -uNr dmd-0.105/dmd/src/dmd/mtype.c dmd-0.106/dmd/src/dmd/mtype.c --- dmd-0.105/dmd/src/dmd/mtype.c 2004-10-25 21:37:14.000000000 +0200 +++ dmd-0.106/dmd/src/dmd/mtype.c 2004-11-04 21:54:30.000000000 +0100 @@ -1286,7 +1286,8 @@ e = e->castTo(n->arrayOf()); // convert to dynamic array arguments = new Array(); arguments->push(e); - arguments->push(n->getInternalTypeInfo()); + arguments->push(n->ty == Tsarray ? n->getTypeInfo(sc) // don't convert to dynamic array + : n->getInternalTypeInfo()); e = new CallExp(e->loc, ec, arguments); e->type = next->arrayOf(); } diff -uNr dmd-0.105/dmd/src/dmd/statement.c dmd-0.106/dmd/src/dmd/statement.c --- dmd-0.105/dmd/src/dmd/statement.c 2004-10-28 20:30:06.000000000 +0200 +++ dmd-0.106/dmd/src/dmd/statement.c 2004-11-02 22:41:26.000000000 +0100 @@ -1839,7 +1839,7 @@ Statement *TryCatchStatement::semantic(Scope *sc) { - body = body->semanticScope(sc, this, NULL); + body = body->semanticScope(sc, NULL /*this*/, NULL); for (int i = 0; i < catches->dim; i++) { Catch *c; diff -uNr dmd-0.105/dmd/src/dmd/struct.c dmd-0.106/dmd/src/dmd/struct.c --- dmd-0.105/dmd/src/dmd/struct.c 2004-08-04 17:46:20.000000000 +0200 +++ dmd-0.106/dmd/src/dmd/struct.c 2004-11-04 20:56:48.000000000 +0100 @@ -183,7 +183,8 @@ if (isUnionDeclaration()) sc2->inunion = 1; sc2->stc &= ~(STCauto | STCstatic); - for (i = 0; i < members->dim; i++) + int members_dim = members->dim; + for (i = 0; i < members_dim; i++) { Dsymbol *s = (Dsymbol *)members->data[i]; s->semantic(sc2); @@ -214,19 +215,22 @@ sd->alignmember(structalign, alignsize, &sd->structsize); // Add members to enclosing struct - for (i = 0; i < fields.dim; i++) + for (i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)fields.data[i]; + Dsymbol *s = (Dsymbol *)members->data[i]; VarDeclaration *vd = s->isVarDeclaration(); - if (vd) + if (vd && vd->storage_class & STCfield) { vd->addMember(sd); if (!sd->isUnionDeclaration()) vd->offset += sd->structsize; sd->fields.push(vd); + sd->members->push(s); + } + else if (!s->isAnonymous()) + { + sd->members->push(s); } - else - error("only fields allowed in anonymous struct"); } if (sd->isUnionDeclaration()) diff -uNr dmd-0.105/dmd/src/dmd/todt.c dmd-0.106/dmd/src/dmd/todt.c --- dmd-0.105/dmd/src/dmd/todt.c 2004-10-28 20:08:40.000000000 +0200 +++ dmd-0.106/dmd/src/dmd/todt.c 2004-11-04 21:02:12.000000000 +0100 @@ -641,7 +641,7 @@ VarDeclaration *v = (VarDeclaration *)fields.data[i]; Initializer *init; - //printf("\tmember '%s' voffset %d, offset = %d\n", v->toChars(), v->offset, offset); + //printf("\tfield '%s' voffset %d, offset = %d\n", v->toChars(), v->offset, offset); dt = NULL; init = v->init; if (init) diff -uNr dmd-0.105/dmd/src/dmd/toobj.c dmd-0.106/dmd/src/dmd/toobj.c --- dmd-0.105/dmd/src/dmd/toobj.c 2004-10-28 15:11:28.000000000 +0200 +++ dmd-0.106/dmd/src/dmd/toobj.c 2004-11-04 21:31:20.000000000 +0100 @@ -85,14 +85,10 @@ for (i = 0; i < members->dim; i++) { Dsymbol *member; - ClassDeclaration *cd; member = (Dsymbol *)members->data[i]; //printf("\tmember '%s'\n", member->toChars()); - if ((cd = member->isClassDeclaration()) != NULL) - { - aclasses.push(cd); - } + member->addLocalClass(&aclasses); } // importedModules[] diff -uNr dmd-0.105/dmd/src/dmd/typinf.c dmd-0.106/dmd/src/dmd/typinf.c --- dmd-0.105/dmd/src/dmd/typinf.c 2004-10-25 21:35:48.000000000 +0200 +++ dmd-0.106/dmd/src/dmd/typinf.c 2004-11-05 01:26:50.000000000 +0100 @@ -52,6 +52,7 @@ Type *t; static TypeInfoDeclaration *internalTI[TMAX]; + //printf("Type::getInternalTypeInfo() %s\n", toChars()); t = toBasetype(); switch (t->ty) { @@ -79,6 +80,7 @@ default: break; } + //printf("\tcalling getTypeInfo() %s\n", t->toChars()); return t->getTypeInfo(NULL); } @@ -91,7 +93,7 @@ { Expression *e; - //printf("Type::getTypeInfo()\n"); + //printf("Type::getTypeInfo() %s\n", toChars()); if (!vtinfo) { vtinfo = getTypeInfoDeclaration(); @@ -114,6 +116,7 @@ TypeInfoDeclaration *Type::getTypeInfoDeclaration() { + //printf("Type::getTypeInfoDeclaration() %s\n", toChars()); return new TypeInfoDeclaration(this, 0); } @@ -135,7 +138,7 @@ void TypeInfoDeclaration::toDt(dt_t **pdt) { - //printf("TypeInfoDeclaration::toDt()\n"); + //printf("TypeInfoDeclaration::toDt() %s\n", toChars()); dtxoff(pdt, Type::typeinfo->toVtblSymbol(), 0, TYnptr); // vtbl for TypeInfo dtdword(pdt, 0); // monitor } @@ -143,7 +146,7 @@ void TypeInfoTypedefDeclaration::toDt(dt_t **pdt) { //printf("TypeInfoTypedefDeclaration::toDt()\n"); - dtxoff(pdt, Type::typeinfotypedef->toVtblSymbol(), 0, TYnptr); // vtbl for TypeInfoTypedef + dtxoff(pdt, Type::typeinfotypedef->toVtblSymbol(), 0, TYnptr); // vtbl for TypeInfo_Typedef dtdword(pdt, 0); // monitor assert(tinfo->ty == Ttypedef); diff -uNr dmd-0.105/dmd/src/phobos/internal/critical.c dmd-0.106/dmd/src/phobos/internal/critical.c --- dmd-0.105/dmd/src/phobos/internal/critical.c 2004-10-29 12:07:36.000000000 +0200 +++ dmd-0.106/dmd/src/phobos/internal/critical.c 2004-11-09 00:34:20.000000000 +0100 @@ -75,6 +75,8 @@ #if linux +#include +#include #include /****************************************** @@ -97,8 +99,16 @@ static pthread_mutexattr_t _criticals_attr; static volatile int inited; +void _STI_critical_init(void); +void _STD_critical_term(void); + void _d_criticalenter(D_CRITICAL_SECTION *dcs) { + if (!inited) + { _STI_critical_init(); + atexit(_STD_critical_term); + } + //printf("_d_criticalenter(dcs = x%x)\n", dcs); if (!dcs->next) { pthread_mutex_lock(&critical_section.cs); @@ -121,7 +131,8 @@ void _STI_critical_init() { if (!inited) - { pthread_mutexattr_init(&_criticals_attr); + { //printf("_STI_critical_init()\n"); + pthread_mutexattr_init(&_criticals_attr); pthread_mutexattr_settype(&_criticals_attr, PTHREAD_MUTEX_RECURSIVE_NP); // The global critical section doesn't need to be recursive @@ -133,7 +144,8 @@ void _STD_critical_term() { if (inited) - { inited = 0; + { //printf("_STI_critical_term()\n"); + inited = 0; while (dcs_list) { pthread_mutex_destroy(&dcs_list->cs); diff -uNr dmd-0.105/dmd/src/phobos/internal/object.d dmd-0.106/dmd/src/phobos/internal/object.d --- dmd-0.105/dmd/src/phobos/internal/object.d 2004-10-29 12:07:36.000000000 +0200 +++ dmd-0.106/dmd/src/phobos/internal/object.d 2004-11-09 00:34:20.000000000 +0100 @@ -114,7 +114,7 @@ } } -class TypeInfoTypedef : TypeInfo +class TypeInfo_Typedef : TypeInfo { uint getHash(void *p) { return base.getHash(p); } int equals(void *p1, void *p2) { return base.equals(p1, p2); } @@ -125,7 +125,7 @@ TypeInfo base; } -class TypeInfoClass : TypeInfo +class TypeInfo_Class : TypeInfo { char[] toString() { return info.name; } diff -uNr dmd-0.105/dmd/src/phobos/object.d dmd-0.106/dmd/src/phobos/object.d --- dmd-0.105/dmd/src/phobos/object.d 2004-10-29 12:07:34.000000000 +0200 +++ dmd-0.106/dmd/src/phobos/object.d 2004-11-09 00:34:18.000000000 +0100 @@ -60,12 +60,12 @@ void swap(void *p1, void *p2); } -class TypeInfoTypedef : TypeInfo +class TypeInfo_Typedef : TypeInfo { TypeInfo base; } -class TypeInfoClass : TypeInfo +class TypeInfo_Class : TypeInfo { ClassInfo info; } diff -uNr dmd-0.105/dmd/src/phobos/std/array.d dmd-0.106/dmd/src/phobos/std/array.d --- dmd-0.105/dmd/src/phobos/std/array.d 2004-10-29 12:07:36.000000000 +0200 +++ dmd-0.106/dmd/src/phobos/std/array.d 2004-11-09 00:34:18.000000000 +0100 @@ -10,6 +10,7 @@ uint linnum; char[] filename; + public: this(char[] filename, uint linnum) { this.linnum = linnum; diff -uNr dmd-0.105/dmd/src/phobos/std/c/time.d dmd-0.106/dmd/src/phobos/std/c/time.d --- dmd-0.105/dmd/src/phobos/std/c/time.d 2004-10-29 12:07:36.000000000 +0200 +++ dmd-0.106/dmd/src/phobos/std/c/time.d 2004-11-09 00:34:18.000000000 +0100 @@ -8,7 +8,21 @@ extern (C): -const uint CLOCKS_PER_SEC = 1000; +version (Windows) +{ const uint CLOCKS_PER_SEC = 1000; +} +else version (linux) +{ const uint CLOCKS_PER_SEC = 1000000; +} +else version (darwin) +{ + const uint CLOCKS_PER_SEC = 100; +} +else +{ + static assert(0); +} + const uint CLK_TCK = 1000; const uint TIMEOFFSET = 315558000; diff -uNr dmd-0.105/dmd/src/phobos/std/format.d dmd-0.106/dmd/src/phobos/std/format.d --- dmd-0.105/dmd/src/phobos/std/format.d 2004-10-29 12:07:36.000000000 +0200 +++ dmd-0.106/dmd/src/phobos/std/format.d 2004-11-09 00:34:18.000000000 +0100 @@ -409,6 +409,12 @@ } return; + case Mangle.Ttypedef: + ti = (cast(TypeInfo_Typedef)ti).base; + m = cast(Mangle)ti.classinfo.name[9]; + formatArg(fc); + return; + default: goto Lerror; } @@ -468,36 +474,35 @@ !(fc == 'o' && flags & FLhash)) { putstr(null); + return; } - else + if (vnumber < base) { vchar = '0' + vnumber; goto L2; } } - else - { - int n = tmpbuf.length; - char c; - int hexoffset = uc ? ('A' - ('9' + 1)) : ('a' - ('9' + 1)); - while (vnumber) - { - c = (vnumber % base) + '0'; - if (c > '9') - c += hexoffset; - vnumber /= base; - tmpbuf[--n] = c; - } - if (tmpbuf.length - n < precision && precision < tmpbuf.length) - { - int m = tmpbuf.length - precision; - tmpbuf[m .. n] = '0'; - n = m; - } - else if (flags & FLhash && fc == 'o') - prefix = "0"; - putstr(tmpbuf[n .. tmpbuf.length]); + int n = tmpbuf.length; + char c; + int hexoffset = uc ? ('A' - ('9' + 1)) : ('a' - ('9' + 1)); + + while (vnumber) + { + c = (vnumber % base) + '0'; + if (c > '9') + c += hexoffset; + vnumber /= base; + tmpbuf[--n] = c; + } + if (tmpbuf.length - n < precision && precision < tmpbuf.length) + { + int m = tmpbuf.length - precision; + tmpbuf[m .. n] = '0'; + n = m; } + else if (flags & FLhash && fc == 'o') + prefix = "0"; + putstr(tmpbuf[n .. tmpbuf.length]); return; Lreal: diff -uNr dmd-0.105/dmd/src/phobos/std/process.d dmd-0.106/dmd/src/phobos/std/process.d --- dmd-0.105/dmd/src/phobos/std/process.d 2004-10-29 12:07:36.000000000 +0200 +++ dmd-0.106/dmd/src/phobos/std/process.d 2004-11-09 00:34:18.000000000 +0100 @@ -3,6 +3,10 @@ * Copyright (C) 2003-2004 by Digital Mars, www.digitalmars.com * Written by Matthew Wilson and Walter Bright * + * Incorporating idea (for execvpe() on Linux) from Russ Lewis + * + * Updated: 21st August 2004 + * * 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. @@ -37,7 +41,7 @@ { foreach(char[] s; a) { - *az++ = toStringz(s); + *az++ = toStringz(s); } *az = null; } @@ -47,6 +51,7 @@ char** argv_ = cast(char**)alloca((char*).sizeof * (1 + argv.length)); toAStringz(argv, argv_); + return std.c.process.execv(toStringz(pathname), argv_); } @@ -55,27 +60,70 @@ char** argv_ = cast(char**)alloca((char*).sizeof * (1 + argv.length)); char** envp_ = cast(char**)alloca((char*).sizeof * (1 + envp.length)); - toAStringz(argv, argv_); toAStringz(envp, envp_); + return std.c.process.execve(toStringz(pathname), argv_, envp_); } int execvp(char[] pathname, char[][] argv) { char** argv_ = cast(char**)alloca((char*).sizeof * (1 + argv.length)); + toAStringz(argv, argv_); + return std.c.process.execvp(toStringz(pathname), argv_); } int execvpe(char[] pathname, char[][] argv, char[][] envp) { +version(linux) +{ + // Is pathname rooted? + if(pathname[0] == '/') + { + // Yes, so just call execve() + return execve(pathname, argv, envp); + } + else + { + // No, so must traverse PATHs, looking for first match + char[][] envPaths = std.string.split(std.string.toString(std.c.stdlib.getenv("PATH")), ":"); + int iRet = 0; + + // Note: if any call to execve() succeeds, this process will cease + // execution, so there's no need to check the execve() result through + // the loop. + + foreach(char[] pathDir; envPaths) + { + char[] composite = pathDir ~ "/" ~ pathname; + + iRet = execve(composite, argv, envp); + } + if(0 != iRet) + { + iRet = execve(pathname, argv, envp); + } + + return iRet; + } +} +else version(Windows) +{ char** argv_ = cast(char**)alloca((char*).sizeof * (1 + argv.length)); char** envp_ = cast(char**)alloca((char*).sizeof * (1 + envp.length)); + toAStringz(argv, argv_); toAStringz(envp, envp_); + return std.c.process.execvpe(toStringz(pathname), argv_, envp_); } +else +{ + static assert(0); +} // version +} /* ////////////////////////////////////////////////////////////////////////// */ @@ -83,11 +131,35 @@ { int main(char[][] args) { -// int i = execv(args[1], args[2 .. args.length]); - int i = execvp(args[1], args[2 .. args.length]); + if(args.length < 2) + { + printf("Must supply executable (and optional arguments)\n"); + + return 1; + } + else + { + char[][] dummy_env; + + dummy_env ~= "VAL0=value"; + dummy_env ~= "VAL1=value"; + +/+ + foreach(char[] arg; args) + { + printf("%.*s\n", arg); + } ++/ + +// int i = execv(args[1], args[1 .. args.length]); +// int i = execvp(args[1], args[1 .. args.length]); + int i = execvpe(args[1], args[1 .. args.length], dummy_env); - printf("exec??() has returned! Error code: %d; errno: %d\n", i, /* errno */0); + printf("exec??() has returned! Error code: %d; errno: %d\n", i, /* std.c.stdlib.getErrno() */-1); - return 0; + return 0; + } } } + +/* ////////////////////////////////////////////////////////////////////////// */ diff -uNr dmd-0.105/dmd/src/phobos/std/recls.d dmd-0.106/dmd/src/phobos/std/recls.d --- dmd-0.105/dmd/src/phobos/std/recls.d 2004-10-29 12:07:36.000000000 +0200 +++ dmd-0.106/dmd/src/phobos/std/recls.d 2004-11-09 00:34:18.000000000 +0100 @@ -606,7 +606,7 @@ public: class Enumerator { - private: + public: this(hrecls_t hSrch, recls_rc_t lastError) { m_hSrch = hSrch;