mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 12:32:27 +01:00
aeaf3fcf12
Safer, a bit faster filesort. Code changes to avoid calls to current_thd() (faster code). Removed all compiler warnings from readline. BitKeeper/etc/ignore: Add my_global.h back. Docs/manual.texi: 4.0.1 Changelog include/my_sys.h: Added strmake_root libmysql/libmysql.c: Don't do signal() on windows (Causes instability problems) mysys/my_alloc.c: Added strmake_root readline/bind.c: Remove warnings readline/complete.c: Remove warnings readline/display.c: Remove warnings readline/funmap.c: Remove warnings readline/histexpand.c: Remove warnings readline/histfile.c: Remove warnings readline/history.h: Remove warnings readline/histsearch.c: Remove warnings readline/isearch.c: Remove warnings readline/kill.c: Remove warnings readline/macro.c: Remove warnings readline/readline.c: Remove warnings readline/readline.h: Remove warnings readline/rltty.c: Remove warnings readline/search.c: Remove warnings readline/shell.c: Remove warnings readline/terminal.c: Remove warnings readline/tilde.c: Remove warnings readline/tilde.h: Remove warnings readline/undo.c: Remove warnings readline/util.c: Remove warnings readline/vi_mode.c: Remove warnings sql-bench/server-cfg.sh: Added use of truncate table sql-bench/test-insert.sh: Added use of truncate table Changed some tests to use keys instead of 'range' sql-bench/test-wisconsin.sh: Cleanup sql/field.cc: Add 'thd' to send() (To avoid usage of 'current_thd') sql/field.h: Add 'thd' to send() (To avoid usage of 'current_thd') sql/filesort.cc: Safer memory allocation; Don't allocate pointer to buffers directly, but use an IO_CACHE instead. This will allow us to use more memory for keys and will also work better if the number of rows that is to be sorted is much larger than expected. sql/item.cc: Add 'thd' to send() (To avoid usage of 'current_thd') sql/item.h: Add 'thd' to send() (To avoid usage of 'current_thd') sql/item_func.h: Cleanup sql/opt_range.cc: Use mem_root instead of sql_alloc() to get more speed sql/sql_class.cc: Add 'thd' to send() (To avoid usage of 'current_thd') sql/sql_class.h: Added strmake() sql/sql_handler.cc: Add 'thd' to send() (To avoid usage of 'current_thd') sql/sql_lex.cc: Use mem_root instead of sql_alloc() to get more speed sql/sql_select.cc: Add 'thd' to send() (To avoid usage of 'current_thd') tests/fork2_test.pl: Fixed typos tests/fork_big.pl: Fixed typos tests/insert_and_repair.pl: Fixed typos tests/rename_test.pl: Fixed typos tests/test_delayed_insert.pl: Fixed typos
138 lines
3.1 KiB
C
138 lines
3.1 KiB
C
/* shell.c -- readline utility functions that are normally provided by
|
|
bash when readline is linked as part of the shell. */
|
|
|
|
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
|
|
|
This file is part of the GNU Readline Library, a library for
|
|
reading lines of text with interactive input and history editing.
|
|
|
|
The GNU Readline Library is free software; you can redistribute it
|
|
and/or modify it under the terms of the GNU General Public License
|
|
as published by the Free Software Foundation; either version 1, or
|
|
(at your option) any later version.
|
|
|
|
The GNU Readline Library is distributed in the hope that it will be
|
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
The GNU General Public License is often shipped with GNU software, and
|
|
is generally kept in a file called COPYING or LICENSE. If you do not
|
|
have a copy of the license, write to the Free Software Foundation,
|
|
675 Mass Ave, Cambridge, MA 02139, USA. */
|
|
#define READLINE_LIBRARY
|
|
|
|
#if defined (HAVE_CONFIG_H)
|
|
# include <config.h>
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
#include <sys/types.h>
|
|
|
|
#if defined (HAVE_UNISTD_H)
|
|
# include <unistd.h>
|
|
#endif /* HAVE_UNISTD_H */
|
|
|
|
#if defined (HAVE_STDLIB_H)
|
|
# include <stdlib.h>
|
|
#else
|
|
# include "ansi_stdlib.h"
|
|
#endif /* HAVE_STDLIB_H */
|
|
|
|
#if defined (HAVE_STDIO_H)
|
|
# include <stdio.h>
|
|
#endif /* HAVE_STDIO_H */
|
|
|
|
#if defined (HAVE_STRING_H)
|
|
# include <string.h>
|
|
#else
|
|
# include <strings.h>
|
|
#endif /* !HAVE_STRING_H */
|
|
|
|
#include <pwd.h>
|
|
|
|
#if !defined (HAVE_GETPW_DECLS)
|
|
extern struct passwd *getpwuid ();
|
|
#endif /* !HAVE_GETPW_DECLS */
|
|
|
|
extern char *xmalloc ();
|
|
|
|
/* All of these functions are resolved from bash if we are linking readline
|
|
as part of bash. */
|
|
|
|
/* Does shell-like quoting using single quotes. */
|
|
char *
|
|
single_quote (string)
|
|
char *string;
|
|
{
|
|
register int c;
|
|
char *result, *r, *s;
|
|
|
|
result = (char *)xmalloc (3 + (3 * strlen (string)));
|
|
r = result;
|
|
*r++ = '\'';
|
|
|
|
for (s = string; s && (c = *s); s++)
|
|
{
|
|
*r++ = c;
|
|
|
|
if (c == '\'')
|
|
{
|
|
*r++ = '\\'; /* insert escaped single quote */
|
|
*r++ = '\'';
|
|
*r++ = '\''; /* start new quoted string */
|
|
}
|
|
}
|
|
|
|
*r++ = '\'';
|
|
*r = '\0';
|
|
|
|
return (result);
|
|
}
|
|
|
|
/* Set the environment variables LINES and COLUMNS to lines and cols,
|
|
respectively. */
|
|
void
|
|
set_lines_and_columns (lines, cols)
|
|
int lines, cols;
|
|
{
|
|
char *b;
|
|
|
|
#if defined (HAVE_PUTENV)
|
|
b = xmalloc (24);
|
|
sprintf (b, "LINES=%d", lines);
|
|
putenv (b);
|
|
b = xmalloc (24);
|
|
sprintf (b, "COLUMNS=%d", cols);
|
|
putenv (b);
|
|
#else /* !HAVE_PUTENV */
|
|
# if defined (HAVE_SETENV)
|
|
b = xmalloc (8);
|
|
sprintf (b, "%d", lines);
|
|
setenv ("LINES", b, 1);
|
|
b = xmalloc (8);
|
|
sprintf (b, "%d", cols);
|
|
setenv ("COLUMNS", b, 1);
|
|
# endif /* HAVE_SETENV */
|
|
#endif /* !HAVE_PUTENV */
|
|
}
|
|
|
|
char *
|
|
get_env_value (varname)
|
|
char *varname;
|
|
{
|
|
return ((char *)getenv (varname));
|
|
}
|
|
|
|
char *
|
|
get_home_dir ()
|
|
{
|
|
char *home_dir;
|
|
struct passwd *entry;
|
|
|
|
home_dir = (char *)NULL;
|
|
entry = getpwuid (getuid ());
|
|
if (entry)
|
|
home_dir = entry->pw_dir;
|
|
return (home_dir);
|
|
}
|