Browse files

Fix replacing file name in headers upon save as

The code used a Scintilla-specific regex escape (\<) which doesn't work
anymore since the time we switched to full PCRE (which uses \b).  So,
update the regular expression to PCRE.

Also, properly escape the name to search in the unlikely case it has
regular expression escapes in it;  and properly check for word
boundaries even when not searching with an extension.
  • Loading branch information...
b4n committed Mar 5, 2013
1 parent 77e142b commit 5b2366964938b54005eec39d392fc5cbea81682b
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/document.c
@@ -1362,10 +1362,11 @@ static void replace_header_filename(GeanyDocument *doc)
g_return_if_fail(doc != NULL);
g_return_if_fail(doc->file_type != NULL);
+ filebase = g_regex_escape_string(GEANY_STRING_UNTITLED, -1);
if (doc->file_type->extension)
- filebase = g_strconcat("\\<", GEANY_STRING_UNTITLED, "\\.\\w+", NULL);
+ SETPTR(filebase, g_strconcat("\\b", filebase, "\\.\\w+", NULL));
- filebase = g_strdup(GEANY_STRING_UNTITLED);
+ SETPTR(filebase, g_strconcat("\\b", filebase, "\\b", NULL));
filename = g_path_get_basename(doc->file_name);

0 comments on commit 5b23669

Please sign in to comment.