MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlParserPrintFileContextInternal

Function xmlParserPrintFileContextInternal

ThirdParty/libxml2/vtklibxml2/error.c:324–386  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

322 */
323
324static void
325xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
326 xmlGenericErrorFunc channel, void *data ) {
327 const xmlChar *cur, *base, *start;
328 unsigned int n, col; /* GCC warns if signed, because compared with sizeof() */
329 xmlChar content[81]; /* space for 80 chars + line terminator */
330 xmlChar *ctnt;
331
332 if ((input == NULL) || (input->cur == NULL))
333 return;
334
335 cur = input->cur;
336 base = input->base;
337 /* skip backwards over any end-of-lines */
338 while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r'))) {
339 cur--;
340 }
341 n = 0;
342 /* search backwards for beginning-of-line (to max buff size) */
343 while ((n < sizeof(content) - 1) && (cur > base) &&
344 (*cur != '\n') && (*cur != '\r')) {
345 cur--;
346 n++;
347 }
348 if ((n > 0) && ((*cur == '\n') || (*cur == '\r'))) {
349 cur++;
350 } else {
351 /* skip over continuation bytes */
352 while ((cur < input->cur) && ((*cur & 0xC0) == 0x80))
353 cur++;
354 }
355 /* calculate the error position in terms of the current position */
356 col = input->cur - cur;
357 /* search forward for end-of-line (to max buff size) */
358 n = 0;
359 start = cur;
360 /* copy selected text to our buffer */
361 while ((*cur != 0) && (*(cur) != '\n') && (*(cur) != '\r')) {
362 int len = input->end - cur;
363 int c = xmlGetUTF8Char(cur, &len);
364
365 if ((c < 0) || (n + len > sizeof(content)-1))
366 break;
367 cur += len;
368 n += len;
369 }
370 memcpy(content, start, n);
371 content[n] = 0;
372 /* print out the selected text */
373 channel(data ,"%s\n", content);
374 /* create blank line with problem pointer */
375 n = 0;
376 ctnt = content;
377 /* (leave buffer space for pointer + line terminator) */
378 while ((n<col) && (n++ < sizeof(content)-2) && (*ctnt != 0)) {
379 if (*(ctnt) != '\t')
380 *(ctnt) = ' ';
381 ctnt++;

Callers 2

xmlFormatErrorFunction · 0.85

Calls 1

xmlGetUTF8CharFunction · 0.85

Tested by

no test coverage detected