groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 01/01: Fix Savannah bug #44768 (Solaris 10 compatibility issues)


From: Bertrand Garrigues
Subject: [groff] 01/01: Fix Savannah bug #44768 (Solaris 10 compatibility issues).
Date: Sun, 03 May 2015 22:03:04 +0000

bgarrigues pushed a commit to branch master
in repository groff.

commit 64db09953a9f725077c4697bc290906f9770a80d
Author: Bertrand Garrigues <address@hidden>
Date:   Mon May 4 00:01:35 2015 +0200

    Fix Savannah bug #44768 (Solaris 10 compatibility issues).
    
    * m4/groff.m4 (GROFF_DIFF_D): new macro to check if `diff' has
    option -D, and search for `gdiff' if not (new variable DIFF_PROG
    will contain the `diff' program to be used).
    
    * m4/groff.m4 (GROFF_HAVE_TEST_EF_OPTION): new macro to check if
    `test' supports the option -ef (created new variable
    HAVE_TEST_EF_OPTION).
    
    * m4/groff.m4 (GROFF_BASH): new macro to search for `bash' (new
    variable BASH_PROG will contain the full path to `bash' or
    `/bin/sh' if `bash' was not found).
    
    * configure.ac: use the 3 new macros defined in m4/groff.m4.
    
    * contrib/gdiffmk/gdiffmk.am: set HAVE_TEST_EF_OPTION, BASH_PROG,
    DIFF_PROG in the generated script `gdiffmk'.
    
    * contrib/gdiffmk/gdiffmk.sh:
    - Fix incorrect space after '!' in sed script regex.
    - `test -ef' is not portable: If `bash' is not available and the
    shell does not support `test -ef', the option to pass a third
    argument as the output file is disabled.
    - Report an error if `diff' does not support -D option.
    - GNU diff and Solaris diff support -D, but #ifndef / #endif are
    treated differently (GNU adds a '!' in the #endif): modify the
    regexs in the sed script accordingly.
---
 ChangeLog                  |   33 ++++++++++++++++++++++++++++++++-
 configure.ac               |    3 +++
 contrib/gdiffmk/gdiffmk.am |    3 +++
 contrib/gdiffmk/gdiffmk.sh |   35 ++++++++++++++++++++++++-----------
 m4/groff.m4                |   39 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 101 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2b7a18a..0cafdd0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2015-05-03  Bertrand Garrigues <address@hidden>
+
+       Fix Savannah bug #44768 (Solaris 10 compatibility issues).
+
+       * m4/groff.m4 (GROFF_DIFF_D): new macro to check if `diff' has
+       option -D, and search for `gdiff' if not (new variable DIFF_PROG
+       will contain the `diff' program to be used).
+
+       * m4/groff.m4 (GROFF_HAVE_TEST_EF_OPTION): new macro to check if
+       `test' supports the option -ef (created new variable
+       HAVE_TEST_EF_OPTION).
+
+       * m4/groff.m4 (GROFF_BASH): new macro to search for `bash' (new
+       variable BASH_PROG will contain the full path to `bash' or
+       `/bin/sh' if `bash' was not found).
+
+       * configure.ac: use the 3 new macros defined in m4/groff.m4.
+
+       * contrib/gdiffmk/gdiffmk.am: set HAVE_TEST_EF_OPTION, BASH_PROG,
+       DIFF_PROG in the generated script `gdiffmk'.
+
+       * contrib/gdiffmk/gdiffmk.sh:
+       - Fix incorrect space after '!' in sed script regex.
+       - `test -ef' is not portable: If `bash' is not available and the
+       shell does not support `test -ef', the option to pass a third
+       argument as the output file is disabled.
+       - Report an error if `diff' does not support -D option.
+       - GNU diff and Solaris diff support -D, but #ifndef / #endif are
+       treated differently (GNU adds a '!' in the #endif): modify the
+       regexs in the sed script accordingly.
+
 2015-05-01  Werner LEMBERG  <address@hidden>
 
        * tmac/tmac.am (TMACNORMALFILES): Add `zh.tmac'.
@@ -16,7 +47,7 @@
        * src/devices/gropdf/gropdf.pl: If module Compress::Zlib is not
        available fallback to producing uncompressed PDF and output a
        warning.
-       
+
 2015-04-22  Bjarni Ingi Gislason  <address@hidden>
 
        Fix Savannah bug #44894.
diff --git a/configure.ac b/configure.ac
index 74b27aa..e25548f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -171,6 +171,9 @@ GROFF_HTML_PROGRAMS
 GROFF_PDFDOC_PROGRAMS
 GROFF_PNMTOPS_NOSETPAGE
 GROFF_MAKE_RM
+GROFF_DIFF_D
+GROFF_HAVE_TEST_EF_OPTION
+GROFF_BASH
 gl_GLIBC21
 gl_LOCALCHARSET
 
diff --git a/contrib/gdiffmk/gdiffmk.am b/contrib/gdiffmk/gdiffmk.am
index d69f566..0308bd1 100644
--- a/contrib/gdiffmk/gdiffmk.am
+++ b/contrib/gdiffmk/gdiffmk.am
@@ -47,6 +47,9 @@ EXTRA_DIST += \
 gdiffmk: $(gdiffmk_srcdir)/gdiffmk.sh
        sed -e "s|address@hidden@]|$(bindir)|g" \
            -e "s|address@hidden@]|$(VERSION)|g" \
+           -e "s|address@hidden@]|$(HAVE_TEST_EF_OPTION)|g" \
+           -e "s|address@hidden@]|$(BASH_PROG)|g" \
+           -e "s|address@hidden@]|$(DIFF_PROG)|g" \
            -e $(SH_SCRIPT_SED_CMD)  $(gdiffmk_srcdir)/gdiffmk.sh >$@
        chmod +x $@
 
diff --git a/contrib/gdiffmk/gdiffmk.sh b/contrib/gdiffmk/gdiffmk.sh
index 4b01538..5f6ce00 100644
--- a/contrib/gdiffmk/gdiffmk.sh
+++ b/contrib/gdiffmk/gdiffmk.sh
@@ -1,4 +1,4 @@
-#! /bin/sh
address@hidden@
 # Copyright (C) 2004-2014 Free Software Foundation, Inc.
 # Written by Mike Bianchi <address@hidden <mailto:address@hidden>>
 # Thanks to Peter Bray for debugging.
@@ -39,6 +39,8 @@ groff \`.mc' requests added to indicate how it is different 
from FILE1.
           Either FILE1 or FILE2 can be standard input, but not both.
   OUTPUT  Copy of FILE2 with \`.mc' commands added.
           \`-' means standard output (the default).
+          If the shell's 'test' does not support option -ef, OUTPUT
+          can only be the standard output.
 
 OPTIONS:
   -a ADDMARK     Mark for added groff source lines.    Default: \`+'.
@@ -55,7 +57,7 @@ OPTIONS:
   -x DIFFCMD     Use a different diff(1) command;
                   one that accepts the \`-Dname' option, such as GNU diff.
   -s SEDCMD      Use a different sed(1) command;
-                  one that accepts ????????????????????, such as GNU sed.
+                  such as GNU sed.
   --version      Print version information on the standard output and exit.
   --help         Print this message on the standard error.
 "
@@ -126,11 +128,19 @@ WouldClobber () {
                ;;
        esac
 
-       if test "$1" -ef "$3"
+       # BASH_PROG is set to /bin/sh if bash was not found
+       if test "$HAVE_TEST_EF_OPTION" = "no" -a "$BASH_PROG" = "/bin/sh"
        then
                Exit 3 \
-                 "The $2 and OUTPUT arguments both point to the same file," \
-                 "\`$1', and it would be overwritten."
+               "Your shell does support test -ef, [OUTPUT] can only be the" \
+               "standard  output."
+       else
+               if test "$1" -ef "$3"
+               then
+                       Exit 3 \
+                       "The $2 and OUTPUT arguments both point to the same 
file," \
+                       "\`$1', and it would be overwritten."
+               fi
        fi
 }
 
@@ -159,8 +169,10 @@ RequiresArgument () {
        return 0
 }
 
address@hidden@
address@hidden@
 BADOPTION=
-DIFFCMD=diff
address@hidden@
 SEDCMD=sed
 D_option=
 br=.br
@@ -232,7 +244,8 @@ 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."
+Use GNU diff instead.  See the \`-x DIFFCMD' option.  You can also
+install GNU diff as gdiff on your system"
 
 if test -n "${BADOPTION}"
 then
@@ -289,7 +302,7 @@ SED_SCRIPT='
                    p
                    d
                  }
-                 /^#endif \/\* \(not\|!\) '"${LABEL}"'/ {
+                 /^#endif \/\* [!not ]*'"${LABEL}"'/ {
                   s/.*/.mc '"${DELETEMARK}"'/p
                   a\
 .mc
@@ -314,8 +327,8 @@ then
 '"${MARK1}"'
                   d
                  }
-                 /^#else \/\* '"${LABEL}"'/ ! {
-                  /^#endif \/\* [!not ]*'"${LABEL}"'/ ! {
+                 /^#else \/\* '"${LABEL}"'/ !{
+                  /^#endif \/\* [!not ]*'"${LABEL}"'/ !{
                    p
                    d
                   }
@@ -334,7 +347,7 @@ then
                    p
                    d
                  }
-                 /^#endif \/\* \(not\|!\) '"${LABEL}"'/ {
+                 /^#endif \/\* [!not ]*'"${LABEL}"'/ {
                   i\
 '"${MARK2}"'\
 '"${br}"'
diff --git a/m4/groff.m4 b/m4/groff.m4
index 166278c..7d9350a 100644
--- a/m4/groff.m4
+++ b/m4/groff.m4
@@ -1372,3 +1372,42 @@ EOF
   groff_is_rm_defined=`make -sf test_make_rm.mk`
   AC_MSG_RESULT([$groff_is_rm_defined])
   rm -f test_make_rm.mk])
+
+# Check if diff has option -D, for gdiffmk. If not, check if gdiff is
+# available on the system and make the same test. If either diff or
+# gdiff is working, it is set to DIFF_PROG.  If -D option is not
+# available, DIFF_PROG is left to diff (gdiffmk will report a
+# problem).
+AC_DEFUN([GROFF_DIFF_D],
+  [AC_MSG_CHECKING(for a diff program that supports option -D)
+  groff_has_diff_d_option=no
+  DIFF_PROG=diff
+  diff -Dx /dev/null /dev/null >/dev/null 2>&1 && groff_has_diff_d_option=yes
+  if test "$groff_has_diff_d_option" = no; then
+    AC_CHECK_PROGS([GDIFF], [gdiff])
+    if test -n "$GDIFF"; then
+      "$GDIFF" -Dx /dev/null /dev/null >/dev/null 2>&1 && 
groff_has_diff_d_option=yes
+      if test "$groff_has_diff_d_option" = yes; then
+        DIFF_PROG="$GDIFF"
+      fi
+    fi
+  fi
+  AC_MSG_RESULT([$groff_has_diff_d_option])
+  AC_SUBST([DIFF_PROG])])
+
+# Check if `test' supports the option -ef.
+AC_DEFUN([GROFF_HAVE_TEST_EF_OPTION],
+  [AC_MSG_CHECKING(whether test supports option -ef)
+  HAVE_TEST_EF_OPTION=no
+  test /dev/null -ef /dev/null > /dev/null 2>&1 && HAVE_TEST_EF_OPTION=yes
+  AC_MSG_RESULT([$HAVE_TEST_EF_OPTION])
+  AC_SUBST([HAVE_TEST_EF_OPTION])])
+
+# gdiffmk will attempt to use bash (for option -ef of 'test'). If bash
+# is not available it will use /bin/sh.
+AC_DEFUN([GROFF_BASH],
+  [AC_PATH_PROGS([BASH_PROG], [bash], [no])
+  if test x$BASH_PROG = xno; then
+     BASH_PROG=/bin/sh
+  fi
+  AC_SUBST([BASH_PROG])])



reply via email to

[Prev in Thread] Current Thread [Next in Thread]