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) /* iksemel (XML parser for Jabber)
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net> ** 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 ** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU Lesser General Public License. ** modify it under the terms of GNU Lesser General Public License.
*/ */
...@@ -652,7 +653,8 @@ sax_core (iksparser *prs, char *buf, int len) ...@@ -652,7 +653,8 @@ sax_core (iksparser *prs, char *buf, int len)
switch (prs->context) { switch (prs->context) {
case C_CDATA: case C_CDATA:
if ('&' == c) { switch(c){
case '&':
if (old < pos && prs->cdataHook) { if (old < pos && prs->cdataHook) {
err = prs->cdataHook (prs->user_data, &buf[old], pos - old); err = prs->cdataHook (prs->user_data, &buf[old], pos - old);
if (IKS_OK != err) return err; if (IKS_OK != err) return err;
...@@ -660,7 +662,7 @@ sax_core (iksparser *prs, char *buf, int len) ...@@ -660,7 +662,7 @@ sax_core (iksparser *prs, char *buf, int len)
prs->context = C_ENTITY; prs->context = C_ENTITY;
prs->entpos = 0; prs->entpos = 0;
break; break;
}else if ('<' == c) { case '<':
if (old < pos && prs->cdataHook) { if (old < pos && prs->cdataHook) {
err = prs->cdataHook (prs->user_data, &buf[old], pos - old); err = prs->cdataHook (prs->user_data, &buf[old], pos - old);
if (IKS_OK != err) return err; if (IKS_OK != err) return err;
...@@ -669,18 +671,20 @@ sax_core (iksparser *prs, char *buf, int len) ...@@ -669,18 +671,20 @@ sax_core (iksparser *prs, char *buf, int len)
prs->tag_name = STACK_PUSH_START; prs->tag_name = STACK_PUSH_START;
if (!prs->tag_name) return IKS_NOMEM; if (!prs->tag_name) return IKS_NOMEM;
prs->context = C_TAG_START; prs->context = C_TAG_START;
break;
} }
break; break;
case C_TAG_START: case C_TAG_START:
prs->context = C_TAG; prs->context = C_TAG;
if ('/' == c) { switch(c){
case '/':
prs->tagtype = IKS_CLOSE; prs->tagtype = IKS_CLOSE;
break; break;
}else if ('?' == c) { case '?':
prs->context = C_PI; prs->context = C_PI;
break; break;
}else if ('!' == c) { case '!':
prs->context = C_MARKUP; prs->context = C_MARKUP;
break; break;
} }
...@@ -689,7 +693,11 @@ sax_core (iksparser *prs, char *buf, int len) ...@@ -689,7 +693,11 @@ sax_core (iksparser *prs, char *buf, int len)
break; break;
case C_TAG: case C_TAG:
if (IS_WHITESPACE(c)) { switch(c){
case ' ':
case '\t':
case '\r':
case '\n':
if (IKS_CLOSE == prs->tagtype) if (IKS_CLOSE == prs->tagtype)
prs->oldcontext = C_TAG_END; prs->oldcontext = C_TAG_END;
else else
...@@ -699,7 +707,7 @@ sax_core (iksparser *prs, char *buf, int len) ...@@ -699,7 +707,7 @@ sax_core (iksparser *prs, char *buf, int len)
stack_old = -1; stack_old = -1;
STACK_PUSH_END; STACK_PUSH_END;
break; break;
}else if ('/' == c) { case '/':
if (IKS_CLOSE == prs->tagtype) return IKS_BADXML; if (IKS_CLOSE == prs->tagtype) return IKS_BADXML;
prs->tagtype = IKS_SINGLE; prs->tagtype = IKS_SINGLE;
prs->context = C_TAG_END; prs->context = C_TAG_END;
...@@ -707,7 +715,7 @@ sax_core (iksparser *prs, char *buf, int len) ...@@ -707,7 +715,7 @@ sax_core (iksparser *prs, char *buf, int len)
stack_old = -1; stack_old = -1;
STACK_PUSH_END; STACK_PUSH_END;
break; break;
}else if ('>' == c) { case '>':
prs->context = C_TAG_END; prs->context = C_TAG_END;
if (stack_old != -1) STACK_PUSH (buf + stack_old, pos - stack_old); if (stack_old != -1) STACK_PUSH (buf + stack_old, pos - stack_old);
stack_old = -1; stack_old = -1;
...@@ -735,11 +743,12 @@ sax_core (iksparser *prs, char *buf, int len) ...@@ -735,11 +743,12 @@ sax_core (iksparser *prs, char *buf, int len)
break; break;
case C_ATTRIBUTE: case C_ATTRIBUTE:
if ('/' == c) { switch(c){
case '/':
prs->tagtype = IKS_SINGLE; prs->tagtype = IKS_SINGLE;
prs->context = C_TAG_END; prs->context = C_TAG_END;
break; break;
}else if ('>' == c) { case '>':
prs->context = C_TAG_END; prs->context = C_TAG_END;
re = 1; re = 1;
break; break;
...@@ -780,12 +789,13 @@ sax_core (iksparser *prs, char *buf, int len) ...@@ -780,12 +789,13 @@ sax_core (iksparser *prs, char *buf, int len)
break; break;
case C_ATTRIBUTE_2: case C_ATTRIBUTE_2:
if ('/' == c) { switch(c){
case '/':
prs->tagtype = IKS_SINGLE; prs->tagtype = IKS_SINGLE;
prs->atts[prs->attcur] = NULL; prs->atts[prs->attcur] = NULL;
prs->context = C_TAG_END; prs->context = C_TAG_END;
break; break;
}else if ('>' == c) { case '>':
prs->atts[prs->attcur] = NULL; prs->atts[prs->attcur] = NULL;
prs->context = C_TAG_END; prs->context = C_TAG_END;
re = 1; re = 1;
...@@ -797,10 +807,11 @@ sax_core (iksparser *prs, char *buf, int len) ...@@ -797,10 +807,11 @@ sax_core (iksparser *prs, char *buf, int len)
case C_VALUE: case C_VALUE:
prs->atts[prs->attcur + 1] = STACK_PUSH_START; prs->atts[prs->attcur + 1] = STACK_PUSH_START;
if ('\'' == c) { switch(c){
case '\'':
prs->context = C_VALUE_APOS; prs->context = C_VALUE_APOS;
break; break;
}else if ('"' == c) { case '\"':
prs->context = C_VALUE_QUOT; prs->context = C_VALUE_QUOT;
break; 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