[Aptitude-svn-commit] r3496 - in branches/aptitude-0.3/aptitude: . src/vscreen

Daniel Burrows dburrows@costa.debian.org
Tue, 28 Jun 2005 00:35:26 +0000


Author: dburrows
Date: Tue Jun 28 00:35:23 2005
New Revision: 3496

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/vscreen/fragment.cc
Log:
Add a long string escape to fragf.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Tue Jun 28 00:35:23 2005
@@ -1,5 +1,10 @@
 2005-06-27  Daniel Burrows  <dburrows@debian.org>
 
+	* src/vscreen/fragment.cc:
+
+	  Add a long string escape to fragf (for printing out stuff that's
+	  already been transcoded).
+
 	* src/vscreen/testvscreen.cc:
 
 	  Use setlocale() to actually enter the current locale (so UTF-8

Modified: branches/aptitude-0.3/aptitude/src/vscreen/fragment.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/fragment.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/fragment.cc	Tue Jun 28 00:35:23 2005
@@ -947,10 +947,13 @@
   argument():format(0) {}
 
   char format;
+  /** If \b true, the 'l' modifier was attached to this argument. */
+  bool islong:1;
   union
   {
     fragment *F;
     const char *s;
+    const wchar_t *ls;
     int attr;
   };
 };
@@ -985,6 +988,9 @@
   // loop 1: count the arguments.
   while(nextpercent!=NULL)
     {
+      if(*(nextpercent+1)=='l')
+	++nextpercent;
+
       switch(*(nextpercent+1))
 	{
 	case '0':
@@ -1052,6 +1058,13 @@
   nextpercent=strchr(start, '%');
   while(nextpercent!=NULL)
     {
+      bool islong=false;
+      if(*(nextpercent+1)=='l')
+	{
+	  islong=true;
+	  ++nextpercent;
+	}
+      
       switch(*(nextpercent+1))
 	{
 	case '0':
@@ -1070,7 +1083,9 @@
 	    int pos=strtol(nextpercent+1, &endptr, 10)-1;
 
 	    // if we saw it before it had better be the same type.
-	    if(arguments[pos].format!=0 && arguments[pos].format!=*(endptr+1))
+	    if(arguments[pos].format!=0 &&
+	       (arguments[pos].format!=*(endptr+1) ||
+		arguments[pos].islong!=islong))
 	      return text_fragment("Bad argument string to fragf: inconsistent positional parameter types!",
 				   get_style("Error"));
 
@@ -1156,9 +1171,17 @@
 
   while(nextpercent!=NULL)
     {
+      bool islong=false;
+
       // First, make a fragment for everything until the percent:
       curstr+=string(start, nextpercent-start);
 
+      if(*(nextpercent+1)=='l')
+	{
+	  islong=true;
+	  ++nextpercent;
+	}
+
       // This is almost always what we want; in the cases when it's not,
       // I override it explicitly.
       start=nextpercent+2;
@@ -1229,7 +1252,10 @@
 	  // should have been verified above.
 	  assert(arguments[argcount].format=='s');
 
-	  curstr+=arguments[argcount].s;
+	  if(islong)
+	    curstr+=transcode(arguments[argcount].ls);
+	  else
+	    curstr+=arguments[argcount].s;
 	  ++argcount;
 	  break;
 	case 'S':