annotate tests/mini/bug55.d @ 883:b52d5de7783f

GC defines and linkage changes.
author Christian Kamm <kamm incasoftware de>
date Thu, 08 Jan 2009 18:20:02 +0100
parents 1bb99290e03a
children
rev   line source
lindquist@92 1 module bug55;
lindquist@270 2 extern(C) int printf(char*, ...);
lindquist@92 3
lindquist@92 4 int atoi(char[] s) {
lindquist@92 5 int i, fac=1;
lindquist@92 6 bool neg = (s.length) && (s[0] == '-');
lindquist@92 7 char[] a = neg ? s[1..$] : s;
lindquist@92 8 foreach_reverse(c; a) {
lindquist@92 9 i += (c-'0') * fac;
lindquist@92 10 fac *= 10;
lindquist@92 11 }
lindquist@92 12 return !neg ? i : -i;
lindquist@92 13 }
lindquist@92 14
lindquist@92 15 void main()
lindquist@92 16 {
lindquist@92 17 printf("64213 = %d\n", atoi("64213"));
lindquist@92 18 printf("-64213 = %d\n", atoi("-64213"));
lindquist@92 19 assert(atoi("64213") == 64213);
lindquist@92 20 assert(atoi("-64213") == -64213);
lindquist@92 21 }