aboutsummaryrefslogtreecommitdiff
path: root/trunk/src/mkpatch
diff options
context:
space:
mode:
authorrudson <rudson@04377dda-e619-0410-9926-eae83683ac58>2008-01-21 23:26:06 +0000
committerrudson <rudson@04377dda-e619-0410-9926-eae83683ac58>2008-01-21 23:26:06 +0000
commit6995184d66fc75394861b75e8b8d2c6fbda2d74f (patch)
treeadc0c74f61377bfec06949faa02d12afe39c0853 /trunk/src/mkpatch
parent8663857fe8799ad580f4127b995e4635f525331d (diff)
downloadsimplepkg-6995184d66fc75394861b75e8b8d2c6fbda2d74f.tar.gz
simplepkg-6995184d66fc75394861b75e8b8d2c6fbda2d74f.tar.bz2
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@484 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'trunk/src/mkpatch')
-rw-r--r--trunk/src/mkpatch44
1 files changed, 28 insertions, 16 deletions
diff --git a/trunk/src/mkpatch b/trunk/src/mkpatch
index 35f5839..2fefcaa 100644
--- a/trunk/src/mkpatch
+++ b/trunk/src/mkpatch
@@ -20,7 +20,7 @@
# - #2 Source_File
#
# Version:
-PROG_VERSION=1.0
+PROG_VERSION=1.1
BASENAME=`basename $0`
function get_line {
@@ -30,7 +30,7 @@ function get_line {
! is_number $1 && exit $ERROR_NOT_NUMBER
[ ! -e $2 ] && exit $ERROR_FILE_NOTFOUND
- sed -n "$1 p" $2
+ sed "$1 q;d" $2
}
function get_diff_line {
@@ -62,6 +62,11 @@ fi
error_codes
# ----------------
+if [ "$1" = "--help" -o "$1" = "-h" ]; then
+ echo "Use: $BASENAME <diff_file> <source_file>"
+ exit $ERROR_HELP
+fi
+
# Check input parameters
[ $# -ne 2 ] && exit $ERROR_PAR_NUMBER
[ ! -e $1 ] && exit $ERROR_FILE_NOTFOUND
@@ -82,50 +87,57 @@ Status_Diff=0
get_diff_line $Diff_Line $Diff_File || exit $?
Source_Line=1
+# Get frist Source_File line
+Source_Str_Line=`get_line $Source_Line $Source_File` || exit $?
while [ $Source_Line -le $Source_N_Lines ]; do
- # Get Source_File line
- Source_Str_Line=`get_line $Source_Line $Source_File` || return $?
# make Actions
case $Diff_Action in
'-')
if [ "$Source_Str_Line" = "$Diff_Str_Line" ]; then
+ Status_Diff=1
let Diff_Line++
else
Diff_Line=$Diff_Pointer
+ Status_Diff=0
echo "$Source_Str_Line"
fi
- get_diff_line $Diff_Line $Diff_File || return $?
+ get_diff_line $Diff_Line $Diff_File || exit $?
+ let Source_Line++
+ Source_Str_Line=`get_line $Source_Line $Source_File` || exit $?
;;
'+')
echo "$Diff_Str_Line"
let Diff_Line++
- get_diff_line $Diff_Line $Diff_File || return $?
- let Source_Line--
+ get_diff_line $Diff_Line $Diff_File || exit $?
;;
' ')
+ if [ "$Source_Str_Line" = "$Diff_Str_Line" ]; then
+ Status_Diff=1
+ let Diff_Line++
+ else
+ Status_Diff=0
+ Diff_Line=$Diff_Pointer
+ fi
echo "$Source_Str_Line"
+ get_diff_line $Diff_Line $Diff_File || exit $?
+ let Source_Line++
+ Source_Str_Line=`get_line $Source_Line $Source_File` || exit $?
;;
'=')
let Diff_Line++
+ Status_Diff=0
Diff_Pointer=$Diff_Line
- get_diff_line $Diff_Line $Diff_File || return $?
- echo "$Source_Str_Line"
+ get_diff_line $Diff_Line $Diff_File || exit $?
;;
'*')
exit $ERROR_MKPATCH
;;
esac
- if [ "$Diff_Action" = " " -a "$Source_Str_Line" = "$Diff_Str_Line" ]; then
- Status_Diff=1
- let Diff_Line++
- get_diff_line $Diff_Line $Diff_File || return $?
- fi
- let Source_Line++
done
# Make others addline "+" in the end file
while [ "$Diff_Action" = "+" -a $Diff_Line -le $Diff_N_Lines ]; do
echo "$Diff_Str_Line"
let Diff_Line++
- get_diff_line $Diff_Line $Diff_File || return $?
+ get_diff_line $Diff_Line $Diff_File || exit $?
done