Mention updated config files.
[rsync.git] / mkproto.awk
index 6a46c46d9bb2bfc9dd7ca9f9ebb95ce2368b66f8..bd2e927b947b86c24e4d447dad5e480fa4cedc97 100644 (file)
@@ -1,74 +1,40 @@
-# generate prototypes for Samba C code
-# tridge, June 1996
+#!/usr/bin/awk -f
 
 BEGIN {
-  inheader=0;
-  print "/* This file is automatically generated with \"make proto\". DO NOT EDIT */"
-  print ""
+    while ((getline i < "proto.h") > 0) old_protos = old_protos ? old_protos "\n" i : i
+    close("proto.h")
+    protos = "/* This file is automatically generated with \"make proto\". DO NOT EDIT */\n"
 }
 
-{
-  if (inheader) {
-    if (match($0,"[)][ \t]*$")) {
-      inheader = 0;
-      printf "%s;\n",$0;
-    } else {
-      printf "%s\n",$0;
-    }
-    next;
-  }
+inheader {
+    protos = protos "\n" ((inheader = /\)[ \t]*$/ ? 0 : 1) ? $0 : $0 ";")
+    next
 }
 
-/^FN_LOCAL_BOOL/ {
-  split($0,a,"[,()]")
-  printf "BOOL %s(int );\n", a[2]
+/^FN_(LOCAL|GLOBAL)_[^(]+\([^,()]+/ {
+    local = /^FN_LOCAL/
+    gsub(/^FN_(LOC|GLOB)AL_|,.*$/, "")
+    sub(/^BOOL\(/, "BOOL ")
+    sub(/^CHAR\(/, "char ")
+    sub(/^INTEGER\(/, "int ")
+    sub(/^STRING\(/, "char *")
+    protos = protos "\n" $0 (local ? "(int module_id);" : "(void);")
+    next
 }
 
-/^FN_LOCAL_STRING/ {
-  split($0,a,"[,()]")
-  printf "char *%s(int );\n", a[2]
-}
-
-/^FN_LOCAL_INT/ {
-  split($0,a,"[,()]")
-  printf "int %s(int );\n", a[2]
-}
-
-/^FN_LOCAL_CHAR/ {
-  split($0,a,"[,()]")
-  printf "char %s(int );\n", a[2]
-}
-
-/^FN_GLOBAL_BOOL/ {
-  split($0,a,"[,()]")
-  printf "BOOL %s(void);\n", a[2]
-}
-
-/^FN_GLOBAL_STRING/ {
-  split($0,a,"[,()]")
-  printf "char *%s(void);\n", a[2]
-}
-
-/^FN_GLOBAL_INT/ {
-  split($0,a,"[,()]")
-  printf "int %s(void);\n", a[2]
-}
-
-/^static|^extern/ || /[;]/ {
-  next;
-}
+/^static|^extern|;/||!/^[A-Za-z][A-Za-z0-9_]* / { next }
 
-!/^[A-Za-z][A-Za-z0-9_]* / {
-  next;
+/\(.*\)[ \t]*$/ {
+    protos = protos "\n" $0 ";"
+    next
 }
 
-/[(].*[)][ \t]*$/ {
-    printf "%s;\n",$0;
-    next;
+/\(/ {
+    inheader = 1
+    protos = protos "\n" $0
 }
 
-/[(]/ {
-  inheader=1;
-  printf "%s\n",$0;
-  next;
+END {
+    if (old_protos != protos) print protos > "proto.h"
+    system("touch proto.h-tstamp")
 }