* xmlSplitQName4: * @name: the full QName * @prefixPtr: pointer to resulting prefix * * Parse a QName. The return value points to the start of the local * name in the input string. If the QName has a prefix, it will be * allocated and stored in @prefixPtr. This string must be freed by * the caller. If there's no prefix, @prefixPtr is set to NULL. * * Returns the local name or NULL if a
| 304 | * Returns the local name or NULL if a memory allocation failed. |
| 305 | */ |
| 306 | const xmlChar * |
| 307 | xmlSplitQName4(const xmlChar *name, xmlChar **prefixPtr) { |
| 308 | xmlChar *prefix; |
| 309 | int l = 0; |
| 310 | |
| 311 | if ((name == NULL) || (prefixPtr == NULL)) |
| 312 | return(NULL); |
| 313 | |
| 314 | *prefixPtr = NULL; |
| 315 | |
| 316 | /* nasty but valid */ |
| 317 | if (name[0] == ':') |
| 318 | return(name); |
| 319 | |
| 320 | /* |
| 321 | * we are not trying to validate but just to cut, and yes it will |
| 322 | * work even if this is as set of UTF-8 encoded chars |
| 323 | */ |
| 324 | while ((name[l] != 0) && (name[l] != ':')) |
| 325 | l++; |
| 326 | |
| 327 | /* |
| 328 | * TODO: What about names with multiple colons? |
| 329 | */ |
| 330 | if ((name[l] == 0) || (name[l+1] == 0)) |
| 331 | return(name); |
| 332 | |
| 333 | prefix = xmlStrndup(name, l); |
| 334 | if (prefix == NULL) |
| 335 | return(NULL); |
| 336 | |
| 337 | *prefixPtr = prefix; |
| 338 | return(&name[l+1]); |
| 339 | } |
| 340 | |
| 341 | /************************************************************************ |
| 342 | * * |
no test coverage detected