[geany/geany] 5b2366: Fix replacing file name in headers upon save as

Colomban Wendling git-noreply at xxxxx
Tue Mar 5 22:47:37 UTC 2013

Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Tue, 05 Mar 2013 22:47:37 UTC
Commit:      5b2366964938b54005eec39d392fc5cbea81682b

Log Message:
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.

Modified Paths:

Modified: src/document.c
5 files changed, 3 insertions(+), 2 deletions(-)
@@ -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);

This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).

More information about the Commits mailing list