gnome-commander r2263 - in trunk: . src



Author: epiotr
Date: Mon Nov  3 22:11:09 2008
New Revision: 2263
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=2263&view=rev

Log:
advrename lexer: report presence of $c/$c(n) in template

Modified:
   trunk/ChangeLog
   trunk/src/gnome-cmd-advrename-dialog.cc
   trunk/src/gnome-cmd-advrename-lexer.h
   trunk/src/gnome-cmd-advrename-lexer.ll

Modified: trunk/src/gnome-cmd-advrename-dialog.cc
==============================================================================
--- trunk/src/gnome-cmd-advrename-dialog.cc	(original)
+++ trunk/src/gnome-cmd-advrename-dialog.cc	Mon Nov  3 22:11:09 2008
@@ -58,6 +58,8 @@
     GnomeCmdData::AdvrenameDefaults *defaults;
     GnomeCmdConvertFunc trim_blanks;
 
+    gboolean template_has_counters;
+
     GtkWidget *pat_list;
     GtkWidget *res_list;
     GtkWidget *move_up_btn;
@@ -738,7 +740,7 @@
     const gchar *templ_string = gtk_entry_get_text (GTK_ENTRY (dialog->priv->templ_entry));
 
     gnome_cmd_advrename_reset_counter (dialog->priv->defaults->counter_start, dialog->priv->defaults->counter_precision, dialog->priv->defaults->counter_increment);
-    gnome_cmd_advrename_parse_template (templ_string);
+    gnome_cmd_advrename_parse_template (templ_string, dialog->priv->template_has_counters);
 
     for (GList *tmp = dialog->priv->entries; tmp; tmp = tmp->next)
     {

Modified: trunk/src/gnome-cmd-advrename-lexer.h
==============================================================================
--- trunk/src/gnome-cmd-advrename-lexer.h	(original)
+++ trunk/src/gnome-cmd-advrename-lexer.h	Mon Nov  3 22:11:09 2008
@@ -24,7 +24,7 @@
 #include "gnome-cmd-file.h"
 
 void gnome_cmd_advrename_reset_counter(unsigned start=1, unsigned precision=-1, unsigned step=1);
-void gnome_cmd_advrename_parse_template(const char *template_string);
+void gnome_cmd_advrename_parse_template(const char *template_string, gboolean &has_counters);
 char *gnome_cmd_advrename_gen_fname(char *new_fname, size_t new_fname_size, GnomeCmdFile *finfo);
 
 

Modified: trunk/src/gnome-cmd-advrename-lexer.ll
==============================================================================
--- trunk/src/gnome-cmd-advrename-lexer.ll	(original)
+++ trunk/src/gnome-cmd-advrename-lexer.ll	Mon Nov  3 22:11:09 2008
@@ -57,7 +57,7 @@
 
 enum {TEXT=1,NAME,EXTENSION,FULL_NAME,COUNTER,XRANDOM,XXRANDOM,PARENT_DIR,GRANDPARENT_DIR,METATAG};
 
-typedef struct
+struct CHUNK
 {
   int type;
   union
@@ -83,12 +83,12 @@
       guint x_prec;     // default: MAX_XRANDOM_PRECISION  (8)
     } random;
   };
-} CHUNK;
+};
 
 
 static vector<CHUNK *> fname_template;
 
-
+static gboolean      fname_template_has_counters = FALSE;
 static unsigned long default_counter_start = 1;
 static unsigned      default_counter_step = 1;
 static unsigned      default_counter_prec = -1;
@@ -178,6 +178,8 @@
                                   p->counter.prec = min (precision, MAX_PRECISION);
 
                                   fname_template.push_back(p);
+
+                                  fname_template_has_counters = TRUE;
                                 }
 
 \$[xX]\({uint}\)                {
@@ -250,6 +252,8 @@
                                   p->counter.prec = default_counter_prec;
 
                                   fname_template.push_back(p);
+
+                                  fname_template_has_counters = TRUE;
                                 }
 
 \$[xX]                          {
@@ -300,7 +304,7 @@
 }
 
 
-void gnome_cmd_advrename_parse_template(const char *template_string)
+void gnome_cmd_advrename_parse_template(const char *template_string, gboolean &has_counters)
 {
   for (vector<CHUNK *>::iterator i=fname_template.begin(); i!=fname_template.end(); ++i)
     switch ((*i)->type)
@@ -318,10 +322,13 @@
     }
 
   fname_template.clear();
+  fname_template_has_counters = FALSE;
 
   yy_scan_string(template_string);
   yylex();
   yy_delete_buffer(YY_CURRENT_BUFFER);
+
+  has_counters = fname_template_has_counters;
 }
 
 



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