Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: capturing output of !! not working



On Sun, 22 Mar 2015 18:35:56 +0000
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> +/**/
> +char *
> +zshlex_raw_mark(int offset)
> +{
> +    if (!lex_add_raw)
> +	return NULL;
> +    return lexbuf_raw.ptr + offset;
> +}
> +
> +/**/
> +void
> +zshlex_raw_back_to_mark(char *mark)
> +{
> +    if (!lex_add_raw)
> +	return;
> +    lexbuf_raw.len -= lexbuf_raw.ptr - mark;
> +    lexbuf_raw.ptr = mark;
> +}
> +

It may have been reallocated... this is safer.

diff --git a/Src/hist.c b/Src/hist.c
index 70dfac0..b44f4ad 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -527,7 +527,8 @@ histsubchar(int c)
     static int marg = -1;
     static zlong mev = -1;
     char *buf, *ptr;
-    char *sline, *lexraw_mark;
+    char *sline;
+    int lexraw_mark;
     Histent ehist;
     size_t buflen;
 
diff --git a/Src/lex.c b/Src/lex.c
index 6b9e942..6d0079c 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -1872,22 +1872,22 @@ zshlex_raw_back(void)
 }
 
 /**/
-char *
+int
 zshlex_raw_mark(int offset)
 {
     if (!lex_add_raw)
-	return NULL;
-    return lexbuf_raw.ptr + offset;
+	return 0;
+    return lexbuf_raw.len + offset;
 }
 
 /**/
 void
-zshlex_raw_back_to_mark(char *mark)
+zshlex_raw_back_to_mark(int mark)
 {
     if (!lex_add_raw)
 	return;
-    lexbuf_raw.len -= lexbuf_raw.ptr - mark;
-    lexbuf_raw.ptr = mark;
+    lexbuf_raw.ptr = tokstr_raw + mark;
+    lexbuf_raw.len = mark;
 }
 
 /*



Messages sorted by: Reverse Date, Date, Thread, Author