doug-merritt@cup.portal.com (05/17/88)
Peter da Silva said: >'*' also has the disadvantage that it conflicts with AmigaDOS usage [...] >It's already overloaded. # is the standard. Please stick to it. There is >an excellent wildcard handler witten by Jeff Lydiatt that I use extensively. >[...] I use "#?.(c|h)|Makefile" quite a bit when moving programs around. It's >equivalent to the csh "{*.[ch],Makefile}" It also allows string alternation, like unix egrep: "(main|misc).#?" which is real handy! Jeff's code is very nice, and very easy to interface to. I suspect that the reason that Jeff's code hasn't been used more extensively is that you've got to put a good wrapper around it. I did so this weekend for my "filetype" program, and it was a few hundred lines of code to make it 100% perfectly general. To search the current directory only requires maybe 10-20 lines of code (foreach dir entry, check whether it matches via Jeff's code). Handling *every* possible case, with error checking, is more complex. But I was real pleased to see "filetype #?/#?/#?" work. I was thinking about releasing this code I wrote as a library routine. The interface looks like this: "av = Glob(&ac, av);" Pretty simple, eh? Anyone need something like this? Is there already something like this around that I somehow overlooked? Even if there is, there's one feature I added that I'd bet is unique... it wildcards *devices* too! I.e. "filetype #?:#?" matches the contents of all the root directories on all the file system devices (and assigns). This required surprisingly little extra code on top of the original stuff. I'm feeling real pleased to have gotten this working nicely. I do have one (dumb) question, though. For some reason I can't find the wildcard documentation in the AmigaDOS manual. Where is it? I wanna know what the magic char "%" is for. And to refresh my memory about uses of '#' other than '#?'. Pretty bad when some dummy doesn't even know what the code he implements does, huh. (blush) :-) Doug Merritt ucbvax!sun.com!cup.portal.com!doug-merritt or ucbvax!eris!doug (doug@eris.berkeley.edu) or ucbvax!unisoft!certes!doug
peter@sugar.UUCP (Peter da Silva) (05/20/88)
In article <5490@cup.portal.com>, doug-merritt@cup.portal.com writes: > I suspect that the reason that Jeff's code hasn't been used more extensively > is that you've got to put a good wrapper around it. If you want to use it just for command line arguments, anyway. In the latest version of Browser I use it to select groups of files. > Handling *every* possible case, with error checking, is > more complex. But I was real pleased to see "filetype #?/#?/#?" work. Good stuff. > I was thinking about releasing this code I wrote as a library routine. > The interface looks like this: "av = Glob(&ac, av);" Pretty simple, eh? > Anyone need something like this? Is there already something like this > around that I somehow overlooked? I used to use "buildav(&ac, &av)", but really you need to change _main to do the globbing for command line args invisibly, and to provide an analog of Examine/ExNext. The best way to implement that would be to duplicate the name of and interface to Manx' "scdir()". Be my guest. I was going to do all of that stuff, but I'd be as happy to let you. char *scdir(pat) char *pat; Returns a pointer to a static area containing the null-terminated name of the next file that matches a pattern. The area containing the name [and presumably the FileInfoBlock(s) and stuff -- ed.] is statically allocated. > one (dumb) question, though. For some reason I can't find the wildcard > documentation in the AmigaDOS manual. Where is it? I wanna know what > the magic char "%" is for. And to refresh my memory about uses of '#' > other than '#?'. How about "del foo#(.o)" to trash foo and foo.o when you're cleaning house? The # can be used to indicate optional parts of a pattern (tho of course del foo(|.o) should work as well). -- -- Peter da Silva `-_-' ...!hoptoad!academ!uhnix1!sugar!peter -- "Have you hugged your U wolf today?" ...!bellcore!tness1!sugar!peter -- Disclaimer: These may be the official opinions of Hackercorp.
doug-merritt@cup.portal.com (05/22/88)
I write: > I suspect that the reason that Jeff's code hasn't been used more extensively > is that you've got to put a good wrapper around it. Peter da Silva writes: >If you want to use it just for command line arguments, anyway. In the latest >version of Browser I use it to select groups of files. Yes...I got it from an old Browser, actually. Just for the record, of course *you* put a wrapper around it too...for the benefit of everyone else, what's going on is that Jeff's code allows you to compare a string against a pattern and see if they match. It has no awareness of directories, filenames, full paths, etc. Hence the wrapper. For a Workbench-based program, one might not need all of the full-path-wildcard features I felt obligated to put into Glob()...expanding just the current directory is sufficient, and much simpler. >I used to use "buildav(&ac, &av)", but really you need to change _main >to do the globbing for command line args invisibly, and to provide an analog >of Examine/ExNext. The best way to implement that would be to duplicate the >name of and interface to Manx' "scdir()". Be my guest. I was going to do all >of that stuff, but I'd be as happy to let you. Actually that's two separate interfaces you're talking about. For enhancing _main(), you could just call the Glob(&ac, av) routine I was talking about, and your command line gets wildcard expanded. The second one is the scdir() you suggest, which would also be useful for some purposes...like to drop into code that was previously using ExNext() with minimum hassle. Question: does scdir() handle patterns like "#?/#?/#?" or is it just current directory? The Manx documentation doesn't say. BTW Manx's scdir() implements Unix style wildcards, while everything that Peter and I are talking about is AmigaDOS style. I'll probably do an scdir() equivalent next time I do a program that needs it. :-) >How about "del foo#(.o)" to trash foo and foo.o when you're cleaning house? >The # can be used to indicate optional parts of a pattern (tho of course >del foo(|.o) should work as well). Ok, thanks. Someone else tells me that "del foo(%|.o)" is also equivalent. Makes me wonder what the point of having '%' is...esthetics? Doug --- Doug Merritt ucbvax!sun.com!cup.portal.com!doug-merritt or ucbvax!eris!doug (doug@eris.berkeley.edu) or ucbvax!unisoft!certes!doug
peter@sugar.UUCP (Peter da Silva) (06/01/88)
In article <5732@cup.portal.com>, doug-merritt@cup.portal.com writes: > I write: > > I suspect that the reason that Jeff's code hasn't been used more extensively > > is that you've got to put a good wrapper around it. > > Peter da Silva writes: > >If you want to use it just for command line arguments, anyway. In the latest > >version of Browser I use it to select groups of files. > > Yes...I got it from an old Browser,... You didn't get it from my "browser", I hope. The source shouldn't be out there... :-> > >I used to use "buildav(&ac, &av)", but really you need to change _main > >to do the globbing for command line args invisibly, and to provide an analog > >of Examine/ExNext. > Actually that's two separate interfaces you're talking about. For Yeh, I know. I didn't intend to imply otherwise. > enhancing _main(), you could just call the Glob(&ac, av) routine I > was talking about, and your command line gets wildcard expanded. I much prefer making this invisible. I mean, really: just how Amiga- specific do you want your CLI programs to be? You should just be able to recompile and link "uudecode" and have it go. > The second one is the scdir() you suggest, which would also be useful > for some purposes...like to drop into code that was previously using > ExNext() with minimum hassle. Or to drop into code that's already using scdir(), so it will suddenly use AmigaDOS wildcarding! > Question: does scdir() handle patterns > like "#?/#?/#?" or is it just current directory? Who cares? If you want to make your replacement code do it the right way that's perfectly cool. -- -- Peter da Silva `-_-' ...!hoptoad!academ!uhnix1!sugar!peter -- "Have you hugged your U wolf today?" ...!bellcore!tness1!sugar!peter -- Disclaimer: These may be the official opinions of Hackercorp.
doug-merritt@cup.portal.com (06/02/88)
Peter da Silva writes: >You didn't get it from my "browser", I hope. The source shouldn't be out >there... :-> Oh. Well, your file requester or whatever it was. I just scanned the Cat Fish index and couldn't find the disk that contains the source I pulled it out of, so I'm not sure exactly anymore. I said: > enhancing _main(), you could just call the Glob(&ac, av) routine I > was talking about, and your command line gets wildcard expanded. Peter replies: >I much prefer making this invisible. I mean, really: just how Amiga- >specific do you want your CLI programs to be? You should just be able >to recompile and link "uudecode" and have it go. Sure. But that's exactly what I said. Note the "_main()" in my quote above, not "main()". In other words, if you have the (invisible) standard startup function "_main()" call something like my Glob(), then the wildcarding *does* happen automagically and invisibly. Doug -- Doug Merritt ucbvax!sun.com!cup.portal.com!doug-merritt or ucbvax!eris!doug (doug@eris.berkeley.edu) or ucbvax!unisoft!certes!doug
peter@sugar.UUCP (Peter da Silva) (06/03/88)
In article <6141@cup.portal.com>, doug-merritt@cup.portal.com writes: > I said: [basically, enhance "_main()"] > Peter replies: [basically, don't want it in "main()"] > Sure. But that's exactly what I said. Note the "_main()" in my quote > above, not "main()". In other words... In other words I'm a dodo. Do you want me to flame myself a-la Leo Schwab for not reading what you wrote or will an apology do? :-> (How do you put a beard in a smiley-face?) -- -- Peter da Silva `-_-' ...!hoptoad!academ!uhnix1!sugar!peter -- "Have you hugged your U wolf today?" ...!bellcore!tness1!sugar!peter -- Disclaimer: These may be the official opinions of Hackercorp.
doug-merritt@cup.portal.com (06/05/88)
In regard to installing wildcards in _main(), Peter da Silva writes: >In other words I'm a dodo. Do you want me to flame myself a-la Leo Schwab >for not reading what you wrote or will an apology do? :-> Thanks, but neither is necessary! We're talking about the same thing, after all. Unless you really *want* to amuse us with Schwabesque Schizoflames... >(How do you put a beard in a smiley-face?) I dunno. How about :-)= Or ;-)### for a long one... Doug -- Doug Merritt ucbvax!sun.com!cup.portal.com!doug-merritt or ucbvax!eris!doug (doug@eris.berkeley.edu) or ucbvax!unisoft!certes!doug
peter@sugar.UUCP (Peter da Silva) (06/13/88)
In article <6223@cup.portal.com>, doug-merritt@cup.portal.com writes: > >(How do you put a beard in a smiley-face?) > I dunno. How about :-)= Or ;-)### for a long one... Great. I get to look like Bork or Father Christmas. :->} -- -- Peter da Silva `-_-' ...!hoptoad!academ!uhnix1!sugar!peter -- "Have you hugged your U wolf today?" ...!bellcore!tness1!sugar!peter -- Disclaimer: These may be the official opinions of Hackercorp.