This commit is contained in:
GitHub Merge Button 2011-11-19 10:25:55 -08:00
commit 2f924cc9e5
8 changed files with 37 additions and 53 deletions

View File

@ -25,35 +25,19 @@ interface Database {
Variant[] args; Variant[] args;
foreach(arg; _arguments) { foreach(arg; _arguments) {
string a; string a;
if(arg == typeid(string)) { if(arg == typeid(string) || arg == typeid(immutable(string)) || arg == typeid(const(string)))
a = va_arg!(string)(_argptr); a = va_arg!string(_argptr);
} else if(arg == typeid(immutable(string))) { else if (arg == typeid(int) || arg == typeid(immutable(int)) || arg == typeid(const(int))) {
a = va_arg!(immutable(string))(_argptr); int e = va_arg!int(_argptr);
} else if(arg == typeid(const(immutable(char)[]))) {
a = va_arg!(const(immutable(char)[]))(_argptr);
} else if (arg == typeid(int)) {
auto e = va_arg!(int)(_argptr);
a = to!string(e);
} else if (arg == typeid(immutable(int))) {
auto e = va_arg!(immutable(int))(_argptr);
a = to!string(e);
} else if (arg == typeid(const(int))) {
auto e = va_arg!(const(int))(_argptr);
a = to!string(e); a = to!string(e);
} else if (arg == typeid(immutable(char))) { } else if (arg == typeid(immutable(char))) {
auto e = va_arg!(immutable(char))(_argptr); char e = va_arg!char(_argptr);
a = to!string(e); a = to!string(e);
} else if (arg == typeid(long)) { } else if (arg == typeid(long) || arg == typeid(const(long)) || arg == typeid(immutable(long))) {
auto e = va_arg!(long)(_argptr); long e = va_arg!long(_argptr);
a = to!string(e);
} else if (arg == typeid(const(long))) {
auto e = va_arg!(const(long))(_argptr);
a = to!string(e);
} else if (arg == typeid(immutable(long))) {
auto e = va_arg!(immutable(long))(_argptr);
a = to!string(e); a = to!string(e);
} else if (arg == typeid(void*)) { } else if (arg == typeid(void*)) {
auto e = va_arg!(void*)(_argptr); void* e = va_arg!(void*)(_argptr);
assert(e is null, "can only pass null pointer"); assert(e is null, "can only pass null pointer");
a = null; a = null;
} else assert(0, "invalid type " ~ arg.toString ); } else assert(0, "invalid type " ~ arg.toString );
@ -162,7 +146,7 @@ string escapedVariants(Database db, in string sql, Variant[] t) {
string fixedup; string fixedup;
int currentIndex; int currentIndex;
int currentStart = 0; int currentStart = 0;
foreach(i, dchar c; sql) { foreach(int i, dchar c; sql) {
if(c == '?') { if(c == '?') {
fixedup ~= sql[currentStart .. i]; fixedup ~= sql[currentStart .. i];
@ -321,7 +305,7 @@ string fixupSqlForDataObjectUse(string sql) {
string[] tableNames; string[] tableNames;
string piece = sql; string piece = sql;
int idx; sizediff_t idx;
while((idx = piece.indexOf("JOIN")) != -1) { while((idx = piece.indexOf("JOIN")) != -1) {
auto start = idx + 5; auto start = idx + 5;
auto i = start; auto i = start;

12
dom.d
View File

@ -2172,7 +2172,7 @@ class Table : Element {
return position; return position;
} }
foreach(i, rowElement; rows) { foreach(int i, rowElement; rows) {
auto row = cast(TableRow) rowElement; auto row = cast(TableRow) rowElement;
assert(row !is null); assert(row !is null);
assert(i < ret.length); assert(i < ret.length);
@ -2186,8 +2186,8 @@ class Table : Element {
// FIXME: colspan == 0 or rowspan == 0 // FIXME: colspan == 0 or rowspan == 0
// is supposed to mean fill in the rest of // is supposed to mean fill in the rest of
// the table, not skip it // the table, not skip it
foreach(j; 0 .. cell.colspan) { foreach(int j; 0 .. cell.colspan) {
foreach(k; 0 .. cell.rowspan) foreach(int k; 0 .. cell.rowspan)
// if the first row, always append. // if the first row, always append.
insertCell(k + i, k == 0 ? -1 : position, cell); insertCell(k + i, k == 0 ? -1 : position, cell);
position++; position++;
@ -2195,7 +2195,7 @@ class Table : Element {
} }
if(ret[i].length > maxLength) if(ret[i].length > maxLength)
maxLength = ret[i].length; maxLength = cast(int) ret[i].length;
} }
// want to ensure it's rectangular // want to ensure it's rectangular
@ -2467,6 +2467,7 @@ class Document {
parentChain = []; parentChain = [];
if(pos >= data.length) if(pos >= data.length)
{
if(strict) { if(strict) {
throw new MarkupError("Gone over the input (is there no root element?), chain: " ~ to!string(parentChain)); throw new MarkupError("Gone over the input (is there no root element?), chain: " ~ to!string(parentChain));
} else { } else {
@ -2475,6 +2476,7 @@ class Document {
else else
return Ele(4); // signal emptiness upstream return Ele(4); // signal emptiness upstream
} }
}
if(data[pos] != '<') { if(data[pos] != '<') {
return Ele(0, readTextNode(), null); return Ele(0, readTextNode(), null);
@ -2701,10 +2703,12 @@ class Document {
root = r.element; root = r.element;
if(root is null) if(root is null)
{
if(strict) if(strict)
assert(0, "empty document should be impossible in strict mode"); assert(0, "empty document should be impossible in strict mode");
else else
parse(`<html><head></head><body></body></html>`); // fill in a dummy document in loose mode since that's what browsers do parse(`<html><head></head><body></body></html>`); // fill in a dummy document in loose mode since that's what browsers do
}
if(0&&sawImproperNesting) { if(0&&sawImproperNesting) {
// in loose mode, we can see some bad nesting. It's hard to fix above though // in loose mode, we can see some bad nesting. It's hard to fix above though

22
html.d
View File

@ -740,7 +740,7 @@ string translateJavascriptSourceWithDToStandardScript(string src)() {
+/ +/
abstract class CssPart { abstract class CssPart {
string toString() const; override string toString() const;
CssPart clone() const; CssPart clone() const;
} }
@ -799,7 +799,7 @@ class CssRuleSet : CssPart {
css = css[idx .. $]; css = css[idx .. $];
int braceCount = 0; int braceCount = 0;
string content; string content;
int f = css.length; size_t f = css.length;
foreach(i, c; css) { foreach(i, c; css) {
if(c == '{') if(c == '{')
braceCount++; braceCount++;
@ -823,7 +823,7 @@ class CssRuleSet : CssPart {
string[] selectors; string[] selectors;
CssPart[] contents; CssPart[] contents;
CssRuleSet clone() const { override CssRuleSet clone() const {
auto n = new CssRuleSet(); auto n = new CssRuleSet();
n.selectors = selectors.dup; n.selectors = selectors.dup;
n.contents = contents.dup; n.contents = contents.dup;
@ -930,7 +930,7 @@ CssPart[] lexCss(string css) {
auto beginningOfBlock = css.indexOf("{"); auto beginningOfBlock = css.indexOf("{");
if(beginningOfBlock == -1 || endOfStatement < beginningOfBlock) if(beginningOfBlock == -1 || endOfStatement < beginningOfBlock)
p = new CssRule(css, endOfStatement); p = new CssRule(css, cast(int) endOfStatement);
else else
p = new CssRuleSet(css); p = new CssRuleSet(css);
} }
@ -947,11 +947,12 @@ CssPart[] lexCss(string css) {
string cssToString(in CssPart[] css) { string cssToString(in CssPart[] css) {
string ret; string ret;
foreach(c; css) { foreach(c; css) {
if(ret.length) if(ret.length) {
if(ret[$ -1] == '}') if(ret[$ -1] == '}')
ret ~= "\n\n"; ret ~= "\n\n";
else else
ret ~= "\n"; ret ~= "\n";
}
ret ~= c.toString(); ret ~= c.toString();
} }
@ -1100,13 +1101,10 @@ class MacroExpander {
args = args[1 .. $]; args = args[1 .. $];
dstring returned; dstring returned;
int iterations = args.length; size_t iterations = args.length;
if(m.args.length != 0) if(m.args.length != 0)
iterations = (args.length + m.args.length - 1) / m.args.length; iterations = (args.length + m.args.length - 1) / m.args.length;
if(iterations < 0)
iterations = 0;
foreach(i; 0 .. iterations) { foreach(i; 0 .. iterations) {
returned ~= expandMacro(m, args); returned ~= expandMacro(m, args);
if(m.args.length < args.length) if(m.args.length < args.length)
@ -1151,7 +1149,7 @@ class MacroExpander {
// the replacement goes // the replacement goes
// src[0 .. startingSliceForReplacement] ~ new ~ src[endingSliceForReplacement .. $]; // src[0 .. startingSliceForReplacement] ~ new ~ src[endingSliceForReplacement .. $];
int startingSliceForReplacement, endingSliceForReplacement; sizediff_t startingSliceForReplacement, endingSliceForReplacement;
dstring functionName; dstring functionName;
dstring[] arguments; dstring[] arguments;
@ -1160,7 +1158,7 @@ class MacroExpander {
startingSliceForReplacement = idx; startingSliceForReplacement = idx;
// idx++; // because the star in UTF 8 is two characters. FIXME: hack -- not needed thx to dstrings // idx++; // because the star in UTF 8 is two characters. FIXME: hack -- not needed thx to dstrings
auto possibility = src[idx + 1 .. $]; auto possibility = src[idx + 1 .. $];
int argsBegin; size_t argsBegin;
bool found = false; bool found = false;
foreach(i, c; possibility) { foreach(i, c; possibility) {
@ -1217,7 +1215,7 @@ class MacroExpander {
goto doReplacement; goto doReplacement;
// actually parsing the arguments // actually parsing the arguments
int currentArgumentStarting = argsBegin + 1; size_t currentArgumentStarting = argsBegin + 1;
int open; int open;

View File

@ -19,7 +19,7 @@ class MsSql : Database {
enforce(env !is null); enforce(env !is null);
scope(failure) scope(failure)
SQLFreeHandle(SQL_HANDLE_ENV, env); SQLFreeHandle(SQL_HANDLE_ENV, env);
SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0); SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, cast(void *) SQL_OV_ODBC3, 0);
SQLAllocHandle(SQL_HANDLE_DBC, env, &conn); SQLAllocHandle(SQL_HANDLE_DBC, env, &conn);
scope(failure) scope(failure)
SQLFreeHandle(SQL_HANDLE_DBC, conn); SQLFreeHandle(SQL_HANDLE_DBC, conn);
@ -50,8 +50,7 @@ class MsSql : Database {
// this is passed to MsSqlResult to control // this is passed to MsSqlResult to control
SQLHSTMT statement; SQLHSTMT statement;
auto returned = SQLAllocHandle(SQL_HANDLE_STMT, conn, auto returned = SQLAllocHandle(SQL_HANDLE_STMT, conn, &statement);
&statement)
enforce(returned == SQL_SUCCESS); enforce(returned == SQL_SUCCESS);
@ -157,7 +156,7 @@ class MsSqlResult : ResultSet {
if(ptr) if(ptr)
goto more; goto more;
} }
} }
row ~= a; row ~= a;
} }

4
rtud.d
View File

@ -102,7 +102,7 @@ int openNetworkFd(string host, ushort port) {
void writeToFd(int fd, string s) { void writeToFd(int fd, string s) {
again: again:
int num = linux.write(fd, s.ptr, s.length); auto num = linux.write(fd, s.ptr, s.length);
if(num < 0) if(num < 0)
throw new Exception("couldn't write"); throw new Exception("couldn't write");
if(num == 0) if(num == 0)
@ -150,7 +150,7 @@ int handleListenerGateway(Cgi cgi, string channelPrefix) {
string[4096] buffer; string[4096] buffer;
for(;;) { for(;;) {
int num = linux.read(f, buffer.ptr, buffer.length); auto num = linux.read(f, buffer.ptr, buffer.length);
if(num < 0) if(num < 0)
throw new Exception("read error"); throw new Exception("read error");
if(num == 0) if(num == 0)

View File

@ -1 +0,0 @@
../../dimage/simpleaudio.d

View File

@ -943,7 +943,7 @@ version(X11) {
void drawText(int x, int y, int x2, int y2, string text) { void drawText(int x, int y, int x2, int y2, string text) {
foreach(line; text.split("\n")) { foreach(line; text.split("\n")) {
XDrawString(display, d, gc, x, y + 12, line.ptr, line.length); XDrawString(display, d, gc, x, y + 12, line.ptr, cast(int) line.length);
y += 16; y += 16;
} }
} }
@ -996,11 +996,11 @@ version(X11) {
if(backgroundIsNotTransparent) { if(backgroundIsNotTransparent) {
swapColors(); swapColors();
XFillPolygon(display, d, gc, points.ptr, points.length, PolygonShape.Complex, CoordMode.CoordModeOrigin); XFillPolygon(display, d, gc, points.ptr, cast(int) points.length, PolygonShape.Complex, CoordMode.CoordModeOrigin);
swapColors(); swapColors();
} }
if(foregroundIsNotTransparent) { if(foregroundIsNotTransparent) {
XDrawLines(display, d, gc, points.ptr, points.length, CoordMode.CoordModeOrigin); XDrawLines(display, d, gc, points.ptr, cast(int) points.length, CoordMode.CoordModeOrigin);
} }
} }
} }

2
web.d
View File

@ -1463,7 +1463,7 @@ string toJson(T)(T a) {
/// like toHtml - it makes a json value of any given type. /// like toHtml - it makes a json value of any given type.
/// It can be used generically, or it can be passed an ApiProvider so you can do a secondary custom /// It can be used generically, or it can be passed an ApiProvider so you can do a secondary custom
/// format. (it calls api.formatAs!(type)(typeRequestString). Why would you want that? Maybe /// format. (it calls api.formatAs!(type)(typeRequestString)). Why would you want that? Maybe
/// your javascript wants to do work with a proper object,but wants to append it to the document too. /// your javascript wants to do work with a proper object,but wants to append it to the document too.
/// Asking for json with secondary format = html means the server will provide both to you. /// Asking for json with secondary format = html means the server will provide both to you.