Revision: 49430
          http://brlcad.svn.sourceforge.net/brlcad/?rev=49430&view=rev
Author:   n_reed
Date:     2012-02-15 18:48:06 +0000 (Wed, 15 Feb 2012)
Log Message:
-----------
zero width should be okay for c conversion too

Modified Paths:
--------------
    brlcad/trunk/src/libbu/sscanf.c

Modified: brlcad/trunk/src/libbu/sscanf.c
===================================================================
--- brlcad/trunk/src/libbu/sscanf.c     2012-02-15 17:24:05 UTC (rev 49429)
+++ brlcad/trunk/src/libbu/sscanf.c     2012-02-15 18:48:06 UTC (rev 49430)
@@ -510,54 +510,52 @@
        case CT_CCL:
        case CT_STRING:
 
-           /* unsupressed %s or %[...] conversion */
-           if (!(flags & SUPPRESS) && c != CT_CHAR) {
-
-               if (width == 0 && !(flags & HAVEWIDTH)) {
-                   struct bu_vls err = BU_VLS_INIT_ZERO;
-
-                   /* No width was provided by caller.
-                    *
-                    * If the caller is using %s or %[...] without a
-                    * maximum field width, then there is a bug in the
-                    * caller code.
-                    *
-                    * sscanf could easily overrun the provided buffer and
-                    * cause a program crash, so just bomb here and make
-                    * the source of the problem clear.
-                    */
-                   bu_vls_sprintf(&err, "ERROR.\n"
-                               "  bu_sscanf was called with bad format string: 
\"%s\"\n"
-                               "  %%s and %%[...] conversions must be bounded 
using "
-                               "a maximum field width.", fmt0);
-                   bu_bomb(bu_vls_addr(&err));
-               }
-
-               if (width == 0) {
-                   /* Caller specified zero width in the format string.
-                    * (%0c %0s or %0[...])
-                    *
-                    * The behavior of sscanf for a zero width is
-                    * undefined, so we provide our own consistent
-                    * behavior here.
-                    *
-                    * The assignment wasn't suppressed, so we'll assume
-                    * the caller provided a pointer and wants us to write
-                    * to it. Just write '\0' and call it a successfull
-                    * assignment.
-                    */
-                   *va_arg(ap, char*) = '\0';
-                   ++partAssigned;
-                   break;
-               }
-               
-           }
-
            /* %lc %l[...] %ls are unsupported */
            if (flags & LONG) {
                EXIT_DUE_TO_MISC_ERROR;
            }
 
+           /* unsupressed %s or %[...] conversion */
+           if (!(flags & SUPPRESS)) {
+               if (width == 0) {
+                   if (flags & HAVEWIDTH) {
+                       /* Caller specified zero width in the format string.
+                        * (%0c %0s or %0[...])
+                        *
+                        * The behavior of sscanf for a zero width is
+                        * undefined, so we provide our own consistent
+                        * behavior here.
+                        *
+                        * The assignment wasn't suppressed, so we'll assume
+                        * the caller provided a pointer and wants us to write
+                        * to it. Just write '\0' and call it a successfull
+                        * assignment.
+                        */
+                       *va_arg(ap, char*) = '\0';
+                       ++partAssigned;
+                       break;
+                   } else if (c != CT_CHAR) {
+                       struct bu_vls err = BU_VLS_INIT_ZERO;
+
+                       /* No width was provided by caller.
+                        *
+                        * If the caller is using %s or %[...] without a
+                        * maximum field width, then there is a bug in the
+                        * caller code.
+                        *
+                        * sscanf could easily overrun the provided buffer and
+                        * cause a program crash, so just bomb here and make
+                        * the source of the problem clear.
+                        */
+                       bu_vls_sprintf(&err, "ERROR.\n"
+                                   "  bu_sscanf was called with bad format 
string: \"%s\"\n"
+                                   "  %%s and %%[...] conversions must be 
bounded using "
+                                   "a maximum field width.", fmt0);
+                       bu_bomb(bu_vls_addr(&err));
+                   }
+               }
+           }
+
            /* ordinary %c or %[...] or %s conversion */
            SSCANF_TYPE(char*);
            break;
@@ -615,7 +613,7 @@
            }
            break;
 
-       /* %[eEfg] conversion */
+       /* %[aefgAEFG] conversion */
        case CT_FLOAT:
            if (flags & LONG) {
                SSCANF_TYPE(double*);

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to