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

java.io.StreamTokenizer quotes - escape sequences parsed wrong

XMLWordPrintable

    • 1.1.1
    • sparc
    • solaris_2.5
    • Not verified



      Name: saC57035 Date: 12/17/96


      The java_io.StreamTokenizer.nextToken(ch) method parses octal escapes
      wrong when analizes quoted strings. Eg. it parses \777 as one character 511
      instead of two characters '\77' and '7'.

      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("\"\\777\""));
       try {
         st.nextToken();
         for(int i=0;i<st.sval.length();i++) System.out.print((int)st.sval.charAt(i)+" ");
         System.out.println();
       } catch (Throwable e) {
         System.out.println("Test failed: "+e+" is thrown");
       }
      }

      }
      -- The output ----------------
      511
      ------------------------------
      ======================================================================

            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: