comparison dmd2/root.c @ 761:fa306ca8843b

Applied fvbommel's patch from #112 Added missing TypeInfoInvariant codegen for D2
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Wed, 12 Nov 2008 02:30:28 +0100
parents f04dde6e882c
children 356e65836fb5
comparison
equal deleted inserted replaced
760:6f33b427bfd1 761:fa306ca8843b
1611 char buffer[128]; 1611 char buffer[128];
1612 char *p; 1612 char *p;
1613 unsigned psize; 1613 unsigned psize;
1614 int count; 1614 int count;
1615 1615
1616 // On some platforms (i.e. x86_64) va_list is an array and thus passed by
1617 // reference. Copy the input list so we can copy it back before retrying.
1618 va_list orig_args;
1619 va_copy(orig_args, args);
1620
1616 p = buffer; 1621 p = buffer;
1617 psize = sizeof(buffer); 1622 psize = sizeof(buffer);
1618 for (;;) 1623 for (;;)
1619 { 1624 {
1620 #if _WIN32 1625 #if _WIN32
1621 count = _vsnprintf(p,psize,format,args); 1626 count = _vsnprintf(p,psize,format,args);
1622 if (count != -1) 1627 if (count != -1)
1623 break; 1628 break;
1624 psize *= 2; 1629 psize *= 2;
1625 #endif 1630 #elif POSIX
1626 #if POSIX
1627 count = vsnprintf(p,psize,format,args); 1631 count = vsnprintf(p,psize,format,args);
1628 if (count == -1) 1632 if (count == -1)
1629 psize *= 2; 1633 psize *= 2;
1630 else if (count >= psize) 1634 else if (count >= psize)
1631 psize = count + 1; 1635 psize = count + 1;
1632 else 1636 else
1633 break; 1637 break;
1634 #endif 1638 #endif
1639 va_copy(args, orig_args);
1635 p = (char *) alloca(psize); // buffer too small, try again with larger size 1640 p = (char *) alloca(psize); // buffer too small, try again with larger size
1636 } 1641 }
1637 write(p,count); 1642 write(p,count);
1638 } 1643 }
1639 1644