SF.net SVN: geany: [610] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Sun Jul 23 13:14:33 UTC 2006
Revision: 610
Author: eht16
Date: 2006-07-23 06:14:23 -0700 (Sun, 23 Jul 2006)
ViewCVS: http://svn.sourceforge.net/geany/?rev=610&view=rev
Log Message:
-----------
Fixed some mistakes from last commit.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/document.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-07-23 08:34:51 UTC (rev 609)
+++ trunk/ChangeLog 2006-07-23 13:14:23 UTC (rev 610)
@@ -1,6 +1,7 @@
2006-07-23 Enrico Tröger <enrico.troeger at uvena.de>
* src/build.c: Search terminal program in PATH (closes #1527203).
+ * src/documents.c: Fixed some mistakes from last commit.
2006-07-22 Nick Treleaven <nick.treleaven at btinternet.com>
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2006-07-23 08:34:51 UTC (rev 609)
+++ trunk/src/document.c 2006-07-23 13:14:23 UTC (rev 610)
@@ -482,6 +482,7 @@
else
{
bom = utils_strcmp(utils_scan_unicode_bom(data), "UTF-8");
+ enc = g_strdup(forced_enc);
}
}
else
@@ -501,8 +502,8 @@
g_free(data);
data = (void*)converted_text;
size = strlen(converted_text);
- /// TODO should it not be UTF-* ?
bom = utils_strcmp(utils_scan_unicode_bom(data), "UTF-8");
+ enc = g_strdup(forced_enc);
}
}
}
@@ -532,7 +533,8 @@
}
}
}
- else
+ // this if is important, else doesn't work because enc can be altered in the above block
+ if (enc == NULL)
{
if (g_utf8_validate(data, size, NULL))
{
@@ -590,7 +592,7 @@
doc_list[idx].mtime = st.st_mtime;
doc_list[idx].changed = FALSE;
doc_list[idx].file_name = g_strdup(utf8_filename);
- doc_list[idx].encoding = g_strdup(enc);
+ doc_list[idx].encoding = enc;
doc_list[idx].unicode_bom = bom;
sci_goto_pos(doc_list[idx].sci, pos, TRUE);
@@ -699,7 +701,7 @@
len = sci_get_length(doc_list[idx].sci) + 1;
if (doc_list[idx].unicode_bom && utils_is_unicode_charset(doc_list[idx].encoding))
{
- data = (gchar*) g_malloc(len + 4); // 3 chars for BOM, 1 for \0
+ data = (gchar*) g_malloc(len + 3); // 3 chars for BOM
data[0] = 0xef;
data[1] = 0xbb;
data[2] = 0xbf;
@@ -708,7 +710,7 @@
}
else
{
- data = (gchar*) g_malloc(len + 1);
+ data = (gchar*) g_malloc(len);
sci_get_text(doc_list[idx].sci, len, data);
}
@@ -720,7 +722,7 @@
gsize conv_len;
// try to convert it from UTF-8 to original encoding
- conv_file_contents = g_convert(data, len, doc_list[idx].encoding, "UTF-8",
+ conv_file_contents = g_convert(data, len-1, doc_list[idx].encoding, "UTF-8",
NULL, &conv_len, &conv_error);
if (conv_error != NULL)
@@ -741,12 +743,12 @@
len = conv_len;
}
}
-
- // len is too long and so 0x00 is written at the end which is not good w/o BOM
- len--;
-
+ else
+ {
+ len = strlen(data);
+ }
locale_filename = g_locale_from_utf8(doc_list[idx].file_name, -1, NULL, NULL, NULL);
- fp = fopen(locale_filename, "w");
+ fp = fopen(locale_filename, "wb"); // this should fix the windows \n problem
if (fp == NULL)
{
msgwin_status_add(_("Error saving file (%s)."), strerror(errno));
@@ -754,12 +756,6 @@
g_free(data);
return;
}
-
-#ifdef GEANY_WIN32
- // ugly hack: on windows '\n' (LF) is taken as CRLF so we must convert it prior to save the doc
- if (sci_get_eol_mode(doc_list[idx].sci) == SC_EOL_CRLF) sci_convert_eols(doc_list[idx].sci, SC_EOL_CRLF);
-#endif
-
bytes_written = fwrite(data, sizeof (gchar), len, fp);
fclose (fp);
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