gnumeric r17097 - in trunk: . plugins/xbase
- From: mortenw svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r17097 - in trunk: . plugins/xbase
- Date: Mon, 26 Jan 2009 16:07:38 +0000 (UTC)
Author: mortenw
Date: Mon Jan 26 16:07:38 2009
New Revision: 17097
URL: http://svn.gnome.org/viewvc/gnumeric?rev=17097&view=rev
Log:
2009-01-26 Morten Welinder <terra gnome org>
* xbase.c (record_deleted): New function.
(record_seek): Start from beginning of record, not +1. Therefore
we will no longer depend on terminating 0x1a.
(record_get_field): Make up for record_seek change.
* boot.c (xbase_file_open): Handle deleted records.
Modified:
trunk/NEWS
trunk/plugins/xbase/ChangeLog
trunk/plugins/xbase/boot.c
trunk/plugins/xbase/xbase.c
trunk/plugins/xbase/xbase.h
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Mon Jan 26 16:07:38 2009
@@ -82,6 +82,7 @@
* Fix performance problem in dependency tracking given large
number of large ranges. [#567389]
* Fix VLOOKUP and HLOOKUP for bools.
+ * Fix problem reading slightly-corrupted dbf file. [#568454]
--------------------------------------------------------------------------
Gnumeric 1.9.3
Modified: trunk/plugins/xbase/boot.c
==============================================================================
--- trunk/plugins/xbase/boot.c (original)
+++ trunk/plugins/xbase/boot.c Mon Jan 26 16:07:38 2009
@@ -208,6 +208,9 @@
record = record_new (file);
row = 1;
do {
+ gboolean deleted = record_deleted (record);
+ if (deleted)
+ continue;
if (row >= gnm_sheet_get_max_rows (sheet)) {
/* FIXME: either we need to add new rows, if posible
or create a larger sheet*/
Modified: trunk/plugins/xbase/xbase.c
==============================================================================
--- trunk/plugins/xbase/xbase.c (original)
+++ trunk/plugins/xbase/xbase.c Mon Jan 26 16:07:38 2009
@@ -72,10 +72,10 @@
g_warning("record_seek: invalid whence (%d)", whence);
return FALSE;
}
- if (offset < 1 || offset > (int)record->file->records)
+ if (offset < 1 || offset > (gsf_off_t)record->file->records)
return FALSE;
record->row = offset;
- offset = (offset-1) * record->file->fieldlen + record->file->headerlen + 1;
+ offset = (offset-1) * record->file->fieldlen + record->file->headerlen;
return !gsf_input_seek (record->file->input, offset, G_SEEK_SET) &&
gsf_input_read (record->file->input, record->file->fieldlen, record->data) != NULL;
}
@@ -98,7 +98,13 @@
{
if (num >= record->file->fields)
return NULL;
- return (gchar *)record->data + record->file->format [num]->pos;
+ return (gchar *)record->data + record->file->format[num]->pos + 1;
+}
+
+gboolean
+record_deleted (XBrecord *record)
+{
+ return record->data[0] == 0x2a;
}
static void
@@ -200,7 +206,7 @@
g_printerr ("unknown 0x%hhx\n", hdr[0]);
}
- x->records = GSF_LE_GET_GUINT32 (hdr + 4) + 1;
+ x->records = GSF_LE_GET_GUINT32 (hdr + 4);
x->headerlen = GSF_LE_GET_GUINT16 (hdr + 8);
x->fieldlen = GSF_LE_GET_GUINT16 (hdr + 10);
#if XBASE_DEBUG > 0
Modified: trunk/plugins/xbase/xbase.h
==============================================================================
--- trunk/plugins/xbase/xbase.h (original)
+++ trunk/plugins/xbase/xbase.h Mon Jan 26 16:07:38 2009
@@ -33,6 +33,7 @@
gboolean record_seek (XBrecord *record, int whence, gsf_off_t row);
void record_free (XBrecord *record);
gchar *record_get_field (XBrecord const *record, guint num);
+gboolean record_deleted (XBrecord *record);
XBfile *xbase_open (GsfInput *input, ErrorInfo **ret_error);
void xbase_close (XBfile *file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]