mdb-sql: Handle ';' as terminators in SQL input files

This commit is contained in:
James Woodcock 2020-09-19 11:28:44 +01:00
parent 9c8b67b8f8
commit eab60a6060

View File

@ -443,15 +443,16 @@ main(int argc, char **argv)
if (s) free(s); if (s) free(s);
if (in) { if (in) {
s=malloc(256); s=malloc(bufsz);
if ((!s) || (!fgets(s, 256, in))) { if (!fgets(s, bufsz, in)) {
/* if we have something in the buffer, run it */ // Backwards compatibility with older MDBTools
// Files read from the command line had an
// implicit "go" at the end
if (strlen(mybuf)) if (strlen(mybuf))
run_query((out) ? out : stdout, strcpy(s, "go");
sql, mybuf, delimiter); else
break; break;
} } else if (s[strlen(s)-1]=='\n')
if (s[strlen(s)-1]=='\n')
s[strlen(s)-1]=0; s[strlen(s)-1]=0;
} else { } else {
sprintf(prompt, "%d => ", line); sprintf(prompt, "%d => ", line);
@ -483,8 +484,8 @@ main(int argc, char **argv)
mybuf = (char *) g_realloc(mybuf, bufsz); mybuf = (char *) g_realloc(mybuf, bufsz);
} }
#ifdef HAVE_READLINE_HISTORY #ifdef HAVE_READLINE_HISTORY
/* don't record blank lines */ /* don't record blank lines, or lines read from files */
if (strlen(s)) add_history(s); if (!in && strlen(s)) add_history(s);
#endif #endif
strcat(mybuf,s); strcat(mybuf,s);
/* preserve line numbering for the parser */ /* preserve line numbering for the parser */