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