Fix bug #12: Balanced square brackets test should recognize multi-line [Illustration] tags
6 * Read a file into memory (which should be freed with g_free when no
7 * longer required). Returns NULL on error and outputs a suitable error
9 * DOS-style line endings and UTF-8 BOM are handled transparently even
10 * on platforms which don't normally use these formats.
12 gboolean file_get_contents_text(const char *filename,char **contents,
13 size_t *length,GError **err)
19 if (!g_file_get_contents(filename,(char **)&raw,&raw_length,err))
21 string=g_string_new(NULL);
23 if (raw_length>=3 && raw[0]==0xEF && raw[1]==0xBB && raw[2]==0xBF)
24 i+=3; /* Skip BOM (U+FEFF) */
25 for(;i<raw_length;i++)
27 g_string_append_c(string,raw[i]);
32 *contents=g_string_free(string,FALSE);
34 g_string_free(string,TRUE);