summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
Diffstat (limited to 'strings')
-rw-r--r--strings/Makefile.am8
-rw-r--r--strings/decimal.c14
-rw-r--r--strings/my_strchr.c48
-rw-r--r--strings/strxnmov.c14
-rw-r--r--strings/xml.c21
5 files changed, 84 insertions, 21 deletions
diff --git a/strings/Makefile.am b/strings/Makefile.am
index c43cf0f290a..b423d395778 100644
--- a/strings/Makefile.am
+++ b/strings/Makefile.am
@@ -22,19 +22,19 @@ pkglib_LIBRARIES = libmystrings.a
# 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
+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
else
if ASSEMBLER_sparc32
# These file MUST all be on the same line!! Otherwise automake
# generats a very broken makefile
ASRCS = bmove_upp-sparc.s strappend-sparc.s strend-sparc.s strinstr-sparc.s strmake-sparc.s strmov-sparc.s strnmov-sparc.s strstr-sparc.s
-CSRCS = strcont.c strfill.c strcend.c is_prefix.c longlong2str.c 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 strxmov.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 my_strtoll10.c str_alloc.c
+CSRCS = strcont.c strfill.c strcend.c is_prefix.c longlong2str.c 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 strxmov.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 my_strtoll10.c str_alloc.c my_strchr.c
else
#no assembler
ASRCS =
# These file MUST all be on the same line!! Otherwise automake
# generats a very broken makefile
-CSRCS = strxmov.c bmove_upp.c strappend.c strcont.c strend.c strfill.c strcend.c is_prefix.c strstr.c strinstr.c strmake.c strnmov.c strmov.c longlong2str.c 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 my_strtoll10.c str_alloc.c
+CSRCS = strxmov.c bmove_upp.c strappend.c strcont.c strend.c strfill.c strcend.c is_prefix.c strstr.c strinstr.c strmake.c strnmov.c strmov.c longlong2str.c 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 my_strtoll10.c str_alloc.c my_strchr.c
endif
endif
@@ -53,7 +53,7 @@ EXTRA_DIST = ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc
bmove_upp-sparc.s strappend-sparc.s strend-sparc.s \
strinstr-sparc.s strmake-sparc.s strmov-sparc.s \
strnmov-sparc.s strstr-sparc.s strxmov-sparc.s \
- t_ctype.h
+ t_ctype.h my_strchr.c
libmystrings_a_LIBADD=
conf_to_src_SOURCES = conf_to_src.c xml.c ctype.c bcmp.c
diff --git a/strings/decimal.c b/strings/decimal.c
index 5fb37d374a2..919d4c7d3bc 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -972,12 +972,18 @@ int decimal2double(decimal_t *from, double *to)
int double2decimal(double from, decimal_t *to)
{
/* TODO: fix it, when we'll have dtoa */
- char s[400], *end;
- sprintf(s, "%.16G", from);
- end= strend(s);
- return string2decimal(s, to, &end);
+ char buff[400], *end;
+ int length, res;
+ DBUG_ENTER("double2decimal");
+ length= my_sprintf(buff, (buff, "%.16G", from));
+ DBUG_PRINT("info",("from: %g from_as_str: %s", from, buff));
+ end= buff+length;
+ res= string2decimal(buff, to, &end);
+ DBUG_PRINT("exit", ("res: %d", res));
+ DBUG_RETURN(res);
}
+
static int ull2dec(ulonglong from, decimal_t *to)
{
int intg1, error=E_DEC_OK;
diff --git a/strings/my_strchr.c b/strings/my_strchr.c
new file mode 100644
index 00000000000..3a5fbea906d
--- /dev/null
+++ b/strings/my_strchr.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 2005 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; either version 2 of the License, or
+ (at your option) any later version.
+
+ 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 */
+
+/*
+ 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
+ in str. This function is multi-byte safe.
+ TODO: should be moved to CHARSET_INFO if it's going to be called
+ frequently.
+*/
+
+#include <my_global.h>
+#include "m_string.h"
+#include "m_ctype.h"
+
+
+byte *my_strchr(CHARSET_INFO *cs, const char *str, const char *end,
+ char c)
+{
+ uint mbl;
+ while (str < end)
+ {
+ mbl= my_mbcharlen(cs, *(uchar *)str);
+ if (mbl < 2)
+ {
+ if (*str == c)
+ return((char *)str);
+ str++;
+ }
+ else
+ str+= mbl;
+ }
+ return(0);
+}
+
diff --git a/strings/strxnmov.c b/strings/strxnmov.c
index 3ef0e57650c..7f5d483061c 100644
--- a/strings/strxnmov.c
+++ b/strings/strxnmov.c
@@ -22,19 +22,17 @@
strxnmov(dst, len, src1, ..., srcn, NullS)
moves the first len characters of the concatenation of src1,...,srcn
- to dst. If there aren't that many characters, a NUL character will
- be added to the end of dst to terminate it properly. This gives the
- same effect as calling strxcpy(buff, src1, ..., srcn, NullS) with a
- large enough buffer, and then calling strnmov(dst, buff, len).
+ to dst and add a closing NUL character.
It is just like strnmov except that it concatenates multiple sources.
Beware: the last argument should be the null character pointer.
Take VERY great care not to omit it! Also be careful to use NullS
and NOT to use 0, as on some machines 0 is not the same size as a
character pointer, or not the same bit pattern as NullS.
- Note: strxnmov is like strnmov in that it moves up to len
- characters; dst will be padded on the right with one NUL characters if
- needed.
+ NOTE
+ strxnmov is like strnmov in that it moves up to len
+ characters; dst will be padded on the right with one '\0' character.
+ if total-string-length >= length then dst[length] will be set to \0
*/
#include <my_global.h>
@@ -58,8 +56,8 @@ char *strxnmov(char *dst,uint len, const char *src, ...)
dst--;
src = va_arg(pvar, char *);
}
- *dst=0;
end:
+ *dst=0;
va_end(pvar);
return dst;
}
diff --git a/strings/xml.c b/strings/xml.c
index 767cb004d34..705da592257 100644
--- a/strings/xml.c
+++ b/strings/xml.c
@@ -104,7 +104,8 @@ static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a)
a->end=p->cur;
if (a->beg[0] == p->cur[0])p->cur++;
a->beg++;
- my_xml_norm_text(a);
+ if (!(p->flags & MY_XML_FLAG_SKIP_TEXT_NORMALIZATION))
+ my_xml_norm_text(a);
lex=MY_XML_STRING;
}
else
@@ -148,7 +149,10 @@ static int my_xml_enter(MY_XML_PARSER *st, const char *str, uint len)
memcpy(st->attrend,str,len);
st->attrend+=len;
st->attrend[0]='\0';
- return st->enter ? st->enter(st,st->attr,st->attrend-st->attr) : MY_XML_OK;
+ if (st->flags & MY_XML_FLAG_RELATIVE_NAMES)
+ return st->enter ? st->enter(st, str, len) : MY_XML_OK;
+ else
+ return st->enter ? st->enter(st,st->attr,st->attrend-st->attr) : MY_XML_OK;
}
@@ -167,7 +171,7 @@ static int my_xml_leave(MY_XML_PARSER *p, const char *str, uint slen)
char s[32];
char g[32];
int rc;
-
+
/* Find previous '.' or beginning */
for( e=p->attrend; (e>p->attr) && (e[0] != '.') ; e--);
glen = (uint) ((e[0] == '.') ? (p->attrend-e-1) : p->attrend-e);
@@ -180,7 +184,10 @@ static int my_xml_leave(MY_XML_PARSER *p, const char *str, uint slen)
return MY_XML_ERROR;
}
- rc = p->leave_xml ? p->leave_xml(p,p->attr,p->attrend-p->attr) : MY_XML_OK;
+ if (p->flags & MY_XML_FLAG_RELATIVE_NAMES)
+ rc= p->leave_xml ? p->leave_xml(p, str, slen) : MY_XML_OK;
+ else
+ rc = p->leave_xml ? p->leave_xml(p,p->attr,p->attrend-p->attr) : MY_XML_OK;
*e='\0';
p->attrend=e;
@@ -240,6 +247,7 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len)
if (MY_XML_IDENT == lex)
{
+ p->current_node_type= MY_XML_NODE_TAG;
if (MY_XML_OK != my_xml_enter(p,a.beg,(uint) (a.end-a.beg)))
return MY_XML_ERROR;
}
@@ -259,6 +267,7 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len)
lex=my_xml_scan(p,&b);
if ( (lex == MY_XML_IDENT) || (lex == MY_XML_STRING) )
{
+ p->current_node_type= MY_XML_NODE_ATTR;
if ((MY_XML_OK != my_xml_enter(p,a.beg,(uint) (a.end-a.beg))) ||
(MY_XML_OK != my_xml_value(p,b.beg,(uint) (b.end-b.beg))) ||
(MY_XML_OK != my_xml_leave(p,a.beg,(uint) (a.end-a.beg))))
@@ -273,6 +282,7 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len)
}
else if ((MY_XML_STRING == lex) || (MY_XML_IDENT == lex))
{
+ p->current_node_type= MY_XML_NODE_ATTR;
if ((MY_XML_OK != my_xml_enter(p,a.beg,(uint) (a.end-a.beg))) ||
(MY_XML_OK != my_xml_leave(p,a.beg,(uint) (a.end-a.beg))))
return MY_XML_ERROR;
@@ -319,7 +329,8 @@ gt:
for ( ; (p->cur < p->end) && (p->cur[0] != '<') ; p->cur++);
a.end=p->cur;
- my_xml_norm_text(&a);
+ if (!(p->flags & MY_XML_FLAG_SKIP_TEXT_NORMALIZATION))
+ my_xml_norm_text(&a);
if (a.beg != a.end)
{
my_xml_value(p,a.beg,(uint) (a.end-a.beg));