diff --git a/std/format.d b/std/format.d index cb30968b4..a96376278 100644 --- a/std/format.d +++ b/std/format.d @@ -5137,6 +5137,7 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr) } //printf("formatArg(fc = '%c', m = '%c')\n", fc, m); + int mi; switch (m) { case Mangle.Tbool: @@ -5279,7 +5280,7 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr) return; case Mangle.Tarray: - int mi = 10; + mi = 10; if (typeid(ti).name.length == 14 && typeid(ti).name[9..14] == "Array") { // array of non-primitive types @@ -5325,8 +5326,7 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr) case Mangle.Tdchar: LarrayDchar: - auto sd = va_arg!(dstring)(argptr); - s = toUTF8(sd); + s = toUTF8(va_arg!(dstring)(argptr)); Lputstr: if (fc != 's') throw new FormatException("string"); @@ -5501,28 +5501,30 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr) } } - ptrdiff_t n = tmpbuf.length; - char c; - int hexoffset = uc ? ('A' - ('9' + 1)) : ('a' - ('9' + 1)); + { + ptrdiff_t n = tmpbuf.length; + char c; + int hexoffset = uc ? ('A' - ('9' + 1)) : ('a' - ('9' + 1)); - while (vnumber) - { - c = cast(char)((vnumber % base) + '0'); - if (c > '9') - c += hexoffset; - vnumber /= base; - tmpbuf[--n] = c; + while (vnumber) + { + c = cast(char)((vnumber % base) + '0'); + if (c > '9') + c += hexoffset; + vnumber /= base; + tmpbuf[--n] = c; + } + if (tmpbuf.length - n < precision && precision < tmpbuf.length) + { + ptrdiff_t m = tmpbuf.length - precision; + tmpbuf[m .. n] = '0'; + n = m; + } + else if (flags & FLhash && fc == 'o') + prefix = "0"; + putstr(tmpbuf[n .. tmpbuf.length]); + return; } - if (tmpbuf.length - n < precision && precision < tmpbuf.length) - { - ptrdiff_t 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: putreal(vreal); diff --git a/std/mmfile.d b/std/mmfile.d index 7af69b035..28ec01a43 100644 --- a/std/mmfile.d +++ b/std/mmfile.d @@ -228,37 +228,41 @@ class MmFile dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, cast(HANDLE)null); - if (hFile == INVALID_HANDLE_VALUE) - goto err1; } else hFile = null; - int hi = cast(int)(size>>32); - hFileMap = CreateFileMappingA(hFile, null, flProtect, - hi, cast(uint)size, null); - if (hFileMap == null) // mapping failed - goto err1; - - if (size == 0) + hFileMap = null; + if (hFile != INVALID_HANDLE_VALUE) { - uint sizehi; - uint sizelow = GetFileSize(hFile,&sizehi); - size = (cast(ulong)sizehi << 32) + sizelow; + int hi = cast(int)(size>>32); + hFileMap = CreateFileMappingA(hFile, null, flProtect, + hi, cast(uint)size, null); } - this.size = size; + if (hFileMap != null) // mapping didn't fail + { - size_t initial_map = (window && 2*window 7 && std.string.icmp(s[0 .. 7], "http://") == 0) { i = 7; @@ -411,7 +411,7 @@ size_t uriLength(string s) if (s.length > 8 && std.string.icmp(s[0 .. 8], "https://") == 0) i = 8; else - goto Lno; + return -1; } // if (icmp(s[0 .. 4], "www.") == 0) // i = 4; @@ -436,12 +436,9 @@ size_t uriLength(string s) } //if (!lastdot || (i - lastdot != 3 && i - lastdot != 4)) if (!lastdot) - goto Lno; + return -1; return i; - -Lno: - return -1; } unittest @@ -466,19 +463,19 @@ size_t emailLength(string s) size_t i; if (!isAlpha(s[0])) - goto Lno; + return -1; for (i = 1; 1; i++) { if (i == s.length) - goto Lno; + return -1; auto c = s[i]; if (isAlphaNum(c)) continue; if (c == '-' || c == '_' || c == '.') continue; if (c != '@') - goto Lno; + return -1; i++; break; } @@ -501,12 +498,9 @@ size_t emailLength(string s) break; } if (!lastdot || (i - lastdot != 3 && i - lastdot != 4)) - goto Lno; + return -1; return i; - -Lno: - return -1; } unittest