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
This commit is contained in:
parent
f3c199807d
commit
cf6d15239e
@ -8,6 +8,9 @@
|
||||
Convert line endings for file templates.
|
||||
Fix line endings when using file header template in a file template
|
||||
(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>
|
||||
|
20
src/utils.c
20
src/utils.c
@ -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)
|
||||
{
|
||||
const gchar *target_eol_char = utils_get_eol_char(target_eol_mode);
|
||||
const gchar *template_eol_char = utils_get_eol_char(template_eol_mode);
|
||||
utils_string_replace_all(template, template_eol_char, target_eol_char);
|
||||
}
|
||||
if (target_eol_mode == SC_EOL_LF)
|
||||
return;
|
||||
|
||||
/* now convert to desired line endings */
|
||||
utils_string_replace_all(string, "\n", eol_str);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
||||
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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user