about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2017-06-28 21:58:45 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2017-06-28 21:58:45 +0000
commit6f62629842614ba3cd807d9eaad722a7d7653969 (patch)
tree64eb7b987d8882f5640455e6bf30381c5f4c9e0f
parentdc4857c90e891a93448b2254887fc35d5f74099e (diff)
downloadnetpbm-mirror-6f62629842614ba3cd807d9eaad722a7d7653969.tar.gz
netpbm-mirror-6f62629842614ba3cd807d9eaad722a7d7653969.tar.xz
netpbm-mirror-6f62629842614ba3cd807d9eaad722a7d7653969.zip
Fix error messages for unprocessable input
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3006 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--converter/other/svgtopam.c38
-rw-r--r--doc/HISTORY4
2 files changed, 38 insertions, 4 deletions
diff --git a/converter/other/svgtopam.c b/converter/other/svgtopam.c
index d1dc4d5f..ca6f4dc7 100644
--- a/converter/other/svgtopam.c
+++ b/converter/other/svgtopam.c
@@ -317,6 +317,19 @@ pathReader_destroy(PathReader * const pathReaderP) {
 
 
 
+static const char *
+pathReader_context(PathReader * const pathReaderP) {
+
+    const char * retval;
+
+    pm_asprintf(&retval, "Character position %u (starting at 0) in '%s'",
+                pathReaderP->cursor, pathReaderP->pathP->pathText);
+
+    return retval;
+}
+
+
+
 static void
 pathReader_skipWhiteSpace(PathReader * const pathReaderP) {
 /*----------------------------------------------------------------------------
@@ -343,7 +356,10 @@ pathReader_getNumber(PathReader *   const pathReaderP,
 
     if (pathReaderP->cursor >= pathTextLength)
         pm_error("Path description ends where a number was expected.");
-    else {
+    else if (!isdigit(pathText[pathReaderP->cursor])) {
+        pm_error("Character '%c' instead of a digit where number expected",
+                 pathText[pathReaderP->cursor]);
+    } else {
         unsigned int number;
 
         number = 0;  /* initial value */
@@ -353,6 +369,10 @@ pathReader_getNumber(PathReader *   const pathReaderP,
             number = 10 * number + (pathText[pathReaderP->cursor] - '0');
             ++pathReaderP->cursor;
         }
+        if (pathText[pathReaderP->cursor] == '.')
+            pm_error("Number contains decimal point.  This program does not "
+                     "know how to deal with fractional positions");
+
         *numberP = number;
     }
 }
@@ -410,14 +430,22 @@ pathReader_getNextCommand(PathReader *  const pathReaderP,
         case 'z':
             pathCommandP->verb = PATH_CLOSEPATH;
             break;
-        default:
-            pm_error("Unrecognized command in <path>: '%c'.",
-                     pathText[pathReaderP->cursor++]);
+        default: {
+            const char * const context = pathReader_context(pathReaderP);
+            
+            pm_errormsg("Unrecognized command in <path>: '%c'.  %s",
+                        pathText[pathReaderP->cursor++], context);
+
+            pm_strfree(context);
+
+            pm_longjmp();
+        }
         }
     }
 }
 
 
+
 static void
 outlineObject(Path *           const pathP,
               struct fillobj * const fillObjP) {
@@ -476,6 +504,8 @@ outlineObject(Path *           const pathP,
                 if (traceDraw)
                     pm_message("Doing cubic spline to (%u, %u)",
                                dest.x, dest.y);
+                pm_error("SVG image contains a cubic spline path.  "
+                         "This program cannot process cubic splines.");
                 /* We need to write ppmd_spline4() */
                 ppmd_spline4p(NULL, 0, 0, 0,
                               makePpmdPoint(currentPos),
diff --git a/doc/HISTORY b/doc/HISTORY
index 55476fd2..12087161 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -53,6 +53,10 @@ not yet  BJH  Release 10.79.00
               like twos complement positive numbers; fail instead.  Always
               broken (svgtopam was new in Netpbm 10.33 (March 2006)).
 
+              svgtopam: fix error messages when input has splines or negative
+              positions.  Always broken (svgtopam was new in Netpbm 10.33
+              (March 2006)).
+
               libnetpbm: fix bug: pm_system_XXX closes Standard Input if you
               supply a Standard Output accepter but not a Standard Input
               feeder.  Broken since Netpbm 10.40 (September 2007).