Commit 1ff9e7fd authored by bell@sanja.is.com.ua's avatar bell@sanja.is.com.ua

Merge sanja.is.com.ua:/home/bell/mysql/mysql-4.1

into sanja.is.com.ua:/home/bell/mysql/work-row-4.1
parents d0f14e0d f666bfcc
...@@ -96,4 +96,5 @@ wax@mysql.com ...@@ -96,4 +96,5 @@ wax@mysql.com
worm@altair.is.lan worm@altair.is.lan
zak@balfor.local zak@balfor.local
zak@linux.local zak@linux.local
zak@mysql.com
zgreant@mysql.com zgreant@mysql.com
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#include <signal.h> #include <signal.h>
#include <violite.h> #include <violite.h>
const char *VER= "13.0"; const char *VER= "13.1";
/* Don't try to make a nice table if the data is too big */ /* Don't try to make a nice table if the data is too big */
#define MAX_COLUMN_LENGTH 1024 #define MAX_COLUMN_LENGTH 1024
...@@ -195,6 +195,7 @@ static void end_pager(); ...@@ -195,6 +195,7 @@ static void end_pager();
static int init_tee(char *); static int init_tee(char *);
static void end_tee(); static void end_tee();
static const char* construct_prompt(); static const char* construct_prompt();
static char *get_arg(char *line);
static void init_username(); static void init_username();
static void add_int_to_prompt(int toadd); static void add_int_to_prompt(int toadd);
...@@ -2313,18 +2314,14 @@ com_use(String *buffer __attribute__((unused)), char *line) ...@@ -2313,18 +2314,14 @@ com_use(String *buffer __attribute__((unused)), char *line)
char *tmp; char *tmp;
char buff[256]; char buff[256];
while (my_isspace(system_charset_info,*line)) strmov(buff, line);
line++; tmp= get_arg(buff);
strnmov(buff,line,sizeof(buff)-1); // Don't destroy history if (!tmp || !*tmp)
if (buff[0] == '\\') // Short command
buff[1]=' ';
tmp=(char *) strtok(buff," \t;"); // Skip connect command
if (!tmp || !(tmp=(char *) strtok(NullS," \t;")))
{ {
put_info("USE must be followed by a database name",INFO_ERROR); put_info("USE must be followed by a database name", INFO_ERROR);
return 0; return 0;
} }
if (!current_db || cmp_database(current_db,tmp)) if (!current_db || cmp_database(current_db, tmp))
{ {
if (one_database) if (one_database)
skip_updates= 1; skip_updates= 1;
...@@ -2360,6 +2357,62 @@ com_use(String *buffer __attribute__((unused)), char *line) ...@@ -2360,6 +2357,62 @@ com_use(String *buffer __attribute__((unused)), char *line)
} }
enum quote_type { NO_QUOTE, SQUOTE, DQUOTE, BTICK };
char *get_arg(char *line)
{
char *ptr;
my_bool quoted= 0, valid_arg= 0;
uint count= 0;
enum quote_type qtype= NO_QUOTE;
ptr= line;
/* skip leading white spaces */
while (my_isspace(system_charset_info, *ptr))
ptr++;
if (*ptr == '\\') // short command was used
ptr+= 2;
while (!my_isspace(system_charset_info, *ptr)) // skip command
ptr++;
while (my_isspace(system_charset_info, *ptr))
ptr++;
if ((*ptr == '\'' && (qtype= SQUOTE)) ||
(*ptr == '\"' && (qtype= DQUOTE)) ||
(*ptr == '`' && (qtype= BTICK)))
{
quoted= 1;
ptr++;
}
for (; ptr && *ptr; ptr++, count++)
{
if (*ptr == '\\') // escaped character
{
// jump over the backslash
char *tmp_ptr, tmp_buff[256];
tmp_ptr= strmov(tmp_buff, (ptr - count));
tmp_ptr-= (strlen(tmp_buff) - count);
strmov(tmp_ptr, (ptr + 1));
strmov(line, tmp_buff);
ptr= line;
ptr+= count;
}
else if (!quoted && *ptr == ' ')
*(ptr + 1) = 0;
else if ((*ptr == '\'' && qtype == SQUOTE) ||
(*ptr == '\"' && qtype == DQUOTE) ||
(*ptr == '`' && qtype == BTICK))
{
*ptr= 0;
break;
}
}
for (ptr-= count; ptr && *ptr; ptr++)
if (!my_isspace(system_charset_info, *ptr))
valid_arg= 1;
return valid_arg ? ptr - count : '\0';
}
static int static int
sql_real_connect(char *host,char *database,char *user,char *password, sql_real_connect(char *host,char *database,char *user,char *password,
uint silent) uint silent)
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment