1@echo off
2Rem
3Rem WARNING WARNING WARNING: This file needs to have DOS CRLF end-of-line
4Rem format, or else stock DOS/Windows shells will refuse to run it.
5Rem
6Rem This batch file unpacks the Bison distribution while simultaneously
7Rem renaming some of the files whose names are invalid on DOS or conflict
8Rem with other file names after truncation to DOS 8+3 namespace.
9Rem
10Rem Copyright (C) 2005, 2006 Free Software Foundation, Inc.
11Rem
12Rem This program is free software; you can redistribute it and/or modify
13Rem it under the terms of the GNU General Public License as published by
14Rem the Free Software Foundation; either version 2, or (at your option)
15Rem any later version.
16Rem
17Rem This program is distributed in the hope that it will be useful,
18Rem but WITHOUT ANY WARRANTY; without even the implied warranty of
19Rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20Rem GNU General Public License for more details.
21Rem
22Rem You should have received a copy of the GNU General Public License
23Rem along with this program; if not, write to the Free Software Foundation,
24Rem Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25Rem
26Rem
27Rem Invoke like this:
28Rem
29Rem     djunpack bison-XYZ.tar.gz
30Rem or
31Rem     djunpack bison-XYZ.tar.bz2
32Rem
33Rem where XYZ is the version number.  If the argument includes leading
34Rem directories, it MUST use backslashes, not forward slashes.
35Rem
36
37set ENVIRONMENT_SIZE_TEST_STRING=ENVIRONMENT_SIZE_TEST_STRING
38if "%ENVIRONMENT_SIZE_TEST_STRING%"=="ENVIRONMENT_SIZE_TEST_STRING" GoTo EnvOk
39Rem If their environment space is too small, re-exec with a larger one
40command.com /e:4096 /c %0 %1
41GoTo End
42
43:EnvOk
44set ENVIRONMENT_SIZE_TEST_STRING=
45if "%1" == "" GoTo NoArgument
46if not exist %1 GoTo NoArchive
47Rem Extract top src dir from archive file.
48djtar -t %1 > top_src.dir
49Rem The following uses a feature of COPY whereby it does not copy
50Rem empty files.  We need that because the previous line will create
51Rem an empty fnchange.tmp even if the command failed for some reason.
52copy top_src.dir junk.tmp > nul
53if not exist junk.tmp GoTo NoDjTar
54del junk.tmp
55sed "1{s/^.*bison-/djtar -x -p -o bison-/;s|$|djgpp/fnchange.lst %%1 > fnchange.tmp|};2,$d" top_src.dir > ext_list.bat
56Rem See the comment above about the reason for using COPY.
57copy ext_list.bat junk.tmp > nul
58if not exist junk.tmp GoTo NoSed
59del junk.tmp
60Rem Extract fnchange.lst from archive.
61call ext_list.bat %1
62del ext_list.bat
63sed "1{s|^.*bison-|s/@V@/bison-|;s|$|g|};2,$d" top_src.dir > version.sed
64sed -f version.sed < fnchange.tmp > fnchange.lst
65del version.sed
66del fnchange.tmp
67del top_src.dir
68Rem unpack the source distribution
69djtar -x -n fnchange.lst %1
70del fnchange.lst
71GoTo End
72
73:NoSed
74del junk.tmp
75echo FAIL: Sed is not available.
76GoTo End
77:NoDjTar
78del junk.tmp
79echo FAIL: DJTAR is not available or no fnchange.lst file in %1.
80GoTo End
81:NoArchive
82echo FAIL: the file %1 does not seem to exist.
83echo Remember that %1 cannot use forward slashes, only backslashes.
84GoTo End
85:NoArgument
86echo FAIL: no archive file has been specified.
87echo Remember that the file name cannot use forward slashes, only backslashes.
88:End
89