diff options
Diffstat (limited to 'gs/base/gxclfile.c')
-rw-r--r-- | gs/base/gxclfile.c | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/gs/base/gxclfile.c b/gs/base/gxclfile.c index e4ef4006c..6c699f728 100644 --- a/gs/base/gxclfile.c +++ b/gs/base/gxclfile.c @@ -1,6 +1,6 @@ /* Copyright (C) 2001-2006 Artifex Software, Inc. All Rights Reserved. - + This software is provided AS-IS with no warranty, either express or implied. @@ -29,20 +29,20 @@ static int clist_fopen(char fname[gp_file_name_sizeof], const char *fmode, - clist_file_ptr * pcf, gs_memory_t * mem, gs_memory_t *data_mem, - bool ok_to_compress) + clist_file_ptr * pcf, gs_memory_t * mem, gs_memory_t *data_mem, + bool ok_to_compress) { if (*fname == 0) { - if (fmode[0] == 'r') - return_error(gs_error_invalidfileaccess); - *pcf = (clist_file_ptr)gp_open_scratch_file_64(mem, + if (fmode[0] == 'r') + return_error(gs_error_invalidfileaccess); + *pcf = (clist_file_ptr)gp_open_scratch_file_64(mem, gp_scratch_file_name_prefix, fname, fmode); } else - *pcf = gp_fopen(fname, fmode); + *pcf = gp_fopen(fname, fmode); if (*pcf == NULL) { - emprintf1(mem, "Could not open the scratch file %s.\n", fname); - return_error(gs_error_invalidfileaccess); + emprintf1(mem, "Could not open the scratch file %s.\n", fname); + return_error(gs_error_invalidfileaccess); } return 0; } @@ -57,8 +57,8 @@ static int clist_fclose(clist_file_ptr cf, const char *fname, bool delete) { return (fclose((FILE *) cf) != 0 ? gs_note_error(gs_error_ioerror) : - delete ? clist_unlink(fname) : - 0); + delete ? clist_unlink(fname) : + 0); } /* ------ Writing ------ */ @@ -81,24 +81,24 @@ clist_fread_chars(void *data, uint len, clist_file_ptr cf) /* is extremely inefficient for small counts, */ /* so we just use straight-line code instead. */ switch (len) { - default: - return fread(str, 1, len, f); - case 8: - *str++ = (byte) getc(f); - case 7: - *str++ = (byte) getc(f); - case 6: - *str++ = (byte) getc(f); - case 5: - *str++ = (byte) getc(f); - case 4: - *str++ = (byte) getc(f); - case 3: - *str++ = (byte) getc(f); - case 2: - *str++ = (byte) getc(f); - case 1: - *str = (byte) getc(f); + default: + return fread(str, 1, len, f); + case 8: + *str++ = (byte) getc(f); + case 7: + *str++ = (byte) getc(f); + case 6: + *str++ = (byte) getc(f); + case 5: + *str++ = (byte) getc(f); + case 4: + *str++ = (byte) getc(f); + case 3: + *str++ = (byte) getc(f); + case 2: + *str++ = (byte) getc(f); + case 1: + *str = (byte) getc(f); } return len; } @@ -129,21 +129,21 @@ clist_rewind(clist_file_ptr cf, bool discard_data, const char *fname) FILE *f = (FILE *) cf; if (discard_data) { - /* - * The ANSI C stdio specification provides no operation for - * truncating a file at a given position, or even just for - * deleting its contents; we have to use a bizarre workaround to - * get the same effect. - */ - char fmode[4]; - - /* Opening with "w" mode deletes the contents when closing. */ - (void)freopen(fname, gp_fmode_wb, f); - strcpy(fmode, "w+"); - strcat(fmode, gp_fmode_binary_suffix); - (void)freopen(fname, fmode, f); + /* + * The ANSI C stdio specification provides no operation for + * truncating a file at a given position, or even just for + * deleting its contents; we have to use a bizarre workaround to + * get the same effect. + */ + char fmode[4]; + + /* Opening with "w" mode deletes the contents when closing. */ + (void)freopen(fname, gp_fmode_wb, f); + strcpy(fmode, "w+"); + strcat(fmode, gp_fmode_binary_suffix); + (void)freopen(fname, fmode, f); } else { - rewind(f); + rewind(f); } } |