From 12b1d9d57eb15915e037a42c8af62ef0360821ff Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 4 Apr 2010 13:27:24 +0000 Subject: [PATCH] Changes: - Process the pattern [01] && defined(...) properly. - Added command-line option -d (debug) to generate-kernel-patch. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1582 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scripts/generate-kernel-patch | 7 ++++++- scripts/specialize-patch | 22 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/scripts/generate-kernel-patch b/scripts/generate-kernel-patch index 98b6b3f48..9360a4f7a 100755 --- a/scripts/generate-kernel-patch +++ b/scripts/generate-kernel-patch @@ -147,6 +147,7 @@ function in_separate_patch { # Argument verification # ######################### +debug_specialize="false" generating_upstream_patch="false" mpt_scst="false" multiple_patches="false" @@ -161,10 +162,11 @@ if [ ! -e scst -o ! -e iscsi-scst -o ! -e srpt -o ! -e scst_local ]; then exit 1 fi -set -- $(/usr/bin/getopt hlmnp:u "$@") +set -- $(/usr/bin/getopt dhlmnp:u "$@") while [ "$1" != "${1#-}" ] do case "$1" in + '-d') debug_specialize="true"; shift;; '-h') usage; exit 1;; '-l') shift;; '-m') mpt_scst="true"; shift;; @@ -178,6 +180,9 @@ do esac done +if [ "${debug_specialize}" = "true" ]; then + specialize_patch_options="${specialize_patch_options} -v debug=1" +fi if [ "${generating_upstream_patch}" = "true" ]; then specialize_patch_options="${specialize_patch_options} -v generating_upstream_patch_defined=1 -v config_tcp_zero_copy_transfer_completion_notification_undefined=1 -v config_scst_proc_undefined=1" fi diff --git a/scripts/specialize-patch b/scripts/specialize-patch index 8a516f68d..1eb59a1e2 100755 --- a/scripts/specialize-patch +++ b/scripts/specialize-patch @@ -42,6 +42,10 @@ function version_code(kver) { # it is the same order as the order of operators in C. function evaluate(stmnt) { + + if (debug) + printf "/* debug specialize-patch: (a) %s */\n", stmnt + # Remove C-style comments. gsub(" *\\/\\*[^*]*\\*\\/ *", "", stmnt) @@ -123,6 +127,9 @@ function evaluate(stmnt) { gsub("defined *\\( *CONFIG_SCST_PROC *\\)", 0, stmnt) } + if (debug) + printf "/* debug specialize-patch: (b) %s */\n", stmnt + do { last_stmnt = stmnt @@ -175,6 +182,12 @@ function evaluate(stmnt) { sub(pattern, (op[1] != 0) && (op[2] != 0), stmnt) } + pattern="([01]) *\\&\\& *(!* *defined *\\( *[A-Za-z_]* *\\))" + while (match(stmnt, pattern, op) != 0) + { + sub(pattern, op[1] != 0 ? op[2] : op[1], stmnt) + } + pattern="(-*[0-9]+) *\\|\\| *(-*[0-9]+)" while (match(stmnt, pattern, op) != 0) { @@ -186,6 +199,10 @@ function evaluate(stmnt) { { sub(pattern, op[1], stmnt) } + + if (debug) + printf "/* debug specialize-patch: (c) %s -> %s */\n", last_stmnt, stmnt + } while (stmnt != last_stmnt) return stmnt @@ -223,7 +240,10 @@ function handle_if() { evaluated = "+#if undecided" } - #printf "%s -> %s\n", $0, evaluated + + if (debug) + printf "/* debug specialize-patch: (d) %s -> %s */\n", $0, evaluated + if (evaluated ~ "^+#if") { if_stmnt[if_nesting_level] = evaluated