* Re: ~ expansion
1993-01-19 3:35 Steve Rikli
@ 1993-01-19 7:14 ` brendan
0 siblings, 0 replies; 3+ messages in thread
From: brendan @ 1993-01-19 7:14 UTC (permalink / raw)
To: Steve Rikli; +Cc: rc
Here's my hack for it:
*** 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)
^ permalink raw reply [flat|nested] 3+ messages in thread