diff -ur sed-3.02.original/doc/sed.1 sed-3.02/doc/sed.1 --- sed-3.02.original/doc/sed.1 Sun May 31 23:16:15 1998 +++ sed-3.02/doc/sed.1 Thu May 2 16:19:19 2002 @@ -25,7 +25,7 @@ .SH SYNOPSIS .nf sed [-n] [-V] [--quiet] [--silent] [--version] [--help] - [-e script] [--expression=script] + [-u] [--unbuffered] [-e script] [--expression=script] [-f script-file] [--file=script-file] [script-if-no-other-script] [file...] @@ -72,6 +72,11 @@ .B p command. .TP +.B -u +.TP +.B --unbuffered +Forces \*(sd to turn off both input and output buffering. +.TP .B -e \fIscript\fP .TP .BI --expression= script diff -ur sed-3.02.original/doc/sed.texi sed-3.02/doc/sed.texi --- sed-3.02.original/doc/sed.texi Mon Jun 29 01:01:51 1998 +++ sed-3.02/doc/sed.texi Thu May 2 16:21:11 2002 @@ -165,6 +165,12 @@ and @sc{sed} will only produce output when explicitly told to via the @code{p} command. address@hidden -u address@hidden --unbuffered address@hidden -u address@hidden --unbuffered +Forces @sc{sed} to turn off both input and output buffering. + @item -e @var{script} @itemx address@hidden @opindex -e diff -ur sed-3.02.original/sed/execute.c sed-3.02/sed/execute.c --- sed-3.02.original/sed/execute.c Mon Jul 6 06:01:01 1998 +++ sed-3.02/sed/execute.c Thu May 2 16:13:16 2002 @@ -82,6 +82,9 @@ /* If set, don't write out the line unless explicitly told to */ extern flagT no_default_output; +/* If set, buffer neither input nor output */ +extern flagT unbuffered; + /* Do we need to be pedantically POSIX compliant? */ extern flagT POSIXLY_CORRECT; @@ -324,7 +327,6 @@ return 1; } -#ifdef HAVE_ISATTY /* fgets() doesn't let us handle NULs and fread() buffers too much * for interactive use. */ @@ -348,7 +350,6 @@ panic("input read error: %s", strerror(errno)); return resultlen; } -#endif /*HAVE_ISATTY*/ static flagT read_file_line(input) @@ -369,11 +370,13 @@ buffer.length = 0; if (!feof(input->fp)) { + if (unbuffered #ifdef HAVE_ISATTY - if (input->is_tty) + || input->is_tty +#endif + ) buffer.length = slow_getline(buffer.text, buffer.alloc, input->fp); else -#endif buffer.length = ck_fread(buffer.text, 1, buffer.alloc, input->fp); } @@ -1046,7 +1049,7 @@ ck_fwrite(text, 1, length, fp); if (nl) ck_fwrite("\n", 1, 1, fp); - if (fp != stdout) + if ((fp != stdout) || (unbuffered)) ck_fflush(fp); } diff -ur sed-3.02.original/sed/sed.c sed-3.02/sed/sed.c --- sed-3.02.original/sed/sed.c Fri Jul 3 03:06:26 1998 +++ sed-3.02/sed/sed.c Thu May 2 16:09:28 2002 @@ -75,6 +75,9 @@ /* If set, don't write out the line unless explicitly told to */ flagT no_default_output = 0; +/* If set, buffer neither input nor output */ +flagT unbuffered = 0; + /* Do we need to be pedantically POSIX compliant? */ flagT POSIXLY_CORRECT; @@ -93,6 +96,8 @@ add the script to the commands to be executed\n\ -f script-file, --file=script-file\n\ add the contents of script-file to the commands to be executed\n\ + -u, --unbuffered\n\ + make stdout unbuffered\n\ --help display this help and exit\n\ -V, --version output version information and exit\n\ \n\ @@ -117,6 +122,7 @@ {"expression", 1, NULL, 'e'}, {"file", 1, NULL, 'f'}, {"quiet", 0, NULL, 'n'}, + {"unbuffered", 0, NULL, 'u'}, {"silent", 0, NULL, 'n'}, {"version", 0, NULL, 'V'}, {"help", 0, NULL, 'h'}, @@ -139,7 +145,7 @@ #endif /*STUB_FROM_RX_LIBRARY_USAGE*/ myname = *argv; - while ((opt = getopt_long(argc, argv, "hnrVe:f:", longopts, NULL)) != EOF) + while ((opt = getopt_long(argc, argv, "hnurVe:f:", longopts, NULL)) != EOF) { switch (opt) { @@ -152,7 +158,9 @@ case 'f': the_program = compile_file(the_program, optarg); break; - + case 'u': + unbuffered = 1; + break; case 'r': use_extended_syntax_p = 1; rx_testing = 1; diff -ur sed-3.02.original/testsuite/help.good sed-3.02/testsuite/help.good --- sed-3.02.original/testsuite/help.good Tue Jun 2 04:26:56 1998 +++ sed-3.02/testsuite/help.good Thu May 2 00:38:35 2002 @@ -6,6 +6,8 @@ add the script to the commands to be executed -f script-file, --file=script-file add the contents of script-file to the commands to be executed + -u, --unbuffered + make stdout unbuffered --help display this help and exit -V, --version output version information and exit