diff --git a/cgi.d b/cgi.d index 50d1e83..e12314d 100644 --- a/cgi.d +++ b/cgi.d @@ -496,7 +496,7 @@ class Cgi { flushDelegate = _flush; auto getenv = delegate string(string var) { if(env is null) - return .getenv(var); + return std.process.environment.get(var); auto e = var in env; if(e is null) return null; diff --git a/color.d b/color.d index 8da2949..44b4e9d 100644 --- a/color.d +++ b/color.d @@ -887,7 +887,12 @@ body { sorted ~= ColorUse(color, count); uses = null; - sorted = sorted.sort; + version(no_phobos) + sorted = sorted.sort; + else { + import std.algorithm : sort; + sort(sorted); + } ubyte[Color] paletteAssignments; foreach(idx, entry; palette) diff --git a/htmltotext.d b/htmltotext.d index 9e03ec2..fbb6ffa 100644 --- a/htmltotext.d +++ b/htmltotext.d @@ -48,33 +48,27 @@ string htmlToText(string html, bool wantWordWrap = true, int wrapAmount = 74) { ele.innerText = "*" ~ ele.innerText ~ "*"; ele.stripOut(); goto again; - break; case "i": case "em": ele.innerText = "/" ~ ele.innerText ~ "/"; ele.stripOut(); goto again; - break; case "u": ele.innerText = "_" ~ ele.innerText ~ "_"; ele.stripOut(); goto again; - break; case "h1": ele.innerText = "\r" ~ ele.innerText ~ "\n" ~ repeat("=", ele.innerText.length) ~ "\r"; ele.stripOut(); goto again; - break; case "h2": ele.innerText = "\r" ~ ele.innerText ~ "\n" ~ repeat("-", ele.innerText.length) ~ "\r"; ele.stripOut(); goto again; - break; case "h3": ele.innerText = "\r" ~ ele.innerText.toUpper ~ "\r"; ele.stripOut(); goto again; - break; case "td": case "p": /* @@ -96,7 +90,6 @@ string htmlToText(string html, bool wantWordWrap = true, int wrapAmount = 74) { } ele.stripOut(); goto again; - break; case "ol": case "ul": ele.innerHTML = "\r" ~ ele.innerHTML ~ "\r"; diff --git a/http.d b/http.d index 37cc95d..2baeeae 100644 --- a/http.d +++ b/http.d @@ -113,7 +113,7 @@ struct UriParts { } } -HttpResponse httpRequest(string method, string uri, const(ubyte)[] content = null, string[string] cookies = null, string headers[] = null) { +HttpResponse httpRequest(string method, string uri, const(ubyte)[] content = null, string[string] cookies = null, string[] headers = null) { import std.socket; auto u = UriParts(uri); @@ -181,7 +181,7 @@ HttpResponse httpRequest(string method, string uri, const(ubyte)[] content = nul of the parameters are the caller's responsibility. Content-Length is added automatically, but YOU must give Content-Type! */ -HttpResponse doHttpRequestOnHelpers(void delegate(string) write, char[] delegate() read, string method, string uri, const(ubyte)[] content = null, string[string] cookies = null, string headers[] = null, bool https = false) +HttpResponse doHttpRequestOnHelpers(void delegate(string) write, char[] delegate() read, string method, string uri, const(ubyte)[] content = null, string[string] cookies = null, string[] headers = null, bool https = false) in { assert(method == "POST" || method == "GET"); } @@ -354,7 +354,6 @@ body { break; case 3: // reading footers goto done; // FIXME - break; } } } else diff --git a/http2.d b/http2.d index 118ed96..4acd816 100644 --- a/http2.d +++ b/http2.d @@ -528,10 +528,8 @@ class HttpRequest { data = data[a+1 .. $]; bodyReadingState.chunkedState = 0; goto start_over; - break; case 3: // reading footers goto done; // FIXME - break; } } diff --git a/jsvar.d b/jsvar.d index bd49bae..c08210a 100644 --- a/jsvar.d +++ b/jsvar.d @@ -168,7 +168,7 @@ writeln(interpret("x*x + 3*x;", var(["x":3]))); }; // call D defined functions in script - globals.func = (var a, var b) { writeln("Hello, world! You are : ", a, " and ", b); }; + globals.func = (var a, var b) { writeln("Hello, world! You are : ", a, " and ", b); }; globals.ex = () { throw new ScriptRuntimeException("test", 1); }; @@ -613,7 +613,7 @@ struct var { this._type = Type.String; this._payload._string = to!string(t); } else static if((is(T == class) || is(T == struct) || isAssociativeArray!T)) { - this,_type = Type.Object; + this._type = Type.Object; auto obj = new PrototypeObject(); this._payload._object = obj; @@ -748,9 +748,8 @@ struct var { if(this._object !is null) return this._object.toString(); return "null"; - } - - return T.init; + } else + return T.init; case Type.Integral: static if(isFloatingPoint!T || isIntegral!T) return to!T(this._payload._integral); @@ -766,11 +765,12 @@ struct var { else return T.init; case Type.String: - static if(__traits(compiles, to!T(this._payload._string))) + static if(__traits(compiles, to!T(this._payload._string))) { try { return to!T(this._payload._string); - } catch (Exception e) {} - return T.init; + } catch (Exception e) { return T.init; } + } else + return T.init; case Type.Array: import std.range; auto pl = this._payload._array; @@ -786,16 +786,15 @@ struct var { foreach(item; pl) ret ~= item.get!(getType); return ret; - } - + } else + return T.init; // is it sane to translate anything else? - - return T.init; case Type.Function: static if(isSomeString!T) return ""; + else + return T.init; // FIXME: we just might be able to do better for both of these - return T.init; //break; } } @@ -1091,7 +1090,6 @@ struct var { } return _arrayPrototype; - break; case Type.Function: assert(_functionPrototype._type == Type.Object); if(_functionPrototype._payload._object is null) { @@ -1099,7 +1097,6 @@ struct var { } return _functionPrototype; - break; case Type.String: assert(_stringPrototype._type == Type.Object); if(_stringPrototype._payload._object is null) { @@ -1107,7 +1104,6 @@ struct var { } return _stringPrototype; - break; case Type.Object: if(_payload._object) return _payload._object._prototype; diff --git a/png.d b/png.d index 20dcc88..af79a95 100644 --- a/png.d +++ b/png.d @@ -1719,7 +1719,7 @@ immutable(ubyte)[] unfilter(ubyte filterType, in ubyte[] data, in ubyte[] previo foreach(i; 0 .. arr.length) { auto prev = i < bpp ? 0 : arr[i - bpp]; arr[i] += cast(ubyte) - std.math.floor( cast(int) (prev + previousLine[i]) / 2); + /*std.math.floor*/( cast(int) (prev + previousLine[i]) / 2); } return assumeUnique(arr); diff --git a/script.d b/script.d index f29f2b6..254a52e 100644 --- a/script.d +++ b/script.d @@ -1471,7 +1471,6 @@ Expression parsePart(MyTokenStreamHere)(ref MyTokenStreamHere tokens) { obj.elements[key.str] = value; goto moreKeys; - break; case "function": tokens.requireNextToken(ScriptToken.Type.symbol, "("); @@ -1969,7 +1968,7 @@ Expression parseExpression(MyTokenStreamHere)(ref MyTokenStreamHere tokens, bool ret = parseAddend(tokens); } else { assert(0); - return null; + // return null; // throw new ScriptCompileException("Parse error, unexpected end of input when reading expression", token.lineNumber); } @@ -2140,13 +2139,12 @@ Expression parseStatement(MyTokenStreamHere)(ref MyTokenStreamHere tokens, strin // whatever else keyword or operator related is actually illegal here throw new ScriptCompileException("Parse error, unexpected " ~ token.str, token.lineNumber); } - break; + // break; case ScriptToken.Type.identifier: case ScriptToken.Type.string: case ScriptToken.Type.int_number: case ScriptToken.Type.float_number: return parseExpression(tokens); - break; } assert(0); diff --git a/simpledisplay.d b/simpledisplay.d index 1fda777..32daab1 100644 --- a/simpledisplay.d +++ b/simpledisplay.d @@ -1681,7 +1681,7 @@ version(Windows) { int biYPelsPerMeter; uint biClrUsed; uint biClrImportant; - RGBQUAD biColors[colorCount]; + RGBQUAD[colorCount] biColors; /* Pixels: Uint8 pixels[] */ @@ -4300,7 +4300,7 @@ struct XKeymapEvent Bool send_event; /* true if this came from a SendEvent request */ Display *display; /* Display the event was read from */ Window window; - byte key_vector[32]; + byte[32] key_vector; } struct XExposeEvent @@ -4563,9 +4563,9 @@ struct XClientMessageEvent Atom message_type; int format; union Data{ - byte b[20]; - short s[10]; - arch_ulong l[5]; + byte[20] b; + short[10] s; + arch_ulong[5] l; } Data data; @@ -4638,7 +4638,7 @@ union XEvent{ XMappingEvent xmapping; XErrorEvent xerror; XKeymapEvent xkeymap; - arch_ulong pad[24]; + arch_ulong[24] pad; } @@ -4942,6 +4942,10 @@ struct Visual void XSetWMName(Display*, Window, XTextProperty*); enum Atom XA_STRING = 31; + enum Atom XA_ATOM = 4; + enum int PropModeAppend = 2; + enum int PropModeReplace = 0; + enum int PropModePrepend = 1; } else version (OSXCocoa) { diff --git a/sqlite.d b/sqlite.d index 0c2a003..91b142f 100644 --- a/sqlite.d +++ b/sqlite.d @@ -138,9 +138,10 @@ class Sqlite : Database { } string error(){ + import core.stdc.string : strlen; char* mesg = sqlite3_errmsg(db); char[] m; - sizediff_t a = std.c.string.strlen(mesg); + sizediff_t a = strlen(mesg); m.length = a; for(int v = 0; v < a; v++) m[v] = mesg[v]; @@ -160,8 +161,9 @@ class Sqlite : Database { int exec(string sql, void delegate (char[][char[]]) onEach = null) { char* mesg; if(sqlite3_exec(db, toStringz(sql), &callback, &onEach, &mesg) != SQLITE_OK) { + import core.stdc.string : strlen; char[] m; - sizediff_t a = std.c.string.strlen(mesg); + sizediff_t a = strlen(mesg); m.length = a; for(int v = 0; v < a; v++) m[v] = mesg[v]; @@ -281,8 +283,9 @@ struct Statement { columnNames.length = count; for(int a = 0; a < count; a++){ + import core.stdc.string : strlen; char* str = sqlite3_column_name(s, a); - sizediff_t l = std.c.string.strlen(str); + sizediff_t l = strlen(str); columnNames[a].length = l; for(int b = 0; b < l; b++) columnNames[a][b] = str[b]; @@ -332,7 +335,8 @@ struct Statement { char* str = sqlite3_column_text(s, a); char[] st; - sizediff_t l = std.c.string.strlen(str); + import core.stdc.string : strlen; + sizediff_t l = strlen(str); st.length = l; for(int aa = 0; aa < l; aa++) st[aa] = str[aa]; @@ -621,15 +625,16 @@ extern(C) int callback(void* cb, int howmany, char** text, char** columns){ char[][char[]] row; + import core.stdc.string : strlen; for(int a = 0; a < howmany; a++){ - sizediff_t b = std.c.string.strlen(columns[a]); + sizediff_t b = strlen(columns[a]); char[] buf; buf.length = b; for(int c = 0; c < b; c++) buf[c] = columns[a][c]; - sizediff_t d = std.c.string.strlen(text[a]); + sizediff_t d = strlen(text[a]); char[] t; t.length = d; for(int c = 0; c < d; c++) diff --git a/stb_truetype.d b/stb_truetype.d index d6d3da4..7ce6779 100644 --- a/stb_truetype.d +++ b/stb_truetype.d @@ -157,8 +157,8 @@ import std.file; alias uint stbtt_uint32; alias int stbtt_int32; - alias char stbtt__check_size32[(stbtt_int32.sizeof)==4 ? 1 : -1]; - alias char stbtt__check_size16[(stbtt_int16.sizeof)==2 ? 1 : -1]; + alias char[(stbtt_int32.sizeof)==4 ? 1 : -1] stbtt__check_size32; + alias char[(stbtt_int16.sizeof)==2 ? 1 : -1] stbtt__check_size16; static import core.stdc.stdlib; alias STBTT_sort = core.stdc.stdlib.qsort; @@ -508,7 +508,7 @@ int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint) return 0; } else if (format == 2) { assert(0); // @TODO: high-byte mapping for japanese/chinese/korean - return 0; + //return 0; } else if (format == 4) { // standard mapping for windows fonts: binary search collection of ranges stbtt_uint16 segcount = ttUSHORT(data+index_map+6) >> 1; stbtt_uint16 searchRange = ttUSHORT(data+index_map+8) >> 1; @@ -581,7 +581,7 @@ int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint) } // @TODO assert(0); - return 0; + // return 0; } int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices) @@ -806,7 +806,7 @@ int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_verte stbtt_uint16 flags, gidx; int comp_num_verts = 0, i; stbtt_vertex* comp_verts = null, tmp = null; - float mtx[6] = [1,0,0,1,0,0]; + float[6] mtx = [1,0,0,1,0,0]; float m, n; flags = ttSHORT(comp); comp+=2; @@ -1231,7 +1231,7 @@ static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcou e[n].invert = 0; if (invert ? p[j].y > p[k].y : p[j].y < p[k].y) { e[n].invert = 1; - a=j,b=k; + a=j;b=k; } e[n].x0 = p[a].x * scale_x + shift_x; e[n].y0 = p[a].y * y_scale_inv * vsubsample + shift_y; @@ -1321,7 +1321,7 @@ stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float o ++n; start = num_points; - x = vertices[i].x, y = vertices[i].y; + x = vertices[i].x; y = vertices[i].y; stbtt__add_point(points, num_points++, x,y); break; case STBTT_vline: @@ -1333,7 +1333,7 @@ stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float o vertices[i].cx, vertices[i].cy, vertices[i].x, vertices[i].y, objspace_flatness_squared, 0); - x = vertices[i].x, y = vertices[i].y; + x = vertices[i].x; y = vertices[i].y; break; } } @@ -1483,7 +1483,7 @@ extern int stbtt_BakeFontBitmap(const ubyte *data, int offset, // font location gw = x1-x0; gh = y1-y0; if (x + gw + 1 >= pw) - y = bottom_y, x = 1; // advance to next row + { y = bottom_y; x = 1; } // advance to next row if (y + gh + 1 >= ph) // check if it fits vertically AFTER potentially moving to next row return -i; assert(x+gw < pw); diff --git a/terminal.d b/terminal.d index 0a625d6..c38aa79 100644 --- a/terminal.d +++ b/terminal.d @@ -1650,7 +1650,6 @@ struct RealTimeConsoleInput { } } return [InputEvent(PasteEvent(data))]; - break; case "\033[M": // mouse event auto buttonCode = nextRaw() - 32; @@ -1714,7 +1713,6 @@ struct RealTimeConsoleInput { m.modifierState = modifiers; return [InputEvent(m)]; - break; default: // look it up in the termcap key database auto cap = terminal.findSequenceInTermcap(sequence); diff --git a/web.d b/web.d index efeedda..7d907f2 100644 --- a/web.d +++ b/web.d @@ -372,7 +372,13 @@ class ApiProvider : WebDotDBaseType { return; // not doing checks void fail() { - throw new PermissionDeniedException("CSRF token test failed"); + throw new PermissionDeniedException("CSRF token test failed " ~ to!string(cgi.postArray)); + /* + ~ "::::::"~cgi.post[ + tokenInfo["key"] + ] ~ " != " ~ + tokenInfo["token"]); + */ } // expiration is handled by the session itself expiring (in the Session class) @@ -2763,9 +2769,10 @@ string formatAs(T, R)(T ret, string format, R api = null, JSONValue* returnValue returnValue.str = retstr; break; case "string": // FIXME: this is the most expensive part of the compile! Two seconds in one of my apps. - static if(is(typeof(ret) == string)) + static if(is(typeof(ret) == string)) { returnValue.str = ret; - else + break; + } else /+ static if(__traits(compiles, to!string(ret))) { retstr = to!string(ret);