This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug other/37080] vasprintf in libiberty fails for %llu on solaris



------- Comment #1 from mark at easterbrook dot org dot uk  2008-12-23 10:51 -------
The follow fixes it. Tested on several Solaris variants:

Patch to libiberty/vasprintf.c:

*** 79,84 ****
--- 79,85 ----
      {
        if (*p++ == '%')
        {
+         int longs = 0;
          while (strchr ("-+ #0", *p))
            ++p;
          if (*p == '*')
***************
*** 100,106 ****
--- 101,111 ----
              total_width += strtoul (p, (char **) &p, 10);
            }
          while (strchr ("hlL", *p))
+         {
+             if (*p=='l' || *p=='L')
+               longs++;
            ++p;
+         }
          /* Should be big enough for any format specifier except %s and
floats.  */
          total_width += 30;
          switch (*p)
***************
*** 112,118 ****
            case 'x':
            case 'X':
            case 'c':
!             (void) va_arg (ap, int);
              break;
            case 'f':
            case 'e':
--- 117,128 ----
            case 'x':
            case 'X':
            case 'c':
!               if (longs == 0)
!                 (void) va_arg (ap, int);
!               else if (longs == 1)
!                 (void) va_arg (ap, long);
!               else
!                 (void) va_arg (ap, long long);
              break;
            case 'f':
            case 'e':


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37080


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]