Suggestion for Changes in the last dowloadable build version pgdbf-0.6.2

60 views
Skip to first unread message

Stephan Kasdorf

unread,
Dec 21, 2017, 2:27:52 AM12/21/17
to PgDBF
Hi Philipp,

first of all thanks for that fantastic peace of code to Kirk, very nice job and a great distribution to the new IT world, it really is almost perfect. I encounted that if one field is set to autoindex ( auto incremented ) it does not get through this check:

332     if(dbfheader.signature == 0x30) {
333         /* Certain Visual FoxPro files have an (empty?) 263-byte buffer
334          * after the header information.  Take that into account when
335          * calculating field counts and possibly seeking over it later. */
336         skipbytes = 263;
337     } else {
338         skipbytes = 0;
339     }

because the signature code would be 0x31 ( same goes for 0x32 ) a old VisualFoxPro expert told me, so I ran a little test by changing that line 332 to, because in both
cases the length would be the same and can be handled the same

332     if((dbfheader.signature == 0x30) || (dbfheader.signature == 0x31) || (dbfheader.signature == 0x32)) {
333         /* Certain Visual FoxPro files have an (empty?) 263-byte buffer
334          * after the header information.  Take that into account when
335          * calculating field counts and possibly seeking over it later. */
336         skipbytes = 263;
337     } else {
338         skipbytes = 0;
339     }

On the next try after compliing I figured out that it was not an issue to import autoindexed ( auto incremented ) files anymore, and after checking it turned out that all data converted was valid too.
So I went on and checked the next part since I encountered that I could not import dbf files that had Varchar fields in it. So I ran through the code again and found this:

538         case 'C':
539             if(optusecreatetable) printf("VARCHAR(%d)", fields[fieldnum].length);
540             break;
541         case 'D':

since the field type Varchar is simulated in VisualFoxPro by a Character field, I just added this case condition:

538         case 'C':
539         case 'V':
540             if(optusecreatetable) printf("VARCHAR(%d)", fields[fieldnum].length);
541             break;

My request, do those changes make sense, and can I keep them like this, will they be added ( which would be really nice )?

Thanks,
Stephan

Philipp Wollermann

unread,
Jan 5, 2018, 6:40:07 AM1/5/18
to Stephan Kasdorf, PgDBF
Hi Stephan,

sorry for taking so long to reply! Thanks for your contributions.

Kirk would be the one who can apply your patch and add it to the main version of pgdbf, but I haven't heard from him in a while - not sure if he's busy with his other work at the moment.

I think your changes look good. I'm not an expert on the actual file format, but it seems like you did some good research and also tested your changes with real data, so that's great. :)

Would you mind sending your patch as a pull request on GitHub? That way it will not be lost, Kirk can eventually merge it and others who have the same problem can just patch it in themselves.

Thanks again,
Philipp


--
You received this message because you are subscribed to the Google Groups "PgDBF" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pgdbf+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages