MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / my_xml_leave

Function my_xml_leave

strings/xml.c:286–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284
285
286static int my_xml_leave(MY_XML_PARSER *p, const char *str, size_t slen)
287{
288 char *e;
289 size_t glen;
290 char s[32];
291 char g[32];
292 int rc;
293
294 /* Find previous '/' or beginning */
295 for (e= p->attr.end; (e > p->attr.start) && (e[0] != '/') ; e--);
296 glen= (size_t) ((e[0] == '/') ? (p->attr.end - e - 1) : p->attr.end - e);
297
298 if (str && (slen != glen))
299 {
300 mstr(s,str,sizeof(s)-1,slen);
301 if (glen)
302 {
303 mstr(g,e+1,sizeof(g)-1,glen),
304 sprintf(p->errstr,"'</%s>' unexpected ('</%s>' wanted)",s,g);
305 }
306 else
307 sprintf(p->errstr,"'</%s>' unexpected (END-OF-INPUT wanted)", s);
308 return MY_XML_ERROR;
309 }
310
311 if (p->flags & MY_XML_FLAG_RELATIVE_NAMES)
312 rc= p->leave_xml ? p->leave_xml(p, str, slen) : MY_XML_OK;
313 else
314 rc= (p->leave_xml ?
315 p->leave_xml(p, p->attr.start, p->attr.end - p->attr.start) :
316 MY_XML_OK);
317
318 *e='\0';
319 p->attr.end= e;
320
321 return rc;
322}
323
324
325int my_xml_parse(MY_XML_PARSER *p,const char *str, size_t len)

Callers 1

my_xml_parseFunction · 0.85

Calls 1

mstrFunction · 0.70

Tested by

no test coverage detected