You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by se...@apache.org on 2006/06/03 05:15:11 UTC

svn commit: r411363 - /incubator/stdcxx/trunk/tests/src/printf.cpp

Author: sebor
Date: Fri Jun  2 20:15:11 2006
New Revision: 411363

URL: http://svn.apache.org/viewvc?rev=411363&view=rev
Log:
2006-06-02  Martin Sebor  <se...@roguewave.com>

	* printf.cpp (_rw_fmtexpr): Added the %{$parameter!:word} drective
	as an extension and corrected logic error (passing a pointer to an
	auto array to free()).

Modified:
    incubator/stdcxx/trunk/tests/src/printf.cpp

Modified: incubator/stdcxx/trunk/tests/src/printf.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/src/printf.cpp?rev=411363&r1=411362&r2=411363&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/printf.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/printf.cpp Fri Jun  2 20:15:11 2006
@@ -2819,7 +2819,7 @@
     char *param = spec.strarg;
 
     // look for the first operator character (if any)
-    char* word = strpbrk (param, ":+-=?");
+    char* word = strpbrk (param, ":+-=?!");
     if (word) {
         if (':' == *word) {
             if (   '+' == word [1] || '-' == word [1]
@@ -2834,6 +2834,13 @@
                 // '=', or '?' is not special
             }
         }
+        else if ('!' == word [0] && ':' == word [1]) {
+            // extension
+            oper [0] = word [0];
+            oper [1] = word [1];
+            *word    = '\0';
+            word    += 2;
+        }
         else {
             oper [0] = *word;
             *word++ = '\0';
@@ -2875,6 +2882,11 @@
     // | ${parameter+word}  |     word    |    word     |    null     |
     // +--------------------+-------------+-------------+-------------+
 
+    // Extension:
+    // +--------------------+-------------+-------------+-------------+
+    // | ${parameter!:word} | assign word | assign word | assign word |
+    // +--------------------+-------------+-------------+-------------+
+
     int assign = 0;
     int error  = 0;
 
@@ -2931,6 +2943,11 @@
         }
         break;
 
+    case '!':
+        val = word ? word : "";
+        assign = 1;
+        break;
+
     default:
         break;
     }
@@ -2953,7 +2970,7 @@
 
         rw_putenv (pbuf);
         if (pbuf != varbuf)
-            free (varbuf);
+            free (pbuf);
     }
 
     if (error) {