- 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
This commit is contained in:
Bart Van Assche
2010-04-04 13:27:24 +00:00
parent 38575b3d34
commit 12b1d9d57e
2 changed files with 27 additions and 2 deletions

View File

@@ -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

View File

@@ -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