diff options
author | Vladislav Vaintroub <wlad@montyprogram.com> | 2011-03-10 09:39:14 +0100 |
---|---|---|
committer | Vladislav Vaintroub <wlad@montyprogram.com> | 2011-03-10 09:39:14 +0100 |
commit | 41d432462b905207b9a1cf51d2fcc88a7b09dd35 (patch) | |
tree | c046292241c90cdf078c49c93539a78e80094ea0 /strings | |
parent | d4a3a7b90ef06cb3eaf68317c42020e2980d3777 (diff) | |
parent | ce675406ca8dbc1532a908803a1371de8432d466 (diff) | |
download | mariadb-git-41d432462b905207b9a1cf51d2fcc88a7b09dd35.tar.gz |
merge 5.2
Diffstat (limited to 'strings')
67 files changed, 208 insertions, 195 deletions
diff --git a/strings/CHARSET_INFO.txt b/strings/CHARSET_INFO.txt index bb8e40025c7..6f0a810be37 100644 --- a/strings/CHARSET_INFO.txt +++ b/strings/CHARSET_INFO.txt @@ -208,14 +208,11 @@ charpos() - calculates the offset of the given position in the string. Used in SQL functions LEFT(), RIGHT(), SUBSTRING(), INSERT() -well_formed_length() - - finds the length of correctly formed multi-byte beginning. - Used in INSERTs to cut a beginning of the given string - which is - a) "well formed" according to the given character set. +well_formed_len() + - returns length of a given multi-byte string in bytes + Used in INSERTs to shorten the given string so it + a) is "well formed" according to the given character set b) can fit into the given data type - Terminates the string in the good position, taking in account - multi-byte character boundaries. lengthsp() - returns the length of the given string without trailing spaces. diff --git a/strings/Makefile.am b/strings/Makefile.am index 6a09abe7479..3ba4685a2a5 100644 --- a/strings/Makefile.am +++ b/strings/Makefile.am @@ -16,13 +16,14 @@ # This file is public domain and comes with NO WARRANTY of any kind INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include +noinst_HEADERS= strings_def.h pkglib_LIBRARIES = libmystrings.a noinst_LTLIBRARIES = libmystrings.la # Exact one of ASSEMBLER_X if ASSEMBLER_x86 ASRCS = strings-x86.s longlong2str-x86.s my_strtoll10-x86.s -CSRCS = bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c str_alloc.c longlong2str_asm.c my_strchr.c strmov.c strmov_overlapp.c +CSRCS = bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c str_alloc.c longlong2str_asm.c my_strchr.c strmov_overlapp.c else if ASSEMBLER_sparc32 # These file MUST all be on the same line!! Otherwise automake diff --git a/strings/bchange.c b/strings/bchange.c index 0b2c62019b5..3a054efdb0a 100644 --- a/strings/bchange.c +++ b/strings/bchange.c @@ -23,8 +23,7 @@ src in a buffer with tot_length bytes. */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" void bchange(register uchar *dst, size_t old_length, register const uchar *src, size_t new_length, size_t tot_length) diff --git a/strings/bcmp.c b/strings/bcmp.c index 39b5f24e055..e34c47ca596 100644 --- a/strings/bcmp.c +++ b/strings/bcmp.c @@ -21,8 +21,7 @@ comparing a shorter string with bcmp. */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" #ifdef HAVE_valgrind #undef bcmp diff --git a/strings/bfill.c b/strings/bfill.c index 2750553f48a..9ca9e6b551b 100644 --- a/strings/bfill.c +++ b/strings/bfill.c @@ -29,8 +29,7 @@ code is presented for your interest and amusement. */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" #if !defined(bfill) && !defined(HAVE_BFILL) diff --git a/strings/bmove.c b/strings/bmove.c index ae9641a5d58..f94f262d7b4 100644 --- a/strings/bmove.c +++ b/strings/bmove.c @@ -36,8 +36,7 @@ code is presented for your interest and amusement. */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" #if !defined(HAVE_BMOVE) && !defined(bmove) diff --git a/strings/bmove512.c b/strings/bmove512.c index 0ae23d1f42d..308646c0586 100644 --- a/strings/bmove512.c +++ b/strings/bmove512.c @@ -25,8 +25,7 @@ fastest way to move a mutiple of 512 byte. */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" #ifndef bmove512 diff --git a/strings/bmove_upp.c b/strings/bmove_upp.c index fb47bda2d1d..fa136751b76 100644 --- a/strings/bmove_upp.c +++ b/strings/bmove_upp.c @@ -22,8 +22,7 @@ "src-len" to the destination "dst-len" counting downwards. */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" #if defined(MC68000) && defined(DS90) diff --git a/strings/conf_to_src.c b/strings/conf_to_src.c index 8bd4b682142..9a7887991a6 100644 --- a/strings/conf_to_src.c +++ b/strings/conf_to_src.c @@ -13,8 +13,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <my_global.h> -#include <m_string.h> +#include "strings_def.h" #include <m_ctype.h> #include <fcntl.h> #include <my_xml.h> @@ -250,7 +249,7 @@ static void fprint_copyright(FILE *file) { fprintf(file, -"/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.\n" +"/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems Inc., 2010-2011 Monty Program Ab\n" "\n" " This program is free software; you can redistribute it and/or modify\n" " it under the terms of the GNU General Public License as published by\n" diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index c9450973866..20edc2f5729 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -26,9 +26,8 @@ * .configure. mbmaxlen_big5=2 */ -#include <my_global.h> -#include "m_string.h" -#include "m_ctype.h" +#include "strings_def.h" +#include <m_ctype.h> #ifdef HAVE_CHARSET_big5 diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index 95544cdf42b..2ec951aaad2 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -18,9 +18,8 @@ /* This file is for binary pseudo charset, created by bar@mysql.com */ -#include <my_global.h> -#include "m_string.h" -#include "m_ctype.h" +#include "strings_def.h" +#include <m_ctype.h> static const uchar ctype_bin[]= { diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c index 4453516c7b3..9961ecacf97 100644 --- a/strings/ctype-cp932.c +++ b/strings/ctype-cp932.c @@ -16,9 +16,8 @@ /* This file is for cp932 charaset (Windows Japanese), and created based on ctype-sjis.c file */ -#include <my_global.h> -#include "m_string.h" -#include "m_ctype.h" +#include "strings_def.h" +#include <m_ctype.h> #ifdef HAVE_CHARSET_cp932 diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c index 2f32d3eae88..6f99b33de8f 100644 --- a/strings/ctype-czech.c +++ b/strings/ctype-czech.c @@ -65,9 +65,8 @@ #ifdef REAL_MYSQL -#include <my_global.h> -#include "m_string.h" -#include "m_ctype.h" +#include "strings_def.h" +#include <m_ctype.h> #else @@ -427,8 +426,7 @@ static my_bool my_like_range_czech(CHARSET_INFO *cs __attribute__((unused)), * * definition table reworked by Jaromir Dolecek <dolecek@ics.muni.cz> */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" static const uchar NEAR ctype_czech[257] = { 0, diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index c16793a9539..2c27e04ab09 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -25,9 +25,8 @@ * .configure. mbmaxlen_euc_kr=2 */ -#include <my_global.h> -#include "m_string.h" -#include "m_ctype.h" +#include "strings_def.h" +#include <m_ctype.h> #ifdef HAVE_CHARSET_euckr diff --git a/strings/ctype-eucjpms.c b/strings/ctype-eucjpms.c index d954c618ed4..d22c9c971c9 100644 --- a/strings/ctype-eucjpms.c +++ b/strings/ctype-eucjpms.c @@ -26,9 +26,8 @@ ctype-ujis.c file. * .configure. mbmaxlen_eucjpms=3 */ -#include <my_global.h> -#include "m_string.h" -#include "m_ctype.h" +#include "strings_def.h" +#include <m_ctype.h> #ifdef HAVE_CHARSET_eucjpms diff --git a/strings/ctype-extra.c b/strings/ctype-extra.c index 3e30931f579..99cec51bdaf 100644 --- a/strings/ctype-extra.c +++ b/strings/ctype-extra.c @@ -21,7 +21,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include <my_global.h> +#include "strings_def.h" #include <m_ctype.h> #ifdef HAVE_CHARSET_dec8 @@ -1040,7 +1040,7 @@ static const uint16 to_uni_cp1251_bulgarian_ci[] = { 0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077, 0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x007F, 0x0402,0x0403,0x201A,0x0453,0x201E,0x2026,0x2020,0x2021, -0x0000,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F, +0x20AC,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F, 0x0452,0x2018,0x2019,0x201C,0x201D,0x2022,0x2013,0x2014, 0x0000,0x2122,0x0459,0x203A,0x045A,0x045C,0x045B,0x045F, 0x00A0,0x040E,0x045E,0x0408,0x00A4,0x0490,0x00A6,0x00A7, @@ -1730,7 +1730,7 @@ static const uint16 to_uni_cp1251_ukrainian_ci[] = { 0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077, 0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x007F, 0x0402,0x0403,0x201A,0x0453,0x201E,0x2026,0x2020,0x2021, -0x0000,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F, +0x20AC,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F, 0x0452,0x2018,0x2019,0x201C,0x201D,0x2022,0x2013,0x2014, 0x0000,0x2122,0x0459,0x203A,0x045A,0x045C,0x045B,0x045F, 0x00A0,0x040E,0x045E,0x0408,0x00A4,0x0490,0x00A6,0x00A7, @@ -3762,7 +3762,7 @@ static const uint16 to_uni_cp1251_bin[] = { 0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077, 0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x007F, 0x0402,0x0403,0x201A,0x0453,0x201E,0x2026,0x2020,0x2021, -0x0000,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F, +0x20AC,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F, 0x0452,0x2018,0x2019,0x201C,0x201D,0x2022,0x2013,0x2014, 0x0000,0x2122,0x0459,0x203A,0x045A,0x045C,0x045B,0x045F, 0x00A0,0x040E,0x045E,0x0408,0x00A4,0x0490,0x00A6,0x00A7, @@ -3877,7 +3877,7 @@ static const uint16 to_uni_cp1251_general_ci[] = { 0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077, 0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x007F, 0x0402,0x0403,0x201A,0x0453,0x201E,0x2026,0x2020,0x2021, -0x0000,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F, +0x20AC,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F, 0x0452,0x2018,0x2019,0x201C,0x201D,0x2022,0x2013,0x2014, 0x0000,0x2122,0x0459,0x203A,0x045A,0x045C,0x045B,0x045F, 0x00A0,0x040E,0x045E,0x0408,0x00A4,0x0490,0x00A6,0x00A7, @@ -3992,7 +3992,7 @@ static const uint16 to_uni_cp1251_general_cs[] = { 0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077, 0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x007F, 0x0402,0x0403,0x201A,0x0453,0x201E,0x2026,0x2020,0x2021, -0x0000,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F, +0x20AC,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F, 0x0452,0x2018,0x2019,0x201C,0x201D,0x2022,0x2013,0x2014, 0x0000,0x2122,0x0459,0x203A,0x045A,0x045C,0x045B,0x045F, 0x00A0,0x040E,0x045E,0x0408,0x00A4,0x0490,0x00A6,0x00A7, diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index 37d0e44a4c6..68ea0957165 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -23,9 +23,8 @@ * .configure. mbmaxlen_gb2312=2 */ -#include <my_global.h> -#include "m_string.h" -#include "m_ctype.h" +#include "strings_def.h" +#include <m_ctype.h> #ifdef HAVE_CHARSET_gb2312 diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index bb9426a4b08..409ecd0c99f 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -25,9 +25,8 @@ * .configure. mbmaxlen_gbk=2 */ -#include <my_global.h> -#include "m_string.h" -#include "m_ctype.h" +#include "strings_def.h" +#include <m_ctype.h> #ifdef HAVE_CHARSET_gbk diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c index ebd019754c9..882e84ae6f6 100644 --- a/strings/ctype-latin1.c +++ b/strings/ctype-latin1.c @@ -13,9 +13,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <my_global.h> -#include "m_string.h" -#include "m_ctype.h" +#include "strings_def.h" +#include <m_ctype.h> static const uchar ctype_latin1[] = { 0, diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index ad9edf18bbe..a11476b6aa1 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -13,9 +13,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <my_global.h> -#include "m_ctype.h" -#include "m_string.h" +#include "strings_def.h" +#include <m_ctype.h> #ifdef USE_MB diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 2c55137e3a0..2894c1fbf95 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -13,9 +13,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <my_global.h> -#include "m_string.h" -#include "m_ctype.h" +#include "strings_def.h" +#include <m_ctype.h> #include "my_sys.h" /* Needed for MY_ERRNO_ERANGE */ #include <errno.h> diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index a79eff70683..cb57f4aafc9 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -16,9 +16,8 @@ /* This file is for Shift JIS charset, and created by tommy@valley.ne.jp. */ -#include <my_global.h> -#include "m_string.h" -#include "m_ctype.h" +#include "strings_def.h" +#include <m_ctype.h> #ifdef HAVE_CHARSET_sjis diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index b956f1958e9..7b5b7ff55cf 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -47,11 +47,10 @@ * .configure. strxfrm_multiply_tis620=4 */ -#include <my_global.h> -#include <my_sys.h> -#include "m_string.h" -#include "m_ctype.h" +#include "strings_def.h" +#include <m_ctype.h> #include "t_ctype.h" +#include <my_sys.h> #ifdef HAVE_CHARSET_tis620 diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 932f58d142f..0d2f1457b34 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -31,10 +31,8 @@ - No combining marks processing is done */ -#include <my_global.h> -#include "m_string.h" -#include "m_ctype.h" - +#include "strings_def.h" +#include <m_ctype.h> #define MY_UCA_CNT_FLAG_SIZE 4096 #define MY_UCA_CNT_FLAG_MASK 4095 diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index d76cbb6e64c..247ff3501d5 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -17,11 +17,9 @@ /* UCS2 support. Written by Alexander Barkov <bar@mysql.com> */ -#include <my_global.h> +#include "strings_def.h" +#include <m_ctype.h> #include <my_sys.h> -#include "m_string.h" -#include "m_ctype.h" -#include <errno.h> #include <stdarg.h> diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index 4ee26acdc4c..03f0c369342 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -25,9 +25,8 @@ * .configure. mbmaxlen_ujis=3 */ -#include <my_global.h> -#include "m_string.h" -#include "m_ctype.h" +#include "strings_def.h" +#include <m_ctype.h> #ifdef HAVE_CHARSET_ujis diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index ae1a7ad0f2e..74113a04524 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -18,10 +18,8 @@ /* UTF8 according RFC 2279 */ /* Written by Alexander Barkov <bar@udm.net> */ -#include <my_global.h> -#include "m_string.h" -#include "m_ctype.h" -#include <errno.h> +#include "strings_def.h" +#include <m_ctype.h> #ifndef EILSEQ #define EILSEQ ENOENT diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c index abef74dd6eb..5b1924d9f4d 100644 --- a/strings/ctype-win1250ch.c +++ b/strings/ctype-win1250ch.c @@ -39,9 +39,8 @@ #define REAL_MYSQL #ifdef REAL_MYSQL -#include "my_global.h" -#include "m_string.h" -#include "m_ctype.h" +#include "strings_def.h" +#include <m_ctype.h> #else diff --git a/strings/ctype.c b/strings/ctype.c index 51e97b9eb48..86b888d29a2 100644 --- a/strings/ctype.c +++ b/strings/ctype.c @@ -13,13 +13,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <my_global.h> +#include "strings_def.h" #include <m_ctype.h> #include <my_xml.h> -#ifndef SCO -#include <m_string.h> -#endif - /* diff --git a/strings/decimal.c b/strings/decimal.c index 1f879fbe9ad..9450cb0d54b 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -99,11 +99,10 @@ implementation-defined. */ -#include <my_global.h> +#include "strings_def.h" #include <m_ctype.h> #include <myisampack.h> #include <my_sys.h> /* for my_alloca */ -#include <m_string.h> #include <decimal.h> /* diff --git a/strings/do_ctype.c b/strings/do_ctype.c index f33ddc5eb81..91e29c55158 100644 --- a/strings/do_ctype.c +++ b/strings/do_ctype.c @@ -20,10 +20,9 @@ #undef DBUG_OFF #endif -#include <my_global.h> +#include "strings_def.h" #include <ctype.h> #include <my_sys.h> -#include "m_string.h" uchar NEAR to_upper[256]; uchar NEAR to_lower[256],NEAR sort_order[256]; diff --git a/strings/int2str.c b/strings/int2str.c index 411762c38d3..03e846c31dc 100644 --- a/strings/int2str.c +++ b/strings/int2str.c @@ -13,8 +13,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" /* _dig_vec arrays are public because they are used in several outer places. diff --git a/strings/is_prefix.c b/strings/is_prefix.c index 451cd468b7e..f116e6bf1bf 100644 --- a/strings/is_prefix.c +++ b/strings/is_prefix.c @@ -21,8 +21,7 @@ A empty t is allways a prefix. */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" int is_prefix(register const char *s, register const char *t) { diff --git a/strings/llstr.c b/strings/llstr.c index 678f8b05f39..fdbe1b6f6dc 100644 --- a/strings/llstr.c +++ b/strings/llstr.c @@ -24,8 +24,7 @@ */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" char *llstr(longlong value,char *buff) { diff --git a/strings/longlong2str.c b/strings/longlong2str.c index 3b837fac6d4..f320baf2e34 100644 --- a/strings/longlong2str.c +++ b/strings/longlong2str.c @@ -37,8 +37,7 @@ itoa assumes that 10 -base numbers are allways signed and other arn't. */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" #if defined(HAVE_LONG_LONG) && !defined(longlong2str) && !defined(HAVE_LONGLONG2STR) diff --git a/strings/longlong2str_asm.c b/strings/longlong2str_asm.c index b4a77511cfa..dd0daf01969 100644 --- a/strings/longlong2str_asm.c +++ b/strings/longlong2str_asm.c @@ -20,8 +20,7 @@ _dig_vector in a portable manner. */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" extern char *longlong2str_with_dig_vector(longlong val,char *dst,int radix, const char *dig_vector); diff --git a/strings/my_strchr.c b/strings/my_strchr.c index 6724bf39ff2..5f1d985ba1a 100644 --- a/strings/my_strchr.c +++ b/strings/my_strchr.c @@ -13,6 +13,44 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "strings_def.h" +#include <m_ctype.h> + +#define NEQ(A, B) ((A) != (B)) +#define EQU(A, B) ((A) == (B)) + +/** + Macro for the body of the string scanning. + + @param CS The character set of the string + @param STR Pointer to beginning of string + @param END Pointer to one-after-end of string + @param ACC Pointer to beginning of accept (or reject) string + @param LEN Length of accept (or reject) string + @param CMP is a function-like for doing the comparison of two characters. + */ + +#define SCAN_STRING(CS, STR, END, ACC, LEN, CMP) \ + do { \ + uint mbl; \ + const char *ptr_str, *ptr_acc; \ + const char *acc_end= (ACC) + (LEN); \ + for (ptr_str= (STR) ; ptr_str < (END) ; ptr_str+= mbl) \ + { \ + mbl= my_mbcharlen((CS), *(uchar*)ptr_str); \ + if (mbl < 2) \ + { \ + DBUG_ASSERT(mbl == 1); \ + for (ptr_acc= (ACC) ; ptr_acc < acc_end ; ++ptr_acc) \ + if (CMP(*ptr_acc, *ptr_str)) \ + goto end; \ + } \ + } \ +end: \ + return (size_t) (ptr_str - (STR)); \ + } while (0) + + /* my_strchr(cs, str, end, c) returns a pointer to the first place in str where c (1-byte character) occurs, or NULL if c does not occur @@ -21,11 +59,6 @@ frequently. */ -#include <my_global.h> -#include "m_string.h" -#include "m_ctype.h" - - char *my_strchr(CHARSET_INFO *cs, const char *str, const char *end, pchar c) { @@ -45,3 +78,26 @@ char *my_strchr(CHARSET_INFO *cs, const char *str, const char *end, return(0); } +/** + Calculate the length of the initial segment of 'str' which consists + entirely of characters not in 'reject'. + + @note The reject string points to single-byte characters so it is + only possible to find the first occurrence of a single-byte + character. Multi-byte characters in 'str' are treated as not + matching any character in the reject string. + + @todo should be moved to CHARSET_INFO if it's going to be called + frequently. + + @internal The implementation builds on the assumption that 'str' is long, + while 'reject' is short. So it compares each character in string + with the characters in 'reject' in a tight loop over the characters + in 'reject'. +*/ + +size_t my_strcspn(CHARSET_INFO *cs, const char *str, const char *str_end, + const char *reject) +{ + SCAN_STRING(cs, str, str_end, reject, strlen(reject), EQU); +} diff --git a/strings/my_strtoll10.c b/strings/my_strtoll10.c index 4f73b1f8e71..f8e3825b441 100644 --- a/strings/my_strtoll10.c +++ b/strings/my_strtoll10.c @@ -13,9 +13,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <my_global.h> +#include "strings_def.h" #include <my_sys.h> /* Needed for MY_ERRNO_ERANGE */ -#include <m_string.h> #undef ULONGLONG_MAX /* diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c index fbe4c1bdf6f..0e6fd09e144 100644 --- a/strings/my_vsnprintf.c +++ b/strings/my_vsnprintf.c @@ -13,10 +13,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <my_global.h> -#include <m_string.h> -#include <stdarg.h> +#include "strings_def.h" #include <m_ctype.h> +#include <stdarg.h> #define MAX_ARGS 32 /* max positional args count*/ diff --git a/strings/r_strinstr.c b/strings/r_strinstr.c index fb1e0c5a090..e342f72ed52 100644 --- a/strings/r_strinstr.c +++ b/strings/r_strinstr.c @@ -22,8 +22,7 @@ the pattern counted from the begining of the string. */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" size_t r_strinstr(reg1 const char * str, size_t from, reg4 const char * search) { diff --git a/strings/str2int.c b/strings/str2int.c index c4a4c07eeff..1bee56d1846 100644 --- a/strings/str2int.c +++ b/strings/str2int.c @@ -37,9 +37,8 @@ call has no problems. */ -#include <my_global.h> -#include "m_string.h" -#include "m_ctype.h" +#include "strings_def.h" +#include <m_ctype.h> #include "my_sys.h" /* defines errno */ #include <errno.h> diff --git a/strings/str_alloc.c b/strings/str_alloc.c index 615ad1ba1e2..bb20fde0f56 100644 --- a/strings/str_alloc.c +++ b/strings/str_alloc.c @@ -13,8 +13,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <my_global.h> -#include <m_string.h> +#include "strings_def.h" static void *my_str_malloc_default(size_t size) { diff --git a/strings/str_test.c b/strings/str_test.c index 3ddfca39419..3ad1392f185 100644 --- a/strings/str_test.c +++ b/strings/str_test.c @@ -15,9 +15,8 @@ /* Test of all stringfunktions that is coded in assembler */ -#include <my_global.h> +#include "strings_def.h" #include <stdarg.h> -#include "m_string.h" #define F_LEN 8 #define F_CHAR 'A' @@ -50,10 +49,10 @@ int main(void) errors=tests=0; init_strings(); - test_arg("bcmp(from,to,5)",(long) my_test(bcmp(from,to,5)),1L); - test_arg("bcmp(from,from,5)",(long) bcmp(from,from,5),0L); + test_arg("bcmp(from,to,5)",(long) my_test(bcmp((uchar*) from, (uchar*) to,5)),1L); + test_arg("bcmp(from,from,5)",(long) bcmp((uchar*) from, (uchar*) from,5),0L); - test_arg("bcmp(from,to,0)",(long) bcmp(from,to,0),0L); + test_arg("bcmp(from,to,0)",(long) bcmp((uchar*) from, (uchar*) 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); @@ -90,10 +89,10 @@ int main(void) 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, + test_strarg("bmove_upp(to+6,from+6,3)",(bmove_upp((uchar*) to+6, (uchar*) 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("bmove_align(to,from,8)",(bmove_align(to,from,8),0L),INT_MAX32, + test_strarg("bmove_upp(to,from,0)",(bmove_upp((uchar*) to, (uchar*) from,0),0L),INT_MAX32,0,0); + test_strarg("bmove_align(to,from,8)",(bmove_align((uchar*) to, (uchar*) 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); @@ -124,7 +123,7 @@ int main(void) 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, + test_strarg("bchange(to,2,from,4,6)",(bchange((uchar*) to,2,(uchar*) from,4,6),0L),INT_MAX32, 4,F_CHAR,2,T_CHAR,0,0); printf("tests: %d errors: %d\n",tests,errors); @@ -233,7 +232,7 @@ int compare_buff(const char *message, char * b1, char * b2, int length, { int i,error=0; - if (bcmp(b1,b2,length)) + if (bcmp((uchar*) b1, (uchar*) b2, length)) { errors++; printf("func: '%s' Buffers differ\nIs: ",message); @@ -259,19 +258,19 @@ int compare_buff(const char *message, char * b1, char * b2, int length, return error; } /* compare_buff */ - /* These are here to be loaded and examined */ + /* These are here to be loaded and examined in debugger */ 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')); + (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; } diff --git a/strings/strappend.c b/strings/strappend.c index bb926f74665..1a95da673a7 100644 --- a/strings/strappend.c +++ b/strings/strappend.c @@ -23,8 +23,7 @@ trunked. The des+len character is allways set to NULL. */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" void strappend(register char *s, size_t len, pchar fill) diff --git a/strings/strcend.c b/strings/strcend.c index 56e31d5f994..426995f5f31 100644 --- a/strings/strcend.c +++ b/strings/strcend.c @@ -22,8 +22,7 @@ occurs, or a pointer to the end-null of s if c does not occur in s. */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" #if defined(MC68000) && defined(DS90) diff --git a/strings/strcont.c b/strings/strcont.c index 5a518a3550f..9041d84b1c1 100644 --- a/strings/strcont.c +++ b/strings/strcont.c @@ -24,8 +24,7 @@ */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" char * strcont(reg1 const char *str,reg2 const char *set) { diff --git a/strings/strend.c b/strings/strend.c index 4dadf0675dc..18facccdc3f 100644 --- a/strings/strend.c +++ b/strings/strend.c @@ -27,8 +27,7 @@ Beware: the asm version works only if strlen(s) < 65535. */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" #if VaxAsm diff --git a/strings/strfill.c b/strings/strfill.c index 4b1fe67b206..9f30ef07548 100644 --- a/strings/strfill.c +++ b/strings/strfill.c @@ -23,8 +23,7 @@ strfill() returns pointer to dest+len; */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" char * strfill(char *s, size_t len, pchar fill) { diff --git a/strings/strings_def.h b/strings/strings_def.h new file mode 100644 index 00000000000..0430e9cd4d6 --- /dev/null +++ b/strings/strings_def.h @@ -0,0 +1,31 @@ +/* Copyright (C) 2011 Monty Program 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 file is to be include first in all files in the string directory */ + +#include <my_global.h> /* Define standar vars */ +#include "m_string.h" /* Exernal defintions of string functions */ + +/* + We can't use the original DBUG_ASSERT() (which includes _db_flush()) + in the strings library as libdbug is compiled after the the strings + library and we don't want to have strings depending on libdbug which + depends on mysys and strings. +*/ + +#if !defined(DBUG_OFF) +#undef DBUG_ASSERT +#define DBUG_ASSERT(A) assert(A) +#endif diff --git a/strings/strinstr.c b/strings/strinstr.c index dce498d61e8..8f2e4ecd1ee 100644 --- a/strings/strinstr.c +++ b/strings/strinstr.c @@ -25,8 +25,7 @@ char is 1. */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" size_t strinstr(reg1 const char *str,reg4 const char *search) { diff --git a/strings/strmake.c b/strings/strmake.c index 56bd3a8f084..761a0cdc5f7 100644 --- a/strings/strmake.c +++ b/strings/strmake.c @@ -24,8 +24,7 @@ strmake() returns pointer to closing null */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" char *strmake(register char *dst, register const char *src, size_t length) { diff --git a/strings/strmov.c b/strings/strmov.c index 5112ad8d90e..322c9f9ec04 100644 --- a/strings/strmov.c +++ b/strings/strmov.c @@ -21,8 +21,7 @@ into dst, which seems useful. */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" #ifndef strmov diff --git a/strings/strmov_overlapp.c b/strings/strmov_overlapp.c index 4cc3e294620..59d980fc7c4 100644 --- a/strings/strmov_overlapp.c +++ b/strings/strmov_overlapp.c @@ -13,8 +13,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" /* A trivial implementation */ char *strmov_overlapp(char *dst, const char *src) diff --git a/strings/strnlen.c b/strings/strnlen.c index 826cd5ae5dd..891087a6ebe 100644 --- a/strings/strnlen.c +++ b/strings/strnlen.c @@ -20,8 +20,7 @@ strnlen(s, len) returns the length of s or len if s is longer than len. */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" #ifndef HAVE_STRNLEN diff --git a/strings/strnmov.c b/strings/strnmov.c index 7e26877637b..2087980429a 100644 --- a/strings/strnmov.c +++ b/strings/strnmov.c @@ -20,8 +20,7 @@ truncated. */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" char *strnmov(register char *dst, register const char *src, size_t n) { diff --git a/strings/strstr.c b/strings/strstr.c index a5b50d12043..b19fb39724c 100644 --- a/strings/strstr.c +++ b/strings/strstr.c @@ -27,8 +27,7 @@ */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" #ifndef HAVE_STRSTR diff --git a/strings/strto.c b/strings/strto.c index fcb0d800b81..858d10a134f 100644 --- a/strings/strto.c +++ b/strings/strto.c @@ -40,7 +40,7 @@ /* see 'strtoll.c' and 'strtoull.c' for the reasons */ #endif -#include "m_ctype.h" +#include <m_ctype.h> #include "my_sys.h" /* defines errno */ #include <errno.h> diff --git a/strings/strtod.c b/strings/strtod.c index 4c9cf931cb3..5f2fd664da3 100644 --- a/strings/strtod.c +++ b/strings/strtod.c @@ -27,7 +27,7 @@ */ #include "my_base.h" /* Includes errno.h + EOVERFLOW */ -#include "m_ctype.h" +#include <m_ctype.h> #ifdef HAVE_IEEEFP_H #include <ieeefp.h> #endif diff --git a/strings/strtol.c b/strings/strtol.c index 42476b0226a..b8269191aa7 100644 --- a/strings/strtol.c +++ b/strings/strtol.c @@ -20,8 +20,7 @@ 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> +#include "strings_def.h" #if !defined(MSDOS) && !defined(HAVE_STRTOL) && !defined(__WIN__) #include "strto.c" diff --git a/strings/strtoll.c b/strings/strtoll.c index cfb6fbd75ee..a619ca69546 100644 --- a/strings/strtoll.c +++ b/strings/strtoll.c @@ -24,8 +24,7 @@ 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> +#include "strings_def.h" #if !defined(HAVE_STRTOLL) && defined(HAVE_LONG_LONG) #define USE_LONGLONG diff --git a/strings/strtoul.c b/strings/strtoul.c index 3e2b51bc982..ce3b61c9b3f 100644 --- a/strings/strtoul.c +++ b/strings/strtoul.c @@ -20,8 +20,7 @@ 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> +#include "strings_def.h" #if !defined(MSDOS) && !defined(HAVE_STRTOUL) #define USE_UNSIGNED diff --git a/strings/strtoull.c b/strings/strtoull.c index 94bf6904f8d..76228ec0717 100644 --- a/strings/strtoull.c +++ b/strings/strtoull.c @@ -24,8 +24,7 @@ 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> +#include "strings_def.h" #if !defined(HAVE_STRTOULL) && defined(HAVE_LONG_LONG) #define USE_UNSIGNED diff --git a/strings/strxmov.c b/strings/strxmov.c index d5d81fd9274..1f4a44b5b88 100644 --- a/strings/strxmov.c +++ b/strings/strxmov.c @@ -30,8 +30,7 @@ character pointer, or not the same bit pattern as NullS. */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" char *strxmov(char *dst,const char *src, ...) { diff --git a/strings/strxnmov.c b/strings/strxnmov.c index 16469be6e45..4685affeac9 100644 --- a/strings/strxnmov.c +++ b/strings/strxnmov.c @@ -35,8 +35,7 @@ if total-string-length >= length then dst[length] will be set to \0 */ -#include <my_global.h> -#include "m_string.h" +#include "strings_def.h" #include <stdarg.h> char *strxnmov(char *dst, size_t len, const char *src, ...) diff --git a/strings/uctypedump.c b/strings/uctypedump.c index 2e484604fd3..3ae4b7935e1 100644 --- a/strings/uctypedump.c +++ b/strings/uctypedump.c @@ -13,15 +13,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -*/ -#include <my_global.h> -#include <m_string.h> +#include "strings_def.h" #include <m_ctype.h> -#include "m_ctype.h" typedef struct my_ctype_name_st @@ -204,7 +197,7 @@ int main(int ac, char ** av) int charnum=0; int num=0; - printf("static unsigned char uctype_page%02X[256]=\n{\n",plane); + printf("static unsigned char uctype_page%02X[256]=\n{\n", (uint) plane); for(charnum=0;charnum<256;charnum++) { @@ -231,7 +224,7 @@ int main(int ac, char ** av) { char plane_name[128]="NULL"; if(uctype[plane].ctype){ - sprintf(plane_name,"uctype_page%02X",plane); + sprintf(plane_name,"uctype_page%02X",(uint) plane); } printf("\t{%d,%s}%s\n",uctype[plane].pctype,plane_name,plane<255?",":""); } diff --git a/strings/udiv.c b/strings/udiv.c index 81ac01ee9c3..7655e52e2cb 100644 --- a/strings/udiv.c +++ b/strings/udiv.c @@ -15,7 +15,7 @@ /* Do udiv and urem if machine dosn't have it */ -#include <my_global.h> +#include "strings_def.h" #include <math.h> unsigned long udiv(long unsigned int a, long unsigned int b) diff --git a/strings/xml.c b/strings/xml.c index 14da69e088a..58b20553ff7 100644 --- a/strings/xml.c +++ b/strings/xml.c @@ -13,8 +13,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "my_global.h" -#include "m_string.h" +#include "strings_def.h" #include "my_xml.h" |