~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to strings/xml.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000 MySQL AB
 
1
/* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
2
2
 
3
3
   This program is free software; you can redistribute it and/or modify
4
4
   it under the terms of the GNU General Public License as published by
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 
15
*/
15
16
 
16
17
#include "my_global.h"
17
18
#include "m_string.h"
106
107
}
107
108
 
108
109
 
 
110
static inline my_bool
 
111
my_xml_parser_prefix_cmp(MY_XML_PARSER *p, const char *s, size_t slen)
 
112
{
 
113
  return (p->cur + slen > p->end) || memcmp(p->cur, s, slen);
 
114
}
 
115
 
 
116
 
109
117
static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a)
110
118
{
111
119
  int lex;
123
131
  a->beg=p->cur;
124
132
  a->end=p->cur;
125
133
  
126
 
  if ((p->end - p->cur > 3) && !bcmp(p->cur,"<!--",4))
 
134
  if (!my_xml_parser_prefix_cmp(p, C_STRING_WITH_LEN("<!--")))
127
135
  {
128
 
    for (; (p->cur < p->end) && bcmp(p->cur, "-->", 3); p->cur++)
129
 
    {}
130
 
    if (!bcmp(p->cur, "-->", 3))
131
 
      p->cur+=3;
 
136
    for (; p->cur < p->end; p->cur++)
 
137
    {
 
138
      if (!my_xml_parser_prefix_cmp(p, C_STRING_WITH_LEN("-->")))
 
139
      {
 
140
        p->cur+= 3;
 
141
        break;
 
142
      }
 
143
    }
132
144
    a->end=p->cur;
133
145
    lex=MY_XML_COMMENT;
134
146
  }
135
 
  else if (!bcmp(p->cur, "<![CDATA[",9))
 
147
  else if (!my_xml_parser_prefix_cmp(p, C_STRING_WITH_LEN("<![CDATA[")))
136
148
  {
137
149
    p->cur+= 9;
138
150
    for (; p->cur < p->end - 2 ; p->cur++)
154
166
  }
155
167
  else if ( (p->cur[0] == '"') || (p->cur[0] == '\'') )
156
168
  {
 
169
    /*
 
170
      "string" or 'string' found.
 
171
      Scan until the closing quote/doublequote, or until the END-OF-INPUT.
 
172
    */
157
173
    p->cur++;
158
174
    for (; ( p->cur < p->end ) && (p->cur[0] != a->beg[0]); p->cur++)
159
175
    {}
160
176
    a->end=p->cur;
161
 
    if (a->beg[0] == p->cur[0])p->cur++;
 
177
    if (p->cur < p->end) /* Closing quote or doublequote has been found */
 
178
      p->cur++;
162
179
    a->beg++;
163
180
    if (!(p->flags & MY_XML_FLAG_SKIP_TEXT_NORMALIZATION))
164
181
      my_xml_norm_text(a);