[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Cvs-cvs] ccvs/src ChangeLog rcs.c
From: |
Derek Robert Price |
Subject: |
[Cvs-cvs] ccvs/src ChangeLog rcs.c |
Date: |
Thu, 07 Sep 2006 19:45:07 +0000 |
CVSROOT: /cvsroot/cvs
Module name: ccvs
Changes by: Derek Robert Price <dprice> 06/09/07 19:45:06
Modified files:
src : ChangeLog rcs.c
Log message:
[bug #17560]
* rcs.c (apply_rcs_changes): Improve comments. Restore repaired error
handling.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/ChangeLog?cvsroot=cvs&r1=1.3494&r2=1.3495
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/rcs.c?cvsroot=cvs&r1=1.380&r2=1.381
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/ChangeLog,v
retrieving revision 1.3494
retrieving revision 1.3495
diff -u -b -r1.3494 -r1.3495
--- ChangeLog 6 Sep 2006 22:10:15 -0000 1.3494
+++ ChangeLog 7 Sep 2006 19:45:06 -0000 1.3495
@@ -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.380
retrieving revision 1.381
diff -u -b -r1.380 -r1.381
--- rcs.c 6 Sep 2006 22:10:15 -0000 1.380
+++ rcs.c 7 Sep 2006 19:45:06 -0000 1.381
@@ -7398,10 +7398,10 @@
* 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
+ * 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 be in an undefined state (though refcounts and such will be
* preserved for garbage collection).
*
@@ -7434,6 +7434,7 @@
struct deltafrag *df;
unsigned long numlines, lastmodline, offset;
struct linevector lines;
+ int err;
dfhead = NULL;
dftail = &dfhead;
@@ -7515,16 +7516,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] =
@@ -7593,31 +7602,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++;
}
@@ -7628,8 +7647,9 @@
orig_lines->vector = lines.vector;
orig_lines->lines_alloced = numlines;
orig_lines->nlines = lines.nlines;
+ }
- return 1;
+ return !err;
}