annotate src/fftw-3.3.5/doc/mdate-sh @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +0000
parents 2cd0e3b3e1fd
children
rev   line source
Chris@42 1 #!/bin/sh
Chris@42 2 # Get modification time of a file or directory and pretty-print it.
Chris@42 3
Chris@42 4 scriptversion=2010-08-21.06; # UTC
Chris@42 5
Chris@42 6 # Copyright (C) 1995-2013 Free Software Foundation, Inc.
Chris@42 7 # written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, June 1995
Chris@42 8 #
Chris@42 9 # This program is free software; you can redistribute it and/or modify
Chris@42 10 # it under the terms of the GNU General Public License as published by
Chris@42 11 # the Free Software Foundation; either version 2, or (at your option)
Chris@42 12 # any later version.
Chris@42 13 #
Chris@42 14 # This program is distributed in the hope that it will be useful,
Chris@42 15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@42 16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@42 17 # GNU General Public License for more details.
Chris@42 18 #
Chris@42 19 # You should have received a copy of the GNU General Public License
Chris@42 20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
Chris@42 21
Chris@42 22 # As a special exception to the GNU General Public License, if you
Chris@42 23 # distribute this file as part of a program that contains a
Chris@42 24 # configuration script generated by Autoconf, you may include it under
Chris@42 25 # the same distribution terms that you use for the rest of that program.
Chris@42 26
Chris@42 27 # This file is maintained in Automake, please report
Chris@42 28 # bugs to <bug-automake@gnu.org> or send patches to
Chris@42 29 # <automake-patches@gnu.org>.
Chris@42 30
Chris@42 31 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
Chris@42 32 emulate sh
Chris@42 33 NULLCMD=:
Chris@42 34 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
Chris@42 35 # is contrary to our usage. Disable this feature.
Chris@42 36 alias -g '${1+"$@"}'='"$@"'
Chris@42 37 setopt NO_GLOB_SUBST
Chris@42 38 fi
Chris@42 39
Chris@42 40 case $1 in
Chris@42 41 '')
Chris@42 42 echo "$0: No file. Try '$0 --help' for more information." 1>&2
Chris@42 43 exit 1;
Chris@42 44 ;;
Chris@42 45 -h | --h*)
Chris@42 46 cat <<\EOF
Chris@42 47 Usage: mdate-sh [--help] [--version] FILE
Chris@42 48
Chris@42 49 Pretty-print the modification day of FILE, in the format:
Chris@42 50 1 January 1970
Chris@42 51
Chris@42 52 Report bugs to <bug-automake@gnu.org>.
Chris@42 53 EOF
Chris@42 54 exit $?
Chris@42 55 ;;
Chris@42 56 -v | --v*)
Chris@42 57 echo "mdate-sh $scriptversion"
Chris@42 58 exit $?
Chris@42 59 ;;
Chris@42 60 esac
Chris@42 61
Chris@42 62 error ()
Chris@42 63 {
Chris@42 64 echo "$0: $1" >&2
Chris@42 65 exit 1
Chris@42 66 }
Chris@42 67
Chris@42 68
Chris@42 69 # Prevent date giving response in another language.
Chris@42 70 LANG=C
Chris@42 71 export LANG
Chris@42 72 LC_ALL=C
Chris@42 73 export LC_ALL
Chris@42 74 LC_TIME=C
Chris@42 75 export LC_TIME
Chris@42 76
Chris@42 77 # GNU ls changes its time format in response to the TIME_STYLE
Chris@42 78 # variable. Since we cannot assume 'unset' works, revert this
Chris@42 79 # variable to its documented default.
Chris@42 80 if test "${TIME_STYLE+set}" = set; then
Chris@42 81 TIME_STYLE=posix-long-iso
Chris@42 82 export TIME_STYLE
Chris@42 83 fi
Chris@42 84
Chris@42 85 save_arg1=$1
Chris@42 86
Chris@42 87 # Find out how to get the extended ls output of a file or directory.
Chris@42 88 if ls -L /dev/null 1>/dev/null 2>&1; then
Chris@42 89 ls_command='ls -L -l -d'
Chris@42 90 else
Chris@42 91 ls_command='ls -l -d'
Chris@42 92 fi
Chris@42 93 # Avoid user/group names that might have spaces, when possible.
Chris@42 94 if ls -n /dev/null 1>/dev/null 2>&1; then
Chris@42 95 ls_command="$ls_command -n"
Chris@42 96 fi
Chris@42 97
Chris@42 98 # A 'ls -l' line looks as follows on OS/2.
Chris@42 99 # drwxrwx--- 0 Aug 11 2001 foo
Chris@42 100 # This differs from Unix, which adds ownership information.
Chris@42 101 # drwxrwx--- 2 root root 4096 Aug 11 2001 foo
Chris@42 102 #
Chris@42 103 # To find the date, we split the line on spaces and iterate on words
Chris@42 104 # until we find a month. This cannot work with files whose owner is a
Chris@42 105 # user named "Jan", or "Feb", etc. However, it's unlikely that '/'
Chris@42 106 # will be owned by a user whose name is a month. So we first look at
Chris@42 107 # the extended ls output of the root directory to decide how many
Chris@42 108 # words should be skipped to get the date.
Chris@42 109
Chris@42 110 # On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below.
Chris@42 111 set x`$ls_command /`
Chris@42 112
Chris@42 113 # Find which argument is the month.
Chris@42 114 month=
Chris@42 115 command=
Chris@42 116 until test $month
Chris@42 117 do
Chris@42 118 test $# -gt 0 || error "failed parsing '$ls_command /' output"
Chris@42 119 shift
Chris@42 120 # Add another shift to the command.
Chris@42 121 command="$command shift;"
Chris@42 122 case $1 in
Chris@42 123 Jan) month=January; nummonth=1;;
Chris@42 124 Feb) month=February; nummonth=2;;
Chris@42 125 Mar) month=March; nummonth=3;;
Chris@42 126 Apr) month=April; nummonth=4;;
Chris@42 127 May) month=May; nummonth=5;;
Chris@42 128 Jun) month=June; nummonth=6;;
Chris@42 129 Jul) month=July; nummonth=7;;
Chris@42 130 Aug) month=August; nummonth=8;;
Chris@42 131 Sep) month=September; nummonth=9;;
Chris@42 132 Oct) month=October; nummonth=10;;
Chris@42 133 Nov) month=November; nummonth=11;;
Chris@42 134 Dec) month=December; nummonth=12;;
Chris@42 135 esac
Chris@42 136 done
Chris@42 137
Chris@42 138 test -n "$month" || error "failed parsing '$ls_command /' output"
Chris@42 139
Chris@42 140 # Get the extended ls output of the file or directory.
Chris@42 141 set dummy x`eval "$ls_command \"\\\$save_arg1\""`
Chris@42 142
Chris@42 143 # Remove all preceding arguments
Chris@42 144 eval $command
Chris@42 145
Chris@42 146 # Because of the dummy argument above, month is in $2.
Chris@42 147 #
Chris@42 148 # On a POSIX system, we should have
Chris@42 149 #
Chris@42 150 # $# = 5
Chris@42 151 # $1 = file size
Chris@42 152 # $2 = month
Chris@42 153 # $3 = day
Chris@42 154 # $4 = year or time
Chris@42 155 # $5 = filename
Chris@42 156 #
Chris@42 157 # On Darwin 7.7.0 and 7.6.0, we have
Chris@42 158 #
Chris@42 159 # $# = 4
Chris@42 160 # $1 = day
Chris@42 161 # $2 = month
Chris@42 162 # $3 = year or time
Chris@42 163 # $4 = filename
Chris@42 164
Chris@42 165 # Get the month.
Chris@42 166 case $2 in
Chris@42 167 Jan) month=January; nummonth=1;;
Chris@42 168 Feb) month=February; nummonth=2;;
Chris@42 169 Mar) month=March; nummonth=3;;
Chris@42 170 Apr) month=April; nummonth=4;;
Chris@42 171 May) month=May; nummonth=5;;
Chris@42 172 Jun) month=June; nummonth=6;;
Chris@42 173 Jul) month=July; nummonth=7;;
Chris@42 174 Aug) month=August; nummonth=8;;
Chris@42 175 Sep) month=September; nummonth=9;;
Chris@42 176 Oct) month=October; nummonth=10;;
Chris@42 177 Nov) month=November; nummonth=11;;
Chris@42 178 Dec) month=December; nummonth=12;;
Chris@42 179 esac
Chris@42 180
Chris@42 181 case $3 in
Chris@42 182 ???*) day=$1;;
Chris@42 183 *) day=$3; shift;;
Chris@42 184 esac
Chris@42 185
Chris@42 186 # Here we have to deal with the problem that the ls output gives either
Chris@42 187 # the time of day or the year.
Chris@42 188 case $3 in
Chris@42 189 *:*) set `date`; eval year=\$$#
Chris@42 190 case $2 in
Chris@42 191 Jan) nummonthtod=1;;
Chris@42 192 Feb) nummonthtod=2;;
Chris@42 193 Mar) nummonthtod=3;;
Chris@42 194 Apr) nummonthtod=4;;
Chris@42 195 May) nummonthtod=5;;
Chris@42 196 Jun) nummonthtod=6;;
Chris@42 197 Jul) nummonthtod=7;;
Chris@42 198 Aug) nummonthtod=8;;
Chris@42 199 Sep) nummonthtod=9;;
Chris@42 200 Oct) nummonthtod=10;;
Chris@42 201 Nov) nummonthtod=11;;
Chris@42 202 Dec) nummonthtod=12;;
Chris@42 203 esac
Chris@42 204 # For the first six month of the year the time notation can also
Chris@42 205 # be used for files modified in the last year.
Chris@42 206 if (expr $nummonth \> $nummonthtod) > /dev/null;
Chris@42 207 then
Chris@42 208 year=`expr $year - 1`
Chris@42 209 fi;;
Chris@42 210 *) year=$3;;
Chris@42 211 esac
Chris@42 212
Chris@42 213 # The result.
Chris@42 214 echo $day $month $year
Chris@42 215
Chris@42 216 # Local Variables:
Chris@42 217 # mode: shell-script
Chris@42 218 # sh-indentation: 2
Chris@42 219 # eval: (add-hook 'write-file-hooks 'time-stamp)
Chris@42 220 # time-stamp-start: "scriptversion="
Chris@42 221 # time-stamp-format: "%:y-%02m-%02d.%02H"
Chris@42 222 # time-stamp-time-zone: "UTC"
Chris@42 223 # time-stamp-end: "; # UTC"
Chris@42 224 # End: