From: Dan F. <dfa...@us...> - 2008-11-26 09:11:16
|
Update of /cvsroot/libexif/exif/exif In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21560/exif Modified Files: actions.c Log Message: Removed the glibc extension code for printing errors since it just made the source code longer. Fixed a problem where an NULL file handle could be used. Index: actions.c =================================================================== RCS file: /cvsroot/libexif/exif/exif/actions.c,v retrieving revision 1.38 retrieving revision 1.39 diff -u -p -d -r1.38 -r1.39 --- actions.c 26 Nov 2008 08:34:06 -0000 1.38 +++ actions.c 26 Nov 2008 09:11:03 -0000 1.39 @@ -27,6 +27,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <errno.h> #include <libexif/exif-ifd.h> @@ -279,28 +280,20 @@ action_insert_thumb (ExifData *ed, ExifL /* Insert new thumbnail */ f = fopen (p.set_thumb, "rb"); - if (!f) -#ifdef __GNUC__ - exif_log (log, -1, "exif", _("Could not open " - "'%s' (%m)!"), p.set_thumb); -#else + if (!f) { exif_log (log, -1, "exif", _("Could not open " "'%s' (%s)!"), p.set_thumb, strerror (errno)); -#endif - fseek (f, 0, SEEK_END); - ed->size = ftell (f); - ed->data = malloc (sizeof (char) * ed->size); - if (ed->size && !ed->data) EXIF_LOG_NO_MEMORY (log, "exif", ed->size); - fseek (f, 0, SEEK_SET); - if (fread (ed->data, sizeof (char), ed->size, f) != ed->size) -#ifdef __GNUC__ - exif_log (log, -1, "exif", _("Could not read " - "'%s' (%m)."), p.set_thumb); -#else - exif_log (log, -1, "exif", _("Could not read " - "'%s' (%s)."), p.set_thumb, strerror (errno)); -#endif - fclose (f); + } else { + fseek (f, 0, SEEK_END); + ed->size = ftell (f); + ed->data = malloc (sizeof (char) * ed->size); + if (ed->size && !ed->data) EXIF_LOG_NO_MEMORY (log, "exif", ed->size); + fseek (f, 0, SEEK_SET); + if (fread (ed->data, sizeof (char), ed->size, f) != ed->size) + exif_log (log, -1, "exif", _("Could not read " + "'%s' (%s)."), p.set_thumb, strerror (errno)); + fclose (f); + } } void @@ -348,17 +341,14 @@ action_save_thumb (ExifData *ed, ExifLog /* Save the thumbnail */ f = fopen (fout, "wb"); if (!f) -#ifdef __GNUC__ - exif_log (log, -1, "exif", _("Could not open '%s' for " - "writing (%m)!"), fout); -#else - exif_log (log, -1, "exif", _("Could not open '%s' for " - "writing (%s)!"), fout, strerror (errno)); -#endif - fwrite (ed->data, 1, ed->size, f); - fclose (f); - fprintf (stdout, _("Wrote file '%s'."), fout); - fprintf (stdout, "\n"); + exif_log (log, -1, "exif", _("Could not open '%s' for " + "writing (%s)!"), fout, strerror (errno)); + else { + fwrite (ed->data, 1, ed->size, f); + fclose (f); + fprintf (stdout, _("Wrote file '%s'."), fout); + fprintf (stdout, "\n"); + } } void |