SF.net SVN: geany: [2307] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Wed Mar 5 17:34:13 UTC 2008


Revision: 2307
          http://geany.svn.sourceforge.net/geany/?rev=2307&view=rev
Author:   eht16
Date:     2008-03-05 09:34:00 -0800 (Wed, 05 Mar 2008)

Log Message:
-----------
Don't open zero byte sized files read-only (e.g. files in /proc).

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

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-03-05 17:09:57 UTC (rev 2306)
+++ trunk/ChangeLog	2008-03-05 17:34:00 UTC (rev 2307)
@@ -4,6 +4,8 @@
    Apply patch from Yura Siamashka to use she-bang filetype detection
    also in filetypes_detect_from_filename() which let plugins benefit
    from this feature.
+ * src/document.c:
+   Don't open zero byte sized files read-only (e.g. files in /proc).
 
 
 2008-03-03  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2008-03-05 17:09:57 UTC (rev 2306)
+++ trunk/src/document.c	2008-03-05 17:34:00 UTC (rev 2307)
@@ -842,7 +842,9 @@
 	tmp_enc_idx = encodings_scan_unicode_bom(filedata->data, filedata->size, NULL);
 
 	/* check whether the size of the loaded data is equal to the size of the file in the filesystem */
-	if (filedata->len != filedata->size && (
+	/* file size may be 0 to allow opening files in /proc/ which have typically a file size
+	 * of 0 bytes */
+	if (filedata->len != filedata->size && filedata->size != 0 && (
 		tmp_enc_idx == GEANY_ENCODING_UTF_8 || /* tmp_enc_idx can be UTF-7/8/16/32, UCS and None */
 		tmp_enc_idx == GEANY_ENCODING_UTF_7 || /* filter out UTF-7/8 and None where no NULL bytes */
 		tmp_enc_idx == GEANY_ENCODING_NONE))   /* are allowed */


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