From 5b12187850d121de50f858b3074f213fcb9c6947 Mon Sep 17 00:00:00 2001 From: Trass3r Date: Wed, 9 Nov 2011 02:58:52 +0100 Subject: [PATCH] some x64 fixes --- cgi.d | 18 +++++++++--------- database.d | 2 +- dom.d | 50 ++++++++++++++++++++++++------------------------- http.d | 6 +++--- mysql.d | 2 +- simpledisplay.d | 2 +- sqlite.d | 24 ++++++++++++------------ web.d | 2 +- 8 files changed, 53 insertions(+), 53 deletions(-) diff --git a/cgi.d b/cgi.d index b7ef2b3..4be667b 100644 --- a/cgi.d +++ b/cgi.d @@ -289,7 +289,7 @@ class Cgi { scriptName = requestUri[0 .. pathInfoStarts]; - int question = requestUri.indexOf("?"); + auto question = requestUri.indexOf("?"); if(question == -1) { queryString = ""; pathInfo = requestUri[pathInfoStarts..$]; @@ -308,7 +308,7 @@ class Cgi { string contentType = ""; foreach(header; headers[1..$]) { - int colon = header.indexOf(":"); + auto colon = header.indexOf(":"); if(colon == -1) throw new Exception("HTTP headers should have a colon!"); string name = header[0..colon].toLower; @@ -408,7 +408,7 @@ class Cgi { if(data.length == 0) post = null;//post.init; else { - int terminator = contentType.indexOf(";"); + auto terminator = contentType.indexOf(";"); if(terminator == -1) terminator = contentType.length; switch(contentType[0..terminator]) { @@ -418,11 +418,11 @@ class Cgi { UploadedFile[string] _files; - int b = contentType[terminator..$].indexOf("boundary=") + terminator; + auto b = contentType[terminator..$].indexOf("boundary=") + terminator; assert(b >= 0, "no boundary"); immutable boundary = contentType[b+9..$]; - int pos = 0; + sizediff_t pos = 0; // all boundaries except the first should have a \r\n before them while(pos < data.length) { @@ -464,7 +464,7 @@ class Cgi { bool isFile = false; foreach(h; pieceHeaders) { - int p = h.indexOf(":"); + auto p = h.indexOf(":"); assert(p != -1, "no colon in header"); string hn = h[0..p]; string hv = h[p+2..$]; @@ -1025,7 +1025,7 @@ string[][string] decodeVariables(string data, string separator = "&") { auto vars = data.split(separator); string[][string] _get; foreach(var; vars) { - int equal = var.indexOf("="); + auto equal = var.indexOf("="); if(equal == -1) { _get[decodeComponent(var)] ~= ""; } else { @@ -1085,7 +1085,7 @@ string encodeVariables(in string[][string] data) { const(ubyte)[] makeChunk(const(ubyte)[] data) { const(ubyte)[] ret; - ret = cast(const(ubyte)[]) toHex(data.length); + ret = cast(const(ubyte)[]) toHex(cast(int) data.length); ret ~= cast(const(ubyte)[]) "\r\n"; ret ~= data; ret ~= cast(const(ubyte)[]) "\r\n"; @@ -1200,7 +1200,7 @@ version(embedded_httpd) writefln("Status: 500 Internal Server Error\nContent-Type: text/html\n\n%s", "Internal Server Error



"~(std.array.replace(std.array.replace(message, "<", "<"), ">", ">"))~"
"); string str = c.toString(); - int idx = str.indexOf("\n"); + auto idx = str.indexOf("\n"); if(idx != -1) str = str[0..idx]; diff --git a/database.d b/database.d index 4e3f93c..1bac9a1 100644 --- a/database.d +++ b/database.d @@ -129,7 +129,7 @@ class DatabaseException : Exception { super(msg); } - this(string msg, string file, int line) { + this(string msg, string file, size_t line) { super(msg, file, line); } } diff --git a/dom.d b/dom.d index fc44c49..6f4f3d3 100644 --- a/dom.d +++ b/dom.d @@ -774,7 +774,7 @@ class Element { bool hasClass(string c) { auto cn = className; - int idx = cn.indexOf(c); + auto idx = cn.indexOf(c); if(idx == -1) return false; @@ -1677,12 +1677,12 @@ class Link : Element { if(href is null) return null; - int ques = href.indexOf("?"); + auto ques = href.indexOf("?"); string str = ""; if(ques != -1) { str = href[ques+1..$]; - int fragment = str.indexOf("#"); + auto fragment = str.indexOf("#"); if(fragment != -1) str = str[0..fragment]; } @@ -1692,7 +1692,7 @@ class Link : Element { string[string] hash; foreach(var; variables) { - int index = var.indexOf("="); + auto index = var.indexOf("="); if(index == -1) hash[var] = ""; else { @@ -1707,12 +1707,12 @@ class Link : Element { /*private*/ void updateQueryString(string[string] vars) { string href = getAttribute("href"); - int question = href.indexOf("?"); + auto question = href.indexOf("?"); if(question != -1) href = href[0..question]; string frag = ""; - int fragment = href.indexOf("#"); + auto fragment = href.indexOf("#"); if(fragment != -1) { frag = href[fragment..$]; href = href[0..fragment]; @@ -2177,7 +2177,7 @@ class Document { } } - int pos = 0; + sizediff_t pos = 0; clear(); @@ -2185,7 +2185,7 @@ class Document { bool sawImproperNesting = false; - int getLineNumber(int p) { + int getLineNumber(sizediff_t p) { int line = 1; foreach(c; data[0..p]) if(c == '\n') @@ -2205,7 +2205,7 @@ class Document { string readTagName() { // remember to include : for namespaces // basically just keep going until >, /, or whitespace - int start = pos; + auto start = pos; while( data[pos] != '>' && data[pos] != '/' && data[pos] != ' ' && data[pos] != '\n' && data[pos] != '\t') pos++; @@ -2219,7 +2219,7 @@ class Document { string readAttributeName() { // remember to include : for namespaces // basically just keep going until >, /, or whitespace - int start = pos; + auto start = pos; while( data[pos] != '>' && data[pos] != '/' && data[pos] != '=' && data[pos] != ' ' && data[pos] != '\n' && data[pos] != '\t') pos++; @@ -2236,7 +2236,7 @@ class Document { case '"': char end = data[pos]; pos++; - int start = pos; + auto start = pos; while(data[pos] != end) pos++; string v = htmlEntitiesDecode(data[start..pos], strict); @@ -2246,7 +2246,7 @@ class Document { if(strict) parseError("Attributes must be quoted"); // read until whitespace or terminator (/ or >) - int start = pos; + auto start = pos; while(data[pos] != '>' && data[pos] != '/' && data[pos] != ' ' && data[pos] != '\n' && data[pos] != '\t') pos++; @@ -2258,7 +2258,7 @@ class Document { } TextNode readTextNode() { - int start = pos; + auto start = pos; while(pos < data.length && data[pos] != '<') { pos++; } @@ -2267,7 +2267,7 @@ class Document { } RawSource readCDataNode() { - int start = pos; + auto start = pos; while(pos < data.length && data[pos] != '<') { pos++; } @@ -2356,7 +2356,7 @@ class Document { break; case '/': // closing an element pos++; // skip the start - int p = pos; + auto p = pos; while(data[pos] != '>') pos++; //writefln("", data[p..pos]); @@ -2399,7 +2399,7 @@ class Document { pos++; } - int whereThisTagStarted = pos; // for better error messages + auto whereThisTagStarted = pos; // for better error messages pos++; @@ -2412,7 +2412,7 @@ class Document { // HACK to handle script as a CDATA section if(tagName == "script" || tagName == "style") { string closer = ""; - int ending = indexOf(data[pos..$], closer); + auto ending = indexOf(data[pos..$], closer); if(loose && ending == -1) ending = indexOf(data[pos..$], closer.toUpper); if(ending == -1) @@ -2771,7 +2771,7 @@ static import std.conv; int intFromHex(string hex) { int place = 1; int value = 0; - for(int a = hex.length - 1; a >= 0; a--) { + for(sizediff_t a = hex.length - 1; a >= 0; a--) { int v; char q = hex[a]; if( q >= '0' && q <= '9') @@ -2808,8 +2808,8 @@ int intFromHex(string hex) { ]; // other is white space or a name. ///. - int idToken(string str, int position) { - int tid = -1; + sizediff_t idToken(string str, sizediff_t position) { + sizediff_t tid = -1; char c = str[position]; foreach(a, token; selectorTokens) if(c == token[0]) { @@ -2830,7 +2830,7 @@ int intFromHex(string hex) { // FIXME: it doesn't support backslash escaped characters // FIXME: it should ignore /* comments */ string[] tokens; - int start = -1; + sizediff_t start = -1; bool skip = false; // get rid of useless, non-syntax whitespace @@ -2853,7 +2853,7 @@ int intFromHex(string hex) { continue; } - int tid = idToken(selector, i); + auto tid = idToken(selector, i); if(tid == -1) { if(start == -1) @@ -3044,7 +3044,7 @@ int intFromHex(string hex) { case 2: // next-sibling auto tmp = start.parentNode; if(tmp !is null) { - int pos = -1; + sizediff_t pos = -1; auto children = tmp.childElements; foreach(i, child; children) { if(child is start) { @@ -3063,7 +3063,7 @@ int intFromHex(string hex) { case 3: // younger sibling auto tmp = start.parentNode; if(tmp !is null) { - int pos = -1; + sizediff_t pos = -1; auto children = tmp.childElements; foreach(i, child; children) { if(child is start) { @@ -3188,7 +3188,7 @@ int intFromHex(string hex) { State state = State.Starting; string attributeName, attributeValue, attributeComparison; foreach(token; tokens) { - int tid = -1; + sizediff_t tid = -1; foreach(i, item; selectorTokens) if(token == item) { tid = i; diff --git a/http.d b/http.d index aa88f54..5cc1d72 100644 --- a/http.d +++ b/http.d @@ -59,14 +59,14 @@ struct UriParts { if(uri[0..7] != "http://") throw new Exception("You must use an absolute, unencrypted URL."); - int posSlash = uri[7..$].indexOf("/"); + auto posSlash = uri[7..$].indexOf("/"); if(posSlash != -1) posSlash += 7; if(posSlash == -1) posSlash = uri.length; - int posColon = uri[7..$].indexOf(":"); + auto posColon = uri[7..$].indexOf(":"); if(posColon != -1) posColon += 7; @@ -160,7 +160,7 @@ body { int size; int start = 0; for(int a = 0; a < response.length; a++) { - switch(state) { + final switch(state) { case 0: // reading hex char c = response[a]; if((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')) { diff --git a/mysql.d b/mysql.d index 41fb9c2..690857d 100644 --- a/mysql.d +++ b/mysql.d @@ -236,7 +236,7 @@ class MySql : Database { string escape(string str) { ubyte[] buffer = new ubyte[str.length * 2 + 1]; - buffer.length = mysql_real_escape_string(mysql, buffer.ptr, cast(cstring) str.ptr, str.length); + buffer.length = mysql_real_escape_string(mysql, buffer.ptr, cast(cstring) str.ptr, cast(uint) str.length); return cast(string) buffer; } diff --git a/simpledisplay.d b/simpledisplay.d index 8b62e54..c778b67 100644 --- a/simpledisplay.d +++ b/simpledisplay.d @@ -1090,7 +1090,7 @@ version(X11) { windowName.value = title.ptr; windowName.encoding = XA_STRING; windowName.format = 8; - windowName.nitems = title.length; + windowName.nitems = cast(uint) title.length; XSetWMName(display, window, &windowName); diff --git a/sqlite.d b/sqlite.d index 4cc1ec2..303316f 100644 --- a/sqlite.d +++ b/sqlite.d @@ -114,7 +114,7 @@ class Sqlite : Database { override ResultSet queryImpl(string sql, Variant[] args...) { auto s = Statement(this, sql); - foreach(i, arg; args) { + foreach(int i, arg; args) { s.bind(i + 1, arg); } @@ -140,7 +140,7 @@ class Sqlite : Database { string error(){ char* mesg = sqlite3_errmsg(db); char[] m; - int a = std.c.string.strlen(mesg); + sizediff_t a = std.c.string.strlen(mesg); m.length = a; for(int v = 0; v < a; v++) m[v] = mesg[v]; @@ -161,7 +161,7 @@ class Sqlite : Database { char* mesg; if(sqlite3_exec(db, toStringz(sql), &callback, &onEach, &mesg) != SQLITE_OK) { char[] m; - int a = std.c.string.strlen(mesg); + sizediff_t a = std.c.string.strlen(mesg); m.length = a; for(int v = 0; v < a; v++) m[v] = mesg[v]; @@ -194,7 +194,7 @@ class Sqlite : Database { class SqliteResult : ResultSet { int getFieldIndex(string field) { - foreach(i, n; columnNames) + foreach(int i, n; columnNames) if(n == field) return i; throw new Exception("no such field " ~ field); @@ -227,7 +227,7 @@ class SqliteResult : ResultSet { } int length() { - return rows.length; + return cast(int) rows.length; } this(Variant[][] rows, char[][] columnNames) { @@ -282,7 +282,7 @@ struct Statement { columnNames.length = count; for(int a = 0; a < count; a++){ char* str = sqlite3_column_name(s, a); - int l = std.c.string.strlen(str); + sizediff_t l = std.c.string.strlen(str); columnNames[a].length = l; for(int b = 0; b < l; b++) columnNames[a][b] = str[b]; @@ -321,7 +321,7 @@ struct Statement { for(int a = 0; a < count; a++){ Variant v; - switch(sqlite3_column_type(s, a)){ + final switch(sqlite3_column_type(s, a)){ case SQLITE_INTEGER: v = sqlite3_column_int(s, a); break; @@ -332,7 +332,7 @@ struct Statement { char* str = sqlite3_column_text(s, a); char[] st; - int l = std.c.string.strlen(str); + sizediff_t l = std.c.string.strlen(str); st.length = l; for(int aa = 0; aa < l; aa++) st[aa] = str[aa]; @@ -484,7 +484,7 @@ template extract(A, T, R...){ if(sqlite3_bind_null(s, col) != SQLITE_OK) throw new DatabaseException("bind " ~ db.error()); } else { - if(sqlite3_bind_text(s, col, value.ptr, value.length, cast(void*)-1) != SQLITE_OK) + if(sqlite3_bind_text(s, col, value.ptr, cast(int) value.length, cast(void*)-1) != SQLITE_OK) throw new DatabaseException("bind " ~ db.error()); } } @@ -504,7 +504,7 @@ template extract(A, T, R...){ if(sqlite3_bind_null(s, col) != SQLITE_OK) throw new DatabaseException("bind " ~ db.error()); } else { - if(sqlite3_bind_blob(s, col, cast(void*)value.ptr, value.length, cast(void*)-1) != SQLITE_OK) + if(sqlite3_bind_blob(s, col, cast(void*)value.ptr, cast(int) value.length, cast(void*)-1) != SQLITE_OK) throw new DatabaseException("bind " ~ db.error()); } } @@ -623,13 +623,13 @@ extern(C) int callback(void* cb, int howmany, char** text, char** columns){ char[][char[]] row; for(int a = 0; a < howmany; a++){ - int b = std.c.string.strlen(columns[a]); + sizediff_t b = std.c.string.strlen(columns[a]); char[] buf; buf.length = b; for(int c = 0; c < b; c++) buf[c] = columns[a][c]; - int d = std.c.string.strlen(text[a]); + sizediff_t d = std.c.string.strlen(text[a]); char[] t; t.length = d; for(int c = 0; c < d; c++) diff --git a/web.d b/web.d index bda5a70..c844fe9 100644 --- a/web.d +++ b/web.d @@ -1352,7 +1352,7 @@ template parameterNamesOf (alias func) } -int indexOfNew(string s, char a) { +sizediff_t indexOfNew(string s, char a) { foreach(i, c; s) if(c == a) return i;