diff options
author | Joris Vink <joris@cvs.openbsd.org> | 2005-10-23 03:47:13 +0000 |
---|---|---|
committer | Joris Vink <joris@cvs.openbsd.org> | 2005-10-23 03:47:13 +0000 |
commit | 8f7d259c3835f79fa285808099d2260f67be99bb (patch) | |
tree | ca5c4982e93b6e114768339d5927aebe88bc2690 /usr.bin | |
parent | c84cf0dd8fd0bf7d99af0ef09fee438bd709eabe (diff) |
- correctly terminate buffer in edscript(), noted by pedro@
- fix patching for large files;
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/cvs/diff3.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/usr.bin/cvs/diff3.c b/usr.bin/cvs/diff3.c index 645be253d2e..3772916914e 100644 --- a/usr.bin/cvs/diff3.c +++ b/usr.bin/cvs/diff3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff3.c,v 1.1 2005/10/22 17:32:57 joris Exp $ */ +/* $OpenBSD: diff3.c,v 1.2 2005/10/23 03:47:12 joris Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -71,7 +71,7 @@ static const char copyright[] = #endif /* not lint */ #ifndef lint -static const char rcsid[] = "$OpenBSD: diff3.c,v 1.1 2005/10/22 17:32:57 joris Exp $"; +static const char rcsid[] = "$OpenBSD: diff3.c,v 1.2 2005/10/23 03:47:12 joris Exp $"; #endif /* not lint */ #include <sys/queue.h> @@ -127,7 +127,7 @@ static struct diff *d23; */ static struct diff *de; static char *overlap; -static int overlapcnt; +static int overlapcnt = 0; static FILE *fp[3]; static int cline[3]; /* # of the last-read line in each file (0-2) */ @@ -328,15 +328,20 @@ ed_patch_lines(struct cvs_lines *dlines, struct cvs_lines *plines) return (-1); } else if (op == 'c') { if ((start > dlines->l_nblines) || - (start < 0) || (*ep != ',')) + (start < 0) || ((*ep != ',') && (*ep != 'c'))) return (-1); - ep++; - end = (int)strtol(ep, &ep, 10); - if ((end < 0) || (*ep != 'c')) - return (-1); + if (*ep == ',') { + ep++; + end = (int)strtol(ep, &ep, 10); + if ((end < 0) || (*ep != 'c')) + return (-1); + } else { + end = start; + } } + for (;;) { if (dlp == NULL) break; @@ -355,12 +360,14 @@ ed_patch_lines(struct cvs_lines *dlines, struct cvs_lines *plines) if (dlp == NULL) return (-1); + if (op == 'c') { - for (i = start; i <= end; i++) { + for (i = 0; i <= (end - start); i++) { ndlp = TAILQ_NEXT(dlp, l_list); TAILQ_REMOVE(&(dlines->l_lines), dlp, l_list); dlp = ndlp; } + dlp = TAILQ_PREV(dlp, cvs_tqh, l_list); } if (op == 'a' || op == 'c') { @@ -747,7 +754,7 @@ static int edscript(int n) { int j, k; - char block[BUFSIZ]; + char block[BUFSIZ+1]; for (n = n; n > 0; n--) { if (!oflag || !overlap[n]) @@ -762,6 +769,7 @@ edscript(int n) block[j] = '\0'; diff_output("%s", block); } + if (!oflag || !overlap[n]) diff_output(".\n"); else { |