diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2013-11-09 18:08:55 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2013-11-09 19:31:43 +0100 |
commit | 39f21d902a2d838da4469bfe25f6fcd3bfd753f4 (patch) | |
tree | 86678298fd9f04ac582773622eebac32a9c82b43 | |
parent | e95716085c0b8d069e13a0e15a3233e4babd5b4e (diff) | |
download | gnutls-39f21d902a2d838da4469bfe25f6fcd3bfd753f4.tar.gz |
Improvements in the detection of function prototypes to account for the new indentation.
-rw-r--r-- | doc/Makefile.am | 30 | ||||
-rwxr-xr-x | doc/scripts/gdoc | 20 | ||||
-rwxr-xr-x | doc/scripts/getfuncs.pl | 89 | ||||
-rw-r--r-- | lib/includes/gnutls/gnutls.h.in | 10 |
4 files changed, 109 insertions, 40 deletions
diff --git a/doc/Makefile.am b/doc/Makefile.am index 54d285adf3..72a77faff6 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -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"; \ diff --git a/doc/scripts/gdoc b/doc/scripts/gdoc index dbe2efe30a..e3db7624df 100755 --- a/doc/scripts/gdoc +++ b/doc/scripts/gdoc @@ -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; - } } } + } diff --git a/doc/scripts/getfuncs.pl b/doc/scripts/getfuncs.pl index 9e7680558a..e7a0387a1b 100755 --- a/doc/scripts/getfuncs.pl +++ b/doc/scripts/getfuncs.pl @@ -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); } } diff --git a/lib/includes/gnutls/gnutls.h.in b/lib/includes/gnutls/gnutls.h.in index f90f836276..11102127da 100644 --- a/lib/includes/gnutls/gnutls.h.in +++ b/lib/includes/gnutls/gnutls.h.in @@ -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, |