* Copyright (c) 1980 The Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)yyput.c 5.3 (Berkeley) 4/16/91";
* pi - Pascal interpreter code translator
* Charles Haley, Bill Joy UCB
* Version 1.2 January 1979
* pxp - Pascal execution profiler
* Version 1.2 January 1979
* Structure describing queued listing lines during the forward move
* of error recovery. These lines will be stroed by yyoutline during
* the forward move and flushed by yyoutfl or yyflush when an
* error occurs or a program termination.
* Filename gives the current input file, lastname is
* the last filename we printed, and lastid is the seqid of the last line
* we printed, to help us avoid printing
* multiple copies of lines.
* Print the current line in the input line
* buffer or, in a forward move of the recovery, queue it for printing.
bp
= tree(6, T_BOTTLE
, yyline
, yylinpt
, filename
, yyseqid
);
bp
->Bnext
= bottled
->Bnext
, bottled
->Bnext
= bp
;
yyprline(charbuf
, yyline
, filename
, yyseqid
);
* Flush all the bottled output.
* Flush the listing to the sequence id toseqid
while (bp
->Bseqid
<= toseqid
) {
yygetline(bp
->Bfile
, bp
->Bseekp
, bp
->Bline
, bp
->Bseqid
);
* Yysync guarantees that the line associated
* with the current token was the last line
* printed for a syntactic error message.
yygetline(yyefile
, yyseekp
, yyeline
, yyeseqid
);
* Yygetline gets a line from a file after we have
* lost it. The pointer efile gives the name of the file,
* seekp its offset in the file, and eline its line number.
* If this routine has been called before the last file
* it worked on will be open in yygetunit, with the files
* name being given in yygetfile. Note that this unit must
* be opened independently of the unit in use for normal i/o
* to this file; if it were a dup seeks would seek both files.
yygetline(efile
, seekp
, eline
, eseqid
)
int seekp
, eline
, eseqid
;
if (efile
!= yygetfile
) {
yygetunit
= open(yygetfile
, 0);
perror(yygetfile
), pexit(DIED
);
if (lseek(yygetunit
, (long)seekp
, 0) < 0)
cnt
= read(yygetunit
, bp
, CBSIZE
);
yyprline(bp
, eline
, efile
, eseqid
);
yygetline(OY
.Yyefile
, OY
.Yyseekp
, OY
.Yyeline
, OY
.Yyeseqid
);
* Print the line in the character buffer which has
* line number line. The buffer may be terminated by a new
* line character or a null character. We process
* form feed directives, lines with only a form feed character, and
* suppress numbering lines which are empty here.
yyprline(buf
, line
, file
, id
)
if (buf
[0] == '\f' && buf
[1] == '\n') {
while (*cp
!= 0 && *cp
!= '\n')
* Set the current file name to be file,
* printing the name, or a header on a new
if (file
== filename
&& opt('n') && (printed
& 02) == 0) {
* Put out an include file name
* if an error occurs but the name has
* not been printed (or if another name
* has been printed since it has).
if (cp
== lastname
&& printed
)