commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1441510 - in /commons/proper/imaging/trunk/src: main/java/org/apache/commons/imaging/common/ test/data/images/png/5/
Date Fri, 01 Feb 2013 16:27:06 GMT
Author: damjan
Date: Fri Feb  1 16:27:06 2013
New Revision: 1441510

URL: http://svn.apache.org/viewvc?rev=1441510&view=rev
Log:
Add single quote parsing to the C parser.
Add some PNG test images for the tRNS chunk.


Added:
    commons/proper/imaging/trunk/src/test/data/images/png/5/
    commons/proper/imaging/trunk/src/test/data/images/png/5/info.txt   (with props)
    commons/proper/imaging/trunk/src/test/data/images/png/5/trns-gray.png   (with props)
    commons/proper/imaging/trunk/src/test/data/images/png/5/trns-palette8.png   (with props)
    commons/proper/imaging/trunk/src/test/data/images/png/5/trns-rgb.png   (with props)
Modified:
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BasicCParser.java

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BasicCParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BasicCParser.java?rev=1441510&r1=1441509&r2=1441510&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BasicCParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BasicCParser.java
Fri Feb  1 16:27:06 2013
@@ -97,6 +97,7 @@ public class BasicCParser {
     public static ByteArrayOutputStream preprocess(final InputStream is,
             final StringBuilder firstComment, final Map<String, String> defines)
             throws IOException, ImageReadException {
+        boolean inSingleQuotes = false;
         boolean inString = false;
         boolean inComment = false;
         boolean inDirective = false;
@@ -119,7 +120,9 @@ public class BasicCParser {
                         inComment = false;
                         seenFirstComment = true;
                     } else {
-                        out.write(c);
+                        if (!seenFirstComment) {
+                            firstComment.append((char)c);
+                        }
                     }
                 } else {
                     if (hadStar && !seenFirstComment) {
@@ -130,12 +133,44 @@ public class BasicCParser {
                         firstComment.append((char) c);
                     }
                 }
+            } else if (inSingleQuotes) {
+                if (c == '\\') {
+                    if (hadBackSlash) {
+                        out.write('\\');
+                        out.write('\\');
+                        hadBackSlash = false;
+                    } else {
+                        hadBackSlash = true;
+                    }
+                } else if (c == '\'') {
+                    if (hadBackSlash) {
+                        out.write('\\');
+                        hadBackSlash = false;
+                    } else {
+                        inSingleQuotes = false;
+                    }
+                    out.write('\'');
+                } else if (c == '\r' || c == '\n') {
+                    byte[] bb = out.toByteArray();
+                    System.err.println(new String(bb));
+                    System.err.println();
+                    throw new ImageReadException("Unterminated single quote in file");
+                } else {
+                    if (hadBackSlash) {
+                        out.write('\\');
+                        hadBackSlash = false;
+                    }
+                    out.write(c);
+                }
             } else if (inString) {
                 if (c == '\\') {
                     if (hadBackSlash) {
                         out.write('\\');
+                        out.write('\\');
+                        hadBackSlash = false;
+                    } else {
+                        hadBackSlash = true;
                     }
-                    hadBackSlash = true;
                 } else if (c == '"') {
                     if (hadBackSlash) {
                         out.write('\\');
@@ -184,6 +219,13 @@ public class BasicCParser {
                     } else {
                         out.write(c);
                     }
+                } else if (c == '\'') {
+                    if (hadSlash) {
+                        out.write('/');
+                    }
+                    hadSlash = false;
+                    out.write(c);
+                    inSingleQuotes = true;
                 } else if (c == '"') {
                     if (hadSlash) {
                         out.write('/');

Added: commons/proper/imaging/trunk/src/test/data/images/png/5/info.txt
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/data/images/png/5/info.txt?rev=1441510&view=auto
==============================================================================
--- commons/proper/imaging/trunk/src/test/data/images/png/5/info.txt (added)
+++ commons/proper/imaging/trunk/src/test/data/images/png/5/info.txt Fri Feb  1 16:27:06 2013
@@ -0,0 +1,2 @@
+These files contributed by Damjan Jovanovic.
+

Propchange: commons/proper/imaging/trunk/src/test/data/images/png/5/info.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/proper/imaging/trunk/src/test/data/images/png/5/trns-gray.png
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/data/images/png/5/trns-gray.png?rev=1441510&view=auto
==============================================================================
Binary file - no diff available.

Propchange: commons/proper/imaging/trunk/src/test/data/images/png/5/trns-gray.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: commons/proper/imaging/trunk/src/test/data/images/png/5/trns-palette8.png
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/data/images/png/5/trns-palette8.png?rev=1441510&view=auto
==============================================================================
Binary file - no diff available.

Propchange: commons/proper/imaging/trunk/src/test/data/images/png/5/trns-palette8.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: commons/proper/imaging/trunk/src/test/data/images/png/5/trns-rgb.png
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/data/images/png/5/trns-rgb.png?rev=1441510&view=auto
==============================================================================
Binary file - no diff available.

Propchange: commons/proper/imaging/trunk/src/test/data/images/png/5/trns-rgb.png
------------------------------------------------------------------------------
    svn:mime-type = image/png



Mime
View raw message