SF.net SVN: geany:[5362] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Tue Nov 2 18:03:06 UTC 2010
Revision: 5362
http://geany.svn.sourceforge.net/geany/?rev=5362&view=rev
Author: ntrel
Date: 2010-11-02 18:03:06 +0000 (Tue, 02 Nov 2010)
Log Message:
-----------
Fix wrongly adding newlines for templates on disk that don't have
LF line endings when default line endings are not LF, e.g. Windows.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/templates.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-11-02 17:42:54 UTC (rev 5361)
+++ trunk/ChangeLog 2010-11-02 18:03:06 UTC (rev 5362)
@@ -18,6 +18,9 @@
Use g_file_replace_contents() if available to save documents - this
should help workaround bugs in GVFS.
Needs testing.
+ * src/templates.c:
+ Fix wrongly adding newlines for templates on disk that don't have
+ LF line endings when default line endings are not LF, e.g. Windows.
2010-11-01 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/src/templates.c
===================================================================
--- trunk/src/templates.c 2010-11-02 17:42:54 UTC (rev 5361)
+++ trunk/src/templates.c 2010-11-02 18:03:06 UTC (rev 5362)
@@ -85,13 +85,14 @@
TEMPLATES_READ_FILE(fname, &templates[id]);
/* FIXME: we should replace the line ends on insertion with doc pref, not on loading */
- if (file_prefs.default_eol_character != SC_EOL_LF)
{
- /* Replace the \n characters in the default template text by the proper
- * platform-specific line ending characters. */
GString *tmp = g_string_new(templates[id]);
const gchar *eol_str = (file_prefs.default_eol_character == SC_EOL_CR) ? "\r" : "\r\n";
+ /* first convert data to LF only */
+ utils_string_replace_all(tmp, "\r\n", "\n");
+ utils_string_replace_all(tmp, "\r", "\n");
+ /* now convert to desired line endings */
utils_string_replace_all(tmp, "\n", eol_str);
setptr(templates[id], tmp->str);
g_string_free(tmp, FALSE);
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