Thread View: gnu.utils.bug
1 messages
1 total messages
Started by trq
Thu, 08 Oct 1992 09:40
file writing bug in sed 1.09
Author: trq
Date: Thu, 08 Oct 1992 09:40
Date: Thu, 08 Oct 1992 09:40
60 lines
1926 bytes
1926 bytes
The following sed command
sed -n -e "s|.*typedef *\(.*\) X*clock_t *;.*|\1|w TMP" < dummy.out
with the following dummy.out:
typedef long clock_t;
typedef long time_t;
should create a "TMP" file that contains "long". Instead, sed 1.09
creates an empty "TMP" file.
This is for sed version 1.09 compiled with GCC version 2.2.2 on a Sun
Sparcstation ELC running SunOS 4.1.1.
The problem is that sed never closes the files it opens, so buffered
writes don't get written. Following is a sample patch to sed.c.
Tom Quinn Theoretical Physics, University of Oxford
Internet: trq@dionysos.thphys.ox.ac.uk
JANET: trq@uk.ac.ox.astro
Phone: 44-865-273956
===================================================================
RCS file: RCS/sed.c,v
retrieving revision 1.1
diff -c -r1.1 sed.c
*** 1.1 1992/10/07 07:51:06
--- sed.c 1992/10/07 09:22:07
***************
*** 181,186 ****
--- 181,187 ----
# define P_(s) ()
#endif
+ void close_files();
void panic P_((char *str, ...));
char *__fp_name P_((FILE *fp));
FILE *ck_fopen P_((char *name, char *mode));
***************
*** 401,409 ****
--- 402,422 ----
if(quit_cmd)
break;
}
+ close_files();
if(bad_input)
exit(2);
exit(0);
+ }
+
+ void close_files()
+ {
+ int nf;
+
+ for(nf = 0; nf < NUM_FPS; nf++)
+ {
+ if(file_ptrs[nf].phile)
+ fclose(file_ptrs[nf].phile);
+ }
}
/* 'str' is a string (from the command line) that contains a sed command.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads