Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.os.vms    |    DEC's VAX* line of computers & VMS.    |    264,096 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 262,717 of 264,096    |
|    =?UTF-8?Q?Arne_Vajh=C3=B8j?= to Craig A. Berry    |
|    Re: FreeTDS port to VMS V9.x on x86?    |
|    24 Jun 25 12:25:50    |
      From: arne@vajhoej.dk              On 6/24/2025 7:51 AM, Craig A. Berry wrote:       > On 6/23/25 9:35 PM, Arne Vajhøj wrote:       >> On 6/23/2025 10:16 PM, Arne Vajhøj wrote:       >>> But why not just steal the trick from it instead of the whole code?       >>>       >>> The trick they use is va_copy.       >>>       >>> I think tds_vasprintf could use va_copy to solve the problem as well!       >>       >> On the other side, then ditching existing code and taking this       >> would also switch form vfprintf to vsnprintf for length       >> determination, which Lawrence is correct would be       >> better.       >       > It turns out tds_vasprtintf already uses vsnprintf if HAVE_VSNPRINTF is       > defined and only falls back to the /dev/null hack if not:       >       > https://github.com/FreeTDS/freetds/blob/master/src/replacements/vasprintf.c       >       > So my next change to FreeTDS will look something like this:       >       > --- vms/config_h.vms;-0 Tue Sep 26 09:23:25 2023       > +++ vms/config_h.vms Tue Jun 24 05:23:20 2025       > @@ -237,7 +237,9 @@       > #define HAVE_SNPRINTF @D_SNPRINTF@       >       > /* Define to 1 if you have the `vsnprintf' function. */       > -#define HAVE_VSNPRINTF 0       > +#if __CRTL_VER >= 70302000       > +#define HAVE_VSNPRINTF 1       > +#endif       >       > /* Define as const if the declaration of iconv() needs const. */       > #if HAVE_ICONV       > [end_of_patch]       >       > That should cover everybody with a VMS system from recent decades.              I don't like the #elif HAVE_VSNPRINTF code in tds_vasprintf.              :-)              The algorithm is basically to try vsnprintf with buffers       increasing in size 512, 1024, 1536, ... until there is space.              That is very inefficient compared to just use the return value.              And since it does not use va_copy, then only the first call to       vsnprintf will work.              Arne              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca