Auto-merge with mysql-5.5-bugteam.

This commit is contained in:
Ramil Kalimullin 2010-11-23 16:44:26 +03:00
commit fb8a31caaf
52 changed files with 2445 additions and 5075 deletions

View file

@ -7,18 +7,3 @@ extra_flags="$amd64_cflags $debug_cflags $valgrind_flags"
extra_configs="$amd64_configs $debug_configs $valgrind_configs $max_configs"
. "$path/FINISH.sh"
if test -z "$just_print"
then
set +v +x
echo "\
******************************************************************************
Note that by default BUILD/compile-pentium-valgrind-max calls 'configure' with
--enable-assembler. When Valgrind detects an error involving an assembly
function (for example an uninitialized value used as an argument of an
assembly function), Valgrind will not print the stacktrace and 'valgrind
--gdb-attach=yes' will not work either. If you need a stacktrace in those
cases, you have to run BUILD/compile-pentium-valgrind-max with the
--disable-assembler argument.
******************************************************************************"
fi

View file

@ -7,18 +7,3 @@ extra_flags="$pentium_cflags $debug_cflags $valgrind_flags"
extra_configs="$pentium_configs $debug_configs $valgrind_configs $max_configs"
. "$path/FINISH.sh"
if test -z "$just_print"
then
set +v +x
echo "\
******************************************************************************
Note that by default BUILD/compile-pentium-valgrind-max calls 'configure' with
--enable-assembler. When Valgrind detects an error involving an assembly
function (for example an uninitialized value used as an argument of an
assembly function), Valgrind will not print the stacktrace and 'valgrind
--gdb-attach=yes' will not work either. If you need a stacktrace in those
cases, you have to run BUILD/compile-pentium-valgrind-max with the
--disable-assembler argument.
******************************************************************************"
fi

View file

@ -7,18 +7,3 @@ extra_flags="$pentium_cflags $debug_cflags $valgrind_flags"
extra_configs="$pentium_configs $debug_configs $valgrind_configs $max_no_ndb_configs"
. "$path/FINISH.sh"
if test -z "$just_print"
then
set +v +x
echo "\
******************************************************************************
Note that by default BUILD/compile-pentium-valgrind-max calls 'configure' with
--enable-assembler. When Valgrind detects an error involving an assembly
function (for example an uninitialized value used as an argument of an
assembly function), Valgrind will not print the stacktrace and 'valgrind
--gdb-attach=yes' will not work either. If you need a stacktrace in those
cases, you have to run BUILD/compile-pentium-valgrind-max with the
--disable-assembler argument.
******************************************************************************"
fi

View file

@ -7,18 +7,3 @@ extra_flags="$pentium64_cflags $debug_cflags $valgrind_flags"
extra_configs="$pentium_configs $debug_configs $valgrind_configs $max_configs"
. "$path/FINISH.sh"
if test -z "$just_print"
then
set +v +x
echo "\
******************************************************************************
Note that by default BUILD/compile-pentium-valgrind-max calls 'configure' with
--enable-assembler. When Valgrind detects an error involving an assembly
function (for example an uninitialized value used as an argument of an
assembly function), Valgrind will not print the stacktrace and 'valgrind
--gdb-attach=yes' will not work either. If you need a stacktrace in those
cases, you have to run BUILD/compile-pentium-valgrind-max with the
--disable-assembler argument.
******************************************************************************"
fi

View file

@ -1,119 +0,0 @@
MySQL FLOSS License Exception
The MySQL AB Exception for Free/Libre and Open Source
Software-only Applications Using MySQL Client Libraries (the
"FLOSS Exception").
Version 0.6, 7 March 2007
Exception Intent
We want specified Free/Libre and Open Source Software (``FLOSS'')
applications to be able to use specified GPL-licensed MySQL client
libraries (the ``Program'') despite the fact that not all FLOSS
licenses are compatible with version 2 of the GNU General Public
License (the ``GPL'').
Legal Terms and Conditions
As a special exception to the terms and conditions of version 2.0
of the GPL:
1. You are free to distribute a Derivative Work that is formed
entirely from the Program and one or more works (each, a
"FLOSS Work") licensed under one or more of the licenses
listed below in section 1, as long as:
a. You obey the GPL in all respects for the Program and the
Derivative Work, except for identifiable sections of the
Derivative Work which are not derived from the Program,
and which can reasonably be considered independent and
separate works in themselves,
b. all identifiable sections of the Derivative Work which
are not derived from the Program, and which can
reasonably be considered independent and separate works
in themselves,
i. are distributed subject to one of the FLOSS licenses
listed below, and
ii. the object code or executable form of those sections
are accompanied by the complete corresponding
machine-readable source code for those sections on
the same medium and under the same FLOSS license as
the corresponding object code or executable forms of
those sections, and
c. any works which are aggregated with the Program or with a
Derivative Work on a volume of a storage or distribution
medium in accordance with the GPL, can reasonably be
considered independent and separate works in themselves
which are not derivatives of either the Program, a
Derivative Work or a FLOSS Work.
If the above conditions are not met, then the Program may only
be copied, modified, distributed or used under the terms and
conditions of the GPL or another valid licensing option from
MySQL AB.
2. FLOSS License List
License name Version(s)/Copyright Date
Academic Free License 2.0
Apache Software License 1.0/1.1/2.0
Apple Public Source License 2.0
Artistic license From Perl 5.8.0
BSD license "July 22 1999"
Common Development and Distribution License (CDDL) 1.0
Common Public License 1.0
Eclipse Public License 1.0
GNU Library or "Lesser" General Public License (LGPL) 2.0/2.1
Jabber Open Source License 1.0
MIT license (As listed in file MIT-License.txt) ---
Mozilla Public License (MPL) 1.0/1.1
Open Software License 2.0
OpenSSL license (with original SSLeay license) "2003" ("1998")
PHP License 3.0
Python license (CNRI Python License) ---
Python Software Foundation License 2.1.1
Sleepycat License "1999"
University of Illinois/NCSA Open Source License ---
W3C License "2001"
X11 License "2001"
Zlib/libpng License ---
Zope Public License 2.0
Due to the many variants of some of the above licenses, we
require that any version follow the 2003 version of the Free
Software Foundation's Free Software Definition
(http://www.gnu.org/philosophy/free-sw.html) or version 1.9 of
the Open Source Definition by the Open Source Initiative
(http://www.opensource.org/docs/definition.php).
3. Definitions
a. Terms used, but not defined, herein shall have the
meaning provided in the GPL.
b. Derivative Work means a derivative work under copyright
law.
4. Applicability: This FLOSS Exception applies to all Programs
that contain a notice placed by MySQL AB saying that the
Program may be distributed under the terms of this FLOSS
Exception. If you create or distribute a work which is a
Derivative Work of both the Program and any other work
licensed under the GPL, then this FLOSS Exception is not
available for that work; thus, you must remove the FLOSS
Exception notice from that work and comply with the GPL in all
respects, including by retaining all GPL notices. You may
choose to redistribute a copy of the Program exclusively under
the terms of the GPL by removing the FLOSS Exception notice
from that copy of the Program, provided that the copy has
never been modified by you or any third party.
Appendix A. Qualified Libraries and Packages
The following is a non-exhaustive list of libraries and packages
which are covered by the FLOSS License Exception. Please note that
this appendix is provided merely as an additional service to
specific FLOSS projects wishing to simplify licensing information
for their users. Compliance with one of the licenses noted under
the "FLOSS license list" section remains a prerequisite.
Package Name Qualifying License and Version
Apache Portable Runtime (APR) Apache Software License 2.0

4512
README

File diff suppressed because it is too large Load diff

View file

@ -122,7 +122,13 @@ IF(UNIX)
CHECK_INCLUDE_FILES(libaio.h HAVE_LIBAIO_H)
CHECK_LIBRARY_EXISTS(aio io_queue_init "" HAVE_LIBAIO)
IF(NOT HAVE_LIBAIO_H OR NOT HAVE_LIBAIO)
MESSAGE(FATAL_ERROR "aio is required on Linux")
MESSAGE(FATAL_ERROR "
aio is required on Linux, you need to install the required library:
Debian/Ubuntu: apt-get install libaio-dev
RedHat/Fedora/Oracle Linux: yum install libaio-devel
SuSE: zypper install libaio-devel
")
ENDIF()
ENDIF()

View file

@ -21,7 +21,7 @@ SET(SHARED_LIB_MAJOR_VERSION "16")
SET(PROTOCOL_VERSION "10")
SET(DOT_FRM_VERSION "6")
# Read value for a variable from configure.in
# Read value for a variable from VERSION.
MACRO(MYSQL_GET_CONFIG_VALUE keyword var)
IF(NOT ${var})

View file

@ -52,8 +52,6 @@
# define memmove(d, s, n) bmove ((d), (s), (n))
#elif defined(HAVE_MEMMOVE)
# define bmove(d, s, n) memmove((d), (s), (n))
#else
# define memmove(d, s, n) bmove((d), (s), (n)) /* our bmove */
#endif
/* Unixware 7 */
@ -96,14 +94,6 @@ extern char _dig_vec_lower[];
/* Prototypes for string functions */
#if !defined(bfill) && !defined(HAVE_BFILL)
extern void bfill(uchar *dst,size_t len,pchar fill);
#endif
#if !defined(HAVE_BMOVE) && !defined(bmove)
extern void bmove(uuchar *dst, const uchar *src,size_t len);
#endif
extern void bmove_upp(uchar *dst,const uchar *src,size_t len);
extern void bchange(uchar *dst,size_t old_len,const uchar *src,
size_t new_len,size_t tot_len);
@ -128,11 +118,6 @@ extern char *strxnmov(char *dst, size_t len, const char *src, ...);
extern size_t strnlen(const char *s, size_t n);
#endif
#if !defined(__cplusplus)
#ifndef HAVE_STRSTR
extern char *strstr(const char *, const char *);
#endif
#endif
extern int is_prefix(const char *, const char *);
/* Conversion routines */

View file

@ -17,11 +17,10 @@
This file defines the client API to MySQL and also the ABI of the
dynamically linked libmysqlclient.
The ABI should never be changed in a released product of MySQL
The ABI should never be changed in a released product of MySQL,
thus you need to take great care when changing the file. In case
the file is changed so the ABI is broken, you must also
update the SHAREDLIB_MAJOR_VERSION in configure.in .
the file is changed so the ABI is broken, you must also update
the SHARED_LIB_MAJOR_VERSION in cmake/mysql_version.cmake
*/
#ifndef _mysql_h

View file

@ -445,6 +445,9 @@ IF(
count(*), 1)
1
DROP TABLE t1;
select @v:=@v:=sum(1) from dual;
@v:=@v:=sum(1)
1
End of 5.1 tests
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(f1 INT AUTO_INCREMENT, PRIMARY KEY(f1));

View file

@ -2622,6 +2622,47 @@ SELECT LEAST((SELECT '' FROM t1),NOW()) FROM `t1`;
ERROR 22007: Incorrect datetime value: '' for column 'NOW()' at row 2
DROP TABLE t1;
SET SQL_MODE=DEFAULT;
#
# Bug#56862 Execution of a query that uses index merge returns a wrong result
#
CREATE TABLE t1 (
pk int NOT NULL AUTO_INCREMENT PRIMARY KEY,
a int,
b int,
INDEX idx(a))
ENGINE=INNODB;
INSERT INTO t1(a,b) VALUES
(11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500),
(3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800),
(6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700),
(13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000);
INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1;
INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1;
INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1 VALUES (1000000, 0, 0);
SET SESSION sort_buffer_size = 1024*36;
EXPLAIN
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
2 DERIVED t1 index_merge PRIMARY,idx idx,PRIMARY 5,4 NULL 1536 Using sort_union(idx,PRIMARY); Using where
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
COUNT(*)
1537
SET SESSION sort_buffer_size = DEFAULT;
DROP TABLE t1;
End of 5.1 tests
#
# Test for bug #39932 "create table fails if column for FK is in different

View file

@ -786,6 +786,49 @@ CREATE TABLE t2
DROP TABLE t1;
SET SQL_MODE=DEFAULT;
--echo #
--echo # Bug#56862 Execution of a query that uses index merge returns a wrong result
--echo #
CREATE TABLE t1 (
pk int NOT NULL AUTO_INCREMENT PRIMARY KEY,
a int,
b int,
INDEX idx(a))
ENGINE=INNODB;
INSERT INTO t1(a,b) VALUES
(11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500),
(3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800),
(6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700),
(13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000);
INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1;
INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1;
INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1 VALUES (1000000, 0, 0);
SET SESSION sort_buffer_size = 1024*36;
EXPLAIN
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
SET SESSION sort_buffer_size = DEFAULT;
DROP TABLE t1;
--echo End of 5.1 tests

View file

@ -1,20 +1,20 @@
select @@global.shared_memory_base_name;
@@global.shared_memory_base_name
MYSQLTEST_VARDIR/tmp/mysqld.1.sock
MYSQL_TMP_DIR/mysqld.1.sock
select @@session.shared_memory_base_name;
ERROR HY000: Variable 'shared_memory_base_name' is a GLOBAL variable
show global variables like 'shared_memory_base_name';
Variable_name Value
shared_memory_base_name MYSQLTEST_VARDIR/tmp/mysqld.1.sock
shared_memory_base_name MYSQL_TMP_DIR/mysqld.1.sock
show session variables like 'shared_memory_base_name';
Variable_name Value
shared_memory_base_name MYSQLTEST_VARDIR/tmp/mysqld.1.sock
shared_memory_base_name MYSQL_TMP_DIR/mysqld.1.sock
select * from information_schema.global_variables where variable_name='shared_memory_base_name';
VARIABLE_NAME VARIABLE_VALUE
SHARED_MEMORY_BASE_NAME MYSQLTEST_VARDIR/tmp/mysqld.1.sock
SHARED_MEMORY_BASE_NAME MYSQL_TMP_DIR/mysqld.1.sock
select * from information_schema.session_variables where variable_name='shared_memory_base_name';
VARIABLE_NAME VARIABLE_VALUE
SHARED_MEMORY_BASE_NAME MYSQLTEST_VARDIR/tmp/mysqld.1.sock
SHARED_MEMORY_BASE_NAME MYSQL_TMP_DIR/mysqld.1.sock
set global shared_memory_base_name=1;
ERROR HY000: Variable 'shared_memory_base_name' is a read only variable
set session shared_memory_base_name=1;

View file

@ -3,17 +3,17 @@
#
# only global
#
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
select @@global.shared_memory_base_name;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.shared_memory_base_name;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
show global variables like 'shared_memory_base_name';
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
show session variables like 'shared_memory_base_name';
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
select * from information_schema.global_variables where variable_name='shared_memory_base_name';
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
select * from information_schema.session_variables where variable_name='shared_memory_base_name';
#

View file

@ -344,6 +344,13 @@ FROM t1 GROUP BY a LIMIT 1;
DROP TABLE t1;
#
# BUG#56138 "valgrind errors about overlapping memory when
# double-assigning same variable"
#
select @v:=@v:=sum(1) from dual;
--echo End of 5.1 tests
#

View file

@ -868,14 +868,8 @@ void my_timer_init(MY_TIMER_INFO *mti)
clock() -- We don't use because it would overflow frequently.
clock_gettime() -- Often we don't use this even when it exists.
In configure.in, we use AC_CHECK_FUNCS(clock_gettime). Not
AC_CHECK_LIB(rc,clock_gettime)
AC_CHECK_FUNCS(clock_gettime)
If we had the above lines in configure.in, we'd have to use
/usr/lib/librt.so or /usr/lib64/librt.so when linking, and
the size of librt.so is 40KB. In tests, clock_gettime often
had resolution = 1000.
clock_gettime() -- In tests, clock_gettime often had
resolution = 1000.
ftime() -- A "man ftime" says: "This function is obsolete.
Don't use it." On every platform that we tested, if ftime()

View file

@ -787,11 +787,8 @@ int field_conv(Field *to,Field *from)
((Field_varstring*)from)->length_bytes ==
((Field_varstring*)to)->length_bytes))
{ // Identical fields
#ifdef HAVE_purify
/* This may happen if one does 'UPDATE ... SET x=x' */
if (to->ptr != from->ptr)
#endif
memcpy(to->ptr,from->ptr,to->pack_length());
// to->ptr==from->ptr may happen if one does 'UPDATE ... SET x=x'
memmove(to->ptr, from->ptr, to->pack_length());
return 0;
}
}

