mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 14:40:30 +03:00
Fix cases where goto skips initialization of variables
This commit is contained in:
parent
19bed560cd
commit
1754eed7f6
3 changed files with 58 additions and 58 deletions
|
@ -5137,6 +5137,7 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("formatArg(fc = '%c', m = '%c')\n", fc, m);
|
//printf("formatArg(fc = '%c', m = '%c')\n", fc, m);
|
||||||
|
int mi;
|
||||||
switch (m)
|
switch (m)
|
||||||
{
|
{
|
||||||
case Mangle.Tbool:
|
case Mangle.Tbool:
|
||||||
|
@ -5279,7 +5280,7 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case Mangle.Tarray:
|
case Mangle.Tarray:
|
||||||
int mi = 10;
|
mi = 10;
|
||||||
if (typeid(ti).name.length == 14 &&
|
if (typeid(ti).name.length == 14 &&
|
||||||
typeid(ti).name[9..14] == "Array")
|
typeid(ti).name[9..14] == "Array")
|
||||||
{ // array of non-primitive types
|
{ // array of non-primitive types
|
||||||
|
@ -5325,8 +5326,7 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr)
|
||||||
|
|
||||||
case Mangle.Tdchar:
|
case Mangle.Tdchar:
|
||||||
LarrayDchar:
|
LarrayDchar:
|
||||||
auto sd = va_arg!(dstring)(argptr);
|
s = toUTF8(va_arg!(dstring)(argptr));
|
||||||
s = toUTF8(sd);
|
|
||||||
Lputstr:
|
Lputstr:
|
||||||
if (fc != 's')
|
if (fc != 's')
|
||||||
throw new FormatException("string");
|
throw new FormatException("string");
|
||||||
|
@ -5501,6 +5501,7 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
ptrdiff_t n = tmpbuf.length;
|
ptrdiff_t n = tmpbuf.length;
|
||||||
char c;
|
char c;
|
||||||
int hexoffset = uc ? ('A' - ('9' + 1)) : ('a' - ('9' + 1));
|
int hexoffset = uc ? ('A' - ('9' + 1)) : ('a' - ('9' + 1));
|
||||||
|
@ -5523,6 +5524,7 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr)
|
||||||
prefix = "0";
|
prefix = "0";
|
||||||
putstr(tmpbuf[n .. tmpbuf.length]);
|
putstr(tmpbuf[n .. tmpbuf.length]);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Lreal:
|
Lreal:
|
||||||
putreal(vreal);
|
putreal(vreal);
|
||||||
|
|
16
std/mmfile.d
16
std/mmfile.d
|
@ -228,17 +228,19 @@ class MmFile
|
||||||
dwCreationDisposition,
|
dwCreationDisposition,
|
||||||
FILE_ATTRIBUTE_NORMAL,
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
cast(HANDLE)null);
|
cast(HANDLE)null);
|
||||||
if (hFile == INVALID_HANDLE_VALUE)
|
|
||||||
goto err1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
hFile = null;
|
hFile = null;
|
||||||
|
|
||||||
|
hFileMap = null;
|
||||||
|
if (hFile != INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
int hi = cast(int)(size>>32);
|
int hi = cast(int)(size>>32);
|
||||||
hFileMap = CreateFileMappingA(hFile, null, flProtect,
|
hFileMap = CreateFileMappingA(hFile, null, flProtect,
|
||||||
hi, cast(uint)size, null);
|
hi, cast(uint)size, null);
|
||||||
if (hFileMap == null) // mapping failed
|
}
|
||||||
goto err1;
|
if (hFileMap != null) // mapping didn't fail
|
||||||
|
{
|
||||||
|
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
{
|
{
|
||||||
|
@ -252,13 +254,15 @@ class MmFile
|
||||||
? 2*window : cast(size_t)size;
|
? 2*window : cast(size_t)size;
|
||||||
p = MapViewOfFileEx(hFileMap, dwDesiredAccess, 0, 0,
|
p = MapViewOfFileEx(hFileMap, dwDesiredAccess, 0, 0,
|
||||||
initial_map, address);
|
initial_map, address);
|
||||||
if (!p) goto err1;
|
if (p)
|
||||||
|
{
|
||||||
data = p[0 .. initial_map];
|
data = p[0 .. initial_map];
|
||||||
|
|
||||||
debug (MMFILE) printf("MmFile.this(): p = %p, size = %d\n", p, size);
|
debug (MMFILE) printf("MmFile.this(): p = %p, size = %d\n", p, size);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
err1:
|
|
||||||
if (hFileMap != null)
|
if (hFileMap != null)
|
||||||
CloseHandle(hFileMap);
|
CloseHandle(hFileMap);
|
||||||
hFileMap = null;
|
hFileMap = null;
|
||||||
|
|
20
std/uri.d
20
std/uri.d
|
@ -401,7 +401,7 @@ size_t uriLength(string s)
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (s.length <= 4)
|
if (s.length <= 4)
|
||||||
goto Lno;
|
return -1;
|
||||||
|
|
||||||
if (s.length > 7 && std.string.icmp(s[0 .. 7], "http://") == 0) {
|
if (s.length > 7 && std.string.icmp(s[0 .. 7], "http://") == 0) {
|
||||||
i = 7;
|
i = 7;
|
||||||
|
@ -411,7 +411,7 @@ size_t uriLength(string s)
|
||||||
if (s.length > 8 && std.string.icmp(s[0 .. 8], "https://") == 0)
|
if (s.length > 8 && std.string.icmp(s[0 .. 8], "https://") == 0)
|
||||||
i = 8;
|
i = 8;
|
||||||
else
|
else
|
||||||
goto Lno;
|
return -1;
|
||||||
}
|
}
|
||||||
// if (icmp(s[0 .. 4], "www.") == 0)
|
// if (icmp(s[0 .. 4], "www.") == 0)
|
||||||
// i = 4;
|
// i = 4;
|
||||||
|
@ -436,12 +436,9 @@ size_t uriLength(string s)
|
||||||
}
|
}
|
||||||
//if (!lastdot || (i - lastdot != 3 && i - lastdot != 4))
|
//if (!lastdot || (i - lastdot != 3 && i - lastdot != 4))
|
||||||
if (!lastdot)
|
if (!lastdot)
|
||||||
goto Lno;
|
return -1;
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
Lno:
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
|
@ -466,19 +463,19 @@ size_t emailLength(string s)
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (!isAlpha(s[0]))
|
if (!isAlpha(s[0]))
|
||||||
goto Lno;
|
return -1;
|
||||||
|
|
||||||
for (i = 1; 1; i++)
|
for (i = 1; 1; i++)
|
||||||
{
|
{
|
||||||
if (i == s.length)
|
if (i == s.length)
|
||||||
goto Lno;
|
return -1;
|
||||||
auto c = s[i];
|
auto c = s[i];
|
||||||
if (isAlphaNum(c))
|
if (isAlphaNum(c))
|
||||||
continue;
|
continue;
|
||||||
if (c == '-' || c == '_' || c == '.')
|
if (c == '-' || c == '_' || c == '.')
|
||||||
continue;
|
continue;
|
||||||
if (c != '@')
|
if (c != '@')
|
||||||
goto Lno;
|
return -1;
|
||||||
i++;
|
i++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -501,12 +498,9 @@ size_t emailLength(string s)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!lastdot || (i - lastdot != 3 && i - lastdot != 4))
|
if (!lastdot || (i - lastdot != 3 && i - lastdot != 4))
|
||||||
goto Lno;
|
return -1;
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
Lno:
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue