bug-gnulib
[Top][All Lists]
Advanced

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

[bug-gnulib] Automatic prototypes, again


From: Simon Josefsson
Subject: [bug-gnulib] Automatic prototypes, again
Date: Sat, 01 Jan 2005 16:50:39 +0100
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux)

This is an attempt to add the "automatic prototype" feature discussed
earlier, in a non-intrusive way.  Unless --automatic-prototypes is
used, everything should behave as before.

What do you think?

2005-01-01  Simon Josefsson  <address@hidden>

        * modules/strdup (Autproto): New field, call gl_AUTOPROTO_STRDUP.

        * gnulib-tool: Make --automatic-prototypes add the Autoproto:
        snippet from modules files, to invoke gl_AUTOPROTO_* M4 functions.

2005-01-01  Simon Josefsson  <address@hidden>

        * strdup.m4 (gl_AUTOPROTO_STRDUP): New function.

Index: gnulib-tool
===================================================================
RCS file: /cvsroot/gnulib/gnulib/gnulib-tool,v
retrieving revision 1.37
diff -u -p -r1.37 gnulib-tool
--- gnulib-tool 15 Dec 2004 22:31:01 -0000      1.37
+++ gnulib-tool 1 Jan 2005 15:43:44 -0000
@@ -1,6 +1,6 @@
 #! /bin/sh
 #
-# Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2004, 2005 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
@@ -93,6 +93,12 @@ Options:
       --libtool             Use libtool rules, for --import.
       --no-changelog        don't update or create ChangeLog files
       --dry-run             For --import, only print what would have been done.
+      --automatic-prototypes
+                            Allow modules to add definitions to
+                            config.h so that you do not have to
+                            include header files for standard
+                            functions (e.g., strdup).  Only supported
+                            by a few modules.
 
 Report bugs to <address@hidden>."
 }
@@ -128,6 +134,7 @@ func_fatal_error ()
 # - lgpl            true if --lgpl was given, blank otherwise
 # - do_changelog    false if --no-changelog was given, : otherwise
 # - dry_run         true if --dry-run was given, blank otherwise
+# - autoproto       true if --automatic-prototypes was given, blank otherwise.
 {
   mode=
   destdir=
@@ -140,6 +147,7 @@ func_fatal_error ()
   do_changelog=:
   dry_run=
   lgpl=
+  autoproto=
 
   supplied_opts="$@"
 
@@ -220,6 +228,9 @@ func_fatal_error ()
       --dry-run )
         dry_run=true
         shift ;;
+      --automatic-prototypes )
+        autoproto=true
+        shift ;;
       --help | --hel | --he | --h )
         func_usage
         exit 0 ;;
@@ -298,6 +309,7 @@ sed_extract_prog=':[        ]*$/ {
     s/^configure\.ac:[         ]*$//
     s/^Makefile\.am:[  ]*$//
     s/^Include:[       ]*$//
+    s/^Autoproto:[     ]*$//
     s/^License:[       ]*$//
     s/^Maintainer:[    ]*$//
     tb
@@ -332,6 +344,12 @@ func_get_autoconf_snippet ()
   sed -n -e "/^configure\.ac$sed_extract_prog" < "$gnulib_dir/modules/$1"
 }
 
+# func_get_autoproto_snippet module
+func_get_autoproto_snippet ()
+{
+  sed -n -e "/^Autoproto$sed_extract_prog" < "$gnulib_dir/modules/$1"
+}
+
 # func_get_automake_snippet module
 func_get_automake_snippet ()
 {
@@ -596,6 +614,9 @@ func_import ()
           echo 'AC_SUBST(LTALLOCA)'
         fi
       fi
+      if test -n "$autoproto"; then
+        func_get_autoproto_snippet "$module" | sed -e '/^$/d;' -e 's/^/  /'
+      fi
     done
     echo "])"
     echo
Index: m4/strdup.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/strdup.m4,v
retrieving revision 1.4
diff -u -p -r1.4 strdup.m4
--- m4/strdup.m4        7 Aug 2004 02:58:12 -0000       1.4
+++ m4/strdup.m4        1 Jan 2005 15:43:44 -0000
@@ -1,5 +1,5 @@
-# strdup.m4 serial 4
-dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+# strdup.m4 serial 5
+dnl Copyright (C) 2002, 2003, 2004, 2005 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
 dnl Public License, this file may be distributed as part of a program
@@ -15,3 +15,11 @@ AC_DEFUN([gl_FUNC_STRDUP],
 
 # Prerequisites of lib/strdup.c.
 AC_DEFUN([gl_PREREQ_STRDUP], [:])
+
+AC_DEFUN([gl_AUTOPROTO_STRDUP],
+[
+  AH_BOTTOM([/* Prototype for strdup. */
+#if !HAVE_DECL_STRDUP
+extern char *strdup (const char *s);
+#endif])
+])
Index: modules/strdup
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/strdup,v
retrieving revision 1.5
diff -u -p -r1.5 strdup
--- modules/strdup      22 Sep 2004 15:11:04 -0000      1.5
+++ modules/strdup      1 Jan 2005 15:43:44 -0000
@@ -17,6 +17,9 @@ lib_SOURCES += strdup.h
 Include:
 "strdup.h"
 
+Autoproto:
+gl_AUTOPROTO_STRDUP
+
 License:
 LGPL
 




reply via email to

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