Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-655

Error in generating meta characters \t \n \r in string literal

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-beta-8
    • 1.0-beta-8
    • parser
    • None

    Description

      My test on groovy-1.0-beta-7:

      // The output is not C:\test
      println "C:
      test"

      // The output is not C:\ntest
      println "C:
      ntest"

      // The output is not C:\rtest
      println "C:
      rtest"

      // unterminated string literal
      println "C:
      "

      // The output is C:\"
      println "C:
      ""

      And here is some similar issue from Jason Braucht:
      -----------[Start of message]----------------------------
      I think I'm seeing something similar using Groovy Version: 1.0-beta-7
      JVM: 1.4.2_05-b04

      'cmd /c dir /b /s \\myProjectName\\trunk
      *.java'.execute()
      behaves differently from:
      "cmd /c dir /b /s \\myProjectName\\trunk
      *.java"'.execute()

      Based on my limited understanding of groovy, I thought those two
      statements would work the same, but they don't. In the process of
      trying to figure out what I was doing wrong I compiled both versions
      and ran the .class through Jad. I noticed an extra slash being
      inserted before the "trunk" in second example. The output from Jad is
      as follows:

      InvokerHelper.invokeNoArgumentsMethod("cmd /c dir /b /s
      \\myProjectName\\trunk
      *.java", "execute");

      and

      InvokerHelper.invokeNoArgumentsMethod("cmd /c dir /b /s
      \\myProjectName\\\trunk
      *.java", "execute"); // notice the extra
      slash before "trunk"

      When I looked at the .class with a hex editor, I noticed there was a
      tab character in place of the 't' in trunk in the second example, so I
      think Jad is decompiling properly.

      Interestingly, when I tried:

      "cmd /c dir /b /s \\myProjectName\\\trunk
      *.java"'.execute()

      the output is the same in the second example above:

      InvokerHelper.invokeNoArgumentsMethod("cmd /c dir /b /s
      \\myProjectName\\\trunk
      *.java", "execute");

      Is this behavior expected?
      -----------[End of message]----------------------------

      Attachments

        1. MetaCharacterPatch.patch
          0.9 kB
          Jochen Theodorou

        Activity

          People

            Unassigned Unassigned
            phkim Kim, Pilho
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: