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

java.io.StreamTokenizer /* comments - line counting wrong

XMLWordPrintable

    • 1.1.1
    • sparc
    • solaris_2.5
    • Not verified



      Name: saC57035 Date: 12/17/96


      The java_io.StreamTokenizer.nextToken() method count lines inside
      of /* .. */ comments wrong. It counts only \n regardless of
      whether there are other (\r or \r\n) line terminators or
      whether \n is ordinary (no increment is needed in this case).

      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("/*\n \r \r */a"));
       st.ordinaryChar('/');
       st.slashStarComments(true);
       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[a], line 2
      ------------------------------
      As we can see, only \n is counted.
      ======================================================================

            apalanissunw Anand Palaniswamy (Inactive)
            savzan Stanislav Avzan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: