pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] CVS: Games/Pingus/src start_screen.cxx,1.15,1.16


From: torangan
Subject: [Pingus-CVS] CVS: Games/Pingus/src start_screen.cxx,1.15,1.16
Date: 12 Apr 2003 12:35:55 -0000

Update of /var/lib/cvs/Games/Pingus/src
In directory dark:/tmp/cvs-serv18318

Modified Files:
        start_screen.cxx 
Log Message:
some boundary checks and better handling of linebreaks


Index: start_screen.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/start_screen.cxx,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- start_screen.cxx    11 Apr 2003 15:15:34 -0000      1.15
+++ start_screen.cxx    12 Apr 2003 12:35:53 -0000      1.16
@@ -184,6 +184,9 @@
     return description;
     
   description = System::translate(plf->get_description());
+  
+  if (description != "")
+    return description;
 
   unsigned int pos = 0;
   while ((pos = description.find('\t', pos)) != std::string::npos)
@@ -196,16 +199,34 @@
   pos = 0;  
   while ((pos = description.find('\n', pos)) != std::string::npos)
     {
-      if (description[pos + 1] == '\n')          // double enter marks 
paragraph
-        description.replace(pos++, 2, 1, '\n');  // replace the two \n by one 
and move pos behind it
+      if (pos < description.length() && description[pos + 1] == '\n')   // 
double enter marks paragraph
+       {
+          description.replace(pos, 2, 1, '\n');                        // 
replace the two \n by one
+       }
+      else if (pos < description.length() - 1 && description[pos + 1] == ' ' 
&& description[pos + 2] == '\n')
+        {
+            description.replace(pos, 3, 1, '\n');                      // 
whitespace between the two \n doesn't matter
+       }
       else
-        description.replace(pos, 1, 1, ' ');
+        {
+          description.replace(pos, 1, 1, ' ');
+         continue;                                                     // no 
\n here anymore, so continue searching
+        }
+
+      if (pos && description[pos - 1] == ' ')
+        description.replace(pos - 1, 2, 1, '\n');                      // no 
whitespace in front
+       
+      if (pos < description.length() && description[pos + 1] == ' ')
+        description.replace(pos, 2, 1, '\n');                          // no 
whitespace behind
+       
+      ++pos;                                                           // we 
don't want to find it again
     }
         
   pos = 0;
   while ((pos = description.find("  ", pos)) != std::string::npos)
     description.replace(pos, 2, 1, ' ');
 
+
   int start_pos      = 0;
   int previous_space = 0;
   pos = 0;
@@ -221,6 +242,7 @@
 
       previous_space = pos;
     }
+    
   return description;
 }
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]