View file

@ -4331,7 +4331,7 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, uint length,
length--; // Fix length change above
entry->value[length]= 0; // Store end \0
}
memcpy(entry->value,ptr,length);
memmove(entry->value, ptr, length);
if (type == DECIMAL_RESULT)
((my_decimal*)entry->value)->fix_buffer_pointer();
entry->length= length;

View file

@ -252,7 +252,7 @@ public:
character set is utf-8, we can safely assume that no
character starts with a zero byte.
*/
return memcmp(m_ptr, rhs->m_ptr, min(m_length, rhs->m_length)+1);
return memcmp(m_ptr, rhs->m_ptr, min(m_length, rhs->m_length));
}
MDL_key(const MDL_key *rhs)

View file

@ -279,6 +279,7 @@ public:
virtual bool reverse_sorted() = 0;
virtual bool unique_key_range() { return false; }
virtual bool clustered_pk_range() { return false; }
enum {
QS_TYPE_RANGE = 0,
@ -553,6 +554,8 @@ public:
THD *thd;
int read_keys_and_merge();
bool clustered_pk_range() { return test(pk_quick_select); }
/* used to get rows collected in Unique */
READ_RECORD read_record;
};

View file

@ -206,6 +206,15 @@ void init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
if (select && my_b_inited(&select->file))
tempfile= &select->file;
else if (select && select->quick && select->quick->clustered_pk_range())
{
/*
In case of QUICK_INDEX_MERGE_SELECT with clustered pk range we have to
use its own access method(i.e QUICK_INDEX_MERGE_SELECT::get_next()) as
sort file does not contain rowids which satisfy clustered pk range.
*/
tempfile= 0;
}
else
tempfile= table->sort.io_cache;
if (tempfile && my_b_inited(tempfile)) // Test if ref-records was used

View file

@ -4060,8 +4060,12 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
continue;
}
#ifdef HAVE_purify
/* Valgrind complains about overlapped memcpy when save_pos==use. */
#if defined(__GNUC__) && !MY_GNUC_PREREQ(4,4)
/*
Old gcc used a memcpy(), which is undefined if save_pos==use:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19410
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39480
*/
if (save_pos != use)
#endif
*save_pos= *use;

View file

