Commit ce355304 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-9885 Client doesn't start if 'TERM' unknown

1. don't exit if setupterm() failed
2. don't use vidattr() if setupterm() failed
parent 95fe71af
...@@ -95,9 +95,16 @@ extern "C" { ...@@ -95,9 +95,16 @@ extern "C" {
#endif #endif
} }
#if !defined(HAVE_VIDATTR) #ifdef HAVE_VIDATTR
#undef vidattr static int have_curses= 0;
#define vidattr(A) {} // Can't get this to work static void my_vidattr(chtype attrs)
{
if (have_curses)
vidattr(attrs);
}
#else
#undef HAVE_SETUPTERM
#define my_vidattr(A) {} // Can't get this to work
#endif #endif
#ifdef FN_NO_CASE_SENSE #ifdef FN_NO_CASE_SENSE
...@@ -4726,9 +4733,9 @@ com_status(String *buffer __attribute__((unused)), ...@@ -4726,9 +4733,9 @@ com_status(String *buffer __attribute__((unused)),
if (skip_updates) if (skip_updates)
{ {
vidattr(A_BOLD); my_vidattr(A_BOLD);
tee_fprintf(stdout, "\nAll updates ignored to this database\n"); tee_fprintf(stdout, "\nAll updates ignored to this database\n");
vidattr(A_NORMAL); my_vidattr(A_NORMAL);
} }
#ifdef USE_POPEN #ifdef USE_POPEN
tee_fprintf(stdout, "Current pager:\t\t%s\n", pager); tee_fprintf(stdout, "Current pager:\t\t%s\n", pager);
...@@ -4796,9 +4803,9 @@ com_status(String *buffer __attribute__((unused)), ...@@ -4796,9 +4803,9 @@ com_status(String *buffer __attribute__((unused)),
} }
if (safe_updates) if (safe_updates)
{ {
vidattr(A_BOLD); my_vidattr(A_BOLD);
tee_fprintf(stdout, "\nNote that you are running in safe_update_mode:\n"); tee_fprintf(stdout, "\nNote that you are running in safe_update_mode:\n");
vidattr(A_NORMAL); my_vidattr(A_NORMAL);
tee_fprintf(stdout, "\ tee_fprintf(stdout, "\
UPDATEs and DELETEs that don't use a key in the WHERE clause are not allowed.\n\ UPDATEs and DELETEs that don't use a key in the WHERE clause are not allowed.\n\
(One can force an UPDATE/DELETE by adding LIMIT # at the end of the command.)\n\ (One can force an UPDATE/DELETE by adding LIMIT # at the end of the command.)\n\
...@@ -4891,9 +4898,10 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate) ...@@ -4891,9 +4898,10 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate)
{ {
if (!inited) if (!inited)
{ {
int errret;
inited=1; inited=1;
#ifdef HAVE_SETUPTERM #ifdef HAVE_SETUPTERM
(void) setupterm((char *)0, 1, (int *) 0); have_curses= setupterm((char *)0, 1, &errret) != ERR;
#endif #endif
} }
if (info_type == INFO_ERROR) if (info_type == INFO_ERROR)
...@@ -4906,7 +4914,7 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate) ...@@ -4906,7 +4914,7 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate)
putchar('\a'); /* This should make a bell */ putchar('\a'); /* This should make a bell */
#endif #endif
} }
vidattr(A_STANDOUT); my_vidattr(A_STANDOUT);
if (error) if (error)
{ {
if (sqlstate) if (sqlstate)
...@@ -4925,9 +4933,9 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate) ...@@ -4925,9 +4933,9 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate)
tee_fputs(": ", file); tee_fputs(": ", file);
} }
else else
vidattr(A_BOLD); my_vidattr(A_BOLD);
(void) tee_puts(str, file); (void) tee_puts(str, file);
vidattr(A_NORMAL); my_vidattr(A_NORMAL);
} }
if (unbuffered) if (unbuffered)
fflush(file); fflush(file);
......
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