[gnome-commander] advrename: concatenate consecutive TEXT chunks into one TEXT chunk



commit 6e05e887f8a42bf3dd5f5968d2128a97cdcdba05
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Fri Oct 23 00:49:22 2009 +0200

    advrename: concatenate consecutive TEXT chunks into one TEXT chunk

 src/gnome-cmd-advrename-lexer.ll |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/src/gnome-cmd-advrename-lexer.ll b/src/gnome-cmd-advrename-lexer.ll
index c9f9bd8..3f4acbc 100644
--- a/src/gnome-cmd-advrename-lexer.ll
+++ b/src/gnome-cmd-advrename-lexer.ll
@@ -43,12 +43,17 @@
 using namespace std;
 
 
-#define   ECHO  {                                                                     \
-                  CHUNK *p = g_new0 (CHUNK, 1);                                       \
-                                                                                      \
-                  p->type = TEXT;                                                     \
-                  p->s = g_string_new(yytext);                                        \
-                  fname_template.push_back(p);                                        \
+#define   ECHO  {                                                                       \
+                  if (fname_template.empty() || fname_template.back()->type!=TEXT)      \
+                  {                                                                     \
+                      CHUNK *p = g_new0 (CHUNK, 1);                                     \
+                      p->type = TEXT;                                                   \
+                      p->s = g_string_sized_new (16);                                   \
+                      g_string_append_len (p->s, yytext, yyleng);                       \
+                      fname_template.push_back(p);                                      \
+                  }                                                                     \
+                  else                                                                  \
+                      g_string_append_len (fname_template.back()->s, yytext, yyleng);   \
                 }
 
 



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