bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnulib] vasnprintf.c: patch for inadequate snprintf on HPUX 10.


From: Bruno Haible
Subject: Re: [Bug-gnulib] vasnprintf.c: patch for inadequate snprintf on HPUX 10.20
Date: Mon, 20 Oct 2003 12:54:41 +0200
User-agent: KMail/1.5

Hi Jim,

> That in turn was because vasnprintf didn't handle the case in which
> snprintf doesn't honor %n, and in addition returns -1 when formatting
> the supplied arguments would require more than the specified size.

Thanks for the analysis and patch; I've committed the following slightly
modified patch (which also copes with the possibility that allocated==0).

Bruno


*** vasnprintf.c        13 Sep 2003 22:14:47 -0000      1.7
--- vasnprintf.c        20 Oct 2003 10:51:01 -0000
***************
*** 707,713 ****
                            p[1] = '\0';
                            continue;
                          }
!                       count = retcount;
                      }
  #endif
  
--- 707,729 ----
                            p[1] = '\0';
                            continue;
                          }
!                       else
!                         {
!                           /* Look at the snprintf() return value.  */
!                           if (retcount < 0)
!                             {
!                               /* HP-UX 10.20 snprintf() is doubly deficient:
!                                  It doesn't understand the '%n' directive,
!                                  *and* it returns -1 (rather than the length
!                                  that would have been required) when the
!                                  buffer is too small.  */
!                               size_t bigger_need = 2 * allocated + 12;
!                               ENSURE_ALLOCATION (bigger_need);
!                               continue;
!                             }
!                           else
!                             count = retcount;
!                         }
                      }
  #endif
  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]