@ -598,11 +598,11 @@ public:
return m_view_access_denied_message_ptr;
}
bool handle_condition(THD *thd, uint sql_errno, const char */* sqlstate */,
bool handle_condition(THD *thd, uint sql_errno, const char * /* sqlstate */,
MYSQL_ERROR::enum_warning_level level,
const char *message, MYSQL_ERROR **/* cond_hdl */)
const char *message, MYSQL_ERROR ** /* cond_hdl */)
{
/*
/*
The handler does not handle the errors raised by itself.
At this point we know if top_view is really a view.
*/
@ -612,7 +612,7 @@ public:
m_handling= TRUE;
bool is_handled;
switch (sql_errno)
{
case ER_TABLEACCESS_DENIED_ERROR:

View file

@ -1,41 +0,0 @@
/* Copyright (C) 2002 MySQL AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; version 2
of the License.
This 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA */
/* File : bfill.c
Author : Richard A. O'Keefe.
Michael Widenius; ifdef MC68000
Updated: 23 April 1984
Defines: bfill()
bfill(dst, len, fill) moves "len" fill characters to "dst".
Thus to set a buffer to 80 spaces, do bfill(buff, 80, ' ').
*/
#include <my_global.h>
#include "m_string.h"
#if !defined(bfill) && !defined(HAVE_BFILL)
void bfill(dst, len, fill)
register byte *dst;
register uint len;
register pchar fill;
{
while (len-- != 0) *dst++ = fill;
}
#endif

View file

@ -1,48 +0,0 @@
/* Copyright (C) 2002 MySQL AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; version 2
of the License.
This 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA */
/* File : bmove.c
Author : Richard A. O'Keefe.
Michael Widenius; ifdef MC68000
Updated: 23 April 1984
Defines: bmove()
bmove(dst, src, len) moves exactly "len" bytes from the source "src"
to the destination "dst". It does not check for NUL characters as
strncpy() and strnmov() do. Thus if your C compiler doesn't support
structure assignment, you can simulate it with
bmove(&to, &from, sizeof from);
The standard 4.2bsd routine for this purpose is bcopy. But as bcopy
has its first two arguments the other way around you may find this a
bit easier to get right.
No value is returned.
*/
#include <my_global.h>
#include "m_string.h"
#if !defined(HAVE_BMOVE) && !defined(bmove)
void bmove(dst, src, len)
register char *dst;
register const char *src;
register uint len;
{
while (len-- != 0) *dst++ = *src++;
}
#endif

View file

@ -1,216 +0,0 @@
# Copyright (C) 2000 MySQL AB
# This program 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; version 2 of the License.
#
# This program 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Optimized longlong2str function for Intel 80x86 (gcc/gas syntax)
# Some set sequences are optimized for pentuimpro II
.file "longlong2str-x86.s"
.version "1.02"
.text
.align 4
.globl longlong2str_with_dig_vector
.type longlong2str_with_dig_vector,@function
longlong2str_with_dig_vector:
subl $80,%esp # Temporary buffer for up to 64 radix-2 digits
pushl %ebp
pushl %esi
pushl %edi
pushl %ebx
movl 100(%esp),%esi # esi = Lower part of val
movl 112(%esp),%ebx # ebx = Radix
movl 104(%esp),%ebp # ebp = Higher part of val
movl 108(%esp),%edi # edi = dst
testl %ebx,%ebx
jge .L144 # Radix was positive
negl %ebx # Change radix to positive
testl %ebp,%ebp # Test if given value is negative
jge .L144
movb $45,(%edi) # Add sign
incl %edi # Change sign of val
negl %esi
adcl $0,%ebp
negl %ebp
.L144: # Test that radix is between 2 and 36
movl %ebx, %eax
addl $-2,%eax # Test that radix is between 2 and 36
cmpl $34,%eax
ja .Lerror # Radix was not in range
leal 92(%esp),%ecx # End of buffer
movl %edi, 108(%esp) # Store possible modified dest
movl 116(%esp), %edi # dig_vec_upper
testl %ebp,%ebp # Test if value > 0xFFFFFFFF
jne .Llongdiv
cmpl %ebx, %esi # Test if <= radix, for easy loop
movl %esi, %eax # Value in eax (for Llow)
jae .Llow
# Value is one digit (negative or positive)
movb (%eax,%edi),%bl
movl 108(%esp),%edi # get dst
movb %bl,(%edi)
incl %edi # End null here
jmp .L10_end
.Llongdiv:
# Value in ebp:esi. div the high part by the radix,
# then div remainder + low part by the radix.
movl %ebp,%eax # edx=0,eax=high(from ebp)
xorl %edx,%edx
decl %ecx
divl %ebx
movl %eax,%ebp # edx=result of last, eax=low(from esi)
movl %esi,%eax
divl %ebx
movl %eax,%esi # ebp:esi = quotient
movb (%edx,%edi),%dl # Store result number in temporary buffer
testl %ebp,%ebp
movb %dl,(%ecx) # store value in buff
ja .Llongdiv # (Higher part of val still > 0)
.align 4
.Llow: # Do rest with integer precision
# Value in 0:eax. div 0 + low part by the radix.
xorl %edx,%edx
decl %ecx
divl %ebx
movb (%edx,%edi),%dl # bh is always zero as ebx=radix < 36
testl %eax,%eax
movb %dl,(%ecx)
jne .Llow
.L160:
movl 108(%esp),%edi # get dst
.Lcopy_end:
leal 92(%esp),%esi # End of buffer
.Lmov: # mov temporary buffer to result (%ecx -> %edi)
movb (%ecx), %al
movb %al, (%edi)
incl %ecx
incl %edi
cmpl %ecx,%esi
jne .Lmov
.L10_end:
movl %edi,%eax # Pointer to end null
movb $0,(%edi) # Store the end null
.L165:
popl %ebx
popl %edi
popl %esi
popl %ebp
addl $80,%esp
ret
.Lerror:
xorl %eax,%eax # Wrong radix
jmp .L165
.Lfe3:
.size longlong2str_with_dig_vector,.Lfe3-longlong2str_with_dig_vector
#
# This is almost equal to the above, except that we can do the final
# loop much more efficient
#
.align 4
.globl longlong10_to_str
.type longlong10_to_str,@function
longlong10_to_str:
subl $80,%esp
pushl %ebp
pushl %esi
pushl %edi
pushl %ebx
movl 100(%esp),%esi # Lower part of val
movl 104(%esp),%ebp # Higher part of val
movl 108(%esp),%edi # get dst
movl 112(%esp),%ebx # Radix (10 or -10)
testl %ebx,%ebx
jge .L10_10 # Positive radix
negl %ebx # Change radix to positive (= 10)
testl %ebp,%ebp # Test if negative value
jge .L10_10
movb $45,(%edi) # Add sign
incl %edi
negl %esi # Change sign of val (ebp:esi)
adcl $0,%ebp
negl %ebp
.L10_10:
leal 92(%esp),%ecx # End of buffer
testl %ebp,%ebp # Test if value > 0xFFFFFFFF
jne .L10_longdiv
cmpl $10, %esi # Test if <= radix, for easy loop
movl %esi, %ebx # Value in eax (for L10_low)
jae .L10_low
# Value is one digit (negative or positive)
addb $48, %bl
movb %bl,(%edi)
incl %edi
jmp .L10_end
.align 4
.L10_longdiv:
# val is stored in in ebp:esi
movl %ebp,%eax # High part of value
xorl %edx,%edx
divl %ebx # Divide by 10
movl %eax,%ebp
movl %esi,%eax
divl %ebx # Divide by 10
decl %ecx
movl %eax,%esi # quotent in ebp:esi
addl $48,%edx # Convert to ascii
movb %dl,(%ecx) # store value in buff
.L10_30:
testl %ebp,%ebp
ja .L10_longdiv
movl %esi,%ebx # Move val to %ebx
.L10_low:
# The following code uses some tricks to change division by 10 to
# multiplication and shifts
movl $0xcccccccd,%esi
.L10_40: # Divide %ebx with 10
movl %ebx,%eax
mull %esi
decl %ecx
shrl $3,%edx
leal (%edx,%edx,4),%eax
addl %eax,%eax
subb %al,%bl # %bl now contains val % 10
addb $48,%bl
movb %bl,(%ecx)
movl %edx,%ebx
testl %ebx,%ebx
jne .L10_40
jmp .Lcopy_end # Shared end with longlong2str
.L10end:
.size longlong10_to_str,.L10end-longlong10_to_str

View file

@ -1,33 +0,0 @@
/* Copyright (C) 2000 MySQL AB
This program 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; version 2 of the License.
This program 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
Wrapper for longlong2str.s
We need this because the assembler code can't access the local variable
_dig_vector in a portable manner.
*/
#include <my_global.h>
#include "m_string.h"
extern char *longlong2str_with_dig_vector(longlong val,char *dst,int radix,
const char *dig_vector);
char *ll2str(longlong val,char *dst,int radix, int upcase)
{
return longlong2str_with_dig_vector(val, dst, radix,
upcase ? _dig_vec_upper : _dig_vec_lower);
}

View file

@ -1,418 +0,0 @@
# Copyright (C) 2003 MySQL AB
#
# This program 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; version 2 of the License.
#
# This program 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Implemention of my_strtoll(): Converting a string to a 64 bit integer.
# For documentation, check my_strtoll.c
.file "my_strtoll10-x86.s"
.version "01.02"
.text
.align 4
.globl my_strtoll10
.type my_strtoll10,@function
# Used stack variables
# ebp-4 dummy for storing endptr if endptr = 0
# ebp-8 First 9 digits of return values
# ebp-12 Pointer to first digit of second part
# ebp-16 Store lowest 2 digits
# ebp-20 != 0 if value was negative
# ebp-24 High max value
# ebp-28 Middle max value
# ebp-32 Low max value
# ebp-36 Temp value
# esi Pointer to input string
# ebx End of string
my_strtoll10:
pushl %ebp
movl %esp,%ebp
subl $48,%esp
pushl %esi
pushl %edi
pushl %ebx
movl 8(%ebp),%esi # esi= nptr
movl 16(%ebp),%ecx # ecx= error (Will be overwritten later)
movl 12(%ebp),%eax # eax= endptr
cmpl $0,%eax # if (endptr)
je .L110
# Fixed length string
movl (%eax),%ebx # bx= end-of-string
.p2align 4,,7
.L100:
cmpl %ebx,%esi
je .Lno_conv
movb (%esi), %al # al= next byte
incl %esi
cmpb $32,%al # Skip space
je .L100
cmpb $9,%al # Skip tab
je .L100
jmp .L130
# String that ends with \0
.L110:
leal -4(%ebp),%edi
movl %edi,12(%ebp) # endptr= &dummy, for easier end check
.p2align 4,,7
.L120:
movb (%esi), %al # al= next byte
incl %esi
cmpb $32,%al
je .L120
cmpb $9,%al
je .L120
testb %al,%al # Test if we found end \0
je .Lno_conv
leal 65535(%esi),%ebx # ebx = end-of-string
.L130:
cmpb $45,%al # Test if '-'
jne .Lpositive
# negative number
movl $-1,(%ecx) # error = -1 (mark that number is negative)
movl $1,-20(%ebp) # negative= 1
movl $92233720,-24(%ebp)
movl $368547758,-28(%ebp)
movl $8,-32(%ebp)
jmp .L460
.p2align 4,,7
.Lpositive:
movl $0,(%ecx) # error=0
movl $0,-20(%ebp) # negative= 0
movl $184467440,-24(%ebp)
movl $737095516,-28(%ebp)
movl $15,-32(%ebp)
cmpb $43,%al # Check if '+'
jne .L462
.L460:
cmpl %ebx,%esi # Check if overflow
je .Lno_conv
movb (%esi), %al # al= next byte after sign
incl %esi
# Remove pre zero to be able to handle a lot of pre-zero
.L462:
cmpb $48,%al
jne .L475 # Number doesn't start with 0
decl %esi
.p2align 4,,7
# Skip pre zeros
.L481:
incl %esi # Skip processed byte
cmpl %ebx,%esi
je .Lms_return_zero
cmpb (%esi),%al # Test if next byte is also zero
je .L481
leal 9(%esi),%ecx # ecx = end-of-current-part
xorl %edi,%edi # Store first 9 digits in edi
jmp .L482
.p2align 4,,7
# Check if first char is a valid number
.L475:
addb $-48,%al
cmpb $9,%al
ja .Lno_conv
.L477:
movzbl %al,%edi # edi = first digit
leal 8(%esi),%ecx # ecx = end-of-current-part
# Handle first 8/9 digits and store them in edi
.L482:
cmpl %ebx,%ecx
jbe .L522
movl %ebx,%ecx # ecx = min(end-of-current-part, end-of-string)
jmp .L522
.p2align 4,,7
.L488:
movb (%esi), %al # al= next byte
incl %esi
addb $-48,%al
cmpb $9,%al
ja .Lend_i_dec_esi
# Calculate edi= edi*10 + al
leal (%edi,%edi,4),%edx
movzbl %al,%eax
leal (%eax,%edx,2),%edi
.L522:
cmpl %ecx,%esi # If more digits at this level
jne .L488
cmpl %ebx,%esi # If end of string
je .Lend_i
movl %edi,-8(%ebp) # Store first 9 digits
movl %esi,-12(%ebp) # store pos to first digit of second part
# Calculate next 9 digits and store them in edi
xorl %edi,%edi
leal 9(%esi),%ecx # ecx= end-of-current-part
movl %ecx,-36(%ebp) # Store max length
cmpl %ebx,%ecx
jbe .L498
movl %ebx,%ecx # ecx = min(end-of-current-part, end-of-string)
.p2align 4,,7
.L498:
movb (%esi), %al # al= next byte
incl %esi
addb $-48,%al
cmpb $9,%al
ja .Lend_i_and_j_decl_esi
# Calculate edi= edi*10 + al
leal (%edi,%edi,4),%edx
movzbl %al,%eax
leal (%eax,%edx,2),%edi
cmpl %ecx,%esi # If end of current part
jne .L498
cmpl %ebx,%esi # If end of string
jne .L500
cmpl -36(%ebp),%esi # Test if string is less than 18 digits
jne .Lend_i_and_j
.L499:
movl $1000000000,%eax
jmp .Lgot_factor # 18 digit string
# Handle the possible next to last digit and store in ecx
.L500:
movb (%esi),%al
addb $-48,%al
cmpb $9,%al
ja .L499 # 18 digit string
incl %esi
movzbl %al,%ecx
cmpl %ebx,%esi # If end of string
je .Lend4
movb (%esi),%al # Read last digit
addb $-48,%al
cmpb $9,%al
ja .Lend4
# ecx= ecx*10 + al
leal (%ecx,%ecx,4),%edx
movzbl %al,%eax
leal (%eax,%edx,2),%ecx
movl 12(%ebp),%eax # eax = endptr
incl %esi
movl %esi,(%eax) # *endptr = end-of-string
cmpl %ebx,%esi
je .L505 # At end of string
movb (%esi),%al # check if extra digits
addb $-48,%al
cmpb $9,%al
jbe .Loverflow
# At this point we have:
# -8(%ebp) First 9 digits
# edi Next 9 digits
# ecx Last 2 digits
# *endpos end-of-string
.L505: # Check that we are not going to get overflow for unsigned long long
movl -8(%ebp),%eax # First 9 digits
cmpl -24(%ebp),%eax
ja .Loverflow
jne .L507
cmpl -28(%ebp),%edi
ja .Loverflow
jne .L507
cmpl -32(%ebp),%ecx
ja .Loverflow
.L507:
movl %edi,-4(%ebp) # Save middle bytes
movl %ecx,%esi # esi = 2 last digits
movl $1215752192,%ecx # %ecx= lower_32_bits(100000000000)
mull %ecx
imull $23,-8(%ebp),%ecx
movl $0,-36(%ebp)
movl %eax,%ebx
imull $1215752192,-36(%ebp),%eax
movl %edx,%edi
addl %ecx,%edi
addl %eax,%edi # Temp in edi:ebx
movl $100,%eax # j= j*100
mull -4(%ebp)
addl %ebx,%eax # edx:eax+= edi:ebx
adcl %edi,%edx
addl %esi,%eax
adcl $0,%edx
jmp .Lms_return
.Loverflow:
# When we come here, *endptr is already updated
movl 16(%ebp),%edx # edx= error
movl $34,(%edx) # *error = 34
movl $-1,%eax
movl %eax,%edx
cmpl $0,-20(%ebp) # If negative
je .Lms_return
xor %eax,%eax # edx:eax = LONGLONG_LMIN
movl $-2147483648,%edx
jmp .Lms_return
# Return value that is in %edi as long long
.p2align 4,,7
.Lend_i_dec_esi:
decl %esi # Fix so that it points at last digit
.Lend_i:
xorl %edx,%edx
movl %edi,%eax
cmpl $0,-20(%ebp)
je .Lreturn_save_endptr # Positive number
negl %eax
cltd # Neg result in edx:eax
jmp .Lreturn_save_endptr
# Return value (%ebp-8) * lfactor[(uint) (edx-start)] + edi
.p2align 4,,7
.Lend_i_and_j_decl_esi:
decl %esi # Fix so that it points at last digit
.Lend_i_and_j:
movl %esi,%ecx
subl -12(%ebp),%ecx # ecx= number of digits in second part
# Calculate %eax= 10 ** %cl, where %cl <= 8
# With an array one could do this with:
# movl 10_factor_table(,%ecx,4),%eax
# We calculate the table here to avoid problems in
# position independent code (gcc -pic)
cmpb $3,%cl
ja .L4_to_8
movl $1000, %eax
je .Lgot_factor # %cl=3, eax= 1000
movl $10, %eax
cmpb $1,%cl # %cl is here 0 - 2
je .Lgot_factor # %cl=1, eax= 10
movl $100, %eax
ja .Lgot_factor # %cl=2, eax=100
movl $1, %eax
jmp .Lgot_factor # %cl=0, eax=1
.L4_to_8: # %cl is here 4-8
cmpb $5,%cl
movl $100000, %eax
je .Lgot_factor # %cl=5, eax=100000
movl $10000, %eax
jbe .Lgot_factor # %cl=4, eax=10000
movl $10000000, %eax
cmpb $7,%cl
je .Lgot_factor # %cl=7, eax=10000000
movl $100000000, %eax
ja .Lgot_factor # %cl=8, eax=100000000
movl $1000000, %eax # %cl=6, eax=1000000
# Return -8(%ebp) * %eax + edi
.p2align 4,,7
.Lgot_factor:
mull -8(%ebp)
addl %edi,%eax
adcl $0,%edx
cmpl $0,-20(%ebp) # if negative
je .Lreturn_save_endptr
negl %eax # Neg edx:%eax
adcl $0,%edx
negl %edx
jmp .Lreturn_save_endptr
# Return -8(%ebp) * $10000000000 + edi*10 + ecx
.p2align 4,,7
.Lend4:
movl %ecx,-16(%ebp) # store lowest digits
movl 12(%ebp),%ebx
movl %esi,(%ebx) # *endpos = end-of-string
movl -8(%ebp),%eax # First 9 digits
movl $1410065408,%ecx # ecx= lower_32_bits(10000000000)
mull %ecx
movl $0,-36(%ebp)
movl %eax,%ebx # Store lowest 32 byte from multiplication
imull $1410065408,-36(%ebp),%eax
movl -8(%ebp),%ecx # First 9 digits
movl %edx,%esi
addl %ecx,%ecx
addl %ecx,%esi
addl %eax,%esi # %esi:%ebx now has -8(%ebp) * $10000000000
movl $10,%eax # Calc edi*10
mull %edi
addl %ebx,%eax # And add to result
adcl %esi,%edx
addl -16(%ebp),%eax # Add lowest digit
adcl $0,%edx
cmpl $0,-20(%ebp) # if negative
je .Lms_return
cmpl $-2147483648,%edx # Test if too big signed integer
ja .Loverflow
jne .L516
testl %eax,%eax
ja .Loverflow
.L516:
negl %eax
adcl $0,%edx
negl %edx
jmp .Lms_return
.p2align 4,,7
.Lno_conv: # Not a legal number
movl 16(%ebp),%eax
movl $33,(%eax) # error= edom
.Lms_return_zero:
xorl %eax,%eax # Return zero
xorl %edx,%edx
.p2align 4,,7
.Lreturn_save_endptr:
movl 12(%ebp),%ecx # endptr= end-of-string
movl %esi,(%ecx) # *endptr= end-of-string
.Lms_return:
popl %ebx
popl %edi
popl %esi
movl %ebp,%esp
popl %ebp
ret
.my_strtoll10_end:
.size my_strtoll10,.my_strtoll10_end-my_strtoll10
.comm res,240,32
.comm end_ptr,120,32
.comm error,120,32
.ident "Monty"

View file

@ -1,275 +0,0 @@
/* Copyright (C) 2000-2003 MySQL AB
This program 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; version 2 of the License.
This program 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Test of all stringfunktions that is coded in assembler */
#include <my_global.h>
#include <stdarg.h>
#include "m_string.h"
#define F_LEN 8
#define F_CHAR 'A'
#define F_FILL 'B'
#define T_LEN 15
#define T_CHAR 'D'
#define T_FILL 'E'
#define F_PREFILL '0'
#define T_PREFILL '1'
static char from_buff[100],to_buff[100];
static char * from, *to;
static int errors,tests;
static int test_strarg(const char *name,...);
static void init_strings (void); /* Init from and to */
void test_arg (const char *message,long func_value,long value);
int compare_buff(const char *message,char * b1,char * b2,int length,
pchar fill, pchar prefill);
static int my_test(int a)
{
return a ? 1 : 0;
}
int main(void)
{
static char v1[]="Monty",v2[]="on",v3[]="Montys",v4[]="ty",v5[]="gr",
v6[]="hohohoo",v7[]="hohoo",v8[]="hohooo",v9[]="t",
cont[]="qwet";
errors=tests=0;
init_strings();
test_arg("memcmp(from,to,5)",(long) my_test(memcmp(from,to,5)),1L);
test_arg("memcmp(from,from,5)",(long) memcmp(from,from,5),0L);
test_arg("memcmp(from,to,0)",(long) memcmp(from,to,0),0L);
test_arg("strend(from)",(long) strend(from),(long) from+F_LEN);
test_arg("strchr(v1,'M')",(long) strchr(v1,'M'),(long) v1);
test_arg("strchr(v1,'y')",(long) strchr(v1,'y'),(long) v1+4);
test_arg("strchr(v1,'x')",(long) strchr(v1,'x'),0L);
test_arg("strcont(v1,cont)",(long) strcont(v1,cont),(long) v1+3);
test_arg("strcont(v1,v2)",(long) strcont(v1,v2),(long) v1+1);
test_arg("strcont(v1,v5)",(long) strcont(v1,v5),0L);
test_arg("is_prefix(v3,v1)",(long) is_prefix(v3,v1),1L);
test_arg("is_prefix(v1,v3)",(long) is_prefix(v1,v3),0L);
test_arg("is_prefix(v3,v4)",(long) is_prefix(v3,v4),0L);
test_arg("strstr(v1,v1)",(long) strstr(v1,v1),(long) v1);
test_arg("strstr(v1,v2)",(long) strstr(v1,v2),(long) v1+1);
test_arg("strstr(v1,v4)",(long) strstr(v1,v4),(long) v1+3);
test_arg("strstr(v6,v7)",(long) strstr(v6,v7),(long) v6+2);
test_arg("strstr(v1,v9)",(long) strstr(v1,v9),(long) v1+3);
test_arg("strstr(v1,v3)",(long) strstr(v1,v3),0L);
test_arg("strstr(v1,v5)",(long) strstr(v1,v5),0L);
test_arg("strstr(v6,v8)",(long) strstr(v6,v8),0L);
test_arg("strlen(from)",(long) strlen(from),(long) F_LEN);
test_arg("strlen(\"\")",(long) strlen(""),0L);
#ifdef HAVE_STRNLEN
test_arg("strnlen(from,3)",(long) strnlen(from,3),3L);
test_arg("strnlen(from,0)",(long) strnlen(from,0),0L);
test_arg("strnlen(from,1000)",(long) strnlen(from,1000),(long) F_LEN);
#endif
test_strarg("bfill(to,4,' ')",(bfill(to,4,' '),0L),INT_MAX32,4,' ',0,0);
test_strarg("bfill(from,0,' ')",(bfill(from,0,' '),0L),INT_MAX32,0,0);
test_strarg("bzero(to,3)",(bzero(to,3),0L),INT_MAX32,3,0,0,0);
test_strarg("bzero(to,0)",(bzero(to,0),0L),INT_MAX32,0,0);
test_strarg("bmove(to,from,4)",(bmove(to,from,4),0L),INT_MAX32,4,F_CHAR,
0,0);
test_strarg("bmove(to,from,0)",(bmove(to,from,0),0L),INT_MAX32,0,0);
test_strarg("bmove_upp(to+6,from+6,3)",(bmove_upp(to+6,from+6,3),0L),INT_MAX32,
3,T_CHAR,3,F_CHAR,0,0);
test_strarg("bmove_upp(to,from,0)",(bmove_upp(to,from,0),0L),INT_MAX32,0,0);
test_strarg("memcpy(to,from,8)",(memcpy(to,from,8),0L),INT_MAX32,
8,F_CHAR,0,0);
test_strarg("strappend(to,3,' ')",(strappend(to,3,' '),0L),INT_MAX32,
3,T_CHAR,1,0,T_LEN-4,T_CHAR,1,0,0,0);
test_strarg("strappend(to,T_LEN+5,' ')",(strappend(to,T_LEN+5,' '),0L),INT_MAX32,
T_LEN,T_CHAR,5,' ',1,0,0,0);
test_strarg("strcat(to,from)",strcat(to,from),to,T_LEN,T_CHAR,
F_LEN,F_CHAR,1,0,0,0);
test_strarg("strcat(to,\"\")",strcat(to,""),INT_MAX32,0,0);
test_strarg("strfill(to,4,' ')",strfill(to,4,' '),to+4,4,' ',1,0,0,0);
test_strarg("strfill(from,0,' ')",strfill(from,0,' '),from,0,1,0,0);
test_strarg("strmake(to,from,4)",strmake(to,from,4),to+4,4,F_CHAR,
1,0,0,0);
test_strarg("strmake(to,from,0)",strmake(to,from,0),to+0,1,0,0,0);
test_strarg("strmov(to,from)",strmov(to,from),to+F_LEN,F_LEN,F_CHAR,0,0);
test_strarg("strmov(to,\"\")",strmov(to,""),to,1,0,0,0);
test_strarg("strnmov(to,from,2)",strnmov(to,from,2),to+2,2,F_CHAR,0,0);
test_strarg("strnmov(to,from,F_LEN+5)",strnmov(to,from,F_LEN+5),to+F_LEN,
F_LEN,F_CHAR,1,0,0,0);
test_strarg("strnmov(to,\"\",2)",strnmov(to,"",2),to,1,0,0,0);
test_strarg("strxmov(to,from,\"!!\",NullS)",strxmov(to,from,"!!",NullS),to+F_LEN+2,F_LEN,F_CHAR,2,'!',0,0,0);
test_strarg("strxmov(to,NullS)",strxmov(to,NullS),to,1,0,0,0);
test_strarg("strxmov(to,from,from,from,from,from,'!!',from,NullS)",strxmov(to,from,from,from,from,from,"!!",from,NullS),to+F_LEN*6+2,F_LEN,F_CHAR,F_LEN,F_CHAR,F_LEN,F_CHAR,F_LEN,F_CHAR,F_LEN,F_CHAR,2,'!',F_LEN,F_CHAR,1,0,0,0);
test_strarg("strxnmov(to,100,from,\"!!\",NullS)",strxnmov(to,100,from,"!!",NullS),to+F_LEN+2,F_LEN,F_CHAR,2,'!',0,0,0);
test_strarg("strxnmov(to,2,NullS)",strxnmov(to,2,NullS),to,1,0,0,0);
test_strarg("strxnmov(to,100,from,from,from,from,from,'!!',from,NullS)",strxnmov(to,100,from,from,from,from,from,"!!",from,NullS),to+F_LEN*6+2,F_LEN,F_CHAR,F_LEN,F_CHAR,F_LEN,F_CHAR,F_LEN,F_CHAR,F_LEN,F_CHAR,2,'!',F_LEN,F_CHAR,1,0,0,0);
test_strarg("strxnmov(to,2,\"!!!\",NullS)",strxnmov(to,2,"!!!",NullS),to+2,2,'!',0,0,0);
test_strarg("strxnmov(to,2,\"!!\",NullS)",strxnmov(to,2,"!!","xx",NullS),to+2,2,'!',0,0,0);
test_strarg("strxnmov(to,2,\"!\",\"x\",\"y\",NullS)",strxnmov(to,2,"!","x","y",NullS),to+2,1,'!',1,'x',0,0,0);
test_strarg("bchange(to,2,from,4,6)",(bchange(to,2,from,4,6),0L),INT_MAX32,
4,F_CHAR,2,T_CHAR,0,0);
printf("tests: %d errors: %d\n",tests,errors);
if (errors)
fputs("--- Some functions doesn't work!! Fix them\n",stderr);
return(errors > 0);
} /* main */
/* Init strings */
void init_strings(void)
{
reg1 int i;
reg2 char *pos;
from=from_buff+3; to=to_buff+3;
pos=from_buff; *pos++= F_FILL; *pos++=F_FILL; *pos++=F_PREFILL;
for (i=0 ; i < F_LEN ; i++)
*pos++=F_CHAR;
*pos++=0;
for (i=0; i<50 ; i++)
*pos++= F_FILL;
pos=to_buff; *pos++= T_FILL; *pos++=T_FILL; *pos++=T_PREFILL;
for (i=0 ; i < T_LEN ; i++)
*pos++=T_CHAR;
*pos++=0;
for (i=0; i<50 ; i++)
*pos++= T_FILL;
} /* init_strings */
/* Test that function return rigth value */
void test_arg(const char *message, long int func_value, long int value)
{
tests++;
printf("testing '%s'\n",message);
if (func_value != value)
{
printf("func: '%s' = %ld Should be: %ld\n",message,func_value,value);
errors++;
}
} /* test_arg */
/* Test function return value and from and to arrays */
static int test_strarg(const char *message,...)
{
long func_value,value;
int error,length;
char chr,cmp_buff[100],*pos,*pos2;
va_list pvar;
tests++;
va_start(pvar,message);
func_value=va_arg(pvar,long);
value=va_arg(pvar,long);
printf("testing '%s'\n",message);
if (func_value != value && value != INT_MAX32)
{
printf("func: '%s' = %ld Should be: %ld\n",message,func_value,value);
errors++;
}
pos= cmp_buff;
while ((length = va_arg(pvar, int)) != 0)
{
chr= (char) (va_arg(pvar, int));
while (length--)
*pos++=chr;
}
pos2=to+ (int)(pos-cmp_buff);
while (pos <= cmp_buff+T_LEN)
*pos++= *pos2++;
if (compare_buff(message,to,cmp_buff,(int) (pos-cmp_buff),T_FILL,T_PREFILL))
{
init_strings();
va_end(pvar);
return 1;
}
pos= cmp_buff;
while ((length = va_arg(pvar, int)) != 0)
{
chr= (char) (va_arg(pvar, int));
while (length--)
*pos++=chr;
}
pos2=from+ (int)(pos-cmp_buff);
while (pos <= cmp_buff+F_LEN)
*pos++= *pos2++;
error=compare_buff(message,from,cmp_buff,(int) (pos-cmp_buff),F_FILL,F_PREFILL);
init_strings();
va_end(pvar);
return (error != 0);
} /* test_strarg */
/* test if function made right value */
int compare_buff(const char *message, char * b1, char * b2, int length,
pchar fill, pchar prefill)
{
int i,error=0;
if (memcmp(b1,b2,length))
{
errors++;
printf("func: '%s' Buffers differ\nIs: ",message);
for (i=0 ; i<length ; i++)
printf("%3d ",b1[i]);
printf("\nShould be: ");
for (i=0 ; i<length ; i++)
printf("%3d ",b2[i]);
puts("");
}
else if (b1[-1] != prefill || b1[-2] != fill || b1[-3] != fill)
{
printf("func: '%s' Chars before buffer is changed\n",message);
errors++;
error=1;
}
else if (b1[length] != fill || b1[length+1] != fill)
{
printf("func: '%s' Chars after buffer is changed\n",message);
errors++;
error=1;
}
return error;
} /* compare_buff */
/* These are here to be loaded and examined */
extern void dummy_functions(void);
void dummy_functions(void)
{
(void) memchr(from,'a',5);
(void) memcmp(from,to,5);
(void) memcpy(from,to,5);
(void) memset(from,' ',5);
(void) strcmp(from,to);
(void) strcpy(from,to);
(void) strstr(from,to);
(void) strrchr(from,'a');
return;
}

View file

@ -1,393 +0,0 @@
# Copyright (C) 2000 MySQL AB
# This program 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; version 2 of the License.
#
# This program 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Optimized string functions Intel 80x86 (gcc/gas syntax)
.file "strings.s"
.version "1.00"
.text
# Move a alligned, not overlapped, by (long) divided memory area
# Args: to,from,length
.globl bmove_align
.type bmove_align,@function
bmove_align:
movl %edi,%edx
push %esi
movl 4(%esp),%edi # to
movl 8(%esp),%esi # from
movl 12(%esp),%ecx # length
addw $3,%cx # fix if not divisible with long
shrw $2,%cx
jz .ba_20
.p2align 4,,7
.ba_10:
movl -4(%esi,%ecx),%eax
movl %eax,-4(%edi,%ecx)
decl %ecx
jnz .ba_10
.ba_20: pop %esi
movl %edx,%edi
ret
.bmove_align_end:
.size bmove_align,.bmove_align_end-bmove_align
# Move a string from higher to lower
# Arg from_end+1,to_end+1,length
.globl bmove_upp
.type bmove_upp,@function
bmove_upp:
movl %edi,%edx # Remember %edi
push %esi
movl 8(%esp),%edi # dst
movl 16(%esp),%ecx # length
movl 12(%esp),%esi # source
test %ecx,%ecx
jz .bu_20
subl %ecx,%esi # To start of strings
subl %ecx,%edi
.p2align 4,,7
.bu_10: movb -1(%esi,%ecx),%al
movb %al,-1(%edi,%ecx)
decl %ecx
jnz .bu_10
.bu_20: pop %esi
movl %edx,%edi
ret
.bmove_upp_end:
.size bmove_upp,.bmove_upp_end-bmove_upp
# Append fillchars to string
# Args: dest,len,fill
.globl strappend
.type strappend,@function
strappend:
pushl %edi
movl 8(%esp),%edi # Memory pointer
movl 12(%esp),%ecx # Length
clrl %eax # Find end of string
repne
scasb
jnz sa_99 # String to long, shorten it
movzb 16(%esp),%eax # Fillchar
decl %edi # Point at end null
incl %ecx # rep made one dec for null-char
movb %al,%ah # (2) Set up a 32 bit pattern.
movw %ax,%dx # (2)
shll $16,%eax # (3)
movw %dx,%ax # (2) %eax has the 32 bit pattern.
movl %ecx,%edx # (2) Save the count of bytes.
shrl $2,%ecx # (2) Number of dwords.
rep
stosl # (5 + 5n)
movb $3,%cl # (2)
and %edx,%ecx # (2) Fill in the odd bytes
rep
stosb # Move last bytes if any
sa_99: movb $0,(%edi) # End of string
popl %edi
ret
.strappend_end:
.size strappend,.strappend_end-strappend
# Find if string contains any char in another string
# Arg: str,set
# Ret: Pointer to first found char in str
.globl strcont
.type strcont,@function
strcont:
movl %edi,%edx
pushl %esi
movl 8(%esp),%esi # str
movl 12(%esp),%ecx # set
clrb %ah # For endtest
jmp sc_60
sc_10: scasb
jz sc_fo # Found char
sc_20: cmp (%edi),%ah # Test if null
jnz sc_10 # Not end of set yet
incl %esi # Next char in str
sc_60: movl %ecx,%edi # %edi = Set
movb (%esi),%al # Test if this char exist
andb %al,%al
jnz sc_20 # Not end of string
clrl %esi # Return Null
sc_fo: movl %esi,%eax # Char found here
movl %edx,%edi # Restore
popl %esi
ret
.strcont_end:
.size strcont,.strcont_end-strcont
# Find end of string
# Arg: str
# ret: Pointer to end null
.globl strend
.type strend,@function
strend:
movl %edi,%edx # Save
movl 4(%esp),%edi # str
clrl %eax # Find end of string
movl %eax,%ecx
decl %ecx # ECX = -1
repne
scasb
movl %edi,%eax
decl %eax # End of string
movl %edx,%edi # Restore
ret
.strend_end:
.size strend,.strend_end-strend
# Make a string with len fill-chars and endnull
# Args: dest,len,fill
# Ret: dest+len
.globl strfill
.type strfill,@function
strfill:
pushl %edi
movl 8(%esp),%edi # Memory pointer
movl 12(%esp),%ecx # Length
movzb 16(%esp),%eax # Fill
movb %al,%ah # (2) Set up a 32 bit pattern
movw %ax,%dx # (2)
shll $16,%eax # (3)
movw %dx,%ax # (2) %eax has the 32 bit pattern.
movl %ecx,%edx # (2) Save the count of bytes.
shrl $2,%ecx # (2) Number of dwords.
rep
stosl # (5 + 5n)
movb $3,%cl # (2)
and %edx,%ecx # (2) Fill in the odd bytes
rep
stosb # Move last bytes if any
movb %cl,(%edi) # End NULL
movl %edi,%eax # End i %eax
popl %edi
ret
.strfill_end:
.size strfill,.strfill_end-strfill
# Find a char in or end of a string
# Arg: str,char
# Ret: pointer to found char or NullS
.globl strcend
.type strcend,@function
strcend:
movl %edi,%edx
movl 4(%esp),%edi # str
movb 8(%esp),%ah # search
clrb %al # for scasb to find end
se_10: cmpb (%edi),%ah
jz se_20 # Found char
scasb
jnz se_10 # Not end
dec %edi # Not found, point at end of string
se_20: movl %edi,%eax
movl %edx,%edi # Restore
ret
.strcend_end:
.size strcend,.strcend_end-strcend
# Test if string has a given suffix
.globl is_prefix
.type is_prefix,@function
is_prefix:
movl %edi,%edx # Save %edi
pushl %esi # and %esi
movl 12(%esp),%esi # get suffix
movl 8(%esp),%edi # s1
movl $1,%eax # Ok and zero-test
ip_10: cmpb (%esi),%ah
jz suf_ok # End of string/ found suffix
cmpsb # Compare strings
jz ip_10 # Same, possible prefix
xor %eax,%eax # Not suffix
suf_ok: popl %esi
movl %edx,%edi
ret
.is_prefix_end:
.size is_prefix,.is_prefix_end-is_prefix
# Find a substring in string
# Arg: str,search
.globl strstr
.type strstr,@function
strstr:
pushl %edi
pushl %esi
movl 12(%esp),%esi # str
movl 16(%esp),%edi # search
movl %edi,%ecx
incl %ecx # %ecx = search+1
movb (%edi),%ah # %ah = First char in search
jmp sf_10
sf_00: movl %edx,%esi # si = Current str-pos
sf_10: movb (%esi),%al # Test if this char exist
andb %al,%al
jz sf_90 # End of string, didn't find search
incl %esi
cmpb %al,%ah
jnz sf_10 # Didn't find first char, continue
movl %esi,%edx # Save str-pos in %edx
movl %ecx,%edi
sf_20: cmpb $0,(%edi)
jz sf_fo # Found substring
cmpsb
jz sf_20 # Char ok
jmp sf_00 # Next str-pos
sf_90: movl $1,%edx # Return Null
sf_fo: movl %edx,%eax # Char found here
decl %eax # Pointed one after
popl %esi
popl %edi
ret
.strstr_end:
.size strstr,.strstr_end-strstr
# Make a string of len length from another string
# Arg: dst,src,length
# ret: end of dst
.globl strmake
.type strmake,@function
strmake:
pushl %edi
pushl %esi
mov 12(%esp),%edi # dst
movl $0,%edx
movl 20(%esp),%ecx # length
movl 16(%esp),%esi # src
cmpl %edx,%ecx
jz sm_90
sm_00: movb (%esi,%edx),%al
cmpb $0,%al
jz sm_90
movb %al,(%edi,%edx)
incl %edx
cmpl %edx,%ecx
jnz sm_00
sm_90: movb $0,(%edi,%edx)
sm_99: lea (%edi,%edx),%eax # Return pointer to end null
pop %esi
pop %edi
ret
.strmake_end:
.size strmake,.strmake_end-strmake
# Move a string with max len chars
# arg: dst,src,len
# ret: pos to first null or dst+len
.globl strnmov
.type strnmov,@function
strnmov:
pushl %edi
pushl %esi
movl 12(%esp),%edi # dst
movl 16(%esp),%esi # src
movl 20(%esp),%ecx # Length of memory-area
jecxz snm_99 # Nothing to do
clrb %al # For test of end-null
snm_10: cmpb (%esi),%al # Next char to move
movsb # move arg
jz snm_20 # last char, fill with null
loop snm_10 # Continue moving
incl %edi # Point two after last
snm_20: decl %edi # Point at first null (or last+1)
snm_99: movl %edi,%eax # Pointer at last char
popl %esi
popl %edi
ret
.strnmov_end:
.size strnmov,.strnmov_end-strnmov
.globl strmov
.type strmov,@function
strmov:
movl %esi,%ecx # Save old %esi and %edi
movl %edi,%edx
movl 8(%esp),%esi # get source pointer (s2)
movl 4(%esp),%edi # %edi -> s1
smo_10: movb (%esi),%al
movsb # move arg
andb %al,%al
jnz smo_10 # Not last
movl %edi,%eax
dec %eax
movl %ecx,%esi # Restore
movl %edx,%edi
ret
.strmov_end:
.size strmov,.strmov_end-strmov
.globl strxmov
.type strxmov,@function
strxmov:
movl %ebx,%edx # Save %ebx, %esi and %edi
mov %esi,%ecx
push %edi
leal 8(%esp),%ebx # Get destination
movl (%ebx),%edi
xorb %al,%al
jmp next_str # Handle source ebx+4
start_str:
movsb
cmpb -1(%edi),%al
jne start_str
decl %edi # Don't copy last null
next_str:
addl $4,%ebx
movl (%ebx),%esi
orl %esi,%esi
jne start_str
movb %al,0(%edi) # Force last to ASCII 0
movl %edi,%eax # Return ptr to ASCII 0
pop %edi # Restore registers
movl %ecx,%esi
movl %edx,%ebx
ret
.strxmov_end:
.size strxmov,.strxmov_end-strxmov

View file

@ -1,52 +0,0 @@
/* Copyright (C) 2002 MySQL AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; version 2
of the License.
This 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA */
/* File : strstr.c
Author : Monty
Updated: 1986.11.24
Defines: strstr()
strstr(src, pat) looks for an instance of pat in src. pat is not a
regex(3) pattern, it is a literal string which must be matched exactly.
The result is a pointer to the first character of the located instance,
or NullS if pat does not occur in src.
*/
#include <my_global.h>
#include "m_string.h"
#ifndef HAVE_STRSTR
char *strstr(register const char *str,const char *search)
{
register char *i,*j;
register char first= *search;
skip:
while (*str != '\0') {
if (*str++ == first) {
i=(char*) str; j=(char*) search+1;
while (*j)
if (*i++ != *j++) goto skip;
return ((char*) str-1);
}
}
return ((char*) 0);
} /* strstr */
#endif

View file

@ -1,209 +0,0 @@
/* Copyright (C) 2000 MySQL AB
This program 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; version 2 of the License.
This program 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
strtol,strtoul,strtoll,strtoull
convert string to long, unsigned long, long long or unsigned long long.
strtoxx(char *src,char **ptr,int base)
converts the string pointed to by src to an long of appropriate long and
returnes it. It skips leading spaces and tabs (but not newlines, formfeeds,
backspaces), then it accepts an optional sign and a sequence of digits
in the specified radix.
If the value of ptr is not (char **)NULL, a pointer to the character
terminating the scan is returned in the location pointed to by ptr.
Trailing spaces will NOT be skipped.
If an error is detected, the result will be LONG_MIN, 0 or LONG_MAX,
(or LONGLONG..) and errno will be set to
EDOM if there are no digits
ERANGE if the result would overflow.
the ptr will be set to src.
This file is based on the strtol from the the GNU C Library.
it can be compiled with the UNSIGNED and/or LONGLONG flag set
*/
#if !defined(_global_h) || !defined(_m_string_h)
# error Calling file must include 'my_global.h' and 'm_string.h'
/* see 'strtoll.c' and 'strtoull.c' for the reasons */
#endif
#include "m_ctype.h"
#include "my_sys.h" /* defines errno */
#include <errno.h>
#undef strtoull
#undef strtoll
#undef strtoul
#undef strtol
#ifdef USE_LONGLONG
#define UTYPE_MAX (~(ulonglong) 0)
#define TYPE_MIN LONGLONG_MIN
#define TYPE_MAX LONGLONG_MAX
#define longtype longlong
#define ulongtype ulonglong
#ifdef USE_UNSIGNED
#define function ulongtype strtoull
#else
#define function longtype strtoll
#endif
#else
#define UTYPE_MAX (ulong) ~0L
#define TYPE_MIN LONG_MIN
#define TYPE_MAX LONG_MAX
#define longtype long
#define ulongtype unsigned long
#ifdef USE_UNSIGNED
#define function ulongtype strtoul
#else
#define function longtype strtol
#endif
#endif
/* Convert NPTR to an `unsigned long int' or `long int' in base BASE.
If BASE is 0 the base is determined by the presence of a leading
zero, indicating octal or a leading "0x" or "0X", indicating hexadecimal.
If BASE is < 2 or > 36, it is reset to 10.
If ENDPTR is not NULL, a pointer to the character after the last
one converted is stored in *ENDPTR. */
function (const char *nptr,char **endptr,int base)
{
int negative;
register ulongtype cutoff;
register unsigned int cutlim;
register ulongtype i;
register const char *s;
register uchar c;
const char *save;
int overflow;
if (base < 0 || base == 1 || base > 36)
base = 10;
s = nptr;
/* Skip white space. */
while (my_isspace(&my_charset_latin1, *s))
++s;
if (*s == '\0')
{
goto noconv;
}
/* Check for a sign. */
negative= 0;
if (*s == '-')
{
negative = 1;
++s;
}
else if (*s == '+')
{
++s;
}
if (base == 16 && s[0] == '0' && my_toupper (&my_charset_latin1, s[1]) == 'X')
s += 2;
/* If BASE is zero, figure it out ourselves. */
if (base == 0)
{
if (*s == '0')
{
if (my_toupper (&my_charset_latin1, s[1]) == 'X')
{
s += 2;
base = 16;
}
else
base = 8;
}
else
base = 10;
}
/* Save the pointer so we can check later if anything happened. */
save = s;
cutoff = UTYPE_MAX / (unsigned long int) base;
cutlim = (uint) (UTYPE_MAX % (unsigned long int) base);
overflow = 0;
i = 0;
for (c = *s; c != '\0'; c = *++s)
{
if (my_isdigit (&my_charset_latin1, c))
c -= '0';
else if (my_isalpha (&my_charset_latin1, c))
c = my_toupper (&my_charset_latin1, c) - 'A' + 10;
else
break;
if (c >= base)
break;
/* Check for overflow. */
if (i > cutoff || (i == cutoff && c > cutlim))
overflow = 1;
else
{
i *= (ulongtype) base;
i += c;
}
}
/* Check if anything actually happened. */
if (s == save)
goto noconv;
/* Store in ENDPTR the address of one character
past the last character we converted. */
if (endptr != NULL)
*endptr = (char *) s;
#ifndef USE_UNSIGNED
/* Check for a value that is within the range of
`unsigned long int', but outside the range of `long int'. */
if (negative)
{
if (i > (ulongtype) TYPE_MIN)
overflow = 1;
}
else if (i > (ulongtype) TYPE_MAX)
overflow = 1;
#endif
if (overflow)
{
my_errno=ERANGE;
#ifdef USE_UNSIGNED
return UTYPE_MAX;
#else
return negative ? TYPE_MIN : TYPE_MAX;
#endif
}
/* Return the result of the appropriate sign. */
return (negative ? -((longtype) i) : (longtype) i);
noconv:
/* There was no number to convert. */
my_errno=EDOM;
if (endptr != NULL)
*endptr = (char *) nptr;
return 0L;
}

View file

@ -1,28 +0,0 @@
/* Copyright (C) 2000 MySQL AB
This program 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; version 2 of the License.
This program 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* This implements strtol() if needed */
/*
These includes are mandatory because they check for type sizes and
functions, especially they handle tricks for Tru64 where 'long' is
64 bit already and our 'longlong' is just a 'long'.
*/
#include <my_global.h>
#include <m_string.h>
#if !defined(HAVE_STRTOL) && !defined(__WIN__)
#include "strto.c"
#endif

View file

@ -1,33 +0,0 @@
/* Copyright (C) 2000 MySQL AB
This program 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; version 2 of the License.
This program 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* This implements strtoll() if needed */
/*
These includes are mandatory because they check for type sizes and
functions, especially they handle tricks for Tru64 where 'long' is
64 bit already and our 'longlong' is just a 'long'.
This solves a problem on Tru64 where the C99 compiler has a prototype
for 'strtoll()' but no implementation, see "6.1 New C99 library functions"
in file '/usr/share/doclib/cc.dtk/release_notes.txt'.
*/
#include <my_global.h>
#include <m_string.h>
#if !defined(HAVE_STRTOLL) && defined(HAVE_LONG_LONG)
#define USE_LONGLONG
#include "strto.c"
#endif

View file

@ -1,29 +0,0 @@
/* Copyright (C) 2000 MySQL AB
This program 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; version 2 of the License.
This program 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* This implements strtol() if needed */
/*
These includes are mandatory because they check for type sizes and
functions, especially they handle tricks for Tru64 where 'long' is
64 bit already and our 'longlong' is just a 'long'.
*/
#include <my_global.h>
#include <m_string.h>
#if !defined(HAVE_STRTOUL)
#define USE_UNSIGNED
#include "strto.c"
#endif

View file

@ -1,34 +0,0 @@
/* Copyright (C) 2000 MySQL AB
This program 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; version 2 of the License.
This program 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* This implements strtoull() if needed */
/*
These includes are mandatory because they check for type sizes and
functions, especially they handle tricks for Tru64 where 'long' is
64 bit already and our 'longlong' is just a 'long'.
This solves a problem on Tru64 where the C99 compiler has a prototype
for 'strtoull()' but no implementation, see "6.1 New C99 library functions"
in file '/usr/share/doclib/cc.dtk/release_notes.txt'.
*/
#include <my_global.h>
#include <m_string.h>
#if !defined(HAVE_STRTOULL) && defined(HAVE_LONG_LONG)
#define USE_UNSIGNED
#define USE_LONGLONG
#include "strto.c"
#endif

View file

@ -1,29 +0,0 @@
#!/bin/sh
# search & check GNU patch
PATCH="gpatch"
$PATCH --version || PATCH="patch"
$PATCH --version || exit
if /usr/bin/test ! -e PKG/stamp-pre ; then
grep VERSION configure | head -1 | sed 's/VERSION=//' > ./PKG/version
touch PKG/stamp-pre
fi
if /usr/bin/test ! -e PKG/stamp-patch ; then
${PATCH} -p0 < ./PKG/patch
touch PKG/stamp-patch
fi
if /usr/bin/test ! -e PKG/stamp-compile ; then
sh ./PKG/compile.sh ujis
touch PKG/stamp-compile
sh ./PKG/doc.sh ujis
fi
cd PKG
sh mkpkg.sh ujis

View file

@ -1,102 +0,0 @@
#!/bin/sh
# GNU ncurses
# search & check GNU make
GMAKE="gmake"
$GMAKE --version || GMAKE="make"
$GMAKE --version || exit
MAKE=$GMAKE
export MAKE
CC=gcc
CFLAGS="-O6 -fomit-frame-pointer"
CXX=gcc
CXXFLAGS="-O6 -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti"
# LDFLAGS="-static"
LD=gcc
export CC
export CXX
export LD
export CFLAGS
export CXXFLAGS
# export LDFLAGS
# Solaris don't have libpthread.a.
if [ "x$1" = "x" ]; then
echo " please set character set"
exit
fi
CHAR="$1"
case "$1" in
[uU]*)
CHAR=ujis
;;
[sS]*)
CHAR=sjis
;;
esac
#---------------
P=`pwd`
if [ -f Makefile ] ; then
${GMAKE} distclean
fi
for i in bin sbin include man share/doc/mysql mysql-data
do
/usr/bin/mkdir -p PKG/tmp-${CHAR}/usr/local/${i}
done
/usr/bin/mkdir -p PKG/tmp-${CHAR}/etc/init.d
#----------------------------
./configure \
--prefix=/usr/local \
--libexecdir=/usr/local/sbin \
--sbindir=/usr/local/sbin \
--localstatedir=/usr/local/mysql-data \
--with-charset=${CHAR} \
--with-extra-charsets=all \
--with-raid \
--without-docs \
--without-bench \
--without-perl \
--with-gcc \
--with-mysqld-ldflags="-static" \
--with-client-ldflags="-static" \
--with-named-curses-libs=/usr/local/lib/libncurses.a \
--with-mysqld-user=mysql
# --with-berkeley-db-includes=/usr/local/include/db3 \
# --with-berkeley-db-libs=/usr/local/lib/libdb3.a \
# --with-low-memory
${GMAKE}
${GMAKE} install DESTDIR=${P}/PKG/tmp-${CHAR}
v=`grep '^SHARED_LIB_VERSION' configure.in | sed 's@SHARED_LIB_VERSION@@' | sed -e 's@=@@' -e 's@:@ @g' | awk '{print $1}'`
km="libmysqlclient.so.$v"
export km
(cd ${P}/PKG/tmp-${CHAR}/usr/local/lib/mysql/ ; \
for i in libmysqlclient* ; do \
if /usr/bin/test ! -L $i ; then \
mv $i ../ ; ln -sf ../$i ; \
fi ; \
done ; \
k=`ls libmysqlclient.so.*.*.*` ; \
cd .. ; \
if /usr/bin/test ! -z libmysqlclient.so ; then \
ln -sf $k libmysqlclient.so ;
fi ; \
if /usr/bin/test ! -z $km ; then \
ln -sf $k $km ;
fi ; \
)
#
(cd ${P}/PKG/tmp-${CHAR}/usr/local/bin ; strip * )
(cd ${P}/PKG/tmp-${CHAR}/usr/local/sbin ; strip * )

