From d1e3313362964b8000f742fbc6eff066a9b30369 Mon Sep 17 00:00:00 2001 From: Mukund Sivaraman Date: Thu, 26 Apr 2007 10:08:08 +0000 Subject: [PATCH] properly parse files with CRLF line-endings which were created in the past 2007-04-26 Mukund Sivaraman * plug-ins/gfig/gfig-dobject.c: properly parse files with CRLF line-endings which were created in the past in Windows. * plug-ins/gfig/gfig.c: open files in binary mode so that the same line-endings are used on all platforms. svn path=/trunk/; revision=22338 --- ChangeLog | 8 ++++++++ plug-ins/gfig/gfig-dobject.c | 5 ++++- plug-ins/gfig/gfig.c | 6 +++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index d46ce3eb77..5794a4b3e5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-04-26 Mukund Sivaraman + + * plug-ins/gfig/gfig-dobject.c: properly parse files with CRLF + line-endings which were created in the past in Windows. + + * plug-ins/gfig/gfig.c: open files in binary mode so that the same + line-endings are used on all platforms. + 2007-04-25 Michael Natterer * app/core/gimpbrush.c (gimp_brush_scale_size): removed bogus diff --git a/plug-ins/gfig/gfig-dobject.c b/plug-ins/gfig/gfig-dobject.c index e5aba25f27..e8a5bb60a0 100644 --- a/plug-ins/gfig/gfig-dobject.c +++ b/plug-ins/gfig/gfig-dobject.c @@ -944,6 +944,10 @@ get_line (gchar *buf, if (slen > 0) buf[slen - 1] = '\0'; + /* Check and remove an '\r' too from Windows */ + if ((slen > 1) && (buf[slen - 2] == '\r')) + buf[slen - 2] = '\0'; + if (ferror (from)) { g_warning (_("Error reading file")); @@ -1088,4 +1092,3 @@ d_pnt_add_line (GfigObject *obj, } } } - diff --git a/plug-ins/gfig/gfig.c b/plug-ins/gfig/gfig.c index 8a6ba02aea..b0b3c76b49 100644 --- a/plug-ins/gfig/gfig.c +++ b/plug-ins/gfig/gfig.c @@ -428,7 +428,7 @@ gfig_load (const gchar *filename, printf ("Loading %s (%s)\n", filename, name); #endif /* DEBUG */ - fp = g_fopen (filename, "r"); + fp = g_fopen (filename, "rb"); if (!fp) { g_message (_("Could not open '%s' for reading: %s"), @@ -752,7 +752,7 @@ gfig_load_from_parasite (void) fname = gimp_temp_name ("gfigtmp"); - fp = g_fopen (fname, "w"); + fp = g_fopen (fname, "wb"); if (!fp) { g_message (_("Error trying to open temporary file '%s' " @@ -787,7 +787,7 @@ gfig_save_callbk (void) savename = gfig_context->current_obj->filename; - fp = g_fopen (savename, "w+"); + fp = g_fopen (savename, "wb+"); if (!fp) {