]> granicus.if.org Git - libass/commitdiff
Fix whitespace trimming
authorGrigori Goronzy <greg@blackbox>
Sat, 11 Jun 2011 01:38:11 +0000 (03:38 +0200)
committerGrigori Goronzy <greg@blackbox>
Sat, 11 Jun 2011 01:47:53 +0000 (03:47 +0200)
Only try to remove any further whitespace in front of a line if the
first character of the line (the break character) is whitespace.

Addresses Issue 35.

libass/ass_render.c

index 4b1e4a30fd8b6c31f6cff1eedd0ae663134a9b12..ef888acf2678c9a26db57fb4539a3b092a72b3a3 100644 (file)
@@ -1364,16 +1364,17 @@ static void trim_whitespace(ASS_Renderer *render_priv)
             }
             // A break itself can contain a whitespace, too
             cur = ti->glyphs + i;
-            if (cur->symbol == ' ')
+            if (cur->symbol == ' ') {
                 cur->skip++;
-            // Mark whitespace after
-            j = i + 1;
-            cur = ti->glyphs + j;
-            while (j < ti->length && IS_WHITESPACE(cur)) {
-                cur->skip++;
-                cur = ti->glyphs + ++j;
+                // Mark whitespace after
+                j = i + 1;
+                cur = ti->glyphs + j;
+                while (j < ti->length && IS_WHITESPACE(cur)) {
+                    cur->skip++;
+                    cur = ti->glyphs + ++j;
+                }
+                i = j - 1;
             }
-            i = j - 1;
         }
     }
 }