View file

@ -1,17 +0,0 @@
#!/bin/sh
CHAR="$1"
case "$1" in
[uU]*)
CHAR=ujis
;;
[sS]*)
CHAR=sjis
;;
esac
cp -r Docs/* PKG/tmp-${CHAR}/usr/local/share/doc/mysql/
cp INSTALL-SOURCE* COPYING* MIRRORS README* PKG/tmp-${CHAR}/usr/local/share/doc/mysql/
cd PKG/tmp-${CHAR}/usr/local/share/doc/mysql/
gzip *.txt *.texi *.info *.pdf

View file

@ -1,47 +0,0 @@
#!/bin/sh
if [ "x$1" = "x" ]; then
echo " please set charset"
exit
fi
CHAR="$1"
case "$1" in
[uU]*)
CHAR=ujis ; CH=uj
;;
[sS]*)
CHAR=sjis ; CH=sj
;;
esac
#-------------------
DIR=`pwd`
VERSION=`cat version`
T=`uname -p`
sed -e "s/@CHAR1@/${CH}/" \
-e "s/@CHAR2@/${CHAR}/" \
-e "s/@VERSION@/${VERSION}/" \
-e "s/@TYPE@/${T}/" \
pkginfo.ini > pkginfo.${CHAR}
sed -e "s,@DIR@,${DIR},g" \
-e "s,@PKGINFO@,${DIR}/pkginfo.${CHAR}," \
prototype.ini > prototype.${CHAR}
INIT="tmp-${CHAR}/etc/init.d/mysql"
cp ../support-files/mysql.server $INIT
chmod 755 $INIT
(cd tmp-${CHAR}; \
chown root etc usr ; \
chgrp sys etc usr ;\
chmod 755 usr etc; \
chgrp sys etc/init.d ; \
chmod 755 etc/init.d ; \
find . -print|pkgproto >> ../prototype.${CHAR})
pkgmk -o -f prototype.${CHAR} -r ${DIR}/tmp-${CHAR}

View file

@ -1,96 +0,0 @@
--- scripts/safe_mysqld.sh.orig Sat Sep 2 17:28:26 2000
+++ scripts/safe_mysqld.sh Sat Sep 2 17:31:19 2000
@@ -89,10 +89,10 @@
NOHUP_NICENESS=`nohup nice`
-if test $? -ne 0 || test x"$NOHUP_NICENESS" = x0 || test ! nice --1 echo foo > /dev/null 2>&1; then
+if test $? -ne 0 || test x"$NOHUP_NICENESS" = x0 || test ! nice -1 echo foo > /dev/null 2>&1; then
NOHUP_NICENESS="nohup"
else
- NOHUP_NICENESS="nice --$NOHUP_NICENESS nohup"
+ NOHUP_NICENESS="nice -$NOHUP_NICENESS nohup"
fi
export MYSQL_UNIX_PORT
@@ -163,7 +163,8 @@
# The only thing is ps x => redhat 5 gives warnings when using ps -x.
# kill -9 is used or the process won't react on the kill.
numofproces=`ps xa | grep -v "grep" | grep -c $ledir/mysqld`
- echo -e "\nNumber of processes running now: $numofproces" | tee -a $err_log
+ echo | tee -a $err_log
+ echo "Number of processes running now: $numofproces" | tee -a $err_log
I=1
while test "$I" -le "$numofproces"
do
@@ -185,4 +186,6 @@
echo "`date +'%y%m%d %H:%M:%S mysqld restarted'`" | tee -a $err_log
done
-echo -e "`date +'%y%m%d %H:%M:%S mysqld ended\n'`" | tee -a $err_log
+echo | tee -a $err_log
+echo "`date +'%y%m%d %H:%M:%S mysqld ended'`" | tee -a $err_log
+echo | tee -a $err_log
--- support-files/mysql.server.sh.orig Sat Sep 2 17:35:56 2000
+++ support-files/mysql.server.sh Sat Sep 2 17:36:35 2000
@@ -23,6 +23,9 @@
mysql_daemon_user=@MYSQLD_USER@
export PATH
+## your options...
+OPT=""
+
mode=$1
if test -w / # determine if we should look at the root config file
@@ -82,8 +85,9 @@
then
# Give extra arguments to mysqld with the my.cnf file. This script may
# be overwritten at next upgrade.
- $bindir/safe_mysqld \
- --user=$mysql_daemon_user --datadir=$datadir --pid-file=$pid_file --log=$log_file &
+ $bindir/safe_mysqld $OPT \
+ --user=$mysql_daemon_user --datadir=$datadir --pid-file=$pid_file &
+# --log=$log_file &
else
echo "Can't execute $bindir/safe_mysqld"
fi
--- configure.orig Sat Sep 2 17:54:03 2000
+++ configure Sat Sep 2 17:54:18 2000
@@ -202,7 +202,7 @@
--with-charset=CHARSET use CHARSET by default (one of: big5 cp1251 cp1257
croat czech danish dec8 dos estonia euc_kr gb2312 gbk
german1 greek hebrew hp8 hungarian koi8_ru koi8_ukr
- latin1 latin2 swe7 usa7 win1250 win1251 win1251ukr
+ latin1 latin2 swe7 usa7 win1250 win1251ukr
ujis sjis tis620; default is latin1)"
ac_help="$ac_help
--with-extra-charsets=cs1,cs2
@@ -8843,7 +8843,7 @@
# Choose a character set
-CHARSETS_AVAILABLE="big5 cp1251 cp1257 croat czech danish dec8 dos estonia euc_kr gb2312 gbk german1 greek hebrew hp8 hungarian koi8_ru koi8_ukr latin1 latin2 swe7 usa7 win1250 win1251 win1251ukr ujis sjis tis620"
+CHARSETS_AVAILABLE="big5 cp1251 cp1257 croat czech danish dec8 dos estonia euc_kr gb2312 gbk german1 greek hebrew hp8 hungarian koi8_ru koi8_ukr latin1 latin2 swe7 usa7 win1250 win1251ukr ujis sjis tis620"
DEFAULT_CHARSET=latin1
# Check whether --with-charset or --without-charset was given.
--- configure.in.orig Sat Sep 2 17:53:57 2000
+++ configure.in Sat Sep 2 17:54:36 2000
@@ -1517,14 +1517,14 @@
dnl or other special handling, you must also create
dnl strings/ctype-$charset_name.c
-CHARSETS_AVAILABLE="big5 cp1251 cp1257 croat czech danish dec8 dos estonia euc_kr gb2312 gbk german1 greek hebrew hp8 hungarian koi8_ru koi8_ukr latin1 latin2 swe7 usa7 win1250 win1251 win1251ukr ujis sjis tis620"
+CHARSETS_AVAILABLE="big5 cp1251 cp1257 croat czech danish dec8 dos estonia euc_kr gb2312 gbk german1 greek hebrew hp8 hungarian koi8_ru koi8_ukr latin1 latin2 swe7 usa7 win1250 win1251ukr ujis sjis tis620"
DEFAULT_CHARSET=latin1
AC_ARG_WITH(charset,
[ --with-charset=CHARSET use CHARSET by default (one of: big5 cp1251 cp1257
croat czech danish dec8 dos estonia euc_kr gb2312 gbk
german1 greek hebrew hp8 hungarian koi8_ru koi8_ukr
- latin1 latin2 swe7 usa7 win1250 win1251 win1251ukr
+ latin1 latin2 swe7 usa7 win1250 win1251ukr
ujis sjis tis620; default is latin1)],
[default_charset="$withval"],
[default_charset="$DEFAULT_CHARSET"])

View file

@ -1,8 +0,0 @@
PKG=MySQL
NAME=MySQL
ARCH=@TYPE@
VERSION=@VERSION@
CATEGORY=utility
VENDOR=TcX DataKonsult AB, Detron HB and MySQL AB
BASEDIR=/
CLASSES=none

View file

@ -1,30 +0,0 @@
#!/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb:/usr/ccs/bin
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
export PATH
export LD_LIBRARY_PATH
D0="/usr/local/mysql-data"
D="${D0}/mysql"
DOFIX=0
if /usr/bin/test ! -f ${D}/tables_priv.frm -a -d ${D} ; then
DOFIX=1
fi
if [ ! -d ${D} ]; then
DOFIX=2
/usr/local/bin/mysql_install_db
fi
chown -R mysql $D0
chgrp -R mysql $D0
if /usr/bin/test $DOFIX -eq 1 ; then
/etc/init.d/mysql start
/usr/local/bin/mysql_fix_privilege_tables
else
/etc/init.d/mysql start || true
fi

View file

@ -1,21 +0,0 @@
#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb:/usr/ccs/bin
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
export PATH
export LD_LIBRARY_PATH
if /usr/bin/test -x /etc/init.d/mysql ; then
/etc/init.d/mysql stop || true
fi
#----- user check
P=`grep mysql /etc/passwd`
G=`grep mysql /etc/group`
if /usr/bin/test "x$G" = "x" ; then
/usr/sbin/groupadd mysql
fi
if /usr/bin/test "x$P" = "x" ; then
/usr/sbin/useradd -g mysql -d /usr/local/mysql-data -s /bin/false mysql
fi

View file

@ -1,25 +0,0 @@
#!/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb:/usr/ccs/bin
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
export PATH
export LD_LIBRARY_PATH
pid=`/usr/bin/ps -e | /usr/bin/grep mysqld | /usr/bin/sed -e 's/^ *//' -e 's/ .*//'`
[ "$pid" != "" ] && /usr/local/bin/mysqladmin shutdown
#---
#/usr/ucb/echo -n "Remove DATA Directory (All data expire) [Y/N]? "
#read I
I=No
case "$I" in
Y*|y*)
/usr/ucb/echo -n "Removing MySQL DATA ALL..."
rm -rf /usr/local/mysql-data
echo "done."
;;
*)
echo "not purge DATA directory"
;;
esac;

