From: brendan@cygnus.com (Brendan Kehoe)
To: rc mailing list <rc@hawkwind.utcs.toronto.edu>
Cc: brendan@cygnus.com
Subject: ~ == $home
Date: Tue, 10 Nov 1992 05:13:56 -0500 [thread overview]
Message-ID: <9211101013.AA01337@cygnus.com> (raw)
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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0,
! 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
--- 38,42 ----
1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0,
! 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, /* ~ */ 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
*************** top: while ((c = gchar()) == ' ' || c ==
*** 98,104 ****
w = RW;
i = 0;
read: do {
buf[i++] = c;
! if (c == '?' || c == '[' || c == '*')
saw_meta = TRUE;
if (i >= 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!
next reply other threads:[~1992-11-10 10:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1992-11-10 10:13 Brendan Kehoe [this message]
1992-11-12 23:25 Stefan Axelsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9211101013.AA01337@cygnus.com \
--to=brendan@cygnus.com \
--cc=rc@hawkwind.utcs.toronto.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).