]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Improvements in the detection of function prototypes to account for the new indentation.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 9 Nov 2013 17:08:55 +0000 (18:08 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 9 Nov 2013 18:31:43 +0000 (19:31 +0100)
doc/Makefile.am
doc/scripts/gdoc
doc/scripts/getfuncs.pl
lib/includes/gnutls/gnutls.h.in

index 54d285adf3da9b99eeda289054002a2800b22d6e..72a77faff626a3d5a5dbb41abe31c64860db0080 100644 (file)
@@ -223,7 +223,7 @@ MAINTAINERCLEANFILES += $(API_FILES)
 
 gnutls-api.texi: $(top_srcdir)/lib/includes/gnutls/gnutls.h.in
        echo "" > $@-tmp
-       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $<|sort|uniq`; do \
+       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $< |sort|uniq`; do \
                echo $(ECHO_N) "Creating documentation for $$i... " && \
                $(srcdir)/scripts/gdoc -texinfo \
                        -function $$i \
@@ -234,7 +234,7 @@ gnutls-api.texi: $(top_srcdir)/lib/includes/gnutls/gnutls.h.in
 
 dane-api.texi: $(top_srcdir)/libdane/includes/gnutls/dane.h
        echo "" > $@-tmp
-       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $<|sort|uniq`; do \
+       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $< |sort|uniq`; do \
                echo $(ECHO_N) "Creating documentation for $$i... " && \
                $(srcdir)/scripts/gdoc -texinfo \
                        -function $$i \
@@ -245,7 +245,7 @@ dane-api.texi: $(top_srcdir)/libdane/includes/gnutls/dane.h
 
 x509-api.texi: $(top_srcdir)/lib/includes/gnutls/x509.h
        echo "" > $@-tmp
-       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $<|sort|uniq`; do \
+       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $< |sort |uniq`; do \
                echo $(ECHO_N) "Creating documentation for $$i... " && \
                $(srcdir)/scripts/gdoc -texinfo \
                        -function $$i \
@@ -256,7 +256,7 @@ x509-api.texi: $(top_srcdir)/lib/includes/gnutls/x509.h
 
 xssl-api.texi: $(top_srcdir)/lib/includes/gnutls/xssl.h
        echo "" > $@-tmp
-       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $<|sort|uniq`; do \
+       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $< |sort|uniq`; do \
                echo $(ECHO_N) "Creating documentation for $$i... " && \
                $(srcdir)/scripts/gdoc -texinfo \
                        -function $$i \
@@ -267,7 +267,7 @@ xssl-api.texi: $(top_srcdir)/lib/includes/gnutls/xssl.h
 
 pgp-api.texi: $(top_srcdir)/lib/includes/gnutls/openpgp.h
        echo "" > $@-tmp
-       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $<|sort|uniq`; do \
+       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $< |sort|uniq`; do \
                echo $(ECHO_N) "Creating documentation for $$i... " && \
                $(srcdir)/scripts/gdoc -texinfo \
                        -function $$i \
@@ -279,7 +279,7 @@ pgp-api.texi: $(top_srcdir)/lib/includes/gnutls/openpgp.h
 
 pkcs12-api.texi: $(top_srcdir)/lib/includes/gnutls/pkcs12.h
        echo "" > $@-tmp
-       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $<|sort|uniq`; do \
+       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $< |sort|uniq`; do \
                echo $(ECHO_N) "Creating documentation for $$i... " && \
                $(srcdir)/scripts/gdoc -texinfo \
                        -function $$i \
@@ -290,7 +290,7 @@ pkcs12-api.texi: $(top_srcdir)/lib/includes/gnutls/pkcs12.h
 
 pkcs11-api.texi: $(top_srcdir)/lib/includes/gnutls/pkcs11.h
        echo "" > $@-tmp
-       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $<|sort|uniq`; do \
+       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $< |sort|uniq`; do \
                echo $(ECHO_N) "Creating documentation for $$i... " && \
                $(srcdir)/scripts/gdoc -texinfo \
                        -function $$i \
@@ -301,7 +301,7 @@ pkcs11-api.texi: $(top_srcdir)/lib/includes/gnutls/pkcs11.h
 
 tpm-api.texi: $(top_srcdir)/lib/includes/gnutls/tpm.h
        echo "" > $@-tmp
-       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $<|sort|uniq`; do \
+       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $< |sort|uniq`; do \
                echo $(ECHO_N) "Creating documentation for $$i... " && \
                $(srcdir)/scripts/gdoc -texinfo \
                        -function $$i \
@@ -312,7 +312,7 @@ tpm-api.texi: $(top_srcdir)/lib/includes/gnutls/tpm.h
 
 abstract-api.texi: $(top_srcdir)/lib/includes/gnutls/abstract.h
        echo "" > $@-tmp
-       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $<|sort|uniq`; do \
+       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $< |sort|uniq`; do \
                echo $(ECHO_N) "Creating documentation for $$i... " && \
                $(srcdir)/scripts/gdoc -texinfo \
                        -function $$i \
@@ -323,7 +323,7 @@ abstract-api.texi: $(top_srcdir)/lib/includes/gnutls/abstract.h
 
 compat-api.texi: $(top_srcdir)/lib/includes/gnutls/compat.h
        echo "" > $@-tmp
-       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $<|sort|uniq`; do \
+       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $< |sort|uniq`; do \
                echo $(ECHO_N) "Creating documentation for $$i... " && \
                $(srcdir)/scripts/gdoc -texinfo \
                        -function $$i \
@@ -334,7 +334,7 @@ compat-api.texi: $(top_srcdir)/lib/includes/gnutls/compat.h
 
 dtls-api.texi: $(top_srcdir)/lib/includes/gnutls/dtls.h
        echo "" > $@-tmp
-       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $<|sort|uniq`; do \
+       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $< |sort|uniq`; do \
                echo $(ECHO_N) "Creating documentation for $$i... " && \
                $(srcdir)/scripts/gdoc -texinfo \
                        -function $$i \
@@ -345,7 +345,7 @@ dtls-api.texi: $(top_srcdir)/lib/includes/gnutls/dtls.h
 
 crypto-api.texi: $(top_srcdir)/lib/includes/gnutls/crypto.h
        echo "" > $@-tmp
-       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $<|sort|uniq`; do \
+       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $< |sort|uniq`; do \
                echo $(ECHO_N) "Creating documentation for $$i... " && \
                $(srcdir)/scripts/gdoc -texinfo \
                        -function $$i \
@@ -356,8 +356,8 @@ crypto-api.texi: $(top_srcdir)/lib/includes/gnutls/crypto.h
 
 ocsp-api.texi: $(top_srcdir)/lib/includes/gnutls/ocsp.h
        echo "" > $@-tmp
-       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $<|sort|uniq`; do \
-               echo $(ECHO_N) "Creating documentation for file $$i... " && \
+       for i in `$(top_srcdir)/doc/scripts/getfuncs.pl < $< |sort|uniq`; do \
+               echo $(ECHO_N) "Creating documentation for $$i... " && \
                $(srcdir)/scripts/gdoc -texinfo \
                        -function $$i \
                        $(C_SOURCE_FILES) >> $@-tmp 2>/dev/null && \
@@ -446,7 +446,7 @@ compare-makefile: enums.texi
                perl -p -e "s,^ENUMS =,ENUMS =$$STR," > tmp-$@; \
        diff -u $(srcdir)/Makefile.am tmp-$@
        rm -f tmp-$@
-       FUNCS=`cat $(HEADER_FILES) | $(top_srcdir)/doc/scripts/getfuncs.pl|sort -d`; \
+       FUNCS=`cat $(HEADER_FILES) | $(top_srcdir)/doc/scripts/getfuncs.pl|sort -d|uniq`; \
        MANS=""; \
        for i in $$FUNCS; do \
                MANS="$$MANS\nFUNCS += functions/$$i\nFUNCS += functions/$$i.short"; \
index dbe2efe30a8dbfb2acf6ce77655b8f618e8aef51..e3db7624dfb50881d3f03166f9c473630ce55d03 100755 (executable)
@@ -937,6 +937,7 @@ $section = $section_default;
 $enum = 0;
 
 $lineno = 0;
+
 foreach $file (@ARGV) {
     if (!open(IN,"<$file")) {
        print STDERR "Error: Cannot open file $file\n";
@@ -992,7 +993,7 @@ foreach $file (@ARGV) {
                    $contents = "";
                }
 
-               $prototype = "";
+               $prototype = '';
                $state = 3;
            } elsif ($line =~ /$doc_content/) {
                # miguel-style comment kludge, look for blank lines after
@@ -1009,19 +1010,25 @@ foreach $file (@ARGV) {
                print STDERR "warning: $lineno: Bad line: $_";
            }
        } elsif ($state == 3) { # scanning for function { (end of prototype)
+           if ($line =~ /([a-zA-Z\s]+)enum(.*)$/) {
+               $enum = 1;
+           }
+
            if ($line =~ m#\s*/\*\s+MACDOC\s*#io) {
              # do nothing
            }
-           elsif ($enum == 1 && $line =~ /(^\s*\{).*/) {
-               $prototype .= "{";
+           elsif ($enum == 1 && $line =~ /(\s*\{).*/) {
+               $prototype = "typedef enum {";
            }
            elsif ($line =~ /([^\{]*)/) {
                $prototype .= $1;
            }
-           if ($enum == 0 && $line =~ /\{/) {
+
+           if ($enum == 0 && $line =~ /;/) {
                $prototype =~ s@/\*.*?\*/@@gos; # strip comments.
                $prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's.
                $prototype =~ s@^ +@@gos; # strip leading spaces
+
                dump_function($prototype);
 
                $function = "";
@@ -1040,6 +1047,7 @@ foreach $file (@ARGV) {
                $prototype =~ s@/\*.*?\*/@@gos; # strip comments.
                $prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's.
                $prototype =~ s@^ +@@gos; # strip leading spaces
+
                dump_enum($prototype);
 
                $function = "";
@@ -1054,10 +1062,8 @@ foreach $file (@ARGV) {
 
                $state = 0;
            }
-           elsif ($line =~ /([a-zA-Z\s]+)enum(.*)$/) {
-               $enum = 1;
-           }
     
        }
     }
+
 }
index 9e7680558a4833ca5df9fcac5db595de7ff33804..e7a0387a1bed2a67f898345f578dc0653e1625b0 100755 (executable)
@@ -3,6 +3,7 @@ eval '(exit $?0)' && eval 'exec perl -wST "$0" ${1+"$@"}'
     if 0;
 
 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
+# Copyright (C) 2013 Nikos Mavrogiannopoulos
 #
 # This file is part of GnuTLS.
 #
@@ -23,27 +24,87 @@ eval '(exit $?0)' && eval 'exec perl -wST "$0" ${1+"$@"}'
 # given a header file in stdin it will print all functions
 
 my $line;
-my $func;
+my $func_name;
+my $prototype;
+
+$state = 0;
+
+# 0: scanning
+# 1: comment
+# 2: struct||enum
+# 3: function
+
+sub function_print {
+  my $prototype = shift @_;
+
+  if ($prototype =~ m/^\s*\w\s+[A-Za-z0-9_]+[\s\*]+([A-Za-z0-9_]+)\s*\(.*/) {
+    $func_name = $1;
+  } elsif ($prototype =~ m/^\s*[A-Za-z0-9_]+[\s\*]+([A-Za-z0-9_]+)\s*\([^\)]+/) {
+    $func_name = $1;
+  } elsif ($prototype =~ m/^\s*\w+\s+\w+[\s\*]+([A-Za-z0-9_]+)\s*\([^\)]+/) {
+    $func_name = $1;
+  } elsif ($prototype =~ m/^[\s\*]*([A-Za-z0-9_]+)\s*\([^\)]+/) {
+    $func_name = $1;
+  } elsif ($prototype =~ m/^[\s\*]*[A-Za-z0-9_]+\s+([A-Za-z0-9_]+)/) {
+    $func_name = $1;
+  }
+
+#print STDERR "function: $prototype\n";
+  if ($func_name ne '' && ($func_name =~ m/gnutls_.*/ || $func_name =~ m/dane_.*/ || $func_name =~ m/xssl_.*/)) {
+    print $func_name . "\n";
+  }
+      
+  return;
+}
 
 while ($line=<STDIN>) {
 
-  if ($line !~ m/typedef/ && $line !~ m/Copyright/ && $line !~ m/doc-skip/) {
-    $func = '';
-    
-    if ($line =~ m/^\s*\w+[\s\*]+([A-Za-z0-9_]+)\s*\([^\)]+/) {
-        $func = $1;
-    }
+  next if ($line eq '');
+# print STDERR "line($state): $line";
 
-    if ($line =~ m/^\s*\w+\s+\w+[\s\*]+([A-Za-z0-9_]+)\s*\([^\)]+/) {
-        $func = $1;
-    }
+  #skip comments
+  if ($state == 0) {
+    if ($line =~ m/^\s*\/\*/) {
+
+      next if ($line =~ m/\*\//);
+
+      $state = 1;
+      next;
+    } elsif ($line =~ m/^\s*typedef\s+enum/ || $line =~ m/^\s*enum/ || 
+             $line =~ m/^\s*struct/ || $line =~ m/^\s*typedef\s+struct/) {
+
+      next if ($line =~ m/;/);
+      $state = 2;
+      next;
+    } elsif ($line !~ m/^\s*extern/ && $line !~ m/^\s*typedef/ && $line !~ m/doc-skip/ && $line =~ m/^\s*\w/) {
+      $state = 3;
 
-    if ($line =~ m/^[\s\*]*([A-Za-z0-9_]+)\s*\([^\)]+/) {
-        $func = $1;
+      $prototype = "$line";
+      $func_name = '';
+
+      if ($line =~ m/;/) {
+        function_print($prototype);
+        $state = 0;
+        next;
+      }
+    }
+  } elsif ($state == 1) { # comment
+    if ($line =~ m/\*\//) {
+      $state = 0;
+      next;
     }
+  } elsif ($state == 2) { #struct||enum
+    if ($line =~ m/;/) {
+      $state = 0;
+      next;
+    }
+  } elsif ($state == 3) {
+    $prototype .= $line;
     
-    if ($func ne '' && ($func =~ m/gnutls_.*/ || $func =~ m/dane_.*/)) {
-      print $func . "\n";
+    if ($line =~ m/;/) {
+      $state = 0;
+
+      function_print($prototype);
     }
   }
 
index f90f836276f2e711ebec8bfd5cd8685a6f83c0f4..11102127dad8db5922ba7087dee7c1d9d1ee5a0d 100644 (file)
@@ -1522,9 +1522,11 @@ typedef ssize_t(*gnutls_vec_push_func) (gnutls_transport_ptr_t,
 
 typedef int (*gnutls_errno_func) (gnutls_transport_ptr_t);
 
-/* This will be defined as macro.
+#if 0
+ /* This will be defined as macro. */
   void gnutls_transport_set_int (gnutls_session_t session, int r);
- */
+#endif
+
 void gnutls_transport_set_int2(gnutls_session_t session, int r, int s);
 #define gnutls_transport_set_int(s, i) gnutls_transport_set_int2(s, i, i)
 
@@ -1614,8 +1616,8 @@ int gnutls_srp_set_server_credentials_file(gnutls_srp_server_credentials_t
 
 const char *gnutls_srp_server_get_username(gnutls_session_t session);
 
-extern void gnutls_srp_set_prime_bits(gnutls_session_t session,
-                                     unsigned int bits);
+void gnutls_srp_set_prime_bits(gnutls_session_t session,
+                               unsigned int bits);
 
 int gnutls_srp_verifier(const char *username,
                        const char *password,