summaryrefslogtreecommitdiff
path: root/doc/scripts
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2013-11-09 18:08:55 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2013-11-09 19:31:43 +0100
commit39f21d902a2d838da4469bfe25f6fcd3bfd753f4 (patch)
tree86678298fd9f04ac582773622eebac32a9c82b43 /doc/scripts
parente95716085c0b8d069e13a0e15a3233e4babd5b4e (diff)
downloadgnutls-39f21d902a2d838da4469bfe25f6fcd3bfd753f4.tar.gz
Improvements in the detection of function prototypes to account for the new indentation.
Diffstat (limited to 'doc/scripts')
-rwxr-xr-xdoc/scripts/gdoc20
-rwxr-xr-xdoc/scripts/getfuncs.pl89
2 files changed, 88 insertions, 21 deletions
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);
}
}