Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4022462

java.io.StreamTokenizer counts lines incorrectly if newline is made ordinary

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.5

      Description



      Name: saC57035 Date: 12/17/96


      The java_io.StreamTokenizer.nextToken() handles EOLs as comment terminator
      even when EOL is ordinary.

      Here is the example demonstrating the bug:
      ---- Test.java ----------------------
      import java.io.*;

      public class Test {

      public static void main( String argv[] ) {
       StreamTokenizer st = new StreamTokenizer
                     (new StringBufferInputStream("/comment \n continued"));
       st.ordinaryChar('\n'); // now \n should not break comments
       try {
         while(st.nextToken() != st.TT_EOF) System.out.println(st);
       } catch (Throwable e) {
         System.out.println("Test failed: "+e+" is thrown");
       }
      }

      }
      -- The output ----------------
      Token[EOL], line 1
      Token[continued], line 1
      ------------------------------
      No output is expected is this case

      NB: line counter is not incremented - that's right 'cos \n
      is not line terminator now.
      ======================================================================

      Name: saC57035 Date: 12/17/96


      The same problem is discovered when testing quoted strings and // comments.
      Please fix that code as well.

      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              savzan Stanislav Avzan (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: