Deleted Added
full compact
glbl.c (67183) glbl.c (81220)
1/* glob.c: This file contains the global command routines for the ed line
2 editor */
3/*-
4 * Copyright (c) 1993 Andrew Moore, Talke Studio.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 13 unchanged lines hidden (view full) ---

22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef lint
1/* glob.c: This file contains the global command routines for the ed line
2 editor */
3/*-
4 * Copyright (c) 1993 Andrew Moore, Talke Studio.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 13 unchanged lines hidden (view full) ---

22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef lint
30#if 0
31static char * const rcsid = "@(#)glob.c,v 1.1 1994/02/01 00:34:40 alm Exp";
32#else
33static char * const rcsid =
34 "$FreeBSD: head/bin/ed/glbl.c 67183 2000-10-16 07:11:30Z brian $";
35#endif
30static const char rcsid[] =
31 "$FreeBSD: head/bin/ed/glbl.c 81220 2001-08-06 22:01:31Z mike $";
36#endif /* not lint */
37
38#include <sys/types.h>
39
40#include <sys/ioctl.h>
41#include <sys/wait.h>
42
43#include "ed.h"

--- 6 unchanged lines hidden (view full) ---

50{
51 pattern_t *pat;
52 line_t *lp;
53 long n;
54 char *s;
55 char delimiter;
56
57 if ((delimiter = *ibufp) == ' ' || delimiter == '\n') {
32#endif /* not lint */
33
34#include <sys/types.h>
35
36#include <sys/ioctl.h>
37#include <sys/wait.h>
38
39#include "ed.h"

--- 6 unchanged lines hidden (view full) ---

46{
47 pattern_t *pat;
48 line_t *lp;
49 long n;
50 char *s;
51 char delimiter;
52
53 if ((delimiter = *ibufp) == ' ' || delimiter == '\n') {
58 sprintf(errmsg, "invalid pattern delimiter");
54 errmsg = "invalid pattern delimiter";
59 return ERR;
60 } else if ((pat = get_compiled_pattern()) == NULL)
61 return ERR;
62 else if (*ibufp == delimiter)
63 ibufp++;
64 clear_active_list();
65 lp = get_addressed_line_node(first_addr);
66 for (n = first_addr; n <= second_addr; n++, lp = lp->q_forw) {

--- 43 unchanged lines hidden (view full) ---

110 if (display_lines(current_addr, current_addr, gflag) < 0)
111 return ERR;
112 while ((n = get_tty_line()) > 0 &&
113 ibuf[n - 1] != '\n')
114 clearerr(stdin);
115 if (n < 0)
116 return ERR;
117 else if (n == 0) {
55 return ERR;
56 } else if ((pat = get_compiled_pattern()) == NULL)
57 return ERR;
58 else if (*ibufp == delimiter)
59 ibufp++;
60 clear_active_list();
61 lp = get_addressed_line_node(first_addr);
62 for (n = first_addr; n <= second_addr; n++, lp = lp->q_forw) {

--- 43 unchanged lines hidden (view full) ---

106 if (display_lines(current_addr, current_addr, gflag) < 0)
107 return ERR;
108 while ((n = get_tty_line()) > 0 &&
109 ibuf[n - 1] != '\n')
110 clearerr(stdin);
111 if (n < 0)
112 return ERR;
113 else if (n == 0) {
118 sprintf(errmsg, "unexpected end-of-file");
114 errmsg = "unexpected end-of-file";
119 return ERR;
120 } else if (n == 1 && !strcmp(ibuf, "\n"))
121 continue;
122 else if (n == 2 && !strcmp(ibuf, "&\n")) {
123 if (cmd == NULL) {
115 return ERR;
116 } else if (n == 1 && !strcmp(ibuf, "\n"))
117 continue;
118 else if (n == 2 && !strcmp(ibuf, "&\n")) {
119 if (cmd == NULL) {
124 sprintf(errmsg, "no previous command");
120 errmsg = "no previous command";
125 return ERR;
126 } else cmd = ocmd;
127 } else if ((cmd = get_extended_line(&n, 0)) == NULL)
128 return ERR;
129 else {
130 REALLOC(ocmd, ocmdsz, n + 1, ERR);
131 memcpy(ocmd, cmd, n + 1);
132 cmd = ocmd;

--- 28 unchanged lines hidden (view full) ---

161 line_t **ts;
162 SPL1();
163#if defined(sun) || defined(NO_REALLOC_NULL)
164 if (active_list != NULL) {
165#endif
166 if ((ts = (line_t **) realloc(active_list,
167 (ti += MINBUFSZ) * sizeof(line_t **))) == NULL) {
168 fprintf(stderr, "%s\n", strerror(errno));
121 return ERR;
122 } else cmd = ocmd;
123 } else if ((cmd = get_extended_line(&n, 0)) == NULL)
124 return ERR;
125 else {
126 REALLOC(ocmd, ocmdsz, n + 1, ERR);
127 memcpy(ocmd, cmd, n + 1);
128 cmd = ocmd;

--- 28 unchanged lines hidden (view full) ---

157 line_t **ts;
158 SPL1();
159#if defined(sun) || defined(NO_REALLOC_NULL)
160 if (active_list != NULL) {
161#endif
162 if ((ts = (line_t **) realloc(active_list,
163 (ti += MINBUFSZ) * sizeof(line_t **))) == NULL) {
164 fprintf(stderr, "%s\n", strerror(errno));
169 sprintf(errmsg, "out of memory");
165 errmsg = "out of memory";
170 SPL0();
171 return ERR;
172 }
173#if defined(sun) || defined(NO_REALLOC_NULL)
174 } else {
175 if ((ts = (line_t **) malloc((ti += MINBUFSZ) *
176 sizeof(line_t **))) == NULL) {
177 fprintf(stderr, "%s\n", strerror(errno));
166 SPL0();
167 return ERR;
168 }
169#if defined(sun) || defined(NO_REALLOC_NULL)
170 } else {
171 if ((ts = (line_t **) malloc((ti += MINBUFSZ) *
172 sizeof(line_t **))) == NULL) {
173 fprintf(stderr, "%s\n", strerror(errno));
178 sprintf(errmsg, "out of memory");
174 errmsg = "out of memory";
179 SPL0();
180 return ERR;
181 }
182 }
183#endif
184 active_size = ti;
185 active_list = ts;
186 SPL0();

--- 44 unchanged lines hidden ---
175 SPL0();
176 return ERR;
177 }
178 }
179#endif
180 active_size = ti;
181 active_list = ts;
182 SPL0();

--- 44 unchanged lines hidden ---