about summary refs log tree commit diff
path: root/converter/ppm/ppmtoarbtxt.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2017-06-10 17:18:14 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2017-06-10 17:18:14 +0000
commit366cb11d031b18c84b14b2828f7d8e6ab26a34e6 (patch)
treef7ca2fe3aee879d1abb9b1f8fcb43a5c5a27f373 /converter/ppm/ppmtoarbtxt.c
parent021f2b97000472cdc185dc804bcbf2c09e6f3925 (diff)
downloadnetpbm-mirror-366cb11d031b18c84b14b2828f7d8e6ab26a34e6.tar.gz
netpbm-mirror-366cb11d031b18c84b14b2828f7d8e6ab26a34e6.tar.xz
netpbm-mirror-366cb11d031b18c84b14b2828f7d8e6ab26a34e6.zip
cleanup
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2994 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/ppm/ppmtoarbtxt.c')
-rw-r--r--converter/ppm/ppmtoarbtxt.c46
1 files changed, 31 insertions, 15 deletions
diff --git a/converter/ppm/ppmtoarbtxt.c b/converter/ppm/ppmtoarbtxt.c
index 882ebdf1..6d4ed04e 100644
--- a/converter/ppm/ppmtoarbtxt.c
+++ b/converter/ppm/ppmtoarbtxt.c
@@ -734,15 +734,20 @@ interpretObjType(const char * const typstr) {
 
 
 static SkeletonObject *
-newIcSkelFromReplString(const char *       const objstr,
+newIcSkelFromReplString(const char *       const icolorObjstr,
                         SkeletonObjectType const objType) {
-
+/*----------------------------------------------------------------------------
+  A new skeleton for an integer color substitution specifier (class
+  OBJTYP_ICOLOR) whose replacement string (the stuff between the parentheses
+  in #(...)) says substitution type 'objType' and the rest of the
+  replacement string is 'icolorObjstr'.
+-----------------------------------------------------------------------------*/
     SkeletonObject * retval;
     unsigned int icolmin, icolmax;
     char formstr[MAX_OBJ_BUF];
     int nOdata;
 
-    nOdata = sscanf(objstr, "%*s%s%u%u", formstr, &icolmin, &icolmax);
+    nOdata = sscanf(icolorObjstr, "%s%u%u", formstr, &icolmin, &icolmax);
 
     if (nOdata == 3)
         retval = newIcolDataObj(objType, formstr, icolmin, icolmax);
@@ -758,16 +763,20 @@ newIcSkelFromReplString(const char *       const objstr,
 
 
 static SkeletonObject *
-newFcSkelFromReplString(const char *       const objstr,
+newFcSkelFromReplString(const char *       const fcolorObjstr,
                         SkeletonObjectType const objType) {
-
+/*----------------------------------------------------------------------------
+  A new skeleton for a floating point color substitution specifier (class
+  OBJTYP_FCOLOR) whose replacement string (the stuff between the parentheses
+  in #(...)) says substitution type 'objType' and the rest of the
+  replacement string is 'fcolorObjstr'.
+-----------------------------------------------------------------------------*/
     SkeletonObject * retval;
     double fcolmin, fcolmax;
     char formstr[MAX_OBJ_BUF];
     int nOdata;
 
-    nOdata = sscanf(objstr, "%*s%s%lf%lf", formstr,
-                    &fcolmin, &fcolmax);
+    nOdata = sscanf(fcolorObjstr, "%s%lf%lf", formstr, &fcolmin, &fcolmax);
 
     if (nOdata == 3)
         retval = newFcolDataObj(objType, formstr, fcolmin, fcolmax);
@@ -783,14 +792,19 @@ newFcSkelFromReplString(const char *       const objstr,
 
 
 static SkeletonObject *
-newISkelFromReplString(const char *       const objstr,
+newISkelFromReplString(const char *       const intObjstr,
                        SkeletonObjectType const objType) {
-
+/*----------------------------------------------------------------------------
+  A new skeleton for an integer substitution specifier (class OBJTYP_INT)
+  whose replacement string (the stuff between the parentheses in #(...))
+  says substitution type 'objType' and the rest of the replacement string is
+  'intObjstr'.
+-----------------------------------------------------------------------------*/
     SkeletonObject * retval;
     char formstr[MAX_OBJ_BUF];
     int nOdata;
 
-    nOdata = sscanf(objstr, "%*s%s", formstr);
+    nOdata = sscanf(intObjstr, "%s", formstr);
     
     if (nOdata == 1)
         retval = newIdataObj(objType, formstr);
@@ -808,7 +822,7 @@ newISkelFromReplString(const char *       const objstr,
 static SkeletonObject *
 newSkeletonFromReplString(const char * const objstr) {
 /*----------------------------------------------------------------------------
-  Create a skeleton from the replacement string 'objstr' (the stuff
+  A new skeleton created from the replacement string 'objstr' (the stuff
   between the parentheses in #(...) ).
 
   Return NULL if it isn't a valid replacement string.
@@ -823,6 +837,7 @@ newSkeletonFromReplString(const char * const objstr) {
 
     SkeletonObject * retval;
     char typstr[MAX_OBJ_BUF];
+    int typlen;
     SkeletonObjectType objType;
     int conversionCt;
     char s1[MAX_OBJ_BUF];    /* Dry read. */
@@ -831,7 +846,8 @@ newSkeletonFromReplString(const char * const objstr) {
 
     typstr[0] = '\0';  /* initial value */
 
-    conversionCt = sscanf(objstr, "%s%s%f%f%s", typstr, s1, &f1, &f2, s2);
+    conversionCt = sscanf(objstr, "%s%n%s%f%f%s",
+                          typstr, &typlen, s1, &f1, &f2, s2);
     switch (conversionCt) {
     case 1: case 2: case 4:
         objType = interpretObjType(typstr);
@@ -842,13 +858,13 @@ newSkeletonFromReplString(const char * const objstr) {
 
     switch (objClass(objType)) {
     case OBJTYP_ICOLOR:
-        retval = newIcSkelFromReplString(objstr, objType);
+        retval = newIcSkelFromReplString(&objstr[typlen], objType);
         break;
     case OBJTYP_FCOLOR:
-        retval = newFcSkelFromReplString(objstr, objType);
+        retval = newFcSkelFromReplString(&objstr[typlen], objType);
         break;
     case OBJTYP_INT:
-        retval = newISkelFromReplString(objstr, objType);
+        retval = newISkelFromReplString(&objstr[typlen], objType);
         break;
     case OBJTYP_BDATA:
         retval = NULL;