bug-gnulib
[Top][All Lists]
Advanced

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

Re: gnulib-tool and autoreconf


From: Bruno Haible
Subject: Re: gnulib-tool and autoreconf
Date: Sun, 7 Dec 2008 17:18:37 +0100
User-agent: KMail/1.9.9

Eric Blake wrote:
> I think it is the existence, and proper maintenance, of m4
> serial numbers that will make your proposed change to autopoint worthwhile.

Yes, the serial numbers will matter now.

> > Therefore I would find it better if autopoint had an option that tells it
> > not to overwrite .m4 files installed by gnulib-tool, or if that behaviour
> > was even the default. What do you think?
>
> I think that would work.

OK. I'm applying this in gettext:


2008-12-07  Bruno Haible  <address@hidden>

        * autopoint.in (func_compare): New function.
        Don't overwrite *.m4 files when the existing file has a version number
        at least as large as the one from the gettext release.
        Reported by Colin Watson <address@hidden>
        and Sylvain Beucler <address@hidden>.

Index: autopoint.in
===================================================================
RCS file: /sources/gettext/gettext/gettext-tools/misc/autopoint.in,v
retrieving revision 1.38
diff -c -3 -r1.38 autopoint.in
*** autopoint.in        20 Apr 2008 06:11:01 -0000      1.38
--- autopoint.in        7 Dec 2008 16:10:43 -0000
***************
*** 471,476 ****
--- 471,510 ----
    esac
  }
  
+ # func_compare existingfile gettextfile
+ # compares the existing file and the file from gettext, and decides whether 
the
+ # existing file should be overwritten with the file from gettext. Returns 0 if
+ # it should be overwritten, or 1 if it should be skipped.
+ sed_extract_serial='s/^#.* serial \([^ ]*\).*/\1/p
+ 1q'
+ func_compare ()
+ {
+   if cmp -s "$1" "$2"; then
+     false
+   else
+     case "$2" in
+       *.m4)
+         # For interoperability with gnulib. gnulib often has newer versions of
+         # the *.m4 files than the latest gettext release. Don't overwrite a
+         # newer version from gnulib with an older version from the gettext
+         # release. The version can be retrieved from the first line, which
+         # looks like this:   # file.m4 serial NN ...
+         existing_serial=`sed -n -e "$sed_extract_serial" < "$1"`
+         gettext_serial=`sed -n -e "$sed_extract_serial" < "$2"`
+         if test -n "$existing_serial" && test -n "$gettext_serial" \
+            && test "$existing_serial" -ge "$gettext_serial" 2> /dev/null; then
+           false
+         else
+           true
+         fi
+         ;;
+       *)
+         true
+         ;;
+     esac
+   fi
+ }
+ 
  # If some files have been locally modified and we have not been requested
  # to overwrite them, then bail out. This is better than leaving a source
  # package around where half of the files are locally modified and half are
***************
*** 483,491 ****
      func_destfile "$file"
      if test -n "$destfile"; then
        if test -f "$destfile"; then
!         if cmp -s "$work_dir/archive/$file" "$destfile"; then
!           :
!         else
            if test -n "$sharedowner"; then
              echo "autopoint: warning: File $destfile has been locally 
modified." 1>&2
            else
--- 517,523 ----
      func_destfile "$file"
      if test -n "$destfile"; then
        if test -f "$destfile"; then
!         if func_compare "$destfile" "$work_dir/archive/$file"; then
            if test -n "$sharedowner"; then
              echo "autopoint: warning: File $destfile has been locally 
modified." 1>&2
            else
***************
*** 553,561 ****
    mustcopy=
    if test -n "$destfile"; then
      if test -f "$destfile"; then
!       if cmp -s "$work_dir/archive/$file" "$destfile"; then
!         :
!       else
          if test -n "$force"; then
            # Overwrite locally modified file.
            mustcopy=yes
--- 585,591 ----
    mustcopy=
    if test -n "$destfile"; then
      if test -f "$destfile"; then
!       if func_compare "$destfile" "$work_dir/archive/$file"; then
          if test -n "$force"; then
            # Overwrite locally modified file.
            mustcopy=yes




reply via email to

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