If you use write(fileno(fp), ...) you can't expect, that ferror(fp) is
meaningfull.
Regards,
Bert
---
source/file.c | 30 ++++++++++++++++++++++++------
1 file changed, 24 insertions(+), 6 deletions(-)
diff --quilt old/source/file.c new/source/file.c
--- old/source/file.c
+++ new/source/file.c
@@ -932,6 +932,7 @@ static int doSave(WindowInfo *window)
struct stat statbuf;
FILE *fp;
int fileLen, result;
+ int ret;
/* Get the full name of the file */
strcpy(fullname, window->path);
@@ -1019,12 +1020,17 @@ static int doSave(WindowInfo *window)
}
/* write to the file */
+ ret = 0;
#ifdef IBM_FWRITE_BUG
- write(fileno(fp), fileString, fileLen);
+ if (0 > write(fileno(fp), fileString, fileLen))
+ {
+ ret = 1;
+ }
#else
fwrite(fileString, sizeof(char), fileLen, fp);
+ ret = ferror(fp);
#endif
- if (ferror(fp))
+ if (0 != ret)
{
DialogF(DF_ERR, window->shell, 1, "Error saving File",
"%s not saved:\n%s", "OK", window->filename, errorString());
@@ -1083,6 +1089,7 @@ int WriteBackupFile(WindowInfo *window)
char name[MAXPATHLEN];
FILE *fp;
int fd, fileLen;
+ int ret;
/* Generate a name for the autoSave file */
backupFileName(window, name, sizeof(name));
@@ -1127,12 +1134,17 @@ int WriteBackupFile(WindowInfo *window)
fileString[fileLen++] = '\n'; /* null terminator no longer needed */
/* write out the file */
+ ret = 0;
#ifdef IBM_FWRITE_BUG
- write(fileno(fp), fileString, fileLen);
+ if (0 > write(fileno(fp), fileString, fileLen))
+ {
+ ret = 1;
+ }
#else
fwrite(fileString, sizeof(char), fileLen, fp);
+ ret = ferror(fp);
#endif
- if (ferror(fp))
+ if (0 != ret)
{
DialogF(DF_ERR, window->shell, 1, "Error saving Backup",
"Error while saving backup for %s:\n%s\n"
@@ -1375,6 +1387,7 @@ void PrintString(const char *string, int
char tmpFileName[L_tmpnam]; /* L_tmpnam defined in stdio.h */
FILE *fp;
int fd;
+ int ret;
/* Generate a temporary file name */
/* If the glibc is used, the linker issues a warning at this point. This
is
@@ -1403,12 +1416,17 @@ void PrintString(const char *string, int
#endif
/* write to the file */
+ ret = 0;
#ifdef IBM_FWRITE_BUG
- write(fileno(fp), string, length);
+ if (0 > write(fileno(fp), string, length))
+ {
+ ret = 1;
+ }
#else
fwrite(string, sizeof(char), length, fp);
+ ret = ferror(fp);
#endif
- if (ferror(fp))
+ if (0 != ret)
{
DialogF(DF_ERR, parent, 1, "Error while Printing",
"%s not printed:\n%s", "OK", jobName, errorString());
--
NEdit Develop mailing list - [email protected]
http://www.nedit.org/mailman/listinfo/develop