mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-04-05 20:31:00 +08:00
Fix bug in read_pg_if_n
This commit is contained in:
parent
402e6be097
commit
2a6d21ce6d
@ -1,3 +1,6 @@
|
||||
Fri Jun 11 16:56:06 CDT 200 Jeff Smith <whydoubt@yahoo.com>
|
||||
* src/libmdb/table.c: Fix bug in read_pg_if_n
|
||||
|
||||
Fri Jun 11 08:52:14 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
|
||||
* src/libmdb/data.c:
|
||||
* src/libmdb/backend.c:
|
||||
|
@ -142,18 +142,17 @@ read_pg_if_16(MdbHandle *mdb, int *cur_pos)
|
||||
guint16
|
||||
read_pg_if_n(MdbHandle *mdb, unsigned char *buf, int *cur_pos, int len)
|
||||
{
|
||||
int half;
|
||||
|
||||
if (*cur_pos + len < mdb->fmt->pg_size) {
|
||||
memcpy(buf, &mdb->pg_buf[*cur_pos], len);
|
||||
return 0;
|
||||
} else {
|
||||
int half = mdb->fmt->pg_size - *cur_pos;
|
||||
memcpy(buf, &mdb->pg_buf[*cur_pos], half);
|
||||
mdb_read_pg(mdb, mdb_pg_get_int32(mdb,4));
|
||||
memcpy(buf + half, &mdb->pg_buf[8], len - half);
|
||||
*cur_pos = 8 - half;
|
||||
return 1;
|
||||
}
|
||||
half = (mdb->fmt->pg_size - *cur_pos - 1);
|
||||
memcpy(buf, &mdb->pg_buf[*cur_pos], half);
|
||||
mdb_read_pg(mdb, mdb_pg_get_int32(mdb,4));
|
||||
memcpy(buf, &mdb->pg_buf[8], len - half);
|
||||
*cur_pos = 8 - (mdb->fmt->pg_size - (*cur_pos));
|
||||
return 1;
|
||||
}
|
||||
|
||||
GPtrArray *mdb_read_columns(MdbTableDef *table)
|
||||
@ -187,7 +186,7 @@ GPtrArray *mdb_read_columns(MdbTableDef *table)
|
||||
read_pg_if(mdb, &cur_col, 0);
|
||||
col.col_type = mdb->pg_buf[cur_col];
|
||||
|
||||
read_pg_if(mdb, &cur_col, cur_col + fmt->col_num_offset); // col_num_offset == 1 or 5
|
||||
read_pg_if(mdb, &cur_col, fmt->col_num_offset); // col_num_offset == 1 or 5
|
||||
col.col_num = mdb->pg_buf[cur_col + fmt->col_num_offset];
|
||||
|
||||
//fprintf(stdout,"----- column %d -----\n",col.col_num);
|
||||
|
Loading…
Reference in New Issue
Block a user