diff --git a/ChangeLog b/ChangeLog index 4159275e56..582e4bf635 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Sat Oct 10 00:48:30 PDT 1998 Manish Singh + + * app/temp_buf.c: applied gimp-entity-980929-1, adds + write error handling + + * app/gimprc.c + * app/install.c + * app/tips_dialog.c: allow use of GIMP_DATADIR to override + compiled in default + + * HACKING + * autogen.sh: we need libtool 1.2b now + Fri Oct 9 18:52:52 BST 1998 Adam D. Moss * plug-ins/gif/gif.c: Added support for persistant GIF diff --git a/HACKING b/HACKING index d3deb8fc09..cc91e09eda 100644 --- a/HACKING +++ b/HACKING @@ -3,7 +3,7 @@ to have the following packages installed: - GNU autoconf 2.12 - GNU automake 1.3 - - GNU libtool 1.2 + - GNU libtool 1.2b These should be available by ftp from prep.ai.mit.edu or any of the fine GNU mirrors. Beta software can be found at alpha.gnu.org. diff --git a/app/base/temp-buf.c b/app/base/temp-buf.c index e3cbc3c5d6..d052e1aeed 100644 --- a/app/base/temp-buf.c +++ b/app/base/temp-buf.c @@ -474,11 +474,21 @@ temp_buf_swap (buf) /* Open file for overwrite */ if ((fp = fopen (filename, "wb"))) { - fwrite (swap->data, swap->width * swap->height * swap->bytes, 1, fp); - fclose (fp); + size_t blocks_written; + blocks_written = fwrite (swap->data, swap->width * swap->height * swap->bytes, 1, fp); + /* Check whether all bytes were written and fclose() was able to flush its buffers */ + if ((0 != fclose (fp)) || (1 != blocks_written)) + { + (void) unlink (filename); + perror ("Write error on temp buf"); + g_message ("Cannot write \"%s\"", filename); + g_free (filename); + return; + } } else { + (void) unlink (filename); perror ("Error in temp buf caching"); g_message ("Cannot write \"%s\"", filename); g_free (filename); @@ -522,11 +532,11 @@ temp_buf_unswap (buf) { if ((fp = fopen (buf->filename, "rb"))) { - size_t blocksRead; - blocksRead = fread (buf->data, buf->width * buf->height * buf->bytes, 1, fp); - fclose (fp); - if (blocksRead != 1) - perror ("Read error on temp buf"); + size_t blocks_read; + blocks_read = fread (buf->data, buf->width * buf->height * buf->bytes, 1, fp); + (void) fclose (fp); + if (blocks_read != 1) + perror ("Read error on temp buf"); else succ = TRUE; } diff --git a/app/dialogs/tips-dialog.c b/app/dialogs/tips-dialog.c index 4c940e520a..9b65acb6f7 100644 --- a/app/dialogs/tips-dialog.c +++ b/app/dialogs/tips-dialog.c @@ -35,13 +35,17 @@ tips_dialog_create () guchar * temp; guchar * src; guchar * dest; + gchar * gimp_data_dir; int x; int y; if (tips_count == 0) { temp = g_malloc (512); - sprintf ((char *)temp, "%s/%s", DATADIR, TIPS_FILE_NAME); + if ((gimp_data_dir = getenv ("GIMP_DATADIR")) != NULL) + sprintf ((char *)temp, "%s/%s", gimp_data_dir, TIPS_FILE_NAME); + else + sprintf ((char *)temp, "%s/%s", DATADIR, TIPS_FILE_NAME); read_tips_file ((char *)temp); g_free (temp); } diff --git a/app/dialogs/user-install-dialog.c b/app/dialogs/user-install-dialog.c index 7327c0b7e9..2453185622 100644 --- a/app/dialogs/user-install-dialog.c +++ b/app/dialogs/user-install-dialog.c @@ -372,6 +372,7 @@ install_run (InstallCallback callback) GdkFont *font; FILE *pfp; char buffer[2048]; + char *gimp_data_dir; struct stat stat_buf; int err; int executable = TRUE; @@ -415,7 +416,11 @@ install_run (InstallCallback callback) gtk_text_insert (GTK_TEXT (text), font_strong, NULL, NULL, "User Installation Log\n\n", -1); /* Generate output */ - sprintf (buffer, "%s/user_install", DATADIR); + if ((gimp_data_dir = getenv ("GIMP_DATADIR")) != NULL) + sprintf (buffer, "%s/user_install", gimp_data_dir); + else + sprintf (buffer, "%s/user_install", DATADIR); + if ((err = stat (buffer, &stat_buf)) != 0) { gtk_text_insert (GTK_TEXT (text), font, NULL, NULL, buffer, -1); @@ -433,8 +438,13 @@ install_run (InstallCallback callback) if (executable == TRUE) { - sprintf (buffer, "%s/user_install %s %s", DATADIR, DATADIR, - gimp_directory ()); + if (gimp_data_dir) + sprintf (buffer, "%s/user_install %s %s", gimp_data_dir, gimp_data_dir, + gimp_directory ()); + else + sprintf (buffer, "%s/user_install %s %s", DATADIR, DATADIR, + gimp_directory ()); + if ((pfp = popen (buffer, "r")) != NULL) { while (fgets (buffer, 2048, pfp)) diff --git a/app/gimprc.c b/app/gimprc.c index 0d657e8d89..00d55fc102 100644 --- a/app/gimprc.c +++ b/app/gimprc.c @@ -324,6 +324,7 @@ parse_gimprc () { char libfilename[512]; char filename[512]; + char *gimp_data_dir; char *gimp_dir; parse_info.buffer = g_new (char, 4096); @@ -334,7 +335,11 @@ parse_gimprc () gimp_dir = gimp_directory (); add_gimp_directory_token (gimp_dir); - sprintf (libfilename, "%s/gimprc", DATADIR); + if ((gimp_data_dir = getenv ("GIMP_DATADIR")) != NULL) + sprintf (libfilename, "%s/gimprc", gimp_data_dir); + else + sprintf (libfilename, "%s/gimprc", DATADIR); + app_init_update_status("Resource configuration", libfilename, -1); if (alternate_system_gimprc != NULL) { diff --git a/app/gui/tips-dialog.c b/app/gui/tips-dialog.c index 4c940e520a..9b65acb6f7 100644 --- a/app/gui/tips-dialog.c +++ b/app/gui/tips-dialog.c @@ -35,13 +35,17 @@ tips_dialog_create () guchar * temp; guchar * src; guchar * dest; + gchar * gimp_data_dir; int x; int y; if (tips_count == 0) { temp = g_malloc (512); - sprintf ((char *)temp, "%s/%s", DATADIR, TIPS_FILE_NAME); + if ((gimp_data_dir = getenv ("GIMP_DATADIR")) != NULL) + sprintf ((char *)temp, "%s/%s", gimp_data_dir, TIPS_FILE_NAME); + else + sprintf ((char *)temp, "%s/%s", DATADIR, TIPS_FILE_NAME); read_tips_file ((char *)temp); g_free (temp); } diff --git a/app/gui/user-install-dialog.c b/app/gui/user-install-dialog.c index 7327c0b7e9..2453185622 100644 --- a/app/gui/user-install-dialog.c +++ b/app/gui/user-install-dialog.c @@ -372,6 +372,7 @@ install_run (InstallCallback callback) GdkFont *font; FILE *pfp; char buffer[2048]; + char *gimp_data_dir; struct stat stat_buf; int err; int executable = TRUE; @@ -415,7 +416,11 @@ install_run (InstallCallback callback) gtk_text_insert (GTK_TEXT (text), font_strong, NULL, NULL, "User Installation Log\n\n", -1); /* Generate output */ - sprintf (buffer, "%s/user_install", DATADIR); + if ((gimp_data_dir = getenv ("GIMP_DATADIR")) != NULL) + sprintf (buffer, "%s/user_install", gimp_data_dir); + else + sprintf (buffer, "%s/user_install", DATADIR); + if ((err = stat (buffer, &stat_buf)) != 0) { gtk_text_insert (GTK_TEXT (text), font, NULL, NULL, buffer, -1); @@ -433,8 +438,13 @@ install_run (InstallCallback callback) if (executable == TRUE) { - sprintf (buffer, "%s/user_install %s %s", DATADIR, DATADIR, - gimp_directory ()); + if (gimp_data_dir) + sprintf (buffer, "%s/user_install %s %s", gimp_data_dir, gimp_data_dir, + gimp_directory ()); + else + sprintf (buffer, "%s/user_install %s %s", DATADIR, DATADIR, + gimp_directory ()); + if ((pfp = popen (buffer, "r")) != NULL) { while (fgets (buffer, 2048, pfp)) diff --git a/app/install.c b/app/install.c index 7327c0b7e9..2453185622 100644 --- a/app/install.c +++ b/app/install.c @@ -372,6 +372,7 @@ install_run (InstallCallback callback) GdkFont *font; FILE *pfp; char buffer[2048]; + char *gimp_data_dir; struct stat stat_buf; int err; int executable = TRUE; @@ -415,7 +416,11 @@ install_run (InstallCallback callback) gtk_text_insert (GTK_TEXT (text), font_strong, NULL, NULL, "User Installation Log\n\n", -1); /* Generate output */ - sprintf (buffer, "%s/user_install", DATADIR); + if ((gimp_data_dir = getenv ("GIMP_DATADIR")) != NULL) + sprintf (buffer, "%s/user_install", gimp_data_dir); + else + sprintf (buffer, "%s/user_install", DATADIR); + if ((err = stat (buffer, &stat_buf)) != 0) { gtk_text_insert (GTK_TEXT (text), font, NULL, NULL, buffer, -1); @@ -433,8 +438,13 @@ install_run (InstallCallback callback) if (executable == TRUE) { - sprintf (buffer, "%s/user_install %s %s", DATADIR, DATADIR, - gimp_directory ()); + if (gimp_data_dir) + sprintf (buffer, "%s/user_install %s %s", gimp_data_dir, gimp_data_dir, + gimp_directory ()); + else + sprintf (buffer, "%s/user_install %s %s", DATADIR, DATADIR, + gimp_directory ()); + if ((pfp = popen (buffer, "r")) != NULL) { while (fgets (buffer, 2048, pfp)) diff --git a/app/temp_buf.c b/app/temp_buf.c index e3cbc3c5d6..d052e1aeed 100644 --- a/app/temp_buf.c +++ b/app/temp_buf.c @@ -474,11 +474,21 @@ temp_buf_swap (buf) /* Open file for overwrite */ if ((fp = fopen (filename, "wb"))) { - fwrite (swap->data, swap->width * swap->height * swap->bytes, 1, fp); - fclose (fp); + size_t blocks_written; + blocks_written = fwrite (swap->data, swap->width * swap->height * swap->bytes, 1, fp); + /* Check whether all bytes were written and fclose() was able to flush its buffers */ + if ((0 != fclose (fp)) || (1 != blocks_written)) + { + (void) unlink (filename); + perror ("Write error on temp buf"); + g_message ("Cannot write \"%s\"", filename); + g_free (filename); + return; + } } else { + (void) unlink (filename); perror ("Error in temp buf caching"); g_message ("Cannot write \"%s\"", filename); g_free (filename); @@ -522,11 +532,11 @@ temp_buf_unswap (buf) { if ((fp = fopen (buf->filename, "rb"))) { - size_t blocksRead; - blocksRead = fread (buf->data, buf->width * buf->height * buf->bytes, 1, fp); - fclose (fp); - if (blocksRead != 1) - perror ("Read error on temp buf"); + size_t blocks_read; + blocks_read = fread (buf->data, buf->width * buf->height * buf->bytes, 1, fp); + (void) fclose (fp); + if (blocks_read != 1) + perror ("Read error on temp buf"); else succ = TRUE; } diff --git a/app/tips_dialog.c b/app/tips_dialog.c index 4c940e520a..9b65acb6f7 100644 --- a/app/tips_dialog.c +++ b/app/tips_dialog.c @@ -35,13 +35,17 @@ tips_dialog_create () guchar * temp; guchar * src; guchar * dest; + gchar * gimp_data_dir; int x; int y; if (tips_count == 0) { temp = g_malloc (512); - sprintf ((char *)temp, "%s/%s", DATADIR, TIPS_FILE_NAME); + if ((gimp_data_dir = getenv ("GIMP_DATADIR")) != NULL) + sprintf ((char *)temp, "%s/%s", gimp_data_dir, TIPS_FILE_NAME); + else + sprintf ((char *)temp, "%s/%s", DATADIR, TIPS_FILE_NAME); read_tips_file ((char *)temp); g_free (temp); } diff --git a/app/user_install.c b/app/user_install.c index 7327c0b7e9..2453185622 100644 --- a/app/user_install.c +++ b/app/user_install.c @@ -372,6 +372,7 @@ install_run (InstallCallback callback) GdkFont *font; FILE *pfp; char buffer[2048]; + char *gimp_data_dir; struct stat stat_buf; int err; int executable = TRUE; @@ -415,7 +416,11 @@ install_run (InstallCallback callback) gtk_text_insert (GTK_TEXT (text), font_strong, NULL, NULL, "User Installation Log\n\n", -1); /* Generate output */ - sprintf (buffer, "%s/user_install", DATADIR); + if ((gimp_data_dir = getenv ("GIMP_DATADIR")) != NULL) + sprintf (buffer, "%s/user_install", gimp_data_dir); + else + sprintf (buffer, "%s/user_install", DATADIR); + if ((err = stat (buffer, &stat_buf)) != 0) { gtk_text_insert (GTK_TEXT (text), font, NULL, NULL, buffer, -1); @@ -433,8 +438,13 @@ install_run (InstallCallback callback) if (executable == TRUE) { - sprintf (buffer, "%s/user_install %s %s", DATADIR, DATADIR, - gimp_directory ()); + if (gimp_data_dir) + sprintf (buffer, "%s/user_install %s %s", gimp_data_dir, gimp_data_dir, + gimp_directory ()); + else + sprintf (buffer, "%s/user_install %s %s", DATADIR, DATADIR, + gimp_directory ()); + if ((pfp = popen (buffer, "r")) != NULL) { while (fgets (buffer, 2048, pfp)) diff --git a/autogen.sh b/autogen.sh index b2cce8a7a4..08e9de429c 100755 --- a/autogen.sh +++ b/autogen.sh @@ -14,7 +14,7 @@ DIE=0 (libtool --version) < /dev/null > /dev/null 2>&1 || { echo echo "You must have libtool installed to compile GIMP." - echo "Get ftp://ftp.gnu.org/pub/gnu/libtool-1.2.tar.gz" + echo "Get ftp://alpha.gnu.org/pub/gnu/libtool-1.2b.tar.gz" echo "(or a newer version if it is available)" DIE=1 }