Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Mon, 19 Feb 2018 04:17:27 UTC Commit: 089786be21422e25c5122d86e0b8b98ffb36798c https://github.com/geany/geany-plugins/commit/089786be21422e25c5122d86e0b8b9...
Log Message: ----------- pohelper: Fix locating line breaks
Properly handle escape sequences when looking for a line break. This fixes handling of "\n", e.g. escaped line breaks.
Modified Paths: -------------- pohelper/src/gph-plugin.c
Modified: pohelper/src/gph-plugin.c 17 lines changed, 16 insertions(+), 1 deletions(-) =================================================================== @@ -858,6 +858,21 @@ get_msgid_text_at (GeanyDocument *doc, return NULL; }
+static const gchar * +find_line_break (const gchar *str) +{ + for (; *str; str++) { + if (*str == '\') { + if (str[1] == 'n') + return str; + else if (str[1]) + str++; + } + } + + return NULL; +} + /* cuts @str in human-readable chunks for max @len. * cuts first at \n, then at spaces and punctuation */ static gchar ** @@ -870,7 +885,7 @@ split_msg (const gchar *str, GString *chunk = g_string_sized_new (len);
while (*str) { - const gchar *nl = strstr (str, "\n"); + const gchar *nl = find_line_break (str); const gchar *p = strpbrk (str, " \t\v\r\n?!,.;:-"); glong chunk_len = g_utf8_strlen (chunk->str, (gssize) chunk->len);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
plugins-commits@lists.geany.org