view build-aux/move-if-change @ 17366:9855b352e525

regex: port to mingw's recent addition of undeclared alarm On mingw (at least, when cross-compiling with Fedora 18's mingw32-headers-2.0.999-0.15.trunk.20121110.fc18.noarch build), compilation of test-regex fails: test-regex.c: In function 'main': test-regex.c:42:11: error: 'SIGALRM' undeclared (first use in this function) test-regex.c:42:11: note: each undeclared identifier is reported only once for each function it appears in test-regex.c:43:3: warning: implicit declaration of function 'alarm' It turns out that recent mingw64 added an export of alarm() and SIGALRM, but guarded their declarations behind __USE_MINGW_ALARM (default off, and with alarm() only in the non-standard <io.h>); so the m4 tests were setting HAVE_ALARM to 1 based on link success but then failing to compile. * doc/posix-functions/alarm.texi (alarm): Document that alarm exists but still doesn't work in newer mingw. * m4/frexp.m4 (gl_FUNC_FREXP_WORKS): Check for alarm declaration, not existence. Ensure SIGALRM is not trapped. * m4/mktime.m4 (gl_FUNC_MKTIME): Likewise. * m4/regex.m4 (gl_REGEX): Likewise. * m4/remainderf.m4 (gl_FUNC_REMAINDERF_WORKS): Likewise. * tests/test-regex.c (main): Use correct probe for alarm. Signed-off-by: Eric Blake <>
author Eric Blake <>
date Mon, 11 Mar 2013 14:51:33 -0600
parents e542fd46ad6f
line wrap: on
line source

# Like mv $1 $2, but if the files are the same, just delete $1.
# Status is zero if successful, nonzero otherwise.

VERSION='2012-01-06 07:23'; # UTC
# The definition above must lie within the first 8 lines in order
# for the Emacs time-stamp write hook (at end) to update it.
# If you change this file with Emacs, please let the write hook
# do its job.  Otherwise, update this string manually.

# Copyright (C) 2002-2013 Free Software Foundation, Inc.

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <>.

usage="usage: $0 SOURCE DEST"

  or:  $0 OPTION
If SOURCE is different than DEST, then move it to DEST; else remove SOURCE.

  --help     display this help and exit
  --version  output version information and exit

The variable CMPPROG can be used to specify an alternative to 'cmp'.

Report bugs to <>."

version=`expr "$VERSION" : '\([^ ]*\)'`
version="move-if-change (gnulib) $version
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law."


for arg
  case $arg in
    --help | --hel | --he | --h)
      exec echo "$help" ;;
    --version | --versio | --versi | --vers | --ver | --ve | --v)
      exec echo "$version" ;;
      break ;;
      echo "$0: invalid option: $arg" >&2
      exit 1 ;;
      break ;;

test $# -eq 2 || { echo "$0: $usage" >&2; exit 1; }

if test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null; then
  rm -f -- "$1"
  if mv -f -- "$1" "$2"; then :; else
    # Ignore failure due to a concurrent move-if-change.
    test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null && rm -f -- "$1"

## Local Variables:
## eval: (add-hook 'write-file-hooks 'time-stamp)
## time-stamp-start: "VERSION='"
## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
## time-stamp-time-zone: "UTC"
## time-stamp-end: "'; # UTC"
## End: