Post by Kerr-Mudd,JohnOn Thu, 27 Jun 2019 09:35:22 GMT, "Kerr-Mudd,John"
Post by Kerr-Mudd,JohnOn Thu, 27 Jun 2019 05:35:40 GMT, wolfgang kern
[]
Post by Kerr-Mudd,JohnPost by wolfgang kern* cant see where/how a duplicate string goes to screen.
It should *either* (default) print dupes, or, if /d passed
('/deleteduplicates'), print non-dupes. The output buffer is written at the
end (DOS int 21 fn x40).
This is more or less the standard unix uniq tool I believe?
I.e. this will also either remove all duplicates from a previously
sorted array of lines, or output the dup'ed lines.
I have written one like this in Pascal, the interesting part happens
when you make the "is equal" requirement less strict:
I.e. ignore case, ignore trailing (and leading?) white space?
Collapse all strings of white space (space/tab) into a single space?
In order to do it efficiently you need to double your input line buffer,
so that after reading a line you immediately collapse it into the
generic form, then you compare this with the similarly processed version
of the previous line.
When you need to output something, you should of course always use the
original version of the line!
BTW, if there is to be an exact match, no conversion, the conversion
function can be one that simply returns the input pointer instead of
allocating/using a separate buffer.
You create one conversion function for each basic piece of
pre-processing to be done, then you have aggregate functions that simply
call down to multiple of these to cover combinations.
At runtime a function pointer directs processing to the currently
selected path, so no test/branch anywhere before the final line-vs-line
compare results are known.
Terje
--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"