TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Jasen Betts
from: Charles Angelich
date: 2003-08-12 15:33:08
subject: getopt()

1237c9711cf0
c_echo



Hello Jasen - 

--8<--cut 

JB>>> try designing something that can do,everything the dos
JB>>> copy command can do (well the things it's documented as
JB>>> being capable of) without it using any switches... 

CA>> There are so many clones of "copy" I never thought to
CA>> write another one but I have written a dropin replacement
CA>> for "sort" in all C code. 

JB> same.... limited to available meory but atleast it uses an
JB> Order(n.log(n)) sort algorithm (qsort() actually) (which is
JB> a vast improvemnt on the n-squared algorithm in the dos one. 

Not clear on what "same" you refer to here. Microsoft's sort is
limited to 55K file sizes. As for "available memory" my sort
uses the first 1 meg of memory and could be expanded beyond
that if I was more ambitious. The definitive DOS sort was
already written, RPSORT, in ASM and can use virtual memory
(hard drive) if necessary. It is no faster than my own but has
as much capacity as is doable on a PC (and a bunch of extra
switch/options). :-) 

Sort was an exercise while reading K&R many years ago. I did
not use the 'canned' qsort(), I copied the one from K&R then
modified it somewhat. 

JB> I wrote a qsort program in qbasic and on a file of 2000
JB> random short words the interpreted sort.bas program could
JB> actiually beat the dos sort.exe 

All things considered, Microsoft's DOS sort is the worst
example of programming within the DOS OS that I can think of. 

--8<--cut

CA>> Yes, I use AWK occasionally and like it (recently
CA>> downloaded Kernighan's W95 executable for AWK) but putting
CA>> the code into the command line is somewhat tedious (for
CA>> me) with the need to escape characters etc. Starts to look
CA>> like PERL code eventually and I don't like PERL. :-) 

JB> yeah, code in the command-line is more a unix thing where
JB> there are fewer limits on command line length. 

I used a few command line AWK routines with aliasing to create
new 'commands' but not for other purposes.  I save the AWK code
in a file. 

JB> I'd post the source for the sort but it's full of turbo-C
JB> isms and dos specific stuff. basically all it did was read
JB> the file into memory then make and index of the lines in an
JB> array of pointers while null-terminating each one. Then it
JB> qsort()ed the index using a compare function based on
JB> stricmp and finally used a for loop to go theough the index
JB> and print out each line one at a time. 

I guess that describes it but as I said, I used the K&R qsort
and I _think_ I wrote my own function to compare the strings?
It's been some years ago now and I haven't even looked at my
sort code for many of those years.  I did write a similarity
sort some years back but that is a horse of a different color.
Binaries of both sort.exe and simsort.exe (along with fuzzy.exe)
are available for downloading from my tech website.

We've had many interesting discussions of sorting algorithms
here in the c_echo not long ago and Bill Buckels did a really
good job writing his similarity sort routines with a little
prodding from me. Of the three sim-sorts I know of mine is
still the fastest but Bill's is the most capable for larger
files. :-)

>
>        ,                          ,
>      o/      Charles.Angelich      \o       ,
>       __o/
>     / >          USA, MI           < \   __\__
 

___ * ATP/16bit 2.31 * 
... DOS the Ghost in the Machine! http://www.undercoverdesign.com/dosghost/

--- Maximus/2 3.01
* Origin: COMM Port OS/2 juge.com 204.89.247.1 (281) 980-9671 (1:106/2000)
SEEN-BY: 633/267 270
@PATH: 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.