Kaydet (Commit) 215c1376 authored tarafından Ali Rıza KESKİN's avatar Ali Rıza KESKİN

Hardy optimized.

üst cb49cf72
/* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
** Modification 2016-2020 Ali Rıza Keskin <parduscix@yandex.ru>
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License.
*/
......@@ -652,7 +653,8 @@ sax_core (iksparser *prs, char *buf, int len)
switch (prs->context) {
case C_CDATA:
if ('&' == c) {
switch(c){
case '&':
if (old < pos && prs->cdataHook) {
err = prs->cdataHook (prs->user_data, &buf[old], pos - old);
if (IKS_OK != err) return err;
......@@ -660,7 +662,7 @@ sax_core (iksparser *prs, char *buf, int len)
prs->context = C_ENTITY;
prs->entpos = 0;
break;
}else if ('<' == c) {
case '<':
if (old < pos && prs->cdataHook) {
err = prs->cdataHook (prs->user_data, &buf[old], pos - old);
if (IKS_OK != err) return err;
......@@ -669,18 +671,20 @@ sax_core (iksparser *prs, char *buf, int len)
prs->tag_name = STACK_PUSH_START;
if (!prs->tag_name) return IKS_NOMEM;
prs->context = C_TAG_START;
break;
}
break;
case C_TAG_START:
prs->context = C_TAG;
if ('/' == c) {
switch(c){
case '/':
prs->tagtype = IKS_CLOSE;
break;
}else if ('?' == c) {
case '?':
prs->context = C_PI;
break;
}else if ('!' == c) {
case '!':
prs->context = C_MARKUP;
break;
}
......@@ -689,7 +693,11 @@ sax_core (iksparser *prs, char *buf, int len)
break;
case C_TAG:
if (IS_WHITESPACE(c)) {
switch(c){
case ' ':
case '\t':
case '\r':
case '\n':
if (IKS_CLOSE == prs->tagtype)
prs->oldcontext = C_TAG_END;
else
......@@ -699,7 +707,7 @@ sax_core (iksparser *prs, char *buf, int len)
stack_old = -1;
STACK_PUSH_END;
break;
}else if ('/' == c) {
case '/':
if (IKS_CLOSE == prs->tagtype) return IKS_BADXML;
prs->tagtype = IKS_SINGLE;
prs->context = C_TAG_END;
......@@ -707,7 +715,7 @@ sax_core (iksparser *prs, char *buf, int len)
stack_old = -1;
STACK_PUSH_END;
break;
}else if ('>' == c) {
case '>':
prs->context = C_TAG_END;
if (stack_old != -1) STACK_PUSH (buf + stack_old, pos - stack_old);
stack_old = -1;
......@@ -735,11 +743,12 @@ sax_core (iksparser *prs, char *buf, int len)
break;
case C_ATTRIBUTE:
if ('/' == c) {
switch(c){
case '/':
prs->tagtype = IKS_SINGLE;
prs->context = C_TAG_END;
break;
}else if ('>' == c) {
case '>':
prs->context = C_TAG_END;
re = 1;
break;
......@@ -780,12 +789,13 @@ sax_core (iksparser *prs, char *buf, int len)
break;
case C_ATTRIBUTE_2:
if ('/' == c) {
switch(c){
case '/':
prs->tagtype = IKS_SINGLE;
prs->atts[prs->attcur] = NULL;
prs->context = C_TAG_END;
break;
}else if ('>' == c) {
case '>':
prs->atts[prs->attcur] = NULL;
prs->context = C_TAG_END;
re = 1;
......@@ -797,10 +807,11 @@ sax_core (iksparser *prs, char *buf, int len)
case C_VALUE:
prs->atts[prs->attcur + 1] = STACK_PUSH_START;
if ('\'' == c) {
switch(c){
case '\'':
prs->context = C_VALUE_APOS;
break;
}else if ('"' == c) {
case '\"':
prs->context = C_VALUE_QUOT;
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment