shithub: mc

Download patch

ref: 420ff90e97759947fe51f953f1d0a2bd7fff7067
parent: bc5b6f51086f4d6f83ab5a9dfd29bab5dbb7a57e
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Nov 24 21:20:51 EST 2011

Fix peekn and eatcomment

    Oops, we didn't exit the comment gobbling loop, and we didn't
    actually add the n to what we were peeking.

--- a/parse/tok.c
+++ b/parse/tok.c
@@ -29,7 +29,7 @@
     if (fidx + n >= fbufsz)
         return '\0';
     else
-        return fbuf[fidx];
+        return fbuf[fidx + n];
 }
 
 static int peek()
@@ -95,6 +95,8 @@
             case '*':
                 if (peekn(1) == '/')
                     depth--;
+                if (depth == 0)
+                    goto done;
                 break;
             case '\n':
                 line++;
@@ -104,6 +106,8 @@
                 break;
         }
     }
+done:
+    return;
 }
 
 void eatspace()