Kaydet (Commit) cf6d1523 authored tarafından Nick Treleaven's avatar Nick Treleaven

Make utils_ensure_same_eol_characters() convert all wrong line

endings to the desired one, not just the most common one.



git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5389 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst f3c19980
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
Convert line endings for file templates. Convert line endings for file templates.
Fix line endings when using file header template in a file template Fix line endings when using file header template in a file template
(oops). (oops).
* src/utils.c, src/utils.h:
Make utils_ensure_same_eol_characters() convert all wrong line
endings to the desired one, not just the most common one.
2010-11-08 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> 2010-11-08 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
......
...@@ -373,18 +373,20 @@ const gchar *utils_get_eol_char(gint eol_mode) ...@@ -373,18 +373,20 @@ const gchar *utils_get_eol_char(gint eol_mode)
} }
void utils_ensure_same_eol_characters(GString *template, gint target_eol_mode) /* Converts line endings to @a target_eol_mode. */
void utils_ensure_same_eol_characters(GString *string, gint target_eol_mode)
{ {
gint template_eol_mode; const gchar *eol_str = utils_get_eol_char(target_eol_mode);
template_eol_mode = utils_get_line_endings(template->str, template->len); /* first convert data to LF only */
utils_string_replace_all(string, "\r\n", "\n");
utils_string_replace_all(string, "\r", "\n");
if (target_eol_mode != template_eol_mode) if (target_eol_mode == SC_EOL_LF)
{ return;
const gchar *target_eol_char = utils_get_eol_char(target_eol_mode);
const gchar *template_eol_char = utils_get_eol_char(template_eol_mode); /* now convert to desired line endings */
utils_string_replace_all(template, template_eol_char, target_eol_char); utils_string_replace_all(string, "\n", eol_str);
}
} }
......
...@@ -144,7 +144,7 @@ gchar *utils_find_open_xml_tag(const gchar sel[], gint size); ...@@ -144,7 +144,7 @@ gchar *utils_find_open_xml_tag(const gchar sel[], gint size);
gboolean utils_is_short_html_tag(const gchar *tag_name); gboolean utils_is_short_html_tag(const gchar *tag_name);
void utils_ensure_same_eol_characters(GString *template, gint target_eol_mode); void utils_ensure_same_eol_characters(GString *string, gint target_eol_mode);
const gchar *utils_get_eol_char(gint eol_mode); const gchar *utils_get_eol_char(gint eol_mode);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment