bug-gnulib
[Top][All Lists]
Advanced

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

new module 'vasprintf-posix'


From: Bruno Haible
Subject: new module 'vasprintf-posix'
Date: Mon, 5 Mar 2007 01:36:25 +0100
User-agent: KMail/1.5.4

Here's the full POSIX compliance variant of the 'vasprintf' module.

2007-03-04  Bruno Haible  <address@hidden>

        * modules/vasprintf-posix: New file.
        * lib/vasprintf.h (asprintf, vasprintf): Rename if REPLACE_VASPRINTF is
        defined.
        * m4/vasprintf-posix.m4: New file.
        * m4/vasprintf.m4 (gl_REPLACE_VASPRINTF): New macro, extracted from
        gl_FUNC_VASPRINTF.
        (gl_FUNC_VASPRINTF): Invoke it.
        * m4/vasnprintf.m4 (gl_REPLACE_VASNPRINTF): Define REPLACE_VASNPRINTF
        here.
        * m4/vasnprintf-posix.m4 (gl_FUNC_VASNPRINTF_POSIX): Not here.

*** ./lib/vasprintf.h   22 Jul 2006 16:30:36 -0000      1.4
--- ./lib/vasprintf.h   5 Mar 2007 00:31:24 -0000
***************
*** 1,5 ****
  /* vsprintf with automatic memory allocation.
!    Copyright (C) 2002-2003 Free Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
--- 1,5 ----
  /* vsprintf with automatic memory allocation.
!    Copyright (C) 2002-2003, 2007 Free Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
***************
*** 49,54 ****
--- 49,58 ----
     If the memory allocation succeeds, store the address of the string in
     *RESULT and return the number of resulting bytes, excluding the trailing
     NUL.  Upon memory allocation error, or some other error, return -1.  */
+ #if REPLACE_VASPRINTF
+ # define asprintf rpl_asprintf
+ # define vasprintf rpl_vasprintf
+ #endif
  extern int asprintf (char **result, const char *format, ...)
         __attribute__ ((__format__ (__printf__, 2, 3)));
  extern int vasprintf (char **result, const char *format, va_list args)
*** ./m4/vasnprintf.m4  4 Mar 2007 23:28:59 -0000       1.11
--- ./m4/vasnprintf.m4  5 Mar 2007 00:31:24 -0000
***************
*** 19,24 ****
--- 19,28 ----
    AC_LIBOBJ([printf-args])
    AC_LIBOBJ([printf-parse])
    AC_LIBOBJ([asnprintf])
+   if test $ac_cv_func_vasnprintf = yes; then
+     AC_DEFINE([REPLACE_VASNPRINTF], 1,
+       [Define if vasnprintf exists but is overridden by gnulib.])
+   fi
    gl_PREREQ_PRINTF_ARGS
    gl_PREREQ_PRINTF_PARSE
    gl_PREREQ_VASNPRINTF
*** ./m4/vasnprintf-posix.m4    4 Mar 2007 23:50:44 -0000       1.2
--- ./m4/vasnprintf-posix.m4    5 Mar 2007 00:31:24 -0000
***************
*** 19,28 ****
       && test $ac_cv_func_vasnprintf = yes; then
      : # vasnprintf exists and is already POSIX compliant.
    else
-     if test $ac_cv_func_vasnprintf = yes; then
-       AC_DEFINE([REPLACE_VASNPRINTF], 1,
-         [Define if vasnprintf exists but is overridden by gnulib.])
-     fi
      if ! expr "$gl_cv_func_printf_directive_a" : ".*yes" > /dev/null; then
        AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], 1,
          [Define if the vasnprintf implementation needs special code for
--- 19,24 ----
*** ./m4/vasprintf.m4   22 Sep 2006 20:10:26 -0000      1.3
--- ./m4/vasprintf.m4   5 Mar 2007 00:31:24 -0000
***************
*** 1,20 ****
! # vasprintf.m4 serial 2
! dnl Copyright (C) 2002-2003, 2006 Free Software Foundation, Inc.
  dnl This file is free software; the Free Software Foundation
  dnl gives unlimited permission to copy and/or distribute it,
  dnl with or without modifications, as long as this notice is preserved.
  
  AC_DEFUN([gl_FUNC_VASPRINTF],
  [
!   AC_REPLACE_FUNCS(vasprintf)
    if test $ac_cv_func_vasprintf = no; then
!     AC_LIBOBJ(asprintf)
!     gl_PREREQ_VASPRINTF_H
!     gl_PREREQ_VASPRINTF
!     gl_PREREQ_ASPRINTF
    fi
  ])
  
  # Prerequisites of lib/vasprintf.h.
  AC_DEFUN([gl_PREREQ_VASPRINTF_H],
  [
--- 1,30 ----
! # vasprintf.m4 serial 3
! dnl Copyright (C) 2002-2003, 2006-2007 Free Software Foundation, Inc.
  dnl This file is free software; the Free Software Foundation
  dnl gives unlimited permission to copy and/or distribute it,
  dnl with or without modifications, as long as this notice is preserved.
  
  AC_DEFUN([gl_FUNC_VASPRINTF],
  [
!   AC_CHECK_FUNCS([vasprintf])
    if test $ac_cv_func_vasprintf = no; then
!     gl_REPLACE_VASPRINTF
    fi
  ])
  
+ AC_DEFUN([gl_REPLACE_VASPRINTF],
+ [
+   AC_LIBOBJ([vasprintf])
+   AC_LIBOBJ([asprintf])
+   if test $ac_cv_func_vasprintf = yes; then
+     AC_DEFINE([REPLACE_VASPRINTF], 1,
+       [Define if vasprintf exists but is overridden by gnulib.])
+   fi
+   gl_PREREQ_VASPRINTF_H
+   gl_PREREQ_VASPRINTF
+   gl_PREREQ_ASPRINTF
+ ])
+ 
  # Prerequisites of lib/vasprintf.h.
  AC_DEFUN([gl_PREREQ_VASPRINTF_H],
  [





reply via email to

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