| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | getopt() |
Hi CHARLES. 09-Aug-03 21:58:00, CHARLES ANGELICH wrote to JASEN BETTS CA> 1237c94464c2 c_echo CA> Hello Jasen - CA>>>>> I haven't used getopt() for some time now but I have often CA>>>>> wondered what the reasons are that most methods of parsing the CA>>>>> command line want to use switch characters such as "/" or "-"? JB>>>> usually to separate switches (ie commands) from filenames or JB>>>> other literals CA>>> With argc available I don't see the need for the switch chars. CA>>> Order of entry should be sufficient. JB>> for trivial tools it often is. CA> To be honest I only write trivial tools, the more trivial the CA> better. I like to think I'm following in the *nix model of just CA> piping from one to the other but I detect a good deal of inertia CA> when even thinking about taking on writing a complete app with CA> user-interface etc. I'm seriously considering Steve Gibson's offer CA> of a template for writing Windows apps but it's all ASM and I CA> would have to install a Windows compiler/assembler to use it. CA> Getting lazy in my old age. ;-) JB>> try designing something that can do,everything the dos copy JB>> command can do (well the things it's documented as being capable JB>> of) without it using any switches... CA> There are so many clones of "copy" I never thought to write CA> another one but I have written a dropin replacement for "sort" in CA> all C code. same.... limited to available meory but atleast it uses an Order(n.log(n)) sort algorithm (qsort() actually) (which is a vast improvemnt on the n-squared algorithm in the dos one. I wrote a qsort program in qbasic and on a file of 2000 random short words the interpreted sort.bas program could actiually beat the dos sort.exe CA> I could fiddle with that one and see if I could remove CA> the switch characters as an exercise but since it is intended to CA> pipe input and output I suspect that would be far too easy. :-) the dos version takes an optional filename... could prove challenging CA> Yes, I use AWK occasionally and like it (recently downloaded CA> Kernighan's W95 executable for AWK) but putting the code into the CA> command line is somewhat tedious (for me) with the need to escape CA> characters etc. Starts to look like PERL code eventually and I CA> don't like PERL. :-) yeah, code in the command-line is more a unix thing where there are fewer limits on command line length. I'd post the source for the sort but it's full of turbo-C isms and dos specific stuff. basically all it did was read the file into memory then make and index of the lines in an array of pointers while null-terminating each one. Then it qsort()ed the index using a compare function based on stricmp and finally used a for loop to go theough the index and print out each line one at a time. -=> Bye <=- ---* Origin: One less than the checksum of "Jasen Betts" (3:640/1042) SEEN-BY: 633/267 270 @PATH: 640/1042 531 954 774/605 123/500 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™.