[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Cvs-cvs] ccvs/src ChangeLog rcs.c [cvs1-11-x-branch]
From: |
Derek Robert Price |
Subject: |
[Cvs-cvs] ccvs/src ChangeLog rcs.c [cvs1-11-x-branch] |
Date: |
Fri, 08 Sep 2006 13:24:34 +0000 |
CVSROOT: /cvsroot/cvs
Module name: ccvs
Branch: cvs1-11-x-branch
Changes by: Derek Robert Price <dprice> 06/09/08 13:24:34
Modified files:
src : ChangeLog rcs.c
Log message:
Merge changes from trunk.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/ChangeLog?cvsroot=cvs&only_with_tag=cvs1-11-x-branch&r1=1.2336.2.474&r2=1.2336.2.475
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/rcs.c?cvsroot=cvs&only_with_tag=cvs1-11-x-branch&r1=1.262.4.57&r2=1.262.4.58
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/ChangeLog,v
retrieving revision 1.2336.2.474
retrieving revision 1.2336.2.475
diff -u -b -r1.2336.2.474 -r1.2336.2.475
--- ChangeLog 7 Sep 2006 00:58:54 -0000 1.2336.2.474
+++ ChangeLog 8 Sep 2006 13:24:34 -0000 1.2336.2.475
@@ -1,3 +1,9 @@
+2006-09-07 Derek Price <address@hidden>
+
+ [bug #17560]
+ * rcs.c (apply_rcs_changes): Improve comments. Restore repaired error
+ handling.
+
2006-09-06 Larry Jones <address@hidden>
* rcs.c (apply_rcs_changes): Improve linked list handling. Remove
Index: rcs.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/rcs.c,v
retrieving revision 1.262.4.57
retrieving revision 1.262.4.58
diff -u -b -r1.262.4.57 -r1.262.4.58
--- rcs.c 7 Sep 2006 00:58:55 -0000 1.262.4.57
+++ rcs.c 8 Sep 2006 13:24:34 -0000 1.262.4.58
@@ -7086,12 +7086,11 @@
* the VERS field of deleted lines is unchanged.
*
* RETURNS
- * Non-zero if the change text is applied successfully to LINES.
+ * Non-zero if the change text is applied successfully to ORIG_LINES.
*
- * If the change text does not appear to apply to LINES (e.g., a
- * line number is invalid), this function will return zero and LINES
- * will be in an undefined state (though refcounts and such will be
- * preserved for garbage collection).
+ * If the change text does not appear to apply to ORIG_LINES (e.g., a
+ * line number is invalid), this function will return zero and ORIG_LINES
+ * will remain unmolested.
*
* ERRORS
* If the change text is improperly formatted (e.g., it is not the output
@@ -7126,6 +7125,7 @@
struct deltafrag *df;
unsigned long numlines, lastmodline, offset;
struct linevector lines;
+ int err;
dfhead = NULL;
dftail = &dfhead;
@@ -7207,16 +7207,24 @@
/* offset created when adding/removing lines
between new and original structure */
offset = 0;
-
+ err = 0;
for (df = dfhead; df != NULL; )
{
unsigned int ln;
unsigned long deltaend;
+ if (df->pos > orig_lines->nlines)
+ err = 1;
+
+ /* On error, just free the rest of the list. */
+ if (!err)
+ {
/* Here we need to get to the line where the next insert will
- begin which is <df->pos> we will fill up to df->pos with
- original items. */
- for (deltaend = df->pos - offset; lastmodline < deltaend; lastmodline++)
+ begin, which is DF->pos in ORIG_LINES. We will fill up to
+ DF->pos - OFFSET in LINES with original items. */
+ for (deltaend = df->pos - offset;
+ lastmodline < deltaend;
+ lastmodline++)
{
/* we need to copy from the orig structure into new one */
lines.vector[lastmodline] =
@@ -7285,31 +7293,41 @@
/* we are removing this many lines from the source. */
offset += df->nlines;
- if (df->pos > orig_lines->nlines
- || df->pos + df->nlines > orig_lines->nlines)
- return 0;
- if (delvers != NULL)
+ if (df->pos + df->nlines > orig_lines->nlines)
+ err = 1;
+ else if (delvers)
for (ln = df->pos; ln < df->pos + df->nlines; ++ln)
- {
- if (--orig_lines->vector[ln]->refcount == 0)
- free (orig_lines->vector[ln]);
- else
+ if (orig_lines->vector[ln]->refcount > 1)
+ /* Annotate needs this but, since the original
+ * vector is disposed of before returning from
+ * this function, we only need keep track if
+ * there are multiple references.
+ */
orig_lines->vector[ln]->vers = delvers;
- orig_lines->vector[ln] = NULL;
- }
break;
}
+ }
df = df->next;
free (dfhead);
dfhead = df;
}
+ if (err)
+ {
+ /* No reason to try and move a half-mutated and known invalid
+ * text into the output buffer.
+ */
+ linevector_free (&lines);
+ }
+ else
+ {
/* add the rest of the remaining lines to the data vector */
for (; lastmodline < numlines; lastmodline++)
{
/* we need to copy from the orig structure into new one */
- lines.vector[lastmodline] = orig_lines->vector[lastmodline + offset];
+ lines.vector[lastmodline] = orig_lines->vector[lastmodline
+ + offset];
lines.vector[lastmodline]->refcount++;
}
@@ -7320,8 +7338,9 @@
orig_lines->vector = lines.vector;
orig_lines->lines_alloced = numlines;
orig_lines->nlines = lines.nlines;
+ }
- return 1;
+ return !err;
}
/* Apply an RCS change text to a buffer. The function name starts