mirror of
https://github.com/mdbtools/mdbtools.git
synced 2026-03-10 00:20:54 +08:00
Merge branch 'dev' of github.com:mdbtools/mdbtools into dev
This commit is contained in:
@@ -20,7 +20,7 @@ OPTIONS
|
||||
-q, --quote char Use to wrap text-like fields. Default is " (double quote).
|
||||
-X, --escape char Use to escape quoted characters within a field. Default is doubling.
|
||||
-N, --namespace prefix Prefix identifiers with prefix.
|
||||
-b --bin strip|raw|octal|hex Binary export mode: strip binaries, export as-is, output \ooo style octal data or output \xx style hexadecimal data.
|
||||
-b, --bin strip|raw|octal|hex Binary export mode: strip binaries, export as-is, output \ooo style octal data or output \xx style hexadecimal data.
|
||||
|
||||
NOTES
|
||||
|
||||
|
||||
@@ -161,12 +161,26 @@ MdbHandle *mdb_sql_open(MdbSQL *sql, char *db_name)
|
||||
|
||||
#ifdef HAVE_WORDEXP
|
||||
wordexp_t words;
|
||||
int need_free_words = 0;
|
||||
|
||||
if (wordexp(db_name, &words, 0)==0) {
|
||||
if (words.we_wordc>0)
|
||||
db_namep = words.we_wordv[0];
|
||||
switch (wordexp(db_name, &words, 0))
|
||||
{
|
||||
case 0:
|
||||
if (words.we_wordc>0)
|
||||
{
|
||||
db_namep = words.we_wordv[0];
|
||||
}
|
||||
need_free_words = 1;
|
||||
break;
|
||||
case WRDE_NOSPACE:
|
||||
// If the error was WRDE_NOSPACE, then perhaps part of the result was allocated.
|
||||
need_free_words = 1;
|
||||
break;
|
||||
default:
|
||||
// Some other error
|
||||
need_free_words = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
sql->mdb = mdb_open(db_namep, MDB_NOFLAGS);
|
||||
@@ -180,7 +194,10 @@ MdbHandle *mdb_sql_open(MdbSQL *sql, char *db_name)
|
||||
}
|
||||
|
||||
#ifdef HAVE_WORDEXP
|
||||
wordfree(&words);
|
||||
if ( need_free_words )
|
||||
{
|
||||
wordfree(&words);
|
||||
}
|
||||
#endif
|
||||
|
||||
return sql->mdb;
|
||||
|
||||
@@ -89,7 +89,7 @@ int main (int argc, char **argv) {
|
||||
fprintf (stderr, "Usage: %s [options] <database filename> <query name>\n",argv[0]);
|
||||
fprintf (stderr, "where options are:\n");
|
||||
fprintf (stderr, " -L\t\t\tList queries in the database (default if no query name is passed)\n");
|
||||
fprintf (stderr, " -1\t\t\tUse newline as the delimiter (used in conjuction with listing)\n");
|
||||
fprintf (stderr, " -1\t\t\tUse newline as the delimiter (used in conjunction with listing)\n");
|
||||
fprintf (stderr, " -d <delimiter>\tSpecify delimiter to use\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user