6 messages in com.perforce.jamming[jamming] String deconstrution.| From | Sent On | Attachments |
|---|---|---|
| Koloseike | 09 Mar 2000 07:33 | |
| Lanc...@scmlabs.com | 09 Mar 2000 09:01 | |
| Matt...@corp.phone.com | 09 Mar 2000 10:27 | |
| Dian...@yahoo.com | 09 Mar 2000 16:54 | |
| Karl...@cisco.com | 10 Mar 2000 09:30 | |
| Karl...@cisco.com | 13 Mar 2000 13:50 |
| Subject: | [jamming] String deconstrution.![]() |
|---|---|
| From: | Karl...@cisco.com (Karl...@cisco.com) |
| Date: | 03/10/2000 09:30:21 AM |
| List: | com.perforce.jamming |
I've attached an alternative approach that we use here. It has the add'l feature of being able to recognize $(TOP) and omit it from the gristing. So:
foo/bar/foo.c becomes <foo!bar>foo.c foo/bar becomes <foo>bar (no file vs dir check) /abs/path/foo/bar/foo.c becomes <foo!bar>foo.c (assuming $(TOP) = /abs/path)
klash | | Adults are nothing but used up children. .|. .|. -- writer Theodore Geisel .|||. .|||. (aka Dr. Seuss) .:::::::.:::::::.
In message <2000...@squeaker.phone.com>, Matt Armstrong writes:
On Thu, Mar 09, 2000 at 10:34:21AM -0500, Koloseike, Jason wrote:
Jam is quite capable of constructing strings, but I can't find anything related to pulling a string apart like strtok().
I would love to be able to create a rule that generates a grist from an actual directory specification.
Rather than:
makeGrist gristVar : dir1 dir2 dir3 ;
I would like to be able write a function:
myMakeGrist gristVar : /dir1/dir2/dir3 ;
Am I missing something? I've all through the documentation and haven't seen anything releated to pulling strings apart.
If you want to split at the directory separator, then you're in luck. The :P variable expansion modifier gives just enough functionality to get what you want. Here is what I've written:
# # splitDir var : dir ; # # Split variable 'dir' containing a filename into its component # parts and assign it to 'var'. # rule splitDir { $(1) = ; splitDirImpl $(1) : $(2) ; }
rule splitDirImpl { local parent ; parent = $(2:P) ;
if $(parent) && $(parent) != $(SLASH) && $(parent) != $(2) { splitDirImpl $(1) : $(parent) ; $(1) += $(2:BS) ; } else { $(1) += $(2) ; } }
_______________________________________________ jamming mailing list - jamm...@perforce.com http://maillist.perforce.com/mailman/listinfo/jamming




