From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay1.UU.NET ([137.39.1.5]) by hawkwind.utcs.toronto.edu with SMTP id <2776>; Tue, 10 Nov 1992 05:14:16 -0500 Received: from cygnus.com by relay1.UU.NET with SMTP (5.61/UUNET-internet-primary) id AA16405; Tue, 10 Nov 92 05:13:57 -0500 Received: by cygnus.com (4.1/SMI-4.1) id AA01337; Tue, 10 Nov 92 02:13:56 PST Date: Tue, 10 Nov 1992 05:13:56 -0500 From: brendan@cygnus.com (Brendan Kehoe) Message-Id: <9211101013.AA01337@cygnus.com> To: rc mailing list Cc: brendan@cygnus.com Subject: ~ == $home Reply-To: brendan@cygnus.com Here's my first crack at making a tilde be used as an alternative to $home (or $h). (Well, it's actually my second--the first was an addition to the grammar, doing `foo~bar' convinced me to forget continuing to use that.) This doesn't support ~user, but can with a little more hacking (I'm too tired right now). A ~ by itself at the beginning of the line still works as the twiddle operator. Just to make life complete, gcc 2.3.1 miscompiles footobar.c (list2array) when optimization isn't being used. (I'll be looking at that before I do ~user.) Brendan *** glob.c.~1~ Mon Feb 17 14:45:24 1992 --- glob.c Tue Nov 10 02:08:26 1992 *************** static List *doglob(char *w, char *m) { *** 194,198 **** zero) since doglob gets called iff there's a metacharacter to be matched */ ! if (*s == '\0') { matched = dmatch(".", dir, metadir); goto end; --- 195,199 ---- zero) since doglob gets called iff there's a metacharacter to be matched */ ! if (*s == '\0' && *w != '~') { matched = dmatch(".", dir, metadir); goto end; *************** static List *doglob(char *w, char *m) { *** 203,206 **** --- 204,216 ---- firstdir.n = NULL; matched = &firstdir; + } else if (*w == '~') { + firstdir.w = varlookup("home")->w; + firstdir.n = NULL; + matched = &firstdir; + if (*s == '\0') { + firstdir.m = NULL; + goto end; + } + firstdir.m = metadir; } else { /* *** lex.c.~1~ Tue Mar 31 08:40:20 1992 --- lex.c Tue Nov 10 02:04:25 1992 *************** *** 38,42 **** 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,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= bufsize) --- 98,111 ---- w = RW; i = 0; + if (c == '~') { + c = gchar(); + ugchar(c); + if (c == ' ' || c == '\t') + return TWIDDLE; + c = '~'; + } read: do { buf[i++] = c; ! if (c == '?' || c == '[' || c == '*' || c == '~') saw_meta = TRUE; if (i >= bufsize) -- Brendan Kehoe brendan@cygnus.com Cygnus Support, Palo Alto, CA +1 415 322 3811 His name's Avery!