Author: tilman
Date: Sun May 26 10:31:41 2024
New Revision: 1917970

URL: http://svn.apache.org/viewvc?rev=1917970&view=rev
Log:
PDFBOX-5829: suuport floats like '-12.-1'

Modified:
    pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java
    
pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSFloat.java

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java?rev=1917970&r1=1917969&r2=1917970&view=diff
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java 
(original)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java 
Sun May 26 10:31:41 2024
@@ -88,6 +88,11 @@ public class COSFloat extends COSNumber
                 // PDFBOX-3500 has 0.-262
                 aFloat = "-" + aFloat.replaceFirst("-", "");
             }
+            else if (aFloat.matches("^-\\d+\\.-\\d+"))
+            {
+                // PDFBOX-5829 has -12.-1
+                aFloat = "-" + aFloat.replace("-", "");
+            }
             else
             {
                 throw new IOException("Error expected floating point number 
actual='" + aFloat + "'", e);

Modified: 
pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSFloat.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSFloat.java?rev=1917970&r1=1917969&r2=1917970&view=diff
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSFloat.java
 (original)
+++ 
pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSFloat.java
 Sun May 26 10:31:41 2024
@@ -384,13 +384,18 @@ class TestCOSFloat extends TestCOSNumber
 
         cosFloat = new COSFloat("0.-262");
         assertEquals(new COSFloat("-0.262"), cosFloat);
+        
+        cosFloat = new COSFloat("-0.-262");
+        assertEquals(new COSFloat("-0.262"), cosFloat);
+        
+        cosFloat = new COSFloat("-12.-1");
+        assertEquals(new COSFloat("-12.1"), cosFloat);
     }
 
     @Test
     void testDuplicateMisplacedNegative()
     {
         assertThrows(IOException.class, () -> new COSFloat("0.-26-2"));
-        assertThrows(IOException.class, () -> new COSFloat("-0.-262"));
         assertThrows(IOException.class, () -> new COSFloat("---0.262"));
         assertThrows(IOException.class, () -> new COSFloat("--0.2-62"));
     }


Reply via email to