Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions sqlite3-dbf.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,7 @@ int main(int argc, char **argv)
}
break;
case 'N':
/* Was a numeric at one point, but for our purposes a text field
* is better because there isn't a perfect overlap between
* FoxPro and PostgreSQL numeric types */
printf("TEXT");
printf("NUMERIC(%d, %d)", fields[fieldnum].length, fields[fieldnum].decimals);
break;
case 'T':
printf("TIMESTAMP");
Expand Down Expand Up @@ -395,7 +392,7 @@ int main(int argc, char **argv)
case 'D':
/* Datestamps */
if(bufoffset[0] == ' ' || bufoffset[0] == '\0') {
printf("'\\N'");
printf("NULL");
} else {
s = outputbuffer;
*s++ = bufoffset[0];
Expand Down Expand Up @@ -472,17 +469,17 @@ int main(int argc, char **argv)
s++;
}
if(*s == '\0') {
printf("'\\N'");
printf("NULL");
} else {
printf("'%s'", s);
printf("%s", s);
}
break;
case 'T':
/* Timestamps */
juliandays = slittleint32_t(bufoffset);
seconds = (slittleint32_t(bufoffset + 4) + 1) / 1000;
if(!(juliandays || seconds)) {
printf("'\\N'");
printf("NULL");
} else {
hours = seconds / 3600;
seconds -= hours * 3600;
Expand Down
4 changes: 4 additions & 0 deletions sqlite3-dbf.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ static void safeprintbuf(const char *buf, const size_t inputsize)
t = targetbuf;
for(s = buf; s <= lastchar; s++) {
switch(*s) {
case '\'':
*t++ = '\'';
*t++ = '\'';
break;
case '\\':
*t++ = '\\';
*t++ = '\\';
Expand Down