bug-gnulib
[Top][All Lists]
Advanced

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

[Bug-gnulib] Re: [PATCH]: strsep.h problem


From: Bruno Haible
Subject: [Bug-gnulib] Re: [PATCH]: strsep.h problem
Date: Tue, 5 Oct 2004 19:39:06 +0200
User-agent: KMail/1.5

Yoann Vandoorselaere wrote:
> Here is a patch for strsep.h, current version will result in this error
> on a system already defining strsep:
>
> strsep.h:41: parse error before "__extension__"
> strsep.h:41: parse error before '&&' token
> 
> @@ -38,6 +38,8 @@
>     Caveat: It doesn't work with multibyte strings unless all of the delimiter
>             characters are ASCII characters < 0x30.  */
>  
> +#if defined HAVE_DECL_STRSEP && !HAVE_DECL_STRSEP
>  extern char *strsep (char **stringp, const char *delim);
> +#endif
>  
>  #endif /* GNULIB_STRSEP_H_ */

Have you encountered a system which has strsep() but doesn't declare it?
In absence of such a system, it's simpler to not check for the declaration,
but just check for the function.

I've fixed the problem using the appended patch.


2004-10-05  Bruno Haible  <address@hidden>

        * m4/strsep.m4 (gl_FUNC_STRSEP): Require AC_GNU_SOURCE. Don't check
        for the declaration of strsep.
        * lib/strsep.h: Don't declare strsep() if HAVE_STRSEP.

diff -c -3 -r1.1 strsep.m4
*** m4/strsep.m4        1 Oct 2004 16:38:25 -0000       1.1
--- m4/strsep.m4        5 Oct 2004 17:40:35 -0000
***************
*** 1,4 ****
! # strsep.m4 serial 1
  dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
  dnl This file is free software, distributed under the terms of the GNU
  dnl General Public License.  As a special exception to the GNU General
--- 1,4 ----
! # strsep.m4 serial 2
  dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
  dnl This file is free software, distributed under the terms of the GNU
  dnl General Public License.  As a special exception to the GNU General
***************
*** 8,15 ****
  
  AC_DEFUN([gl_FUNC_STRSEP],
  [
    AC_REPLACE_FUNCS(strsep)
-   AC_CHECK_DECLS_ONCE(strsep)
    gl_PREREQ_STRSEP
  ])
  
--- 8,17 ----
  
  AC_DEFUN([gl_FUNC_STRSEP],
  [
+   dnl Persuade glibc <string.h> to declare strsep().
+   AC_REQUIRE([AC_GNU_SOURCE])
+ 
    AC_REPLACE_FUNCS(strsep)
    gl_PREREQ_STRSEP
  ])
  
diff -c -3 -r1.1 strsep.h
*** lib/strsep.h        1 Oct 2004 16:38:25 -0000       1.1
--- lib/strsep.h        5 Oct 2004 17:40:35 -0000
***************
*** 20,30 ****
  #ifndef GNULIB_STRSEP_H_
  #define GNULIB_STRSEP_H_
  
  /*
!  * Get strsep, if available.
   */
  #include <string.h>
  
  /* Searches the next delimiter (char listed in DELIM) starting at *STRINGP.
     If one is found, it is overwritten with a NUL, and *STRINGP is advanced
     to point to the next char after it.  Otherwise, *STRINGP is set to NULL.
--- 20,34 ----
  #ifndef GNULIB_STRSEP_H_
  #define GNULIB_STRSEP_H_
  
+ #if HAVE_STRSEP
+ 
  /*
!  * Get strsep() declaration.
   */
  #include <string.h>
  
+ #else
+ 
  /* Searches the next delimiter (char listed in DELIM) starting at *STRINGP.
     If one is found, it is overwritten with a NUL, and *STRINGP is advanced
     to point to the next char after it.  Otherwise, *STRINGP is set to NULL.
***************
*** 40,43 ****
--- 44,49 ----
  
  extern char *strsep (char **stringp, const char *delim);
  
+ #endif
+ 
  #endif /* GNULIB_STRSEP_H_ */





reply via email to

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