mirror of
https://github.com/mdbtools/mdbtools.git
synced 2026-03-10 00:20:54 +08:00
Fix bug in column name ordering
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
Mon Jun 14 22:52:00 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
|
||||||
|
* src/libmdb/table.c: Fix bug in column name ordering
|
||||||
|
|
||||||
Mon Jun 14 07:12:37 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
|
Mon Jun 14 07:12:37 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
|
||||||
* src/libmdb/table.c: Make better use of read_pg_if_n
|
* src/libmdb/table.c: Make better use of read_pg_if_n
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static gint mdb_col_comparer(MdbColumn *a, MdbColumn *b)
|
static gint mdb_col_comparer(MdbColumn **a, MdbColumn **b)
|
||||||
{
|
{
|
||||||
if (a->col_num > b->col_num)
|
if ((*a)->col_num > (*b)->col_num)
|
||||||
return 1;
|
return 1;
|
||||||
else if (a->col_num < b->col_num)
|
else if ((*a)->col_num < (*b)->col_num)
|
||||||
return -1;
|
return -1;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
@@ -162,7 +162,6 @@ GPtrArray *mdb_read_columns(MdbTableDef *table)
|
|||||||
MdbColumn *pcol;
|
MdbColumn *pcol;
|
||||||
unsigned char *col;
|
unsigned char *col;
|
||||||
int i, cur_pos, name_sz;
|
int i, cur_pos, name_sz;
|
||||||
GSList *slist = NULL;
|
|
||||||
|
|
||||||
table->columns = g_ptr_array_new();
|
table->columns = g_ptr_array_new();
|
||||||
|
|
||||||
@@ -220,17 +219,16 @@ GPtrArray *mdb_read_columns(MdbTableDef *table)
|
|||||||
pcol->col_size=0;
|
pcol->col_size=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
slist = g_slist_insert_sorted(slist,pcol,(GCompareFunc)mdb_col_comparer);
|
g_ptr_array_add(table->columns, pcol);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (col);
|
g_free (col);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** column names
|
** column names - ordered the same as the column attributes table
|
||||||
*/
|
*/
|
||||||
for (i=0;i<table->num_cols;i++) {
|
for (i=0;i<table->num_cols;i++) {
|
||||||
/* fetch the column */
|
pcol = g_ptr_array_index(table->columns, i);
|
||||||
pcol = g_slist_nth_data (slist, i);
|
|
||||||
|
|
||||||
if (IS_JET4(mdb)) {
|
if (IS_JET4(mdb)) {
|
||||||
char *tmp_buf;
|
char *tmp_buf;
|
||||||
@@ -252,13 +250,9 @@ GPtrArray *mdb_read_columns(MdbTableDef *table)
|
|||||||
fprintf(stderr,"Unknown MDB version\n");
|
fprintf(stderr,"Unknown MDB version\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* turn this list into an array */
|
|
||||||
for (i=0;i<table->num_cols;i++) {
|
|
||||||
pcol = g_slist_nth_data (slist, i);
|
|
||||||
g_ptr_array_add(table->columns, pcol);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_slist_free(slist);
|
/* Sort the columns by col_num */
|
||||||
|
g_ptr_array_sort(table->columns, (GCompareFunc)mdb_col_comparer);
|
||||||
|
|
||||||
table->index_start = cur_pos;
|
table->index_start = cur_pos;
|
||||||
return table->columns;
|
return table->columns;
|
||||||
|
|||||||
Reference in New Issue
Block a user