zsh-workers
 help / color / mirror / code / Atom feed
* Re: ksh (with PATCH)
@ 2000-03-13  9:38 Sven Wischnowsky
  0 siblings, 0 replies; 5+ messages in thread
From: Sven Wischnowsky @ 2000-03-13  9:38 UTC (permalink / raw)
  To: zsh-workers


I wrote:

> ...
>
> - test -d .  -a '(' ! -f . ')' isn't parsed correctly.

Sorry, wrong line. The offending one was: [[ '!' = ! ]]. The problem
is that the ! (without quotes) is reported as the BANG token when we
are in conditions. The patch tries to minimally invasive, making the
lexer report it as BANG only when we are in the first word of a
condition.

> - [[ $(print -r - "$(print -r - 'abc*|" \')") !=  'abc*|" \' ]] isn't
>   parsed correctly either.

Maybe this is just that we use quoting differently?

Bye
 Sven

diff -ru ../z.old/Src/lex.c Src/lex.c
--- ../z.old/Src/lex.c	Mon Mar 13 10:34:59 2000
+++ Src/lex.c	Mon Mar 13 10:35:28 2000
@@ -1526,7 +1526,7 @@
 	    } else if (incond && !strcmp(yytext, "]]")) {
 		tok = DOUTBRACK;
 		incond = 0;
-	    } else if (incond && yytext[0] == '!' && !yytext[1])
+	    } else if (incond == 1 && yytext[0] == '!' && !yytext[1])
 		tok = BANG;
 	}
 	inalmore = 0;

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: ksh (with PATCH)
@ 2000-03-13  9:17 Sven Wischnowsky
  0 siblings, 0 replies; 5+ messages in thread
From: Sven Wischnowsky @ 2000-03-13  9:17 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On Mar 10,  4:33pm, Sven Wischnowsky wrote:
> } Subject: ksh (with PATCH)
> }
> } - Two problems with `|&':
> }   - The pipe-code was put in the wrong place.
> }   - SEPERs weren't skipped.
> 
> You can't trust ksh's tests of |&, can you?  It means something entirely
> different in ksh.

I didn't. The ksh-test just showed the two bugs in our parsing of `|&'.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: ksh (with PATCH)
  2000-03-10 15:33 Sven Wischnowsky
@ 2000-03-10 16:34 ` Bart Schaefer
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2000-03-10 16:34 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

On Mar 10,  4:33pm, Sven Wischnowsky wrote:
} Subject: ksh (with PATCH)
}
} - Two problems with `|&':
}   - The pipe-code was put in the wrong place.
}   - SEPERs weren't skipped.

You can't trust ksh's tests of |&, can you?  It means something entirely
different in ksh.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: ksh (with PATCH)
@ 2000-03-10 15:54 Sven Wischnowsky
  0 siblings, 0 replies; 5+ messages in thread
From: Sven Wischnowsky @ 2000-03-10 15:54 UTC (permalink / raw)
  To: zsh-workers


I wrote:

> Of course, there are also many other things that failed, including:
> 
> ...
> 
> These may be changed, someway, I think.

Err... I didn't want to give the impression that I think we should or
have to implement these[1], I just wanted to say that these at least
wouldn't be that hard, I think (the subscript thing may be a bigger
problem than I can see now).


Bye
 Sven

[1] Personally, I don't care much about ksh compatibility.

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 5+ messages in thread

* ksh (with PATCH)
@ 2000-03-10 15:33 Sven Wischnowsky
  2000-03-10 16:34 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Sven Wischnowsky @ 2000-03-10 15:33 UTC (permalink / raw)
  To: zsh-workers


There is a whole lot of fun waiting for us... the source distribution
of ksh93 contains a directory with tests. Sigh.


Things I hope to have fixed with the patch below:

- typeset -Ai foo reported an error message because bin_typeset() wasn't 
  checking for combinations of PM_HASHED with PM_INTEGER or PM_?FLOAT.
  The order in which the tests are done in bin_typeset() means that
  the float/integer options override the -[aA]. Is that really a good
  idea? Even without looking at compatibility to ksh this seems wrong.
  In ksh typeset -Ai works, I think we should create an assoc in this
  case (unless someone wants to write all the code needed to get real
  assocs-of-ints in zsh).
