tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From man...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/jasper/resources messages.properties
Date Mon, 24 Apr 2000 22:53:14 GMT
mandar      00/04/24 15:53:14

  Modified:    src/share/org/apache/jasper/compiler JspReader.java
                        Mark.java
               src/share/org/apache/jasper/resources messages.properties
  Log:
  Bug fix for 228, 275:
  
  Can't include a JSP file more than once.
  
  The fix is somewhat involved, will be nice to get
  testing milege on this one.
  
  Revision  Changes    Path
  1.14      +40 -15    jakarta-tomcat/src/share/org/apache/jasper/compiler/JspReader.java
  
  Index: JspReader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspReader.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- JspReader.java	2000/03/28 04:29:48	1.13
  +++ JspReader.java	2000/04/24 22:53:12	1.14
  @@ -80,12 +80,14 @@
    * @author Anselm Baird-Smith
    * @author Harish Prabandham
    * @author Rajiv Mordani
  + * @author Mandar Raje
    */
   public class JspReader {
       protected Mark current  = null;
       String master = null;
   
       Vector sourceFiles = new Vector();
  +    int currFileId = 0;
       int size = 0;
       
       private JspCompilationContext context;
  @@ -105,8 +107,23 @@
               return -1;
   	sourceFiles.addElement(file);
   	this.size++;
  -	return sourceFiles.size()-1;
  +	return sourceFiles.size() - 1;
       }
  +    
  +
  +    /**
  +     * Unregister the source file.
  +     * This method is used to implement file inclusion. Each included file
  +     * gets a uniq identifier (which is the index in the array of source files).
  +     * @return The index of the now registered file.
  +     */
  +    protected int unregisterSourceFile(String file) {
  +        if (!sourceFiles.contains(file))
  +            return -1;
  +	sourceFiles.removeElement(file);
  +	this.size--;
  +	return sourceFiles.size() - 1;
  +    }
   
       /**
        * Push a new file onto the stack.
  @@ -153,7 +170,7 @@
                                                            new Object[] { 
                                                                file 
                                                            }));
  -                                                         
  +	currFileId = fileid;
                                        
   	InputStreamReader reader = null;
   	try {
  @@ -179,9 +196,11 @@
   		caw.write(buf, 0, i);
   	    caw.close();
   	    if (current == null) {
  -		current = new Mark( this, caw.toCharArray(), fileid, file.getParent(), encoding );
  +		current = new Mark( this, caw.toCharArray(), fileid, getFile(fileid),
  +				    file.getParent(), encoding );
   	    } else {
  -		current.pushStream( caw.toCharArray(), fileid, file.getParent(), encoding );
  +		current.pushStream( caw.toCharArray(), fileid, getFile(fileid),
  +				    file.getParent(), encoding );
   	    }
   
           } catch (FileNotFoundException fnfe) {
  @@ -200,14 +219,20 @@
   	}
       }
   
  -    public boolean popFile() {
  +    public boolean popFile() throws ParseException {
   	// Is stack created ? (will happen if the Jsp file we'r looking at is
   	// missing.
   	if (current == null) 
   		return false;
   
   	// Restore parser state:
  -	size--;
  +	//size--;
  +	String fName = getFile(currFileId);
  +	currFileId = unregisterSourceFile(fName);
  +	if (currFileId < -1)
  +	    throw new ParseException
  +		(Constants.getString("jsp.error.file.not.registered",
  +				     new Object[] {fName}));
   
   	return current.popStream();
       }
  @@ -225,7 +250,7 @@
   	return new JspReader(file, ctx, encoding);
       }
   
  -    public boolean hasMoreInput() {
  +    public boolean hasMoreInput() throws ParseException {
   	if (current.cursor >= current.stream.length) {
   	    while (popFile()) {
   		if (current.cursor < current.stream.length) return true;
  @@ -235,7 +260,7 @@
   	return true;
       }
       
  -    public int nextChar() {
  +    public int nextChar() throws ParseException {
   	if (!hasMoreInput())
   	    return -1;
   	
  @@ -282,7 +307,7 @@
   	return new String(current.stream, cur_cursor, current.cursor-cur_cursor);
       };
   
  -    char[] getChars(Mark start, Mark stop) {
  +    char[] getChars(Mark start, Mark stop) throws ParseException {
   	Mark oldstart = mark();
   	reset(start);
   	CharArrayWriter caw = new CharArrayWriter();
  @@ -305,7 +330,7 @@
   	current = new Mark(mark);
       }
   
  -    public boolean matchesIgnoreCase(String string) {
  +    public boolean matchesIgnoreCase(String string) throws ParseException {
   	Mark mark = mark();
   	int ch = 0;
   	int i = 0;
  @@ -320,7 +345,7 @@
   	return true;
       }
   
  -    public boolean matches(String string) {
  +    public boolean matches(String string) throws ParseException {
   	Mark mark = mark();
   	int ch = 0;
   	int i = 0;
  @@ -335,12 +360,12 @@
   	return true;
       }
       
  -    public void advance(int n) {
  +    public void advance(int n) throws ParseException {
   	while (--n >= 0)
   	    nextChar();
       }
   
  -    public int skipSpaces() {
  +    public int skipSpaces() throws ParseException {
   	int i = 0;
   	while (isSpace()) {
   	    i++;
  @@ -357,7 +382,7 @@
        * <strong>null</strong> otherwise.
        */
       public Mark skipUntil(String limit)
  -    {
  +    throws ParseException {
   	Mark ret = null;
   	int limlen = limit.length();
   	int ch;
  @@ -659,7 +684,7 @@
        * any space character as defined by <code>isSpace</code>.
        * @return A boolean.
        */
  -    private boolean isDelimiter() {
  +    private boolean isDelimiter() throws ParseException {
   	if ( ! isSpace() ) {
   	    int ch = peekChar();
   	    // Look for a single-char work delimiter:
  
  
  
  1.3       +18 -10    jakarta-tomcat/src/share/org/apache/jasper/compiler/Mark.java
  
  Index: Mark.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/Mark.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Mark.java	1999/12/21 13:14:16	1.2
  +++ Mark.java	2000/04/24 22:53:12	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/Mark.java,v 1.2
1999/12/21 13:14:16 rubys Exp $
  - * $Revision: 1.2 $
  - * $Date: 1999/12/21 13:14:16 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/Mark.java,v 1.3
2000/04/24 22:53:12 mandar Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/04/24 22:53:12 $
    *
    * ====================================================================
    * 
  @@ -70,6 +70,7 @@
   public final class Mark {
       int cursor, line, col;	// position within current stream
       int fileid;			// fileid of current stream
  +    String fileName;            // name of the current file
       String baseDir;		// directory of file for current stream
       char[] stream = null;	// current stream
       Stack includeStack = null;	// stack of stream and stream state of streams
  @@ -88,17 +89,20 @@
       class IncludeState {
   	int cursor, line, col;
   	int fileid;
  +	String fileName;
   	String baseDir;
   	String encoding;
   	char[] stream = null;
   
   	IncludeState(int inCursor, int inLine, int inCol, int inFileid, 
  -		     String inBaseDir, String inEncoding, char[] inStream) 
  +		     String name, String inBaseDir, String inEncoding,
  +		     char[] inStream) 
   	{
   	    cursor = inCursor;
   	    line = inLine;
   	    col = inCol;
   	    fileid = inFileid;
  +	    fileName = name;
   	    baseDir = inBaseDir;
   	    encoding = inEncoding;
   	    stream = inStream;
  @@ -114,13 +118,14 @@
       * @param inEncoding encoding of current file
       * @param inBaseDir base directory of requested jsp file
       */
  -    Mark(JspReader reader, char[] inStream, int fileid, String inBaseDir, 
  -	 String inEncoding) 
  +    Mark(JspReader reader, char[] inStream, int fileid, String name,
  +	 String inBaseDir, String inEncoding) 
       {
   	this.reader = reader;
   	this.stream = inStream;
   	this.cursor = this.line = this.col = 0;
   	this.fileid = fileid;
  +	this.fileName = name;
   	this.baseDir = inBaseDir;
   	this.encoding = inEncoding;
   	this.includeStack = new Stack();
  @@ -130,6 +135,7 @@
   	this.reader = other.reader;
   	this.stream = other.stream;
   	this.fileid = other.fileid;
  +	this.fileName = other.fileName;
   	this.cursor = other.cursor;
   	this.line = other.line;
   	this.col = other.col;
  @@ -150,12 +156,12 @@
        * @param inBaseDir directory of file
   	 * @param inEncoding encoding of new file
        */
  -    public void pushStream(char[] inStream, int inFileid, String inBaseDir, 
  -		           String inEncoding) 
  +    public void pushStream(char[] inStream, int inFileid, String name,
  +			   String inBaseDir, String inEncoding) 
       {
   
   	// store current state in stack
  -	includeStack.push(new IncludeState(cursor, line, col, fileid, baseDir, 
  +	includeStack.push(new IncludeState(cursor, line, col, fileid, name, baseDir, 
   					   encoding, stream) );
   
   	// set new variables
  @@ -163,6 +169,7 @@
   	line = 0;
   	col = 0;
   	fileid = inFileid;
  +	fileName = name;
   	baseDir = inBaseDir;
   	encoding = inEncoding;
   	stream = inStream;
  @@ -184,6 +191,7 @@
   	line = state.line;
   	col = state.col;
   	fileid = state.fileid;
  +	fileName = state.fileName;
   	baseDir = state.baseDir;
   	stream = state.stream;
   	return true;
  @@ -196,7 +204,7 @@
       }
   
       public String getFile() {
  -        return reader.getFile(fileid);
  +        return this.fileName;
       }
       
       public String toShortString() {
  
  
  
  1.17      +2 -1      jakarta-tomcat/src/share/org/apache/jasper/resources/messages.properties
  
  Index: messages.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/resources/messages.properties,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- messages.properties	2000/03/30 04:28:06	1.16
  +++ messages.properties	2000/04/24 22:53:13	1.17
  @@ -69,7 +69,8 @@
   jsp.error.invalid.attribute={0}: Invalid attribute, {1}
   jsp.error.usebean.class.notfound=Class: {0} not found
   jsp.error.file.cannot.read=Cannot read file: {0}
  -jsp.error.file.already.registered=Seen file {0} already, maybe this is a recursive include?!
  +jsp.error.file.already.registered=Recursive include of file {0}
  +jsp.error.file.not.registered=file {0} not seen in include
   jsp.error.quotes.unterminated=Unterminated quotes
   jsp.error.attr.quoted=Attribute value should be quoted
   jsp.error.attr.novalue=Attribute {0} has no value
  
  
  

Mime
View raw message