mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-12 02:43:14 +01:00
Branch statements now emit a new block after it. Fixed the _adSort runtime function had a bad signature. Added a missing dot prefix on compiler generated string tables for string switch. Fixed, PTRSIZE seems like it was wrong on 64bit, now it definitely gets set properly.
22 lines
454 B
D
22 lines
454 B
D
module bug55;
|
|
extern(C) int printf(char*, ...);
|
|
|
|
int atoi(char[] s) {
|
|
int i, fac=1;
|
|
bool neg = (s.length) && (s[0] == '-');
|
|
char[] a = neg ? s[1..$] : s;
|
|
foreach_reverse(c; a) {
|
|
i += (c-'0') * fac;
|
|
fac *= 10;
|
|
}
|
|
return !neg ? i : -i;
|
|
}
|
|
|
|
void main()
|
|
{
|
|
printf("64213 = %d\n", atoi("64213"));
|
|
printf("-64213 = %d\n", atoi("-64213"));
|
|
assert(atoi("64213") == 64213);
|
|
assert(atoi("-64213") == -64213);
|
|
}
|