View file

@ -1,4 +0,0 @@
i pkginfo=@PKGINFO@
i postinstall=@DIR@/postinstall
i preinstall=@DIR@/preinstall
i preremove=@DIR@/preremove

View file

@ -1 +0,0 @@
3.23.23-beta

View file

@ -1,8 +0,0 @@
Windows building readme
======================================
The Windows build system uses a tool named CMake to generate build files for
a variety of project systems. This tool is combined with a set of jscript
files to enable building of MySQL for Windows directly out of a bzr clone.
For relevant information and/or for building binaries from source distribution,
please refer to http://forge.mysql.com/wiki/CMake

View file

@ -1,320 +0,0 @@
// Configure.js
//
// Copyright (C) 2006 MySQL AB
//
// This program 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; version 2 of the License.
//
// This program 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.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
ForReading = 1;
ForWriting = 2;
ForAppending = 8;
try
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var args = WScript.Arguments
// read in the Unix configure.in file
var configureInTS = fso.OpenTextFile("configure.in", ForReading);
var configureIn = configureInTS.ReadAll();
configureInTS.Close();
var default_comment = "Source distribution";
var default_port = GetValue(configureIn, "MYSQL_TCP_PORT_DEFAULT");
var actual_port = 0;
var configfile = fso.CreateTextFile("win\\configure.data", true);
for (i=0; i < args.Count(); i++)
{
var parts = args.Item(i).split('=');
switch (parts[0])
{
case "CYBOZU":
case "EMBED_MANIFESTS":
case "EXTRA_DEBUG":
case "WITH_EMBEDDED_SERVER":
case "WITHOUT_ATOMICS":
configfile.WriteLine("SET (" + args.Item(i) + " TRUE CACHE BOOL \"\")");
break;
case "MYSQL_SERVER_SUFFIX":
case "MYSQLD_EXE_SUFFIX":
configfile.WriteLine("SET (" + parts[0] + " \""
+ parts[1] + "\" CACHE STRING \"\")");
break;
case "COMPILATION_COMMENT":
default_comment = parts[1];
break;
case "MYSQL_TCP_PORT":
actual_port = parts[1];
break;
}
}
if (actual_port == 0)
{
// if we actually defaulted (as opposed to the pathological case of
// --with-tcp-port=<MYSQL_TCP_PORT_DEFAULT> which might in theory
// happen if whole batch of servers was built from a script), set
// the default to zero to indicate that; we don't lose information
// that way, because 0 obviously indicates that we can get the
// default value from MYSQL_TCP_PORT. this seems really evil, but
// testing for MYSQL_TCP_PORT==MYSQL_TCP_PORT_DEFAULT would make a
// a port of MYSQL_TCP_PORT_DEFAULT magic even if the builder did not
// intend it to mean "use the default, in fact, look up a good default
// from /etc/services if you can", but really, really meant 3306 when
// they passed in 3306. When they pass in a specific value, let them
// have it; don't second guess user and think we know better, this will
// just make people cross. this makes the the logic work like this
// (which is complicated enough):
//
// - if a port was set during build, use that as a default.
//
// - otherwise, try to look up a port in /etc/services; if that fails,
// use MYSQL_TCP_PORT_DEFAULT (at the time of this writing 3306)
//
// - allow the MYSQL_TCP_PORT environment variable to override that.
//
// - allow command-line parameters to override all of the above.
//
// the top-most MYSQL_TCP_PORT_DEFAULT is read from win/configure.js,
// so don't mess with that.
actual_port = default_port;
default_port = 0;
}
configfile.WriteLine("SET (COMPILATION_COMMENT \"" +
default_comment + "\" CACHE STRING \"\" )");
configfile.WriteLine("SET (PROTOCOL_VERSION \"" +
GetValue(configureIn, "PROTOCOL_VERSION") + "\" CACHE STRING \"\")");
configfile.WriteLine("SET (DOT_FRM_VERSION \"" +
GetValue(configureIn, "DOT_FRM_VERSION") + "\" CACHE STRING \"\")");
configfile.WriteLine("SET (MYSQL_TCP_PORT_DEFAULT \"" + default_port + "\" CACHE STRING \"\")");
configfile.WriteLine("SET (MYSQL_TCP_PORT \"" + actual_port + "\" CACHE STRING \"\")");
configfile.WriteLine("SET (MYSQL_UNIX_ADDR \"MySQL\" CACHE STRING \"\")");
var version = GetVersion(configureIn);
configfile.WriteLine("SET (VERSION \"" + version + "\" CACHE STRING \"\")");
configfile.WriteLine("SET (MYSQL_BASE_VERSION \"" +
GetBaseVersion(version) + "\" CACHE STRING \"\")");
configfile.WriteLine("SET (MYSQL_VERSION_ID \"" +
GetVersionId(version) + "\" CACHE STRING \"\")");
var engineOptions = ParsePlugins();
for (option in engineOptions)
{
configfile.WriteLine("SET(" + engineOptions[option] + " TRUE CACHE BOOL \"\")");
}
configfile.Close();
fso = null;
WScript.Echo("done!");
}
catch (e)
{
WScript.Echo("Error: " + e.description);
}
function GetValue(str, key)
{
var pos = str.indexOf(key+'=');
if (pos == -1) return null;
pos += key.length + 1;
var end = str.indexOf("\n", pos);
if (str.charAt(pos) == "\"")
pos++;
if (str.charAt(end-1) == "\"")
end--;
return str.substring(pos, end);
}
function GetVersion(str)
{
var key = "AC_INIT([MySQL Server], [";
var pos = str.indexOf(key);
if (pos == -1) return null;
pos += key.length;
var end = str.indexOf("]", pos);
if (end == -1) return null;
return str.substring(pos, end);
}
function GetBaseVersion(version)
{
var dot = version.indexOf(".");
if (dot == -1) return null;
dot = version.indexOf(".", dot+1);
if (dot == -1) dot = version.length;
return version.substring(0, dot);
}
function GetVersionId(version)
{
var dot = version.indexOf(".");
if (dot == -1) return null;
var major = parseInt(version.substring(0, dot), 10);
dot++;
var nextdot = version.indexOf(".", dot);
if (nextdot == -1) return null;
var minor = parseInt(version.substring(dot, nextdot), 10);
dot = nextdot+1;
var stop = version.indexOf("-", dot);
if (stop == -1) stop = version.length;
var build = parseInt(version.substring(dot, stop), 10);
var id = major;
if (minor < 10)
id += '0';
id += minor;
if (build < 10)
id += '0';
id += build;
return id;
}
function PluginConfig(isGroup, include)
{
this.isGroup = isGroup;
this.include = include;
}
// Parse command line arguments specific to plugins (aka storage engines).
//
// --with-plugin-PLUGIN, --with-plugins=group, --with-plugins=PLUGIN[,PLUGIN...]
// --without-plugin-PLUGIN is supported.
//
// Legacy option WITH_<PLUGIN>_STORAGE_ENGINE is supported as well.
// The function returns string array with elements like WITH_SOME_STORAGE_ENGINE
// or WITHOUT_SOME_STORAGE_ENGINE.
//
// This function handles groups, for example effect of specifying --with-plugins=max
// is the same as --with-plugins==archive,federated,falcon,innobase...
function ParsePlugins()
{
var config = new Array();
config["DEFAULT"] = new PluginConfig(true,true);
// Parse command line parameters
for (i=0; i< WScript.Arguments.length;i++)
{
var option = WScript.Arguments.Item(i);
var match = /WITH_(\w+)_STORAGE_ENGINE/.exec(option);
if (match == null)
match = /--with-plugin-(\w+)/.exec(option);
if (match != null)
{
config[match[1].toUpperCase()] = new PluginConfig(false,true);
continue;
}
match = /WITHOUT_(\w+)_STORAGE_ENGINE/.exec(option);
if (match == null)
match = /--without-plugin-(\w+)/.exec(option);
if (match != null)
{
config[match[1].toUpperCase()] =
new PluginConfig(false,false);
continue;
}
match = /--with-plugins=([\w,\-_]+)/.exec(option);
if(match != null)
{
var plugins = match[1].split(",");
for(var key in plugins)
{
config[plugins[key].toUpperCase()] =
new PluginConfig(null,true);
}
continue;
}
match = /--without-plugins=([\w,\-_]+)/.exec(option);
if(match != null)
{
var plugins = match[1].split(",");
for(var key in plugins)
config[plugins[key].toUpperCase()] =
new PluginConfig(null, false);
continue;
}
}
// Read plugin definitions, find out groups plugins belong to.
var fc = new Enumerator(fso.GetFolder("storage").SubFolders);
for (;!fc.atEnd(); fc.moveNext())
{
var subfolder = fc.item();
var name = subfolder.name.toUpperCase();
// Handle case where storage engine was already specified by name in
// --with-plugins or --without-plugins.
if (config[name] != undefined)
{
config[name].isGroup = false;
continue;
}
config[name] = new PluginConfig(false,null);
// Handle groups. For each plugin, find out which group it belongs to
// If this group was specified on command line for inclusion/exclusion,
// then include/exclude the plugin.
filename = subfolder +"\\plug.in";
if (fso.FileExists(filename))
{
var content = fso.OpenTextFile(filename, ForReading).ReadAll();
var match =
/MYSQL_STORAGE_ENGINE([ ]*)[\(]([^\)]+)[\)]/.exec(content);
if (match== null)
continue;
match = /\[[\w,\-_]+\][\s]?\)/.exec(match[0]);
if (match == null)
continue;
groups = match[0].split(/[\,\(\)\[\] ]/);
for (var key in groups)
{
var group = groups[key].toUpperCase();
if (config[group] != undefined)
{
config[group].isGroup = true;
if (config[group].include != null)
{
config[name].include = config[group].include;
break;
}
}
}
}
}
var arr = new Array();
for(key in config)
{
var eng = config[key];
if(eng.isGroup != undefined && !eng.isGroup && eng.include != undefined)
{
if (fso.FolderExists("storage\\"+key) || key=="PARTITION")
{
arr[arr.length] = eng.include?
"WITH_"+key+"_STORAGE_ENGINE":"WITHOUT_"+key+"_STORAGE_ENGINE";
}
}
}
return arr;
}

