From c2a205a8e12f3daaeb7fd1c92ad862999ae630dc Mon Sep 17 00:00:00 2001 From: Werner LEMBERG Date: Mon, 13 Dec 2004 20:53:26 +0000 Subject: [PATCH] Add `-x' command line option to select a diff program. * gdiffmk.sh: Add code to handle `-x'. Move test for working `diff' down. Fix sed pattern. (Usage): Updated. * gdiffmk.man: Updated. --- contrib/gdiffmk/ChangeLog | 10 ++++++++++ contrib/gdiffmk/gdiffmk.man | 24 +++++++++++++++++++++++- contrib/gdiffmk/gdiffmk.sh | 44 +++++++++++++++++++++++++------------------- 3 files changed, 58 insertions(+), 20 deletions(-) diff --git a/contrib/gdiffmk/ChangeLog b/contrib/gdiffmk/ChangeLog index 15d73788..a461b440 100644 --- a/contrib/gdiffmk/ChangeLog +++ b/contrib/gdiffmk/ChangeLog @@ -1,3 +1,13 @@ +2004-12-13 Mike Bianchi + + Add `-x' command line option to select a diff program. + + * gdiffmk.sh: Add code to handle `-x'. + Move test for working `diff' down. + Fix sed pattern. + (Usage): Updated. + * gdiffmk.man: Updated. + 2004-12-12 Mike Bianchi * README: New file. diff --git a/contrib/gdiffmk/gdiffmk.man b/contrib/gdiffmk/gdiffmk.man index 94d75e97..19bf40d1 100644 --- a/contrib/gdiffmk/gdiffmk.man +++ b/contrib/gdiffmk/gdiffmk.man @@ -43,6 +43,7 @@ gdiffmk \- mark differences between groff/nroff/troff files .OP \-a \%addmark .OP \-c \%changemark .OP \-d \%deletemark +.OP \-x \%diffcmd .OP \-\- .OP \-\-help .OP \-\-version @@ -51,6 +52,8 @@ gdiffmk \- mark differences between groff/nroff/troff files [ .I \%output ] +.br +.ad \na . . .SH DESCRIPTION @@ -125,6 +128,22 @@ Default: .BR * . . .TP +.BI \-x diffcmd +Use the +.I diffcmd +command to perform the comparison of +.I file1 +and +.I file2 . +In particular, +.I diffcmd +should accept the +.BI \-D name +option. +Default: +.BR diff (1). +. +.TP .B \-\- All the following arguments are treated as file names, even if they begin with @@ -150,13 +169,16 @@ on the output of all the preprocessors instead of the input source. .LP .B gdiffmk relies on the -.B \-D +.BI \-D name option of GNU .BR diff (1) to make a merged `#ifdef' output format. It hasn't been tested whether other versions of .BR diff (1) do support this option. +See also the +.BI \-x diffcmd +option. . .LP Report bugs to bug-groff@gnu.org. diff --git a/contrib/gdiffmk/gdiffmk.sh b/contrib/gdiffmk/gdiffmk.sh index a2ffcfac..87bc9c36 100644 --- a/contrib/gdiffmk/gdiffmk.sh +++ b/contrib/gdiffmk/gdiffmk.sh @@ -23,16 +23,6 @@ cmd=$( basename $0 ) -diff -Dx /dev/null /dev/null >/dev/null 2>&1 || - { - echo >&2 "${cmd}: " \ - "The \`diff' program does not accept " \ - "the required -DNAME option." - echo >&2 "${cmd}: " \ - "Use GNU diff instead." - exit 126 - } - function Usage { if test "$#" -gt 0 then @@ -51,12 +41,14 @@ groff \`.mc' requests added to indicate how it is different from FILE1. OUTPUT Copy of FILE2 with \`.mc' commands added. \`-' means standard output (the default). -options: +OPTIONS: -a addmark Mark for added groff source lines. Default: +. -c changemark Mark for changed groff source lines. Default: |. -d deletemark Mark for deleted groff source lines. Default: *. - --version Print version information on standard output and exit. - --help Print this message on standard error. + -x diffcmd Use a different diff(1) command; + one that accepts the \`-Dname' option, such as GNU diff. + --version Print version information on the standard output and exit. + --help Print this message on the standard error. " exit 255 } @@ -150,19 +142,24 @@ function RequiresArgument { } badoption= -for option +diffcmd=diff +for OPTION do - case "${option}" in + case "${OPTION}" in -a*) - addmark=$( RequiresArgument "${option}" $2 ) && + addmark=$( RequiresArgument "${OPTION}" $2 ) && shift ;; -c*) - changemark=$( RequiresArgument "${option}" $2 ) && + changemark=$( RequiresArgument "${OPTION}" $2 ) && shift ;; -d*) - deletemark=$( RequiresArgument "${option}" $2 ) && + deletemark=$( RequiresArgument "${OPTION}" $2 ) && + shift + ;; + -x* ) + diffcmd=$( RequiresArgument "${OPTION}" $2 ) && shift ;; --version) @@ -190,6 +187,11 @@ do shift done +${diffcmd} -Dx /dev/null /dev/null >/dev/null 2>&1 || + Usage "The \`${diffcmd}' program does not accept" \ + "the required \`-Dname' option. +Use GNU diff instead. See the \`-x diffcmd' option." + if test -n "${badoption}" then Usage "${badoption}" @@ -246,7 +248,11 @@ diff -D"${label}" -- ${FILE1} ${FILE2} | p d } - /^#endif \/\* not '"${label}"'/ s/.*/.mc '"${deletemark}"'/p + /^#endif \/\* not '"${label}"'/ { + s/.*/.mc '"${deletemark}"'/p + a\ +.mc + } d } p -- 2.11.4.GIT