]> git.proxmox.com Git - mirror_frr.git/commitdiff
2005-04-16 Paul Jakma <paul@dishone.st>
authorpaul <paul>
Sat, 16 Apr 2005 15:51:05 +0000 (15:51 +0000)
committerpaul <paul>
Sat, 16 Apr 2005 15:51:05 +0000 (15:51 +0000)
* memtypes.c: the comment about use of comments in the comments
  headers was causing comment within comment warnings from compiler
* memtypes.awk: Add extensive comments on the file format for
  memtypes.c.
  tighten the pattern for the MTYPE matching action (suggestion from
  Andrew) and tighten which field we try the match on.

lib/ChangeLog
lib/memtypes.awk
lib/memtypes.c

index c50a3646930239750f256d13125398f43292d091..e5ee54947b0b4148cedd4eee6ccd42233dab84ac 100644 (file)
@@ -1,3 +1,12 @@
+2005-04-16 Paul Jakma <paul@dishone.st>
+
+       * memtypes.c: the comment about use of comments in the comments
+         headers was causing comment within comment warnings from compiler
+       * memtypes.awk: Add extensive comments on the file format for
+         memtypes.c.
+         tighten the pattern for the MTYPE matching action (suggestion from
+         Andrew) and tighten which field we try the match on.
+
 2005-04-15 Paul Jakma <paul@dishone.st>
 
        * memtypes.c: The new, unified location for memory type definitions.
index 2da6547bff5106a914ed8234e8be67579bcd898b..9ab931bfaa99ce2aa2f6a3f6c40b3b67fc897086 100644 (file)
@@ -1,13 +1,37 @@
-# $Id: memtypes.awk,v 1.1 2005/04/15 11:47:15 paul Exp $
+# $Id: memtypes.awk,v 1.2 2005/04/16 15:51:05 paul Exp $
 #
 # Scan a file of memory definitions (see eg memtypes.c) and generate
 # a corresponding header file with an enum of the MTYPE's and declarations
 # for the struct memory_list arrays
 #
+# struct memory_list's must be declared as:
+# '\nstruct memory_list memory_list_<name>[] .....'
+#
+# Each MTYPE_ within the definition must the second token on the line,
+# tokens being delineated by whitespace. It may only consist of the set of
+# characters [A-Z_0-9]. Eg:
+#
+# '\n  {  MTYPE_AWESOME_IPV8 , "Amazing new protocol, says genius" {}..boo'
+#
+# We try to ignore lines whose first token is /* or *, ie C comment lines.
+# So the following should work fine:
+#
+# '/* This is the best memory_list ever!
+# ' * It's got all my MTYPE's */
+# '
+# 'struct memory_list memory_list_my_amazing_mlist[] = =
+# '{
+# '  { MTYPE_DONGLE, "Dongle widget" }
+# '  { MTYPE_FROB, "Frobulator" },
+# '{  MTYPE_WIPPLE, "Wipple combombulator"}
+# '}}}
+#
+# Even if it isn't quite a valid C declaration.
+#
 
 BEGIN {
        mlistregex = "memory_list_(.*)\\[\\]";
-       mtyperegex = "^.*(MTYPE_[A-Z_0-9]+).*$";
+       mtyperegex = "^(MTYPE_[A-Z_0-9]+).*";
        header = "/* Auto-generated from memtypes.c by " ARGV[0] ". */\n";
        header = header "/* Do not edit! */\n";
        header = header "\n#ifndef _QUAGGA_MEMTYPES_H\n";
@@ -17,12 +41,16 @@ BEGIN {
        printf ("%s\n", header);
 }
 
+# catch lines beginning with 'struct memory list ' and try snag the
+# memory_list name. Has to be 3rd field.
 ($0 ~ /^struct memory_list /) && (NF >= 3) {
        mlists[lcount++] = gensub(mlistregex,"\\1",g,$3);
 }
 
-($1 != "/*") && ($1 != "*") && ($2 ~ /MTYPE_/) { 
-       mtype[tcount++] = gensub(mtyperegex,"\\1",1, $0);
+# snag the MTYPE, it must self-standing and the second field,
+# though we do manage to tolerate the , C seperator being appended
+($1 !~ /^\/?\*/) && ($2 ~ /^MTYPE_/) { 
+       mtype[tcount++] = gensub(mtyperegex,"\\1",1, $2);
 } 
 
 END {
index a643d43b2ad9ffced28c68c788273bf60b4ac33b..6ee75a5823921dc55be5953157d682dc394dc73f 100644 (file)
@@ -3,10 +3,10 @@
  * MTYPE_ and memory_list_.. information in order to autogenerate 
  * memtypes.h.
  *
- * The script is sensitive to the format (though not whitespace), s
- * be careful. Comment lines /must/ start with either /* or *.
+ * The script is sensitive to the format (though not whitespace), see
+ * the top of memtypes.awk for more details.
  *
- * $Id: memtypes.c,v 1.1 2005/04/15 11:47:15 paul Exp $
+ * $Id: memtypes.c,v 1.2 2005/04/16 15:51:05 paul Exp $
  */
 
 #include "zebra.h"