kinman      01/10/04 12:12:52

  Modified:    jasper/src/share/org/apache/jasper/compiler Compiler.java
  Log:
  PR: 2693, 3822
  Catch NumberFormatException when attempting to get the line number from
  javac error messages, so that the messages will be dispalyed if we guess
  wrong.  Also filter the line so that tags in strings are displayed
  correctly.
  
  Revision  Changes    Path
  1.14      +32 -21    
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/Compiler.java
  
  Index: Compiler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/Compiler.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Compiler.java     2001/09/25 00:46:59     1.13
  +++ Compiler.java     2001/10/04 19:12:52     1.14
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/Compiler.java,v
 1.13 2001/09/25 00:46:59 remm Exp $
  - * $Revision: 1.13 $
  - * $Date: 2001/09/25 00:46:59 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/Compiler.java,v
 1.14 2001/10/04 19:12:52 kinman Exp $
  + * $Revision: 1.14 $
  + * $Date: 2001/10/04 19:12:52 $
    *
    * ====================================================================
    * 
  @@ -311,26 +311,37 @@
               int beginColon=line.indexOf(':', 2); // Drive letter on Windows !!
               int endColon=line.indexOf(':', beginColon+1);
   
  -            if (beginColon<0 || endColon<0) {
  -                errorMsg.append(line);
  -                errorMsg.append('\n');
  -                continue;
  -            }
  -
  -            String nr = line.substring(beginColon+1, endColon);
  -            int lineNr = Integer.parseInt( nr );
  -
  -            //System.out.println("lineNr: " + lineNr);
  +            if (!(beginColon<0 || endColon<0 ||
  +                     line.startsWith("Note: "))){ // deprecation warning
   
  -            // Now do the mapping
  -            String mapping = findMapping(map, lineNr);
  -            if (mapping == null)
  -                errorMsg.append('\n');
  -            else
  -                errorMsg.append(mapping);
  -            errorMsg.append(line);
  +                try {
  +                    String nr = line.substring(beginColon+1, endColon);
  +                    int lineNr = Integer.parseInt( nr );
  +                    //System.out.println("lineNr: " + lineNr);
  +
  +                    // Now do the mapping
  +                    String mapping = findMapping(map, lineNr);
  +                    if (mapping == null)
  +                        errorMsg.append('\n');
  +                    else
  +                        errorMsg.append(mapping);
  +                }
  +                catch (NumberFormatException ex) {
  +                    // If for some reason our guess at the location of the line
  +                    // number failed, time to give up.
  +                }
  +            }
  +            // Replace '<' in line with "&lt;", ">" with "&gt;" in line
  +            for (int i = 0; i < line.length(); i++) {
  +                char c = line.charAt(i);
  +                if (c == '<')
  +                    errorMsg.append("&lt;");
  +                else if (c == '>')
  +                    errorMsg.append("&gt;");
  +                else
  +                    errorMsg.append(c);
  +            }
               errorMsg.append('\n');
  -
           }
           br.close();
           map.clear();
  
  
  


Reply via email to