develooper Front page | perl.perl5.porters | Postings from January 2006

Re: [PATCH] snprintf() and vsnprintf() (was Re: [PATCH] Configure:stdio char (un)signedness)

Thread Previous | Thread Next
From:
H.Merijn Brand
Date:
January 3, 2006 07:51
Subject:
Re: [PATCH] snprintf() and vsnprintf() (was Re: [PATCH] Configure:stdio char (un)signedness)
Message ID:
20060103165122.0363b723@pc09
On Mon, 2 Jan 2006 09:37:27 -0600, Steve Peters <steve@fisharerojo.org> wrote:

> On Mon, Jan 02, 2006 at 07:53:53AM +0200, Jarkko Hietaniemi wrote:
> > H.Merijn Brand wrote:
> > > On Sat, 26 Nov 2005 11:25:18 +0200, Jarkko Hietaniemi
> > > <jhietaniemi@gmail.com> wrote:
> > > 
> > >> Not that the detection of the stdio char signedness is all that
> > >> important these days, but I grew bored by these warnings in Tru64:
> > > 
> > > Sorry for the delay. This sounds very reasonable, and I have applied
> > > this in change #26557. Thanks.
> > 
> > If I may present a tiny wish for (5.9.3) Configure; since we seem to
> > scan for the safe strl*() functions these days, how about also scanning
> > for snprintf() and vsnprintf(), for the same reason, providing a safer
> > API for  people doing XS work?  (One might of course use sv_*pvf*() for
> > the same effect, but sometimes that is an overkill.)  (Use also
> > Porting/checkcfgvar.pl, and tweak vms/*.)
> > Thank you.
> 
> Adding support for snprintf() and vsnprintf() isn't too difficult to do if
> you optimistically (or foolishly) assume these functions both return int's
> as POSIX specifies.  As both functions are relatively new to most libc's,
> I'll assume the standards are being followed for now.
> 
> Bellow is the patch of what would be needed to make it work.
> Of course, metaconfig should be used to make this happen, and I left off the
> necessary changes to Porting/Glossary due to the large "DO NO EDIT THIS
> FILE" warning.

Thanks, I have applied it a bit modified because of sorting issues and
typoes :) in change #26606

Porting/Glossary has not (yet) been changed. This file should be generated,
but that fails for ages now: also sorting issues, but different from the
config_h.SH issues that were solved with Porting/config_h.pl

So please, yes, gimme a Glossary patch :)

Another note for the handy.h change. If you take the time to modify the
defined placeholder line, I'd be delighted if you remove the defines that are
already used and do not need placeholders anymore.

> Enjoy,
> 
> Steve Peters
> steve@fisharerojo.org
> 
> --- config_h.SH.old     2005-10-31 12:18:10.000000000 -0600
> +++ config_h.SH 2006-01-02 09:09:51.000000000 -0600
> @@ -2688,6 +2688,12 @@
>  #$d_vprintf HAS_VPRINTF        /**/
>  #$d_charvspr USE_CHAR_VSPRINTF         /**/
> 
> +/* HAS_VSNPRINTF:
> + *     This symbol, if defined, indicates that the vsnprintf routine is
> + *     available for use.
> + */
> +#$d_vsnprintf HAS_VSNPRINTF    /**/
> +
>  /* HAS_WRITEV:
>   *     This symbol, if defined, indicates that the writev routine is
>   *     available to do scatter writes.
> @@ -3960,6 +3966,12 @@
>   */
>  #$d_sigprocmask HAS_SIGPROCMASK                /**/
> 
> +/* HAS_SNPRINTF:
> + *     This symbol, if defined, indicates that the snprintf() library
> + *     function is available for use.
> + */
> +#$d_snprintf HAS_SNPRINTF              /**/
> +
>  /* HAS_SOCKATMARK:
>   *     This symbol, if defined, indicates that the sockatmark routine is
>   *     available to test whether a socket is at the out-of-band mark.
> --- Configure.old       2006-01-02 08:55:18.000000000 -0600
> +++ Configure   2006-01-02 09:17:14.000000000 -0600
> @@ -690,6 +690,7 @@
>  d_msg_proxy=''
>  d_oldsock=''
>  d_scm_rights=''
> +d_snprintf=''
>  d_socket=''
>  d_sockpair=''
>  sockethdr=''
> @@ -778,6 +779,7 @@
>  d_volatile=''
>  d_charvspr=''
>  d_vprintf=''
> +d_vsnprintf=''
>  d_wait4=''
>  d_waitpid=''
>  d_wcstombs=''
> @@ -16536,6 +16538,10 @@
>  eval $setvar
>  $rm -f try.c try
> 
> +: see if snprintf exists
> +set snprintf d_snprintf
> +eval $inlibc
> +
>  : see if sockatmark exists
>  set sockatmark d_sockatmark
>  eval $inlibc
> @@ -17628,6 +17634,10 @@
>  *) usevfork='false';;
>  esac
> 
> +: see if vsnprintf exists
> +set closedir d_vsnprintf
> +eval $inlibc
> +
>  : see if closedir exists
>  set closedir d_closedir
>  eval $inlibc
> @@ -21375,6 +21385,7 @@
>  d_sigaction='$d_sigaction'
>  d_sigprocmask='$d_sigprocmask'
>  d_sigsetjmp='$d_sigsetjmp'
> +d_snprintf='$d_snprintf'
>  d_sockatmark='$d_sockatmark'
>  d_sockatmarkproto='$d_sockatmarkproto'
>  d_socket='$d_socket'
> @@ -21456,6 +21467,7 @@
>  d_voidtty='$d_voidtty'
>  d_volatile='$d_volatile'
>  d_vprintf='$d_vprintf'
> +d_vsnprintf='$d_vsnprintf'
>  d_wait4='$d_wait4'
>  d_waitpid='$d_waitpid'
>  d_wcstombs='$d_wcstombs'
> --- handy.h.old 2006-01-02 08:53:36.000000000 -0600
> +++ handy.h     2006-01-02 09:20:48.000000000 -0600
> @@ -175,7 +175,7 @@
>  #endif
> 
>  /* HMB H.Merijn Brand - a placeholder for preparing Configure patches */
> -#if defined(HAS_MALLOC_SIZE) && defined(HAS_MALLOC_GOOD_SIZE) &&
> defined(HAS_CLE ARENV)
> +#if defined(HAS_MALLOC_SIZE) && defined(HAS_MALLOC_GOOD_SIZE) &&
> defined(HAS_CLE ARENV) && defined(HAS_SNPRINTF) && defined(HAS_VSNPRINTF)
>  /* Not (yet) used at top level, but mention them for metaconfig */
>  #endif
> 
> 


-- 
H.Merijn Brand        Amsterdam Perl Mongers (http://amsterdam.pm.org/)
using Perl 5.6.2, 5.8.0, 5.8.5, & 5.9.2  on HP-UX 10.20, 11.00 & 11.11,
 AIX 4.3 & 5.2, SuSE 9.2 & 9.3, and Cygwin. http://www.cmve.net/~merijn
Smoking perl: http://www.test-smoke.org,    perl QA: http://qa.perl.org
 reports  to: smokers-reports@perl.org,                perl-qa@perl.org

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About