Re: [patch] support back-references when bulk renaming
Rogutes <[email protected]> Sun, 30 Nov 2008 17:38:35 +0200
| Newsgroups | gmane.comp.desktop.rox.devel |
|---|---|
| Message-ID | <[email protected]> |
Thomas Leonard (2008-11-30 10:44): > 2008/11/27 Rogutes <[email protected]>: > > Hello, > > > > I thought it would be nice to have back-references support in the bulk > > renaming dialog, so one could, for example, type > > > > Replace: "\(.*\) (\([0-9]\{4\}\))" > > With: "[\2]: \1" > > > If my patch seems awkward (I hardly know C and just tried to mimic the > > surrounding code), then this is a feature request. > > Looks pretty good (and useful). I think your array may be one element > too small (whole pattern plus nine back-refs = 10 offsets). > > You might find the code would be simpler if you used the g_string_* > functions rather than realloc (e.g. g_string_append): > > http://library.gnome.org/devel/glib/unstable/glib-Strings.html > > 1. Append everything before the match > 2. Append the characters in the with string, expanding references as you go > 3. Append everything after the match > > Do you want to update the patch? If not, I'll try to find some time to > do it myself. Only standard str* functions were used in bulk_rename.c and I thought I should do the same (it looks like I should've asked)... Ok, I will try to update the patch and make the code simpler. By the way, I find extended regular expressions more comfortable to use when replacing with back-references. Right now one has to use "\(.*\) (\([0-9]\{4\}\))", but it could be "(.*) \(([0-9]{4})\)", if REG_EXTENDED cflag were set in regcomp(). Would an options for this be acceptable? Perhaps by adding a checkbox at the bottom of the dialog? Thanks, RogutÄ—s ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ rox-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/rox-devel