summaryrefslogtreecommitdiffstats
path: root/ylwrap
diff options
context:
space:
mode:
authorJason Merrill <jason@gcc.gnu.org>1997-08-21 18:57:35 -0400
committerJason Merrill <jason@gcc.gnu.org>1997-08-21 18:57:35 -0400
commit6599da043e22e96ac830fb50a61c1b6d95d1b142 (patch)
treea3b19970338bdae580faff126a716e1d5520400c /ylwrap
parentlex.c (real_yylex): Don't use getc directly. (diff)
downloadgcc-6599da043e22e96ac830fb50a61c1b6d95d1b142.tar.gz
gcc-6599da043e22e96ac830fb50a61c1b6d95d1b142.tar.bz2
gcc-6599da043e22e96ac830fb50a61c1b6d95d1b142.tar.xz
Initial revision
From-SVN: r14877
Diffstat (limited to 'ylwrap')
-rwxr-xr-xylwrap107
1 files changed, 107 insertions, 0 deletions
diff --git a/ylwrap b/ylwrap
new file mode 100755
index 00000000000..b5b62184383
--- /dev/null
+++ b/ylwrap
@@ -0,0 +1,107 @@
1#! /bin/sh
2# ylwrap - wrapper for lex/yacc invocations.
3# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
4# Written by Tom Tromey <tromey@cygnus.com>.
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2, or (at your option)
9# any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20# Usage:
21# ylwrap PROGRAM INPUT [OUTPUT DESIRED]... -- [ARGS]...
22# * PROGRAM is program to run.
23# * INPUT is the input file
24# * OUTPUT is file PROG generates
25# * DESIRED is file we actually want
26# * ARGS are passed to PROG
27# Any number of OUTPUT,DESIRED pairs may be used.
28
29# The program to run.
30prog="$1"
31shift
32# Make any relative path in $prog absolute.
33case "$prog" in
34 /*) ;;
35 */*) prog="`pwd`/$prog" ;;
36esac
37
38# The input.
39input="$1"
40shift
41case "$input" in
42 /*)
43 # Absolute path; do nothing.
44 ;;
45 *)
46 # Relative path. Make it absolute. Why? Because otherwise any
47 # debugging info in the generated file will point to the wrong
48 # place. This is really gross.
49 input="`pwd`/$input"
50 ;;
51esac
52
53pairlist=
54while test "$#" -ne 0; do
55 if test "$1" = "--"; then
56 shift
57 break
58 fi
59 pairlist="$pairlist $1"
60 shift
61done
62
63# FIXME: add hostname here for parallel makes that run commands on
64# other machines. But that might take us over the 14-char limit.
65dirname=ylwrap$$
66trap "cd `pwd`; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15
67mkdir $dirname || exit 1
68
69cd $dirname
70$prog ${1+"$@"} "$input"
71status=$?
72
73if test $status -eq 0; then
74 set X $pairlist
75 shift
76 first=yes
77 while test "$#" -ne 0; do
78 if test -f "$1"; then
79 # If $2 is an absolute path name, then just use that,
80 # otherwise prepend `../'.
81 case "$2" in
82 /*) target="$2";;
83 *) target="../$2";;
84 esac
85 mv "$1" "$target" || status=$?
86 else
87 # A missing file is only an error for the first file. This
88 # is a blatant hack to let us support using "yacc -d". If -d
89 # is not specified, we don't want an error when the header
90 # file is "missing".
91 if test $first = yes; then
92 status=1
93 fi
94 fi
95 shift
96 shift
97 first=no
98 done
99else
100 status=$?
101fi
102
103# Remove the directory.
104cd ..
105rm -rf $dirname
106
107exit $status