[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/runtime/kioslave/man
From:       Martin Koller <kollix () aon ! at>
Date:       2011-01-03 2:31:51
Message-ID: 20110103023151.78BBAAC8AE () svn ! kde ! org
[Download RAW message or body]

SVN commit 1211075 by mkoller:

fix the endless loop in man:groff(7) by implementing .break
and also implement .nop macro


 M  +18 -3     man2html.cpp  


--- trunk/KDE/kdebase/runtime/kioslave/man/man2html.cpp #1211074:1211075
@@ -630,6 +630,7 @@
 static int tabstops[20] = { 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96 };
 static int maxtstop = 12;
 static int curpos = 0;
+static bool break_the_while_loop = false;
 
 static char *scan_troff(char *c, bool san, char **result);
 static char *scan_troff_mandoc(char *c, bool san, char **result);
@@ -3137,7 +3138,7 @@
 /// Processing the .while request
 static void request_while(char*& c, int j, bool mdoc)
 {
-  // ### TODO: .break and .continue
+  // ### TODO: .continue
   kDebug(7107) << "Entering .while";
   c += j;
   char* newline = skip_till_newline(c);
@@ -3153,7 +3154,7 @@
   const bool oldwhileloop = s_whileloop;
   s_whileloop = true;
   int result = true; // It must be an int due to the call to scan_expression
-  while (result)
+  while (result && !break_the_while_loop)
   {
     // Unlike for a normal macro, we have the condition at start, so we do not need \
to prepend extra bytes  char* liveloop = qstrdup(macro.data());
@@ -3384,6 +3385,8 @@
 #define REQ_do       149 // groff(7) "DO command"
 #define REQ_Dx       150 // mdoc(7) "DragonFly" macro
 #define REQ_Ta       151 // mdoc(7) "Ta" inside .It macro
+#define REQ_break    152 // groff(7) "Break out of a while loop"
+#define REQ_nop      153 // groff(7) .nop macro
 
 static int get_request(char *req, int len)
 {
@@ -3401,7 +3404,7 @@
     "Cd", "Cm", "Ic", "Ms", "Or", "Sy", "Dv", "Ev", "Fr", "Li", "No", "Ns",
     "Tn", "nN", "%A", "%D", "%N", "%O", "%P", "%Q", "%V", "%B", "%J", "%R",
     "%T", "An", "Aq", "Bq", "Qq", "UR", "UE", "UN", "tr", "troff", "nroff", "als",
-    "rr", "rnn", "aln", "shift", "while", "do", "Dx", "Ta", 0
+    "rr", "rnn", "aln", "shift", "while", "do", "Dx", "Ta", "break", "nop", 0
   };
   int r = 0;
   while (requests[r] && qstrncmp(req, requests[r], len)) r++;
@@ -5629,9 +5632,16 @@
         }
         case REQ_while: // groff(7) "WHILE loop"
         {
+          break_the_while_loop = false;
           request_while(c, j, mandoc_command);
           break;
         }
+        case REQ_break: // groff(7) Break out of a while loop.
+        {
+          c += j;
+          break_the_while_loop = true;
+          break;
+        }
         case REQ_do: // groff(7) "DO command"
         {
           // ### HACK: we just replace do by a \n and a .
@@ -5641,6 +5651,11 @@
           // The . will be treated as next character
           break;
         }
+        case REQ_nop:  // groff(7) nop
+        {
+          c += j;
+          break;
+        }
         default:
         {
           if (mandoc_command &&


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic