* xmlSchemaCollapseString: * @value: a value * * Removes and normalize white spaces in the string * * Returns the new string or NULL if no change was required. */
| 2226 | * Returns the new string or NULL if no change was required. |
| 2227 | */ |
| 2228 | xmlChar * |
| 2229 | xmlSchemaCollapseString(const xmlChar *value) { |
| 2230 | const xmlChar *start = value, *end, *f; |
| 2231 | xmlChar *g; |
| 2232 | int col = 0; |
| 2233 | |
| 2234 | if (value == NULL) return(NULL); |
| 2235 | while ((*start != 0) && (IS_BLANK_CH(*start))) start++; |
| 2236 | end = start; |
| 2237 | while (*end != 0) { |
| 2238 | if ((*end == ' ') && (IS_BLANK_CH(end[1]))) { |
| 2239 | col = end - start; |
| 2240 | break; |
| 2241 | } else if ((*end == 0xa) || (*end == 0x9) || (*end == 0xd)) { |
| 2242 | col = end - start; |
| 2243 | break; |
| 2244 | } |
| 2245 | end++; |
| 2246 | } |
| 2247 | if (col == 0) { |
| 2248 | f = end; |
| 2249 | end--; |
| 2250 | while ((end > start) && (IS_BLANK_CH(*end))) end--; |
| 2251 | end++; |
| 2252 | if ((start == value) && (f == end)) return(NULL); |
| 2253 | return(xmlStrndup(start, end - start)); |
| 2254 | } |
| 2255 | start = xmlStrdup(start); |
| 2256 | if (start == NULL) return(NULL); |
| 2257 | g = (xmlChar *) (start + col); |
| 2258 | end = g; |
| 2259 | while (*end != 0) { |
| 2260 | if (IS_BLANK_CH(*end)) { |
| 2261 | end++; |
| 2262 | while (IS_BLANK_CH(*end)) end++; |
| 2263 | if (*end != 0) |
| 2264 | *g++ = ' '; |
| 2265 | } else |
| 2266 | *g++ = *end++; |
| 2267 | } |
| 2268 | *g = 0; |
| 2269 | return((xmlChar *) start); |
| 2270 | } |
| 2271 | |
| 2272 | /** |
| 2273 | * xmlSchemaValAtomicListNode: |
no test coverage detected