[gnome-commander/gcmd-1-3] Fixed problem #541891 (file names with % in advanced file rename tool)
- From: Piotr Eljasiak <epiotr src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-commander/gcmd-1-3] Fixed problem #541891 (file names with % in advanced file rename tool)
- Date: Mon, 26 Oct 2009 19:04:10 +0000 (UTC)
commit b1f08af3ae9ade5f898ec7ae0e7df513b703b0bb
Author: Piotr Eljasiak <epiotr src gnome org>
Date: Mon Oct 26 19:54:34 2009 +0100
Fixed problem #541891 (file names with % in advanced file rename tool)
src/gnome-cmd-advrename-lexer.ll | 30 ++++++++++++++++++++++++++++--
1 files changed, 28 insertions(+), 2 deletions(-)
---
diff --git a/src/gnome-cmd-advrename-lexer.ll b/src/gnome-cmd-advrename-lexer.ll
index 676e071..aa72b6f 100644
--- a/src/gnome-cmd-advrename-lexer.ll
+++ b/src/gnome-cmd-advrename-lexer.ll
@@ -95,6 +95,10 @@ static vector<CHUNK *> fname_template;
static gboolean fname_template_has_counters = FALSE;
static gboolean fname_template_has_percent = FALSE;
+#define SUB_S "\x1A"
+const char SUB = '\x1A';
+const char ESC = '\x1B';
+
inline void echo(const gchar *s, gssize length)
{
@@ -293,12 +297,13 @@ tag_name {ape}|{audio}|{doc}|{exif}|{file}|{flac}|{id3}|{image}|{iptc}|{pdf}|
\$\$ echo("$",1);
%[Dnt] { // substitute %[Dnt] with %%[Dnt]
- echo("%",1);
- ECHO;
+ echo(SUB_S SUB_S,2);
+ echo(yytext+1,1);
fname_template_has_percent = TRUE;
}
%. {
+ *yytext = SUB;
ECHO;
fname_template_has_percent = TRUE;
}
@@ -419,6 +424,21 @@ inline void find_dirs (const gchar *path, const gchar *&parent_dir, const gchar
}
+inline gboolean convert (char *s, char from, char to)
+{
+ gboolean retval = FALSE;
+
+ for (; *s; ++s)
+ if (*s==from)
+ {
+ *s = to;
+ retval = TRUE;
+ }
+
+ return retval;
+}
+
+
char *gnome_cmd_advrename_gen_fname (GnomeCmdFile *f, size_t new_fname_size)
{
if (fname_template.empty())
@@ -517,8 +537,14 @@ char *gnome_cmd_advrename_gen_fname (GnomeCmdFile *f, size_t new_fname_size)
char *new_fname = g_new (char, new_fname_size+1);
+ gboolean new_fname_has_percent = convert ((char *) fmt.c_str(), '%', ESC);
+ convert ((char *) fmt.c_str(), SUB, '%');
+
if (!strftime(new_fname, new_fname_size+1, fmt.c_str(), localtime(&f->info->mtime))) // if new_fname is not big enough...
new_fname[new_fname_size] = '\0'; // ... truncate
+ if (new_fname_has_percent)
+ convert (new_fname, ESC, '%');
+
return new_fname;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]