summaryrefslogtreecommitdiff
path: root/sql/gstream.cc
diff options
context:
space:
mode:
authormonty@narttu.mysql.fi <>2002-08-30 12:40:40 +0300
committermonty@narttu.mysql.fi <>2002-08-30 12:40:40 +0300
commit7134ffec210edde21860a2b2c2654be481de49b4 (patch)
tree1bb81fd601075133af9ee99bd7ac94baf5ffc46c /sql/gstream.cc
parent921f7c9c551d9e1bdd5083ebe71d204ab6246ba1 (diff)
parentdd5382187e68ff5337e1fe7ba5f86f0d9cdd31d5 (diff)
downloadmariadb-git-7134ffec210edde21860a2b2c2654be481de49b4.tar.gz
Merge with 4.0.3
Some simple optimzations, more comments and indentation changes. Add ` around database in 'use database' in binary log. Moved max_error_count and max_warning_count to variables struct. Removed SHOW_WARNS_COUNT and SHOW_ERRORS_COUNT calls. Changed string functions to use character set of first string argument as default return characterset (Each string function can change the above assumption if needed)
Diffstat (limited to 'sql/gstream.cc')
-rw-r--r--sql/gstream.cc137
1 files changed, 137 insertions, 0 deletions
diff --git a/sql/gstream.cc b/sql/gstream.cc
new file mode 100644
index 00000000000..5a58fef6744
--- /dev/null
+++ b/sql/gstream.cc
@@ -0,0 +1,137 @@
+#include "mysql_priv.h"
+
+int GTextReadStream::get_next_toc_type() const
+{
+ const char *cur = m_cur;
+ while((*cur)&&(strchr(" \t\r\n",*cur)))
+ {
+ cur++;
+ }
+ if(!(*cur))
+ {
+ return eostream;
+ }
+
+ if(((*cur>='a') && (*cur<='z')) || ((*cur>='A') && (*cur<='Z')) || (*cur=='_'))
+ {
+ return word;
+ }
+
+ if(((*cur>='0') && (*cur<='9')) || (*cur=='-') || (*cur=='+') || (*cur=='.'))
+ {
+ return numeric;
+ }
+
+ if(*cur == '(')
+ {
+ return l_bra;
+ }
+
+ if(*cur == ')')
+ {
+ return r_bra;
+ }
+
+ if(*cur == ',')
+ {
+ return comma;
+ }
+
+ return unknown;
+}
+
+const char *GTextReadStream::get_next_word(int *word_len)
+{
+ const char *cur = m_cur;
+ while((*cur)&&(strchr(" \t\r\n",*cur)))
+ {
+ cur++;
+ }
+ m_last_text_position = cur;
+
+ if(!(*cur))
+ {
+ return 0;
+ }
+
+ const char *wd_start = cur;
+
+ if(((*cur<'a') || (*cur>'z')) && ((*cur<'A') || (*cur>'Z')) && (*cur!='_'))
+ {
+ return NULL;
+ }
+
+ ++cur;
+
+ while(((*cur>='a') && (*cur<='z')) || ((*cur>='A') && (*cur<='Z')) || (*cur=='_') ||
+ ((*cur>='0') && (*cur<='9')))
+ {
+ ++cur;
+ }
+
+ *word_len = cur - wd_start;
+
+ m_cur = cur;
+
+ return wd_start;
+}
+
+int GTextReadStream::get_next_number(double *d)
+{
+ const char *cur = m_cur;
+ while((*cur)&&(strchr(" \t\r\n",*cur)))
+ {
+ cur++;
+ }
+
+ m_last_text_position = cur;
+ if(!(*cur))
+ {
+ set_error_msg("Numeric constant expected");
+ return 1;
+ }
+
+ if(((*cur<'0') || (*cur>'9')) && (*cur!='-') && (*cur!='+') && (*cur!='.'))
+ {
+ set_error_msg("Numeric constant expected");
+ return 1;
+ }
+
+ char *endptr;
+
+ *d = strtod(cur, &endptr);
+
+ if(endptr)
+ {
+ m_cur = endptr;
+ }
+
+ return 0;
+}
+
+char GTextReadStream::get_next_symbol()
+{
+ const char *cur = m_cur;
+ while((*cur)&&(strchr(" \t\r\n",*cur)))
+ {
+ cur++;
+ }
+ if(!(*cur))
+ {
+ return 0;
+ }
+
+ m_cur = cur + 1;
+ m_last_text_position = cur;
+
+ return *cur;
+}
+
+void GTextReadStream::set_error_msg(const char *msg)
+{
+ size_t len = strlen(msg);
+ m_err_msg = (char *)my_realloc(m_err_msg, len + 1, MYF(MY_ALLOW_ZERO_PTR));
+ memcpy(m_err_msg, msg, len + 1);
+}
+
+