From 38e9793ec9652460f54776e88875683326fb486b Mon Sep 17 00:00:00 2001 From: thib Date: Thu, 22 Jun 2000 15:34:06 +0000 Subject: [PATCH] Initial revision --- script/gen-in.pl | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 script/gen-in.pl diff --git a/script/gen-in.pl b/script/gen-in.pl new file mode 100755 index 0000000..81c8b40 --- /dev/null +++ b/script/gen-in.pl @@ -0,0 +1,51 @@ +#!/usr/bin/perl + +# - read define assignations in config.h +# - read variable assignations in Makefile +# - construct a hash with that reads +# - read file given in arg 1 and perform substitutions +# of the name of a variable by its value +# +# ex : "@@VERSION@" will be substitute by "0.8.4" +# +# + substitute "@@Date@" by the current date + + +%map = (); + + + +open(CONFIG, "./config.h") or print "error while opening config.h\n" and exit; + +while ( ) { + if ( /^\#define\s+(\w+?)\s+([\w\/-]+?)\s/ ) { + $map{$1} = $2; + } + if ( /^\#define\s+(\w+?)\s+["](.+?)["]\s/ ) { + $map{$1} = $2; + } + +} + +open(MAKEFILE, "./Makefile") or print "error while opening Makefile\n" and exit; + +while ( ) { + if ( /^\s*?(\w+?)\s*?=\s*?([\w\.\/-]+)\s/ ) { + $map{$1} = $2; + } + if ( /^\#define\s+(\w+?)\s+["](.+)["]\s/ ) { + $map{$1} = $2; + } + +} + +chop ($map{Date} = `date +%m/%d/%Y`); + +open(SRC, $ARGV[0]) or print "error while opening $ARGV[0]\n" and exit; +open(DEST, ">$ARGV[1]") or print "error while opening $ARGV[1]\n" and exit; + +while ( ) { + s/@@([^@]*)@/$map{$1}/g; + print DEST $_; + +} -- 2.40.0