You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by su...@apache.org on 2016/12/07 17:04:37 UTC
[1/2] incubator-trafodion git commit: [TRAFODION 2381] Enhance awk
script to support many variations of distros.
Repository: incubator-trafodion
Updated Branches:
refs/heads/master 67a8fb468 -> 82604a295
[TRAFODION 2381] Enhance awk script to support many variations of distros.
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/9c1ea1b4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/9c1ea1b4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/9c1ea1b4
Branch: refs/heads/master
Commit: 9c1ea1b4e191417c1b2f4ce055dc6c8648b1a31b
Parents: 0bbd910
Author: Prashant Vasudev <pr...@esgyn.com>
Authored: Wed Nov 30 19:57:35 2016 +0000
Committer: Prashant Vasudev <pr...@esgyn.com>
Committed: Wed Nov 30 19:57:35 2016 +0000
----------------------------------------------------------------------
core/sqf/src/seatrans/hbase-trx/pp.awk | 152 ++++++++++++++++++++--------
1 file changed, 107 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9c1ea1b4/core/sqf/src/seatrans/hbase-trx/pp.awk
----------------------------------------------------------------------
diff --git a/core/sqf/src/seatrans/hbase-trx/pp.awk b/core/sqf/src/seatrans/hbase-trx/pp.awk
index 3a42552..58421ed 100644
--- a/core/sqf/src/seatrans/hbase-trx/pp.awk
+++ b/core/sqf/src/seatrans/hbase-trx/pp.awk
@@ -19,93 +19,151 @@
# under the License.
#
# @@@ END COPYRIGHT @@@
-# The following example has been tested to work.
+# The following example has been tested to work. Any other
+# combination is not guranteed to work.
# If the file f1 contains the following, run this script
# as follows:
# awk -f pp.awk -v distro=HDP2.3 f1 > f2
+# awk -f pp.awk -v distro=APACHE1.1 f1 > f2
#
# contents of file f1:
-# #ifdef HDP2.3
-# this is HDP2.3 specific code
-# #else
-# this is anything other than HDP2.3 code
-# #endif
-#
-# #ifndef HDP2.3
-# this is anything other than HDP2.3 code partof ifndef construct
-# #else
-# this is HDP2.3 code part of ifndef else construct
-# #endif
-#
-# this is common code for all cases
-#
-# #ifdef CDH5.4
-# this is CDH5.4 specific code
-# #endif
-#
-# #ifdef CDH5.5 HDP2.3 APACHE1.1 CDH5.7
-# this is common CDH5.5 or HDP2.3 or APACHE1.1 or CDH5.7
-# #else
-# this is anything other than CDH5.5 or HDP2.3 or APACHE1.1 or CDH5.7 code
-# #endif
+# #ifdef HDP2.3
+# this is HDP2.3 specific code
+# #else
+# this is anything other than [HDP2.3] code
+# #endif
+#
+# common code 1
+#
+# #ifndef HDP2.3
+# this is anything other than [HDP2.3] code partof ifndef construct
+# #else
+# this is HDP2.3 code part of ifndef else construct
+# #endif
+#
+# common code 2
+#
+# #ifdef CDH5.4
+# this is CDH5.4 specific code
+# #endif
+#
+# common code 3
+#
+# #ifdef CDH5.5 HDP2.3 APACHE1.1 CDH5.7
+# this is common CDH5.5 or HDP2.3 or APACHE1.1 or CDH5.7
+# #else
+# this is anything other than [CDH5.5] or [HDP2.3] or [APACHE1.1] or [CDH5.7] code
+# #endif
+#
+# common code 4
+#
+# #ifdef CDH5.5 HDP2.3
+# this is common CDH5.5 or HDP2.3
+# #elseif APACHE1.1
+# this is specific to APACHE1.1 part of elseif construct
+# #elseif CDH5.7
+# this is specific to CDH5.7 part of elseif construct
+# #else
+# this is anything other than [CDH5.5] or [HDP2.3] or [APACHE1.1] or [CDH5.7] code
+# #endif
+#
+# common code 5
+#
+# #ifdef CDH5.5 HDP2.3
+# this is common CDH5.5 or HDP2.3
+# #elseif APACHE1.1
+# this is specific to APACHE1.1 part of elseif construct
+# #elseif CDH5.7
+# this is specific to CDH5.7 part of elseif construct
+# #endif
+#
+# common code 6
+
BEGIN{
printline=1 #print current line or not.
matchBegun=0 #match succeeded, keep printing
unmatchBegun=0 #opposite of match, keep non-printing
+unmatchTillEndif=0 #specific to #elseif case.
ifdefpattern = "#ifdef"
endifpattern = "#endif"
elsepattern = "#else"
ifndefpattern = "#ifndef"
-#distro passed in as argument
+elseifpattern = "#elseif"
+#distro passed in as argument, can only be one tag set by makefile at a time.
}
{
#By default print everything
printline =1
#########################
-# This section deals with resetting flags
+# This section deals with #else #elseif #endif tags
########################
#reset when #endif is encountered
- if(($0 ~ endifpattern) && (matchBegun == 1))
+ if($1 == endifpattern)
{
printline = 0
- matchBegun = 0
+ matchBegun = 0
+ unmatchBegun = 0
+ unmatchTillEndif = 0
}
- #reset when #endif is encountered
- if(($0 ~ endifpattern) && (unmatchBegun == 1))
- {
- printline = 0
- unmatchBegun = 0
- }
-
+ # Handle #else in this section.
#when #else is encountered and unmatchBegun, reset unmatchBegun
#start print subsequent lines.
- if(($0 ~ elsepattern) && (unmatchBegun == 1))
+ if(($1 == elsepattern) && (unmatchBegun == 1))
{
printline = 0
unmatchBegun = 0
- matchBegun = 1
+ matchBegun = 0
}
else
{
#when #else is encountered and matchBegun, reset matchBegun
#start unprint subsequent lines by setting unmatchBegun
- if(($0 ~ elsepattern) && (matchBegun == 1))
+ if(($1 == elsepattern) && (matchBegun == 1))
{
printline = 0
unmatchBegun = 1
+ matchBegun = 0
}
}
-
+
+ # Handle #elseif in this section.
+ #when #elseif is encountered and unmatchBegun, reset unmatchBegun
+ #start print subsequent lines.
+ if(($1 == elseifpattern) && ($0 ~ distro) && (unmatchBegun == 1))
+ {
+ printline = 0
+ unmatchBegun = 0
+ matchBegun = 1
+ }
+ else
+ {
+ #when #elseif is encountered and matchBegun, reset matchBegun
+ #start unprint subsequent lines by setting unmatchBegun
+ if(($1 == elseifpattern) && (matchBegun == 1))
+ {
+ printline = 0
+ unmatchBegun = 0 #setting to 1 or 0 does not matter.
+ matchBegun = 0
+ unmatchTillEndif = 1 #setting to 1 handles subsequent #else
+ }
+ }
+
##########################
-# This section matches distro string and sets flags
+# This section matches distro string and sets flags.
+# This section deals with #ifdef and #ifndef tags only.
+#
+# printline is set 0 in all cases below to indicate not to print
+# current line. matchBegun and unmatchBegun toggles appropriately.
+# matchBegun used for all lines that must be included.
+# unmatchBegun used for all lines that must be excluded.
##########################
- if($0 ~ ifdefpattern)
+ if($1 == ifdefpattern)
{
- if( $2 ~ distro || $3 ~ distro || $4 ~ distro || $5 ~ distro || $6 ~ distro)
+ if($0 ~ distro)
{
printline = 0
matchBegun = 1
@@ -116,9 +174,9 @@ ifndefpattern = "#ifndef"
unmatchBegun = 1
}
}
- if($0 ~ ifndefpattern)
+ if($1 == ifndefpattern)
{
- if($2 ~ distro || $3 ~ distro || $4 ~ distro || $5 ~ distro || $6 ~ distro)
+ if($0 ~ distro)
{
printline = 0
unmatchBegun = 1
@@ -136,7 +194,11 @@ ifndefpattern = "#ifndef"
#if unmatchBegun discard those lines
if(unmatchBegun == 1)
printline = 0
-
+
+ #if unmatchTillEndif discard those lines
+ if(unmatchTillEndif == 1)
+ printline = 0
+
if(printline == 1)
print $0;
}
[2/2] incubator-trafodion git commit: Merge [TRAFODION-2381] PR-860
Enhance awk script to support many variations of distros
Posted by su...@apache.org.
Merge [TRAFODION-2381] PR-860 Enhance awk script to support many variations of distros
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/82604a29
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/82604a29
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/82604a29
Branch: refs/heads/master
Commit: 82604a295fbb7eab4ccd0df073e18dd9d0462ec9
Parents: 67a8fb4 9c1ea1b
Author: Suresh Subbiah <su...@apache.org>
Authored: Wed Dec 7 17:03:59 2016 +0000
Committer: Suresh Subbiah <su...@apache.org>
Committed: Wed Dec 7 17:03:59 2016 +0000
----------------------------------------------------------------------
core/sqf/src/seatrans/hbase-trx/pp.awk | 152 ++++++++++++++++++++--------
1 file changed, 107 insertions(+), 45 deletions(-)
----------------------------------------------------------------------