SF.net SVN: geany: [1168] trunk/src/document.c

eht16 at users.sourceforge.net eht16 at xxxxx
Sun Jan 7 18:48:56 UTC 2007


Revision: 1168
          http://svn.sourceforge.net/geany/?rev=1168&view=rev
Author:   eht16
Date:     2007-01-07 10:48:56 -0800 (Sun, 07 Jan 2007)

Log Message:
-----------
Added a little comment for writing Unicode BOMs.
Fixed a compiler warning.

Modified Paths:
--------------
    trunk/src/document.c

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2007-01-07 16:22:41 UTC (rev 1167)
+++ trunk/src/document.c	2007-01-07 18:48:56 UTC (rev 1168)
@@ -1,7 +1,8 @@
 /*
  *      document.c - this file is part of Geany, a fast and lightweight IDE
  *
- *      Copyright 2006 Enrico Troeger <enrico.troeger at uvena.de>
+ *      Copyright 2005-2007 Enrico Troeger <enrico.troeger at uvena.de>
+ *      Copyright 2006-2007 Nick Treleaven <nick.treleaven at btinternet.com>
  *
  *      This program is free software; you can redistribute it and/or modify
  *      it under the terms of the GNU General Public License as published by
@@ -548,7 +549,7 @@
 	filedata->len -= bom_len;
 	// overwrite the BOM with the remainder of the file contents, plus the NULL terminator.
 	g_memmove(filedata->data, filedata->data + bom_len, filedata->len + 1);
-	g_realloc(filedata->data, filedata->len + 1);
+	filedata->data = g_realloc(filedata->data, filedata->len + 1);
 }
 
 
@@ -878,7 +879,9 @@
 
 	len = sci_get_length(doc_list[idx].sci) + 1;
 	if (doc_list[idx].has_bom && encodings_is_unicode_charset(doc_list[idx].encoding))
-	{
+	{	// always write a UTF-8 BOM because in this moment the text itself is still in UTF-8
+		// encoding, it will be converted to doc_list[idx].encoding below and this conversion
+		// also changes the BOM
 		data = (gchar*) g_malloc(len + 3);	// 3 chars for BOM
 		data[0] = 0xef;
 		data[1] = 0xbb;


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