summaryrefslogtreecommitdiffstats
path: root/tcsh-6.18.01-reverse-history-handling-in-loops.patch
blob: 236f50d1dd88d16125771bb2b2e4f3c02584f075 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
From dde61c8a6ee767bbfa20018ab277e3e38e3a613f Mon Sep 17 00:00:00 2001
From: Roman Kollar <rkollar@redhat.com>
Date: Fri, 12 Oct 2012 13:40:12 +0200
Subject: [PATCH] Reverse patch for history handling in loops

Originally reported at Red Hat Bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=814069

Reverse patch for commit 23a51b0a709628af57729a07cbbfae3c95e98e6f in the upstream repo

Adjusted by Jaromir Koncicky (jkoncick) to fit with version 6.18.01
---
 sh.func.c | 137 +-------------------------------------------------------------
 1 file changed, 1 insertion(+), 136 deletions(-)

diff --git a/sh.func.c b/sh.func.c
index 31c5330..b564e53 100644
--- a/sh.func.c
+++ b/sh.func.c
@@ -61,7 +61,6 @@ static	void	doagain		(void);
 static  const char *isrchx	(int);
 static	void	search		(int, int, Char *);
 static	int	getword		(struct Strbuf *);
-static	struct wordent	*histgetword	(struct wordent *);
 static	void	toend		(void);
 static	void	xecho		(int, Char **);
 static	int	islocale_var	(Char *);
@@ -754,7 +753,6 @@ search(int type, int level, Char *goal)
 {
     struct Strbuf word = Strbuf_INIT;
     Char *cp;
-    struct wordent *histent = NULL, *ohistent = NULL;
 
     Stype = type;
     Sgoal = goal;
@@ -767,28 +765,12 @@ search(int type, int level, Char *goal)
     }
     cleanup_push(&word, Strbuf_cleanup);
     do {
-	    
-	if (intty) {
-	    histent = xmalloc(sizeof(*histent));
-	    ohistent = xmalloc(sizeof(*histent));
-	    ohistent->word = STRNULL;
-	    ohistent->next = histent;
-	    histent->prev = ohistent;
-	}
-
 	if (intty && fseekp == feobp && aret == TCSH_F_SEEK)
 	    printprompt(1, isrchx(type == TC_BREAK ? zlast : type));
 	/* xprintf("? "), flush(); */
 	(void) getword(&word);
 	Strbuf_terminate(&word);
 
-	if (intty && Strlen(word.s) > 0) {
-	    histent->word = Strsave(word.s);
-	    histent->next = xmalloc(sizeof(*histent));
-	    histent->next->prev = histent;
-	    histent = histent->next;
-	}
-
 	switch (srchx(word.s)) {
 
 	case TC_ELSE:
@@ -864,126 +846,12 @@ search(int type, int level, Char *goal)
 		level = -1;
 	    break;
 	}
-	if (intty) {
-	    ohistent->prev = histgetword(histent);
-	    ohistent->prev->next = ohistent;
-	    savehist(ohistent, 0);
-	    freelex(ohistent);
-	    xfree(ohistent);
-	} else 
-	    (void) getword(NULL);
+    (void) getword(NULL);
     } while (level >= 0);
  end:
     cleanup_until(&word);
 }
 
-static struct wordent *
-histgetword(struct wordent *histent) 
-{
-    int found = 0, first;
-    eChar c, d;
-    int e;
-    struct Strbuf *tmp;
-    tmp = xmalloc(sizeof(*tmp));
-    tmp->size = 0;
-    tmp->s = NULL;
-    c = readc(1);
-    d = 0;
-    e = 0;
-    for (;;) {
-	tmp->len = 0;
-	Strbuf_terminate (tmp);
-	while (c == ' ' || c == '\t')
-	    c = readc(1);
-	if (c == '#')
-	    do
-		c = readc(1);
-	    while (c != CHAR_ERR && c != '\n');
-	if (c == CHAR_ERR)
-	    goto past;
-	if (c == '\n') 
-	    goto nl;
-	unreadc(c);
-	found = 1;
-	first = 1;
-	do {
-	    e = (c == '\\');
-	    c = readc(1);
-	    if (c == '\\' && !e) {
-		if ((c = readc(1)) == '\n') {
-		    e = 1;
-		    c = ' ';
-		} else {
-		    unreadc(c);
-		    c = '\\';
-		}
-	    }
-	    if ((c == '\'' || c == '"') && !e) {
-		if (d == 0)
-		    d = c;
-		else if (d == c)
-		    d = 0;
-	    }
-	    if (c == CHAR_ERR)
-		goto past;
-	    
-	    Strbuf_append1(tmp, (Char) c);
-	    
-	    if (!first && !d && c == '(' && !e) {
-		break;
-	    }
-	    first = 0;
-	} while (d || e || (c != ' ' && c != '\t' && c != '\n'));
-	tmp->len--;
-	if (tmp->len) {
-	    Strbuf_terminate(tmp);
-	    histent->word = Strsave(tmp->s);
-	    histent->next = xmalloc(sizeof (*histent));
-	    histent->next->prev = histent;
-	    histent = histent->next;
-	}
-	if (c == '\n') {
-	nl:
-	    tmp->len = 0;
-	    Strbuf_append1(tmp, (Char) c);
-	    Strbuf_terminate(tmp);
-	    histent->word = Strsave(tmp->s);
-	    return histent;
-	}
-    }
-    
-past:
-    switch (Stype) {
-
-    case TC_IF:
-	stderror(ERR_NAME | ERR_NOTFOUND, "then/endif");
-	break;
-
-    case TC_ELSE:
-	stderror(ERR_NAME | ERR_NOTFOUND, "endif");
-	break;
-
-    case TC_BRKSW:
-    case TC_SWITCH:
-	stderror(ERR_NAME | ERR_NOTFOUND, "endsw");
-	break;
-
-    case TC_BREAK:
-	stderror(ERR_NAME | ERR_NOTFOUND, "end");
-	break;
-
-    case TC_GOTO:
-	setname(short2str(Sgoal));
-	stderror(ERR_NAME | ERR_NOTFOUND, "label");
-	break;
-
-    default:
-	break;
-    }
-    /* NOTREACHED */
-    return NULL;
-}
-
 static int
 getword(struct Strbuf *wp)
 {
-- 
1.7.11.4