From: Rogutės <ro...@go...> - 2008-12-05 02:41:22
|
Thomas Leonard (2008-11-30 10:44): > 2008/11/27 Rogutes <ro...@go...>: > > 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. I have attached an updated patch. Looks much better now, thanks for the advice! I haven't added the REG_EXTENDED cflag to regcomp() in this patch, but I agree that it could be the default. -- Rogutės |