View file

@ -1,96 +0,0 @@
/*
manifest.js - Writes a custom XML manifest for each executable/library
5 command line options must be supplied:
name - Name of the executable/library into which the mainfest will be
embedded.
version - Version of the executable
arch - Architecture intended.
exe_level - Application execution level.
[asInvoker|highestAvailable|requireAdministrator]
outfile - Final destination where mainfest will be written.
Example:
cscript manifest.js name=mysql version=5.0.32 arch=X86 type=win32
exe_level=asInvoker outfile=out.xml
*/
try
{
var args = WScript.Arguments
for (i=0; i < args.Count(); i++)
{
var parts = args.Item(i).split('=');
switch (parts[0])
{
case "name":
var app_name= parts[1];
break;
case "version":
var supp_version= parts[1];
// Clean up the supplied version string.
var end= supp_version.indexOf("-");
if (end == -1) end= supp_version.length;
var app_version= supp_version.substring(0, end);
var fourth_element= 0;
if(app_version.match(/[a-z]$/)) {
fourth_element+= (1 + app_version.charCodeAt(end-1) - "a".charCodeAt(0));
app_version= app_version.substring(0,--end);
}
if(app_version.match(/sp[1-9]$/)) {
fourth_element+= 100*(app_version.charCodeAt(end-1) - "0".charCodeAt(0));
app_version= app_version.substring(0, end-3);
end-= 3;
}
app_version+= "." + fourth_element;
break;
case "arch":
var app_arch= parts[1];
break;
case "exe_level":
var app_exe_level= parts[1];
break;
case "outfile":
var manifest_file= parts[1];
break;
default:
WScript.echo("Invalid argument supplied.");
}
}
if (i != 5)
throw new Error(1, "Incorrect number of arguments.");
var manifest_xml= "<?xml version=\'1.0\' encoding=\'UTF-8\' standalone=\'yes\'?>\r\n";
manifest_xml+= "<assembly xmlns=\'urn:schemas-microsoft-com:asm.v1\'";
manifest_xml+= " manifestVersion=\'1.0\'>\r\n";
// Application Information
manifest_xml+= "\t<assemblyIdentity name=\'" + app_name + "\'";
manifest_xml+= " version=\'" + app_version + "\'";
manifest_xml+= " processorArchitecture=\'" + app_arch + "\'";
manifest_xml+= " publicKeyToken=\'02ad33b422233ae3\'";
manifest_xml+= " type=\'win32\' />\r\n";
// Identify the application security requirements.
manifest_xml+= "\t<trustInfo xmlns=\'urn:schemas-microsoft-com:asm.v2\'>\r\n";
manifest_xml+= "\t\t<security>\r\n\t\t\t<requestedPrivileges>\r\n\t\t\t\t";
manifest_xml+= "<requestedExecutionLevel level=\'" + app_exe_level + "\'";
manifest_xml+= " uiAccess=\'false\'/>\r\n";
manifest_xml+= "\t\t\t</requestedPrivileges>\r\n\t\t</security>\r\n";
manifest_xml+= "\t</trustInfo>\r\n</assembly>\r\n";
// Write the valid XML to it's final destination.
var outfileXML = WScript.CreateObject("Msxml2.DOMDocument.3.0");
outfileXML.async = false;
if (!outfileXML.loadXML(manifest_xml))
{
WScript.Echo(manifest_xml);
throw new Error(2, "Invalid XML");
}
outfileXML.save(manifest_file);
WScript.Echo("Success, created custom manifest!");
WScript.Quit(0);
}
catch (e)
{
WScript.Echo("Error: " + e.description);
WScript.Quit(1);
}