- Here-docs. Two things:
  - Something like:
      foo << \! | cat
      baz
      !
    failed utterly (the important bit is the `| cat'). That's because
    I forgot to update the pointers in the herdocs structs when
    inserting or deleting wordcodes.
  - zsh converts here-docs to here-strings during parsing, but the
    text (job-text, $functions, etc.) created for it didn't quote the
    here-string. I've made this put such strings always in single
    quotes, lokks better, I think. I don't plan to even attempt to
    change it so that here-docs are kept in parsed code.
- Two problems with `|&':
  - The pipe-code was put in the wrong place.
  - SEPERs weren't skipped.


Things that should be fixed some day:

- test -d .  -a '(' ! -f . ')' isn't parsed correctly.
- [[ $(print -r - "$(print -r - 'abc*|" \')") !=  'abc*|" \' ]] isn't
  parsed correctly either.


Of course, there are also many other things that failed, including:

- The ${foo:x:y} subscript syntax.
- $_ and $LINENO seem to be writable in ksh.
- [[ string ]] seems to be allowed...
- ksh has some mathematical functions built-in, things we have in the
  mathfunc module.

These may be changed, someway, I think.


One last remark: ksh seems to have some kind of structs (?):

    point=(
	float x
	float y
    )
    (( point.x = cos(pi/6), point.y = sin(pi/6) ))

Or is it part of the name-space stuff? (Haven't read the manual yet.)
Anyway: Whew!


Ok, here is the patch... some SEGVs less.

Bye
 Sven

diff -ru ../z.old/Src/builtin.c Src/builtin.c
--- ../z.old/Src/builtin.c	Fri Mar 10 13:57:27 2000
+++ Src/builtin.c	Fri Mar 10 14:38:28 2000
@@ -1816,17 +1816,17 @@
 
     /* Sanity checks on the options.  Remove conficting options. */
     if (on & PM_FFLOAT) {
-	off |= PM_RIGHT_B | PM_LEFT | PM_RIGHT_Z | PM_UPPER | PM_ARRAY
-	    | PM_INTEGER | PM_EFLOAT;
+	off |= PM_RIGHT_B | PM_LEFT | PM_RIGHT_Z | PM_UPPER | PM_ARRAY |
+	    PM_HASHED | PM_INTEGER | PM_EFLOAT;
 	/* Allow `float -F' to work even though float sets -E by default */
 	on &= ~PM_EFLOAT;
     }
     if (on & PM_EFLOAT)
-	off |= PM_RIGHT_B | PM_LEFT | PM_RIGHT_Z | PM_UPPER | PM_ARRAY
-	    | PM_INTEGER | PM_FFLOAT;
+	off |= PM_RIGHT_B | PM_LEFT | PM_RIGHT_Z | PM_UPPER | PM_ARRAY |
+	    PM_HASHED | PM_INTEGER | PM_FFLOAT;
     if (on & PM_INTEGER)
 	off |= PM_RIGHT_B | PM_LEFT | PM_RIGHT_Z | PM_UPPER | PM_ARRAY |
-	    PM_EFLOAT | PM_FFLOAT;
+	    PM_HASHED | PM_EFLOAT | PM_FFLOAT;
     if (on & PM_LEFT)
 	off |= PM_RIGHT_B | PM_INTEGER | PM_EFLOAT | PM_FFLOAT;
     if (on & PM_RIGHT_B)
diff -ru ../z.old/Src/lex.c Src/lex.c
--- ../z.old/Src/lex.c	Fri Mar 10 13:57:28 2000
+++ Src/lex.c	Fri Mar 10 15:20:49 2000
@@ -339,10 +339,9 @@
 	    char *name;
 
 	    hwbegin(0);
-	    cmdpush(WC_REDIR_TYPE(*(hdocs->pc)) == HEREDOC ?
-		    CS_HEREDOC : CS_HEREDOCD);
+	    cmdpush(hdocs->type == HEREDOC ? CS_HEREDOC : CS_HEREDOCD);
 	    STOPHIST
-	    name = gethere(hdocs->str, WC_REDIR_TYPE(*hdocs->pc));
+	    name = gethere(hdocs->str, hdocs->type);
 	    ALLOWHIST
 	    cmdpop();
 	    hwend();
diff -ru ../z.old/Src/parse.c Src/parse.c
--- ../z.old/Src/parse.c	Fri Mar 10 13:57:29 2000
+++ Src/parse.c	Fri Mar 10 16:22:00 2000
@@ -233,6 +233,18 @@
 /**/
 int ecsoffs, ecssub, ecnfunc;
 
+/* Adjust pointers in here-doc structs. */
+
+static void
+ecadjusthere(int p, int d)
+{
+    struct heredocs *h;
+
+    for (h = hdocs; h; h = h->next)
+	if (h->pc >= p)
+	    h->pc += d;
+}
+
 /* Insert n free code-slots at position p. */
 
 static void
@@ -250,6 +262,7 @@
     if ((m = ecused - p) > 0)
 	memmove(ecbuf + p + n, ecbuf + p, m * sizeof(wordcode));
     ecused += n;
+    ecadjusthere(p, n);
 }
 
 /* Add one wordcode. */
@@ -278,6 +291,7 @@
     if (n > 0)
 	memmove(ecbuf + p, ecbuf + p + 1, n * sizeof(wordcode));
     ecused--;
+    ecadjusthere(p, -1);
 }
 
 /* Build the wordcode for a string. */
@@ -682,7 +696,6 @@
 	for (r = p + 1; wc_code(ecbuf[r]) == WC_REDIR; r += 3);
 
 	ecispace(r, 3);
-	p += 3;
 	ecbuf[r] = WCB_REDIR(MERGEOUT);
 	ecbuf[r + 1] = 2;
 	ecbuf[r + 2] = ecstrcode("1");
@@ -690,6 +703,8 @@
 	*complex = 1;
 	cmdpush(CS_ERRPIPE);
 	yylex();
+	while (tok == SEPER)
+	    yylex();
 	ecbuf[p] = WCB_PIPE(WC_PIPE_MID, (line >= 0 ? line + 1 : 0));
 	ecispace(p + 1, 1);
 	ecbuf[p + 1] = ecused - 1 - p;
@@ -1577,12 +1592,6 @@
 	/* <<[-] name */
 	struct heredocs **hd;
 
-	for (hd = &hdocs; *hd; hd = &(*hd)->next);
-	*hd = zalloc(sizeof(struct heredocs));
-	(*hd)->next = NULL;
-	(*hd)->pc = ecbuf + r;
-	(*hd)->str = tokstr;
-
 	/* If we ever need more than three codes (or less), we have to change
 	 * the factors in par_cmd() and par_simple(), too. */
 	ecispace(r, 3);
@@ -1590,6 +1599,13 @@
 	ecbuf[r] = WCB_REDIR(type);
 	ecbuf[r + 1] = fd1;
 
+	for (hd = &hdocs; *hd; hd = &(*hd)->next);
+	*hd = zalloc(sizeof(struct heredocs));
+	(*hd)->next = NULL;
+	(*hd)->type = type;
+	(*hd)->pc = r;
+	(*hd)->str = tokstr;
+
 	yylex();
 	return;
     }
@@ -1626,10 +1642,10 @@
 
 /**/
 void
-setheredoc(Wordcode pc, int type, char *str)
+setheredoc(int pc, int type, char *str)
 {
-    pc[0] = WCB_REDIR(type);
-    pc[2] = ecstrcode(str);
+    ecbuf[pc] = WCB_REDIR(type);
+    ecbuf[pc + 2] = ecstrcode(str);
 }
 
 /*
diff -ru ../z.old/Src/text.c Src/text.c
--- ../z.old/Src/text.c	Fri Mar 10 13:57:31 2000
+++ Src/text.c	Fri Mar 10 15:37:03 2000
@@ -737,7 +737,12 @@
 		taddchr('0' + f->fd1);
 	    taddstr(fstr[f->type]);
 	    taddchr(' ');
-	    taddstr(f->name);
+	    if (f->type == HERESTR) {
+		taddchr('\'');
+		taddstr(bslashquote(f->name, NULL, 1));
+		taddchr('\'');
+	    } else
+		taddstr(f->name);
 	    taddchr(' ');
 	    break;
 #ifdef DEBUG
diff -ru ../z.old/Src/zsh.h Src/zsh.h
--- ../z.old/Src/zsh.h	Fri Mar 10 13:57:31 2000
+++ Src/zsh.h	Fri Mar 10 15:20:17 2000
@@ -737,7 +737,8 @@
 
 struct heredocs {
     struct heredocs *next;
-    Wordcode pc;
+    int type;
+    int pc;
     char *str;
 };
 

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2000-03-13  9:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-13  9:38 ksh (with PATCH) Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
2000-03-13  9:17 Sven Wischnowsky
2000-03-10 15:54 Sven Wischnowsky
2000-03-10 15:33 Sven Wischnowsky
2000-03-10 16:34 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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).