From 1f8e3540a3596fd8dcac7aa9026bf8dad2e88613 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 23 Jul 2016 19:34:10 +0100 Subject: [PATCH] [Fix] Simplify state machine by ignoring multiple spaces --- src/ragel/newlines_strip.rl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ragel/newlines_strip.rl b/src/ragel/newlines_strip.rl index a2f5620bd..190a759ac 100644 --- a/src/ragel/newlines_strip.rl +++ b/src/ragel/newlines_strip.rl @@ -2,7 +2,8 @@ machine newlines_strip; action Double_CRLF { - if (!crlf_added) { + if (!crlf_added && p > c) { + (*newlines_count)++; g_byte_array_append (data, (const guint8 *)"\n", 1); c = p; } @@ -48,9 +49,8 @@ CRLF = ("\r" . "\n") | ( "\r" ) | ("\n"); DOUBLE_CRLF = (CRLF <: (WSP* CRLF)+) %Double_CRLF; ANY_CRLF = CRLF | DOUBLE_CRLF; - LINE_ELT = ((WSP+ %WSP)** :> ((^space)+) >Text_Start %Text_End <: (WSP+ %WSP)**); - LINE = LINE_ELT+; - TEXT = ANY_CRLF** . (LINE <: ANY_CRLF %Line_CRLF)+ | LINE | ANY_CRLF %Line_CRLF; + LINE = (([^\r\n]+) >Text_Start %Text_End); + TEXT = ANY_CRLF* . (LINE <: ANY_CRLF %Line_CRLF)+ | LINE | ANY_CRLF %Line_CRLF; main := TEXT; }%% -- 2.39.5