C and AWK questions - (nf)

jim at ism780b.UUCP jim at ism780b.UUCP
Sat Aug 18 14:11:04 AEST 1984


#R:chemabs:-13400:ism780b:25500016:000:1007
ism780b!jim    Aug 16 14:22:00 1984

malloc buffers get clobbered by falling off the end, usually by
an improper limit check on an array index.  A very frequent method
is
	newfoo = strcpy(malloc(strlen(foo)), foo);

which is wrong because strlen does not include the terminating NUL.

Several programs, such as make and find, contain subroutines which
do shell filename expansion.  For some reason these have never been
extracted out into a libc routine.

It is depressing that awk does not have so fundamental a function as
system(), so there is no way to execute other commands from within awk.
Nor is there any way to read input from more than one file.

the "uniq" command will eliminate duplicates, yield only the lines which
are not duplicates, yield only lines which are duplicates, or produce
each unique line with a count of occurrences, according to your fancy.

If you just want the first occurrence of a pattern in a given file,
use  sed '/pattern/q'  or  awk '/pattern/ {print; exit}'

-- Jim Balter, INTERACTIVE Systems (ima!jim)



More information about the Comp.lang.c mailing list