Article View: gnu.utils.bug
Article #63sed 1.11 "-n" fix
From: Andrew Herbert
Date: Wed, 04 Nov 1992 11:58
Date: Wed, 04 Nov 1992 11:58
109 lines
3413 bytes
3413 bytes
Hi guys,
sed has a bug that causes it to print out lines even when it has been told not
to (with the -n commandline option). For instance, the "n" command will cause
sed to print out a line. This stuffs up various scripts used by INN. Here
is the fix (also a 386BSD conditional which should probably be made more
general - how about just using memcpy in your code, plus a #define memcpy(a,b,c)
bcopy(b,a,c) for people that don't have memcpy?).
Thanks for your the sed - it works great now.
Andrew
*** sed.c.unhacked Sun Oct 18 18:45:56 1992
--- sed.c Wed Nov 4 00:48:45 1992
***************
*** 42,47 ****
--- 42,48 ----
#include <strings.h>
#endif
+ #ifndef __386BSD__
void bcopy (from, to, len)
char * from;
char * to;
***************
*** 58,63 ****
--- 59,65 ----
while (len--)
*to++ = *from++;
}
+ #endif
char *version_string = "GNU sed version 1.11";
***************
*** 1166,1172 ****
case 'c':
line.length=0;
! if(!(cur_cmd->aflags&A1_MATCHED_BIT))
ck_fwrite(cur_cmd->x.cmd_txt.text,1,cur_cmd->x.cmd_txt.text_len,stdout);
end_cycle++;
break;
--- 1168,1174 ----
case 'c':
line.length=0;
! if(!(cur_cmd->aflags&A1_MATCHED_BIT) && !no_default_output)
ck_fwrite(cur_cmd->x.cmd_txt.text,1,cur_cmd->x.cmd_txt.text_len,stdout);
end_cycle++;
break;
***************
*** 1210,1216 ****
break;
case 'i':
! ck_fwrite(cur_cmd->x.cmd_txt.text,1,cur_cmd->x.cmd_txt.text_len,stdout);
break;
case 'l':
--- 1212,1219 ----
break;
case 'i':
! if(!no_default_output)
! ck_fwrite(cur_cmd->x.cmd_txt.text,1,cur_cmd->x.cmd_txt.text_len,stdout);
break;
case 'l':
***************
*** 1283,1289 ****
case 'n':
if (feof(input_file)) goto quit;
! ck_fwrite(line.text,1,line.length,stdout);
read_pattern_space();
break;
--- 1286,1293 ----
case 'n':
if (feof(input_file)) goto quit;
! if(!no_default_output)
! ck_fwrite(line.text,1,line.length,stdout);
read_pattern_space();
break;
***************
*** 1409,1417 ****
tmp.text=t.text;
tmp.length=t.length;
tmp.alloc=t.alloc;
! if(cur_cmd->x.cmd_regex.flags&S_WRITE_BIT)
ck_fwrite(line.text,1,line.length,cur_cmd->x.cmd_regex.wio_file);
! if(cur_cmd->x.cmd_regex.flags&S_PRINT_BIT)
ck_fwrite(line.text,1,line.length,stdout);
break;
--- 1413,1421 ----
tmp.text=t.text;
tmp.length=t.length;
tmp.alloc=t.alloc;
! if(cur_cmd->x.cmd_regex.flags&S_WRITE_BIT && !no_default_output)
ck_fwrite(line.text,1,line.length,cur_cmd->x.cmd_regex.wio_file);
! if(cur_cmd->x.cmd_regex.flags&S_PRINT_BIT && !no_default_output)
ck_fwrite(line.text,1,line.length,stdout);
break;
Technical Details
Message-ID:
<199211031358.AA03950@werple.apana.org.au>Path:
arc1-ca.pugleaf.net!sparky!uunet!news.encore.com!csar!foxtail!sdd.hp.com!cs.utexas.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!werple.apana.ORG.AU!andrewShow Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug Path: arc1-ca.pugleaf.net!sparky!uunet!news.encore.com!csar!foxtail!sdd.hp.com!cs.utexas.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!werple.apana.ORG.AU!andrew From: andrew@werple.apana.ORG.AU (Andrew Herbert) Subject: sed 1.11 "-n" fix Message-ID: <199211031358.AA03950@werple.apana.org.au> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Wed, 4 Nov 1992 11:58:04 GMT Approved: bug-gnu-utils@prep.ai.mit.edu Lines: 110