[gnome-commander/gcmd-1-3] advrename: replaced ECHO() macro with inlined echo() function counterpart



commit 3a11bc02d8bcbe473cf50a088da485d787165749
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Sat Oct 24 00:46:24 2009 +0200

    advrename: replaced ECHO() macro with inlined echo() function counterpart

 src/gnome-cmd-advrename-lexer.ll |   37 +++++++++++++++++--------------------
 1 files changed, 17 insertions(+), 20 deletions(-)
---
diff --git a/src/gnome-cmd-advrename-lexer.ll b/src/gnome-cmd-advrename-lexer.ll
index 3f4acbc..ac08f1b 100644
--- a/src/gnome-cmd-advrename-lexer.ll
+++ b/src/gnome-cmd-advrename-lexer.ll
@@ -43,18 +43,7 @@
 using namespace std;
 
 
-#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);   \
-                }
+#define   ECHO  echo(yytext, yyleng)
 
 
 enum {TEXT=1,NAME,EXTENSION,FULL_NAME,COUNTER,XRANDOM,XXRANDOM,PARENT_DIR,GRANDPARENT_DIR,METATAG};
@@ -105,6 +94,21 @@ static vector<CHUNK *> fname_template;
 
 static gboolean      fname_template_has_counters = FALSE;
 
+
+inline void echo(const gchar *s, gssize length)
+{
+  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, s, length);
+    fname_template.push_back(p);
+  }
+  else
+    g_string_append_len (fname_template.back()->s, s, length);
+}
+
 %}
 
 int        -?[0-9]+
@@ -285,14 +289,7 @@ tag_name    {ape}|{audio}|{doc}|{exif}|{file}|{flac}|{id3}|{image}|{iptc}|{pdf}|
                                   fname_template.push_back(p);
                                 }
 
-\$\$                            {
-                                  CHUNK *p = g_new0 (CHUNK,1);
-
-                                  p->type = TEXT;
-                                  p->s = g_string_new("$");
-
-                                  fname_template.push_back(p);
-                                }
+\$\$                            echo("$",1);
 
 %[Dnt]                          yytext[1] = '%';  ECHO;
 



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