View file

@ -1,21 +0,0 @@
# - MYSQL_EMBED_MANIFEST(target_name required_privs)
# Create a manifest for target_name. Set the execution level to require_privs
#
# NOTE. PROCESSOR_ARCH must be defined before this MACRO is called.
MACRO(MYSQL_EMBED_MANIFEST _target_name _required_privs)
ADD_CUSTOM_COMMAND(
TARGET ${_target_name}
PRE_LINK
COMMAND cscript.exe
ARGS "${PROJECT_SOURCE_DIR}/win/create_manifest.js" name=$(TargetName) version=${VERSION} arch=${PROCESSOR_ARCH} exe_level=${_required_privs} outfile=$(IntDir)\\$(TargetFileName).intermediate.manifest
COMMENT "Generates the contents of the manifest contents.")
ADD_CUSTOM_COMMAND(
TARGET ${_target_name}
POST_BUILD
COMMAND mt.exe ARGS -nologo -hashupdate -makecdfs -manifest $(IntDir)\\$(TargetFileName).intermediate.manifest -outputresource:$(TargetPath)
COMMAND makecat.exe ARGS $(IntDir)\\$(TargetFileName).intermediate.manifest.cdf
COMMAND signtool.exe ARGS sign /a /t http://timestamp.verisign.com/scripts/timstamp.dll $(TargetPath)
COMMENT "Embeds the manifest contents, creates a cryptographic catalog, signs the target with Authenticode certificate.")
ENDMACRO(MYSQL_EMBED_MANIFEST)