diff -uNr dmd-0.116/dmd/src/dmd/aggregate.h dmd-0.117/dmd/src/dmd/aggregate.h --- dmd-0.116/dmd/src/dmd/aggregate.h 2004-12-30 00:15:36.000000000 +0100 +++ dmd-0.117/dmd/src/dmd/aggregate.h 2005-03-10 09:34:22.000000000 +0100 @@ -45,6 +45,7 @@ // 0: no size // 1: size is correct // 2: cannot determine size; fwd referenced + int isdeprecated; // !=0 if deprecated Scope *scope; // !=NULL means context to use // Special member functions @@ -61,6 +62,7 @@ static void alignmember(unsigned salign, unsigned size, unsigned *poffset); Type *getType(); void addField(Scope *sc, VarDeclaration *v); + int isDeprecated(); // is aggregate deprecated? // Back end Symbol *stag; // tag symbol for debug data @@ -154,6 +156,7 @@ ClassInfoDeclaration *vclassinfo; // the ClassInfo object for this ClassDeclaration int com; // !=0 if this is a COM class int isauto; // !=0 if this is an auto class + int isabstract; // !=0 if abstract class ClassDeclaration(Loc loc, Identifier *id, Array *baseclasses); Dsymbol *syntaxCopy(Dsymbol *s); diff -uNr dmd-0.116/dmd/src/dmd/attrib.c dmd-0.117/dmd/src/dmd/attrib.c --- dmd-0.116/dmd/src/dmd/attrib.c 2005-01-12 02:45:18.000000000 +0100 +++ dmd-0.117/dmd/src/dmd/attrib.c 2005-03-08 21:59:56.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 @@ -11,6 +11,12 @@ #include #include +#if _WIN32 +#include "mem.h" +#elif linux +#include "../root/mem.h" +#endif + #include "declaration.h" #include "init.h" #include "attrib.h" @@ -20,6 +26,7 @@ #include "expression.h" #include "dsymbol.h" +extern void obj_includelib(char *name); /********************************* AttribDeclaration ****************************/ @@ -588,6 +595,20 @@ printf("\n"); } } + else if (ident == Id::lib) + { + if (!args || args->dim != 1) + error("string argument expected for pragma(lib, \"libname\")"); + else + { + Expression *e = (Expression *)args->data[0]; + + e = e->semantic(sc); + args->data[0] = (void *)e; + if (e->op != TOKstring) + error("string expected for pragma msg, not '%s'", e->toChars()); + } + } else error("unrecognized pragma(%s)", ident->toChars()); @@ -602,6 +623,23 @@ } } +void PragmaDeclaration::toObjFile() +{ + if (ident == Id::lib) + { + assert(args && args->dim == 1); + + Expression *e = (Expression *)args->data[0]; + + assert(e->op == TOKstring); + + StringExp *se = (StringExp *)e; + char *name = (char *)mem.malloc(se->len + 1); + memcpy(name, se->string, se->len); + name[se->len] = 0; + obj_includelib(name); + } +} void PragmaDeclaration::toCBuffer(OutBuffer *buf) { diff -uNr dmd-0.116/dmd/src/dmd/attrib.h dmd-0.117/dmd/src/dmd/attrib.h --- dmd-0.116/dmd/src/dmd/attrib.h 2004-12-03 01:43:24.000000000 +0100 +++ dmd-0.117/dmd/src/dmd/attrib.h 2005-03-08 21:58:04.000000000 +0100 @@ -106,6 +106,7 @@ Dsymbol *syntaxCopy(Dsymbol *s); void semantic(Scope *sc); void toCBuffer(OutBuffer *buf); + void toObjFile(); // compile to .obj file }; struct DebugDeclaration : AttribDeclaration diff -uNr dmd-0.116/dmd/src/dmd/class.c dmd-0.117/dmd/src/dmd/class.c --- dmd-0.116/dmd/src/dmd/class.c 2005-02-12 02:38:22.000000000 +0100 +++ dmd-0.117/dmd/src/dmd/class.c 2005-03-10 09:32:48.000000000 +0100 @@ -87,6 +87,7 @@ com = 1; #endif isauto = 0; + isabstract = 0; } Dsymbol *ClassDeclaration::syntaxCopy(Dsymbol *s) @@ -116,11 +117,16 @@ unsigned offset; //printf("ClassDeclaration::semantic(%s), type = %p, sizeok = %d\n", toChars(), type, sizeok); + //printf("parent = %p, '%s'\n", sc->parent, sc->parent ? sc->parent->toChars() : ""); //{ static int n; if (++n == 20) *(char*)0=0; } if (!scope) - { type = type->semantic(loc, sc); + { + if (sc->parent && !sc->parent->isModule()) + parent = sc->parent; + + type = type->semantic(loc, sc); handle = handle->semantic(loc, sc); } if (!members) // if forward reference @@ -279,9 +285,13 @@ if (sc->stc & STCauto) isauto = 1; + if (sc->stc & STCabstract) + isabstract = 1; + if (sc->stc & STCdeprecated) + isdeprecated = 1; sc = sc->push(this); - sc->stc &= ~(STCauto | STCstatic); + sc->stc &= ~(STCauto | STCstatic | STCabstract); sc->parent = this; if (isCOMclass()) @@ -567,6 +577,8 @@ int ClassDeclaration::isAbstract() { + if (isabstract) + return TRUE; for (int i = 1; i < vtbl.dim; i++) { FuncDeclaration *fd = ((Dsymbol *)vtbl.data[i])->isFuncDeclaration(); @@ -574,6 +586,7 @@ //printf("\tvtbl[%d] = %p\n", i, fd); if (!fd || fd->isAbstract()) { + isabstract |= 1; return TRUE; } } diff -uNr dmd-0.116/dmd/src/dmd/debcond.c dmd-0.117/dmd/src/dmd/debcond.c --- dmd-0.116/dmd/src/dmd/debcond.c 2004-11-03 15:44:36.000000000 +0100 +++ dmd-0.117/dmd/src/dmd/debcond.c 2005-03-09 19:03:04.000000000 +0100 @@ -116,6 +116,7 @@ "Windows", "Win32", "Win64", "linux", "LittleEndian", "BigEndian", + "all", "none", }; diff -uNr dmd-0.116/dmd/src/dmd/declaration.c dmd-0.117/dmd/src/dmd/declaration.c --- dmd-0.116/dmd/src/dmd/declaration.c 2005-02-27 19:43:54.000000000 +0100 +++ dmd-0.117/dmd/src/dmd/declaration.c 2005-03-10 15:59:24.000000000 +0100 @@ -198,6 +198,8 @@ } this->inSemantic = 1; + storage_class |= sc->stc & STCdeprecated; + // Given: // alias foo.bar.abc def; // it is not knowable from the syntax whether this is an alias diff -uNr dmd-0.116/dmd/src/dmd/declaration.h dmd-0.117/dmd/src/dmd/declaration.h --- dmd-0.116/dmd/src/dmd/declaration.h 2005-02-27 19:15:50.000000000 +0100 +++ dmd-0.117/dmd/src/dmd/declaration.h 2005-03-10 01:20:56.000000000 +0100 @@ -331,6 +331,7 @@ FuncAliasDeclaration(FuncDeclaration *funcalias); FuncAliasDeclaration *isFuncAliasDeclaration() { return this; } + char *kind(); }; struct FuncLiteralDeclaration : FuncDeclaration @@ -339,6 +340,7 @@ FuncLiteralDeclaration(Loc loc, Loc endloc, Type *type, enum TOK tok, ForeachStatement *fes); + Dsymbol *syntaxCopy(Dsymbol *); int isNested(); FuncLiteralDeclaration *isFuncLiteralDeclaration() { return this; } diff -uNr dmd-0.116/dmd/src/dmd/expression.c dmd-0.117/dmd/src/dmd/expression.c --- dmd-0.116/dmd/src/dmd/expression.c 2005-03-07 12:16:02.000000000 +0100 +++ dmd-0.117/dmd/src/dmd/expression.c 2005-03-10 16:00:40.000000000 +0100 @@ -1027,6 +1027,8 @@ //printf("DsymbolExp:: '%s' is a symbol\n", toChars()); //printf("s = '%s', s->kind = '%s'\n", s->toChars(), s->kind()); + if (!s->isFuncDeclaration()) // functions are checked after overloading + checkDeprecated(sc, s); s = s->toAlias(); //printf("s = '%s', s->kind = '%s'\n", s->toChars(), s->kind()); if (!s->isFuncDeclaration()) @@ -1035,6 +1037,7 @@ if (sc->func) thiscd = sc->func->parent->isClassDeclaration(); + // This should happen after overload resolution for functions, not before if (s->needThis() && hasThis(sc)) { // Supply an implicit 'this', as in @@ -1668,11 +1671,13 @@ error("cannot create instance of interface %s", cd->toChars()); if (cd->isAbstract()) error("cannot create instance of abstract class %s", cd->toChars()); + checkDeprecated(sc, cd); f = cd->ctor; if (f) { assert(f); f = f->overloadResolve(loc, arguments); + checkDeprecated(sc, f); member = f->isCtorDeclaration(); assert(member); @@ -1943,6 +1948,11 @@ this->fd = fd; } +Expression *FuncExp::syntaxCopy() +{ + return new FuncExp(loc, (FuncLiteralDeclaration *)fd->syntaxCopy(NULL)); +} + Expression *FuncExp::semantic(Scope *sc) { #if LOGSEMANTIC @@ -2941,6 +2951,7 @@ sc->callSuper |= CSXany_ctor | CSXsuper_ctor; f = f->overloadResolve(loc, arguments); + checkDeprecated(sc, f); e1 = new DotVarExp(e1->loc, e1, f); e1 = e1->semantic(sc); t1 = e1->type; @@ -2974,6 +2985,7 @@ f = cd->ctor; f = f->overloadResolve(loc, arguments); + checkDeprecated(sc, f); e1 = new DotVarExp(e1->loc, e1, f); e1 = e1->semantic(sc); t1 = e1->type; diff -uNr dmd-0.116/dmd/src/dmd/expression.h dmd-0.117/dmd/src/dmd/expression.h --- dmd-0.116/dmd/src/dmd/expression.h 2005-03-07 12:22:28.000000000 +0100 +++ dmd-0.117/dmd/src/dmd/expression.h 2005-03-10 01:16:08.000000000 +0100 @@ -356,6 +356,7 @@ Expression *toLvalue(Expression *e); Expression *modifiableLvalue(Scope *sc, Expression *e); elem *toElem(IRState *irs); + dt_t **toDt(dt_t **pdt); //int inlineCost(InlineCostState *ics); Expression *doInline(InlineDoState *ids); @@ -369,6 +370,7 @@ FuncLiteralDeclaration *fd; FuncExp(Loc loc, FuncLiteralDeclaration *fd); + Expression *syntaxCopy(); Expression *semantic(Scope *sc); char *toChars(); void toCBuffer(OutBuffer *buf); diff -uNr dmd-0.116/dmd/src/dmd/func.c dmd-0.117/dmd/src/dmd/func.c --- dmd-0.116/dmd/src/dmd/func.c 2005-03-07 14:52:12.000000000 +0100 +++ dmd-0.117/dmd/src/dmd/func.c 2005-03-10 09:58:30.000000000 +0100 @@ -63,6 +63,7 @@ { FuncDeclaration *f; + //printf("FuncDeclaration::syntaxCopy('%s')\n", toChars()); if (s) f = (FuncDeclaration *)s; else @@ -109,6 +110,8 @@ if (isConst() || isAuto()) error("functions cannot be const or auto"); + if (isAbstract() && !isVirtual()) + error("non-virtual functions cannot be abstract"); #if 0 if (isAbstract() && fbody) error("abstract functions cannot have bodies"); @@ -587,7 +590,9 @@ ClassDeclaration *cd = isClassMember(); //printf("callSuper = x%x\n", sc2->callSuper); - if (!(sc2->callSuper & CSXany_ctor) && + assert(cd || global.errors); + + if (cd && !(sc2->callSuper & CSXany_ctor) && cd->baseClass && cd->baseClass->ctor) { sc2->callSuper = 0; @@ -1181,6 +1186,8 @@ //printf("FuncDeclaration::needThis() '%s'\n", toChars()); int i = isThis() != NULL; //printf("\t%d\n", i); + if (!i && isFuncAliasDeclaration()) + i = ((FuncAliasDeclaration *)this)->funcalias->needThis(); return i; } @@ -1259,6 +1266,11 @@ this->funcalias = funcalias; } +char *FuncAliasDeclaration::kind() +{ + return "function alias"; +} + /****************************** FuncLiteralDeclaration ************************/ @@ -1277,6 +1289,20 @@ this->ident = Identifier::generateId(id); this->tok = tok; this->fes = fes; + //printf("FuncLiteralDeclaration() id = '%s', type = '%s'\n", this->ident->toChars(), type->toChars()); +} + +Dsymbol *FuncLiteralDeclaration::syntaxCopy(Dsymbol *s) +{ + FuncLiteralDeclaration *f; + + //printf("FuncLiteralDeclaration::syntaxCopy('%s')\n", toChars()); + if (s) + f = (FuncLiteralDeclaration *)s; + else + f = new FuncLiteralDeclaration(loc, endloc, type->syntaxCopy(), tok, fes); + FuncDeclaration::syntaxCopy(f); + return f; } int FuncLiteralDeclaration::isNested() diff -uNr dmd-0.116/dmd/src/dmd/idgen.c dmd-0.117/dmd/src/dmd/idgen.c --- dmd-0.116/dmd/src/dmd/idgen.c 2005-03-07 12:09:02.000000000 +0100 +++ dmd-0.117/dmd/src/dmd/idgen.c 2005-03-08 11:39:10.000000000 +0100 @@ -162,6 +162,7 @@ { "apply", "opApply" }, // For pragma's + { "lib" }, { "msg" }, // For toHash diff -uNr dmd-0.116/dmd/src/dmd/lexer.c dmd-0.117/dmd/src/dmd/lexer.c --- dmd-0.116/dmd/src/dmd/lexer.c 2005-03-07 14:35:16.000000000 +0100 +++ dmd-0.117/dmd/src/dmd/lexer.c 2005-03-11 12:44:50.000000000 +0100 @@ -1367,6 +1367,7 @@ case 'x': state = STATE_hex0; break; + case '.': if (p[1] == '.') // .. is a separate token goto done; @@ -1728,6 +1729,7 @@ { // Get next char from input c = *p++; + //printf("dblstate = %d, c = '%c'\n", dblstate, c); while (1) { switch (dblstate) @@ -1735,6 +1737,8 @@ case 0: // opening state if (c == '0') dblstate = 9; + else if (c == '.') + dblstate = 3; else dblstate = 1; break; @@ -1804,7 +1808,7 @@ { case 'F': case 'f': -#if __GNUC__ +#if 0 t->float80value = strtod((char *)stringbuffer.data, NULL); #else t->float80value = strtof((char *)stringbuffer.data, NULL); @@ -1848,10 +1852,8 @@ #if _WIN32 && __DMC__ __locale_decpoint = save; #endif -#if !__GNUC__ if (errno == ERANGE) error("number is not representable"); -#endif return result; } @@ -2034,6 +2036,8 @@ { "uint", TOKuns32 }, { "long", TOKint64 }, { "ulong", TOKuns64 }, + { "cent", TOKcent, }, + { "ucent", TOKucent, }, { "float", TOKfloat32 }, { "double", TOKfloat64 }, { "real", TOKfloat80 }, diff -uNr dmd-0.116/dmd/src/dmd/lexer.h dmd-0.117/dmd/src/dmd/lexer.h --- dmd-0.116/dmd/src/dmd/lexer.h 2004-08-30 01:08:24.000000000 +0200 +++ dmd-0.117/dmd/src/dmd/lexer.h 2005-03-09 18:06:18.000000000 +0100 @@ -113,6 +113,7 @@ TOKimaginary32, TOKimaginary64, TOKimaginary80, TOKcomplex32, TOKcomplex64, TOKcomplex80, TOKchar, TOKwchar, TOKdchar, TOKbit, + TOKcent, TOKucent, // Aggregates TOKstruct, TOKclass, TOKinterface, TOKunion, TOKenum, TOKimport, diff -uNr dmd-0.116/dmd/src/dmd/mars.c dmd-0.117/dmd/src/dmd/mars.c --- dmd-0.116/dmd/src/dmd/mars.c 2005-03-03 16:26:08.000000000 +0100 +++ dmd-0.117/dmd/src/dmd/mars.c 2005-03-07 22:33:28.000000000 +0100 @@ -49,7 +49,7 @@ copyright = "Copyright (c) 1999-2005 by Digital Mars"; written = "written by Walter Bright"; - version = "v0.116"; + version = "v0.117"; global.structalign = 8; memset(¶ms, 0, sizeof(Param)); diff -uNr dmd-0.116/dmd/src/dmd/parse.c dmd-0.117/dmd/src/dmd/parse.c --- dmd-0.116/dmd/src/dmd/parse.c 2005-03-07 12:24:44.000000000 +0100 +++ dmd-0.117/dmd/src/dmd/parse.c 2005-03-09 10:17:34.000000000 +0100 @@ -3202,8 +3202,10 @@ Token *t = *pt; int tmp; + //printf("isParameters()\n"); if (t->value != TOKlparen) return FALSE; + t = peek(t); while (1) { @@ -3226,6 +3228,12 @@ tmp = FALSE; if (!isDeclarator(&t, &tmp, TOKreserved)) return FALSE; + if (t->value == TOKassign) + { t = peek(t); + if (!isExpression(&t)) + return FALSE; + continue; + } if (t->value == TOKcomma) { t = peek(t); continue; @@ -3263,6 +3271,12 @@ continue; break; + case TOKcomma: + case TOKrparen: + if (nest) + continue; + break; + case TOKeof: return FALSE; diff -uNr dmd-0.116/dmd/src/dmd/statement.c dmd-0.117/dmd/src/dmd/statement.c --- dmd-0.116/dmd/src/dmd/statement.c 2005-03-05 15:51:12.000000000 +0100 +++ dmd-0.117/dmd/src/dmd/statement.c 2005-03-11 13:26:06.000000000 +0100 @@ -717,7 +717,7 @@ } var->semantic(sc); if (!sc->insert(var)) - assert(0); + error("%s already defined", var->ident->toChars()); if (dim == 2 && i == 0) key = var; @@ -1000,6 +1000,10 @@ // semantic analysis of the skipped code. // This feature allows a limited form of conditional compilation. condition = condition->optimize(WANTflags); +#if 0 + /* Don't do this because of: + * if (0) { Label: ... ; } else { ... ; goto Label; } + */ if (condition->isBool(FALSE)) { Statement *s; @@ -1019,6 +1023,7 @@ return s; } else +#endif { // Evaluate at runtime unsigned cs0 = sc->callSuper; unsigned cs1; @@ -1040,10 +1045,10 @@ int IfStatement::fallOffEnd() { - if ((!ifbody || !ifbody->fallOffEnd()) && - (!elsebody || !elsebody->fallOffEnd())) - return FALSE; - return TRUE; + if (!ifbody || ifbody->fallOffEnd() || + !elsebody || elsebody->fallOffEnd()) + return TRUE; + return FALSE; } @@ -1266,21 +1271,25 @@ break; } - for (int j = 0; 1; j++) + for (Scope *scx = sc; scx; scx = scx->enclosing) { - if (j == cases->dim) + if (!scx->sw) + continue; + for (int j = 0; j < scx->sw->cases->dim; j++) { - gcs->error("case %s not found", gcs->exp->toChars()); - break; - } - CaseStatement *cs = (CaseStatement *)cases->data[j]; + CaseStatement *cs = (CaseStatement *)scx->sw->cases->data[j]; - if (cs->exp->equals(gcs->exp)) - { - gcs->cs = cs; - break; + if (cs->exp->equals(gcs->exp)) + { + gcs->cs = cs; + goto Lfoundcase; + } } } + gcs->error("case %s not found", gcs->exp->toChars()); + + Lfoundcase: + ; } if (!sc->sw->sdefault) @@ -2050,13 +2059,17 @@ int TryCatchStatement::fallOffEnd() { + int result = FALSE; + + if (body) + result = body->fallOffEnd(); for (int i = 0; i < catches->dim; i++) { Catch *c; c = (Catch *)catches->data[i]; - c->handler->fallOffEnd(); + result |= c->handler->fallOffEnd(); } - return body->fallOffEnd(); + return result; } /******************************** Catch ***************************/ diff -uNr dmd-0.116/dmd/src/dmd/struct.c dmd-0.117/dmd/src/dmd/struct.c --- dmd-0.116/dmd/src/dmd/struct.c 2005-02-10 13:46:00.000000000 +0100 +++ dmd-0.117/dmd/src/dmd/struct.c 2005-03-10 09:34:26.000000000 +0100 @@ -29,6 +29,7 @@ alignsize = 0; // size of struct for alignment purposes structalign = 0; // struct member alignment in effect sizeok = 0; // size not determined yet + isdeprecated = 0; inv = NULL; aggNew = NULL; aggDelete = NULL; @@ -102,6 +103,10 @@ return type; } +int AggregateDeclaration::isDeprecated() +{ + return isdeprecated; +} /**************************** * Do byte or word alignment as necessary. diff -uNr dmd-0.116/dmd/src/dmd/template.c dmd-0.117/dmd/src/dmd/template.c --- dmd-0.116/dmd/src/dmd/template.c 2005-02-27 18:19:32.000000000 +0100 +++ dmd-0.117/dmd/src/dmd/template.c 2005-03-10 00:57:04.000000000 +0100 @@ -1333,7 +1333,7 @@ { Array *a; int i; - if (sc->scopesym && sc->scopesym->members) + if (sc->scopesym && sc->scopesym->members && !sc->scopesym->isTemplateMixin()) { //printf("\t1: adding to %s %s\n", sc->scopesym->kind(), sc->scopesym->toChars()); a = sc->scopesym->members; @@ -1803,7 +1803,7 @@ { int i; #if LOG - printf("TemplateInstance::toObjFile('%s')\n", toChars()); + printf("TemplateInstance::toObjFile('%s', this = %p)\n", toChars(), this); #endif if (members) { @@ -2250,6 +2250,7 @@ void TemplateMixin::toObjFile() { + //printf("TemplateMixin::toObjFile('%s')\n", toChars()); TemplateInstance::toObjFile(); } diff -uNr dmd-0.116/dmd/src/dmd/todt.c dmd-0.117/dmd/src/dmd/todt.c --- dmd-0.116/dmd/src/dmd/todt.c 2005-02-10 12:16:50.000000000 +0100 +++ dmd-0.117/dmd/src/dmd/todt.c 2005-03-09 22:15:46.000000000 +0100 @@ -528,6 +528,23 @@ return dtxoff(pdt, s, offset, TYnptr); } +dt_t **VarExp::toDt(dt_t **pdt) +{ + //printf("VarExp::toDt() %d\n", op); + VarDeclaration *v = var->isVarDeclaration(); + if (v && v->isConst() && type->toBasetype()->ty != Tsarray && v->init) + { dt_t **pdtend; + + for (pdtend = pdt; *pdtend; pdtend = &((*pdtend)->DTnext)) + ; + *pdtend = v->init->toDt(); + return pdt; + } + error("non-constant expression %s", toChars()); + pdt = dtnzeros(pdt, 1); + return pdt; +} + /* ================================================================= */ // Generate the data for the static initializer. diff -uNr dmd-0.116/dmd/src/phobos/std/c/stdio.d dmd-0.117/dmd/src/phobos/std/c/stdio.d --- dmd-0.116/dmd/src/phobos/std/c/stdio.d 2005-03-07 16:13:42.000000000 +0100 +++ dmd-0.117/dmd/src/phobos/std/c/stdio.d 2005-03-11 19:16:12.000000000 +0100 @@ -246,7 +246,7 @@ int fputws(wchar_t *, FILE *); wchar_t * _getws(wchar_t *); int _putws(wchar_t *); -//int wprintf(wchar_t *, ...); +int wprintf(wchar_t *, ...); int fwprintf(FILE *, wchar_t *, ...); int vwprintf(wchar_t *, va_list); int vfwprintf(FILE *, wchar_t *, va_list); diff -uNr dmd-0.116/dmd/src/phobos/std/c/windows/windows.d dmd-0.117/dmd/src/phobos/std/c/windows/windows.d --- dmd-0.116/dmd/src/phobos/std/c/windows/windows.d 2005-03-07 16:13:42.000000000 +0100 +++ dmd-0.117/dmd/src/phobos/std/c/windows/windows.d 2005-03-11 19:16:14.000000000 +0100 @@ -357,6 +357,8 @@ DWORD GetFileAttributesA(char *lpFileName); DWORD GetFileAttributesW(wchar *lpFileName); DWORD GetFileSize(HANDLE hFile, DWORD *lpFileSizeHigh); +BOOL CopyFileA(LPCSTR lpExistingFileName, LPCSTR lpNewFileName, BOOL bFailIfExists); +BOOL CopyFileW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, BOOL bFailIfExists); BOOL MoveFileA(char *from, char *to); BOOL MoveFileW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName); BOOL ReadFile(HANDLE hFile, void *lpBuffer, DWORD nNumberOfBytesToRead, diff -uNr dmd-0.116/dmd/src/phobos/std/file.d dmd-0.117/dmd/src/phobos/std/file.d --- dmd-0.116/dmd/src/phobos/std/file.d 2005-03-07 16:13:40.000000000 +0100 +++ dmd-0.117/dmd/src/phobos/std/file.d 2005-03-11 19:16:12.000000000 +0100 @@ -536,6 +536,24 @@ return std.string.toStringz(s); } + +/*************************************************** + * Copy a file. + */ + +void copy(char[] from, char[] to) +{ + BOOL result; + + if (useWfuncs) + result = CopyFileW(std.utf.toUTF16z(from), std.utf.toUTF16z(to), false); + else + result = CopyFileA(toMBSz(from), toMBSz(to), false); + if (!result) + throw new FileException(to, GetLastError()); +} + + } /* =========================== linux ======================= */ @@ -886,8 +904,6 @@ } } -} - /*************************************************** * Copy a file. */ @@ -898,6 +914,7 @@ /* If the file is very large, this won't work, but * it's a good start. + * BUG: it should maintain the file timestamps */ buffer = read(from); write(to, buffer); @@ -906,3 +923,5 @@ +} + diff -uNr dmd-0.116/dmd/src/phobos/std/string.d dmd-0.117/dmd/src/phobos/std/string.d --- dmd-0.116/dmd/src/phobos/std/string.d 2005-03-07 16:13:40.000000000 +0100 +++ dmd-0.117/dmd/src/phobos/std/string.d 2005-03-11 19:16:12.000000000 +0100 @@ -1456,7 +1456,7 @@ for (i = 0; i < s.length; i++) { - if (!iswhite(s[i])) + if (!std.ctype.isspace(s[i])) break; } return s[i .. s.length]; @@ -1468,7 +1468,7 @@ for (i = s.length; i > 0; i--) { - if (!iswhite(s[i - 1])) + if (!std.ctype.isspace(s[i - 1])) break; } return s[0 .. i];