SF.net SVN: geany:[5389] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Tue Nov 9 18:17:57 UTC 2010
Revision: 5389
http://geany.svn.sourceforge.net/geany/?rev=5389&view=rev
Author: ntrel
Date: 2010-11-09 18:17:57 +0000 (Tue, 09 Nov 2010)
Log Message:
-----------
Make utils_ensure_same_eol_characters() convert all wrong line
endings to the desired one, not just the most common one.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/utils.c
trunk/src/utils.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-11-09 18:14:33 UTC (rev 5388)
+++ trunk/ChangeLog 2010-11-09 18:17:57 UTC (rev 5389)
@@ -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>
Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c 2010-11-09 18:14:33 UTC (rev 5388)
+++ trunk/src/utils.c 2010-11-09 18:17:57 UTC (rev 5389)
@@ -373,18 +373,20 @@
}
-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);
}
Modified: trunk/src/utils.h
===================================================================
--- trunk/src/utils.h 2010-11-09 18:14:33 UTC (rev 5388)
+++ trunk/src/utils.h 2010-11-09 18:17:57 UTC (rev 5389)
@@ -144,7 +144,7 @@
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);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list