RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: [email protected] Module: rpm Date: 07-Apr-2010 16:59:30 Branch: HEAD Handle: 2010040714592901 Modified files: rpm CHANGES rpm/rpmio rpmsql.c rpm/tools dbsql.c Log: - sqlite: INTERACTIVE chrome buffing to add helpful prompt nags. Summary: Revision Changes Path 1.3308 +1 -0 rpm/CHANGES 2.9 +23 -0 rpm/rpmio/rpmsql.c 2.11 +6 -88 rpm/tools/dbsql.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/CHANGES ============================================================================ $ cvs diff -u -r1.3307 -r1.3308 CHANGES --- rpm/CHANGES 7 Apr 2010 13:37:54 -0000 1.3307 +++ rpm/CHANGES 7 Apr 2010 14:59:29 -0000 1.3308 @@ -1,5 +1,6 @@ 5.2b1 -> 5.3a1 + - jbj: sqlite: INTERACTIVE chrome buffing to add helpful prompt nags. - jbj: sqlite: haul out the construction scaffholding trash. - jbj: sqlite: return the output as the macro expansion value. - jbj: dbsql: incremental step toward the desired rpmsql object API. @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmsql.c ============================================================================ $ cvs diff -u -r2.8 -r2.9 rpmsql.c --- rpm/rpmio/rpmsql.c 7 Apr 2010 13:37:55 -0000 2.8 +++ rpm/rpmio/rpmsql.c 7 Apr 2010 14:59:29 -0000 2.9 @@ -2697,11 +2697,34 @@ /* Perform the SQL operation(s). */ if (*s == '\0') { /* INTERACTIVE */ + static int oneshot; uint32_t _flags = sql->flags; FILE * _out = sql->out; sql->flags |= RPMSQL_FLAGS_INTERACTIVE; sql->out = stdout; + if (!oneshot) { +#ifdef REFERENCE + extern char *db_full_version(int *, int *, int *, int *, int *); + fprintf(sql->out, "%s\n" + "Enter \".help\" for instructions\n" + "Enter SQL statements terminated with a \";\"\n", + db_full_version(NULL, NULL, NULL, NULL, NULL)); +#endif + fprintf(sql->out, "SQLite version %s\n\t(%s)\n" + "Enter \".help\" for instructions\n" + "Enter SQL statements terminated with a \";\"\n", + sqlite3_libversion(), sqlite3_sourceid()); +#if defined(HAVE_READLINE) && HAVE_READLINE==1 + if (sql->zHistory) + read_history(sql->zHistory); +#endif + oneshot++; + } rc = rpmsqlInput(sql, NULL); + if (sql->zHistory) { + stifle_history(100); + write_history(sql->zHistory); + } if (rc != 0) rc = RPMRC_FAIL; sql->out = _out; sql->flags = _flags; @@ . patch -p0 <<'@@ .' Index: rpm/tools/dbsql.c ============================================================================ $ cvs diff -u -r2.10 -r2.11 dbsql.c --- rpm/tools/dbsql.c 7 Apr 2010 13:37:55 -0000 2.10 +++ rpm/tools/dbsql.c 7 Apr 2010 14:59:30 -0000 2.11 @@ -25,74 +25,10 @@ #define _RPMSQL_INTERNAL #include <rpmsql.h> -/* -** Build options detected by SQLite's configure script but not normally part -** of config.h. Accept what configure detected unless it was overridden on the -** command line. -*/ -#ifndef HAVE_EDITLINE -#define HAVE_EDITLINE 0 -#endif -#if !HAVE_EDITLINE -#undef HAVE_EDITLINE -#endif - -#ifndef HAVE_READLINE -#define HAVE_READLINE 0 -#endif -#if !HAVE_READLINE -#undef HAVE_READLINE -#endif - -#ifndef SQLITE_OS_UNIX -#define SQLITE_OS_UNIX 1 -#endif -#if !SQLITE_OS_UNIX -#undef SQLITE_OS_UNIX -#endif - -#ifndef SQLITE_OS_WIN -#define SQLITE_OS_WIN 0 -#endif -#if !SQLITE_OS_WIN -#undef SQLITE_OS_WIN -#endif - -#ifndef SQLITE_THREADSAFE +#define SQLITE_OS_UNIX 1 /* XXX needed? */ #define SQLITE_THREADSAFE 1 -#endif -#if !SQLITE_THREADSAVE -#undef SQLITE_THREADSAVE -#endif - -#ifndef SQLITE_THREAD_OVERRIDE_LOCK -#define SQLITE_THREAD_OVERRIDE_LOCK -1 -#endif -#if !SQLITE_THREAD_OVERRIDE_LOCK -#undef SQLITE_THREAD_OVERRIDE_LOCK -#endif - -#ifndef SQLITE_TEMP_STORE #define SQLITE_TEMP_STORE 1 -#endif -#if !SQLITE_THREAD_OVERRIDE_LOCK -#undef SQLITE_THREAD_OVERRIDE_LOCK -#endif - -#include "sqlite3.h" - -#if defined(HAVE_EDITLINE) && HAVE_EDITLINE==1 -#include <editline/readline.h> -#elif defined(HAVE_READLINE) && HAVE_READLINE==1 -# include <readline/readline.h> -# include <readline/history.h> -#else -# define readline(p) local_getline(p,stdin) -# define add_history(X) -# define read_history(X) -# define write_history(X) -# define stifle_history(X) -#endif +#include <sqlite3.h> #include "debug.h" @@ -117,8 +53,7 @@ { int _flags = (isatty(0) ? RPMSQL_FLAGS_INTERACTIVE : 0); rpmsql sql = rpmsqlNew(argv, _flags | 0x80000000); - char *zErrMsg = NULL; - char *zFirstCmd = NULL; + const char * zFirstCmd = NULL; const char ** av = NULL; int ac; int ec = 1; /* assume error */ @@ -141,7 +76,7 @@ goto exit; } if (ac > 1) - zFirstCmd = xstrdup(av[1]); /* XXX strdup? */ + zFirstCmd = av[1]; if (sql->out == NULL) /* XXX needed? */ sql->out = stdout; @@ -156,31 +91,14 @@ ec = (int) rpmsqlRun(NULL, zFirstCmd, NULL); /* FILE | STRING */ } else { /* Run commands received from standard input */ - if (F_ISSET(sql, INTERACTIVE)) { - extern char *db_full_version(int *, int *, int *, int *, - int *); - printf("%s\n" "Enter \".help\" for instructions\n" - "Enter SQL statements terminated with a \";\"\n", - db_full_version(NULL, NULL, NULL, NULL, NULL) - ); -#if defined(HAVE_READLINE) && HAVE_READLINE==1 - if (sql->zHistory) - read_history(sql->zHistory); -#endif + if (F_ISSET(sql, INTERACTIVE)) ec = (int) rpmsqlRun(NULL, "", NULL); /* INTERACTIVE */ - if (sql->zHistory) { - stifle_history(100); - write_history(sql->zHistory); - } - } else { + else ec = (int) rpmsqlRun(NULL, "-", NULL); /* STDIN */ - } } exit: - zFirstCmd = _free(zFirstCmd); - sql = rpmsqlFree(sql); rpmioClean(); @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository [email protected]
