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

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

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.1.1
    • CPU:
      sparc
    • OS:
      solaris_2.5
    • Verification:
      Not verified

      Description



      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.
      ======================================================================

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: