Commit cd150450 authored by Manish Singh's avatar Manish Singh

applied gimp-entity-980929-1, adds write error handling

* 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

-Yosh
parent 10877b4e
Sat Oct 10 00:48:30 PDT 1998 Manish Singh <yosh@gimp.org>
* 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 <adam@gimp.org>
* plug-ins/gif/gif.c: Added support for persistant GIF
......
......@@ -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.
......
......@@ -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;
}
......
......@@ -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);
}
......
......@@ -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))
......
......@@ -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)
{
......
......@@ -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);
}
......
......@@ -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))
......
......@@ -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))
......
......@@ -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;
}
......
......@@ -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);
}
......
......@@ -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))
......
......@@ -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
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment