diff options
author | Ruan HE <ruan.he@orange.com> | 2015-09-04 07:35:06 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@172.30.200.206> | 2015-09-04 07:35:06 +0000 |
commit | ca6aa8198d2335f8c326c3dd4d26bf5899064214 (patch) | |
tree | 6274a2d971fc0cac0896efe8583927d0190e3d20 /moon-abe/pbc-0.5.14/doc/extract | |
parent | 92fd2dbfb672d7b2b1cdfd5dd5cf89f7716b3e12 (diff) | |
parent | 3baeb11a8fbcfcdbc31976d421f17b85503b3ecd (diff) |
Merge "init attribute-based encryption"
Diffstat (limited to 'moon-abe/pbc-0.5.14/doc/extract')
-rw-r--r-- | moon-abe/pbc-0.5.14/doc/extract | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/moon-abe/pbc-0.5.14/doc/extract b/moon-abe/pbc-0.5.14/doc/extract new file mode 100644 index 00000000..77a6a69a --- /dev/null +++ b/moon-abe/pbc-0.5.14/doc/extract @@ -0,0 +1,67 @@ +#!/usr/bin/gawk -f +# Extract GMP-style documentation from source using AsciiDoc format. +# Fragile: +# - requires function definition/declaration to end with ")\n" or ");" or ") {" +# - does not play nice with function pointer parameters + +# Look for the magic string "/*@manual " +/^\/\*@manual / { + outfile = "gen/" gensub(".*manual ", "", 1) ".txt" + print "Writing to " outfile + n = 0 + getline + # Stop at the line "*/". + while ($0 != "*/") { + a[n] = $0 + n++ + getline + } + +# Simple version with no markup: +# do { +# getline +# print +# } while (!match($0, ";") && !match($0, "{")) + +# Mark up bits of the function declaration with AsciiDoc, e.g: +# "int main(int argc, char *argv[]);" should become +# "int *main*('int argc', 'char *argv[]');" +# Also suppress "static inline". + getline + +# Handle variable declarations. + if (!match($0, "\\(")) { + s = gensub("([^ ]*);", "*\\1*", 1) # Bold variable name. +# Handle macro declarations. + } else if (match($0, "^#define")) { + s = gensub("^#define *(.*[^ ]) *\\\\$", "*\\1*", 1) +# Otherwise it's a function. + } else { + + sub("static inline ", "") + s = gensub("(\\w*)\\(", " *\\1*(", 1) # Bold function name. + s = gensub("\\((.*$)", "('\\1", 1, s) # First parameter. + gsub(", *", "', '", s) # Separating commas. + gsub("_ptr", "_t", s) +# Handle multi-line function declarations. + while (!match(s, ");") && !match(s, ") *$") && !match(s, ") *{")) { + getline + gsub("^ *", "") # Remove leading whitespace. + gsub(", *", "', '") # Commas again. + gsub("_ptr", "_t") + s = s $0 + } + s = gensub("(.*)\\)", "\\1')", 1, s) # Last parameter + gsub("_ptr", "_t", s) + gsub(")[^)]*$", ")", s); + } + + print s "\n" > outfile + if (n > 0) { + print "____" > outfile + for(i = 0; i < n; i++) { + print a[i] > outfile + } + print "____" > outfile + } +} |