From 27295376f34e1ccff4b4e4cfec62deb0a3755f92 Mon Sep 17 00:00:00 2001
From: Rainer Backofen <rainer.backofen@tu-dresden.de>
Date: Wed, 8 Jun 2011 07:52:01 +0000
Subject: [PATCH] added script to automatically make changes needed for
 revision 0.9 (GET_PARAMETER()->Paraemters::get() etc. )

---
 AMDiS/other/scripts/changeToRevision/README   | 12 +++-
 .../changeToRevision/applyChangesToRelease0.9 | 23 ++++++++
 .../changeToRevision/updateGET_PARAMETER.gawk | 56 +++++++++++++++++++
 3 files changed, 89 insertions(+), 2 deletions(-)
 create mode 100755 AMDiS/other/scripts/changeToRevision/applyChangesToRelease0.9
 create mode 100755 AMDiS/other/scripts/changeToRevision/updateGET_PARAMETER.gawk

diff --git a/AMDiS/other/scripts/changeToRevision/README b/AMDiS/other/scripts/changeToRevision/README
index feb855a5..c536a5d0 100644
--- a/AMDiS/other/scripts/changeToRevision/README
+++ b/AMDiS/other/scripts/changeToRevision/README
@@ -4,9 +4,17 @@ to new revisions according AMDiS/ChangeLog.
 Start the script in your directory. 
 All files in directory src will be changed according AMDiS/ChangeLog.
 First directory src is copied.
+Script may ruin your code...
 No warranty!! NO WARRANTY !!!
 
 ---------------------------------------------------------------------
-1. applyChanges4Rev1210 (all cahnges according ChangeLog)
+1. applyChanges4Rev1210 (all changes according ChangeLog)
+
+2. applyChangesToRelease0.9  and updateGET_PARAMETER.gawk 
+   changes:
+     Laplace_SOT -> Simple_SOT
+     ProblemVec->ProblemStat
+     ProblemInstatVec->ProblemInstat
+     GET_PARAMETER(...)->Parameters::get(...)
+   details see in  updateGET_PARAMETER.gawk
 
-  
diff --git a/AMDiS/other/scripts/changeToRevision/applyChangesToRelease0.9 b/AMDiS/other/scripts/changeToRevision/applyChangesToRelease0.9
new file mode 100755
index 00000000..1ab936cd
--- /dev/null
+++ b/AMDiS/other/scripts/changeToRevision/applyChangesToRelease0.9
@@ -0,0 +1,23 @@
+#!/bin/bash
+#
+# secures current directory in src_beforeChanges
+# replaces according ChangeLog in every 
+# file in src directory.
+# 
+# 
+# on your own responsibility
+#  Rainer
+#
+if [ -f ./updateGET_PARAMETER.gawk ]
+  then
+    echo "updateGET_PARAMETER.gawk found"
+    cp -r src src_beforeChangesToRelaease0.9
+#
+    find src/* -type f | while read file
+    do
+	./updateGET_PARAMETER.gawk < $file > $file.$$
+	mv -v	$file.$$ $file	
+    done
+else
+ echo "you need updateGET_PARAMETER.gawk "
+fi
\ No newline at end of file
diff --git a/AMDiS/other/scripts/changeToRevision/updateGET_PARAMETER.gawk b/AMDiS/other/scripts/changeToRevision/updateGET_PARAMETER.gawk
new file mode 100755
index 00000000..b391f658
--- /dev/null
+++ b/AMDiS/other/scripts/changeToRevision/updateGET_PARAMETER.gawk
@@ -0,0 +1,56 @@
+#! /usr/bin/gawk -f
+
+BEGIN{
+#print "Change old style GET_PARAMETER(..) \
+#to new Style Parameters::get(...)\n";
+lineComplete=1;
+cmdline="";
+}
+ { cmdline=cmdline$0; $0=cmdline;}
+ /GET_PARAMETER/ { ##find line with GET_PARAMETER
+     ## check if line is complete
+     ##print " 1 "cmdline;
+     gsub(/\(\)/,"XRAINERXX",cmdline );
+     gsub(/\(0\)/,"XRAINERXX0",cmdline );
+     gsub(/\(1\)/,"XRAINERXX1",cmdline );
+     gsub(/\(2\)/,"XRAINERXX2",cmdline );
+     gsub(/\(3\)/,"XRAINERXX3",cmdline );
+     gsub(/\(4\)/,"XRAINERXX4",cmdline );
+     split(cmdline,l,"[()]");
+     if(l[3]) {lineComplete=1; }
+     else {lineComplete=0;}
+     if(lineComplete==1){	
+	 ## find argument of GET_PARAMETER l[2]	
+	 split(cmdline,l,"[()]"); 
+	 split(cmdline,lw,"GET_"); ## get leading whitespaces
+	 ## split arguments => a[2] is label a[3]or a[4] variable
+	 split(l[2],a,",");
+	 ## find variable
+	 checkFormat=match(a[3],"\"");
+	 if(checkFormat) {val=a[4];}
+	 else{val=a[3];}
+	 gsub(/^[ \t]+|[ \t]+$/,"",val)## remove whitespaces 
+	 where=match(val,"&")  ##check for & 
+	 if (where!=0){ 
+	     gsub(/\&/,"",val);
+	 }else{
+	     val="(&"val")";	
+	 }		 
+	 cmdline= lw[1]"Parameters::get("a[2]","val");"  ;
+	 gsub(/XRAINERXX/,"()",cmdline );        
+	 gsub(/XRAINERXX0/,"(0)",cmdline );        
+	 gsub(/XRAINERXX1/,"(1)",cmdline );        
+	 gsub(/XRAINERXX2/,"(2)",cmdline );        
+	 gsub(/XRAINERXX3/,"(3)",cmdline );        
+	 gsub(/XRAINERXX4/,"(4)",cmdline );        
+     }	  
+ }
+{ if(lineComplete==1) {
+	gsub(/ProblemInstatVec/,"ProblemInstat",cmdline)
+	gsub(/ProblemVec/,"ProblemStat",cmdline)
+	gsub(/FactorLaplace_SOT/,"Simple_SOT",cmdline)
+	gsub(/Laplace_SOT/,"Simple_SOT",cmdline)
+	print cmdline;
+	cmdline=""; } }
+				
+
-- 
GitLab