FreeBSD/contrib/mdocml/demandoc.c
/*
 * Strip the escapes out of a string, emitting the results.
 */
Strip the escapes out of a string, emitting the results.
Strip the escapes out of a string emitting the results .
static void
pstring(const char *p, int col, int *colp, int list)
{
	enum mandoc_esc	 esc;
	const char	*start, *end;
	int		 emit;
again:
	if (list && '\0' != *p) {
		while (isspace((unsigned char)*p))
			p++;
		while ('\'' == *p || '(' == *p || '"' == *p)
			p++;
		emit = isalpha((unsigned char)p[0]) &&
			isalpha((unsigned char)p[1]);
		for (start = p; '\0' != *p; p++)
			if ('\\' == *p) {
				p++;
				esc = mandoc_escape(&p, NULL, NULL);
				if (ESCAPE_ERROR == esc)
					return;
				emit = 0;
			} else if (isspace((unsigned char)*p))
				break;
		end = p - 1;
		while (end > start)
			if ('.' == *end || ',' == *end ||
					'\'' == *end || '"' == *end ||
					')' == *end || '!' == *end ||
					'?' == *end || ':' == *end ||
					';' == *end)
				end--;
			else
				break;
		if (emit && end - start >= 1) {
			for ( ; start <= end; start++)
				if (ASCII_HYPH == *start)
					putchar('-');
				else
					putchar((unsigned char)*start);
			putchar('\n');
		}
		if (isspace((unsigned char)*p))
			goto again;
		return;
	}
	while (*colp < col) {
		putchar(' ');
		(*colp)++;
	}
	while ('\0' != *p)
		if ('\\' == *p) {
			p++;
			esc = mandoc_escape(&p, NULL, NULL);
			if (ESCAPE_ERROR == esc)
				break;
		} else {
			putchar((unsigned char )*p++);
			(*colp)++;
		}
}
static void pstring ( const char * p , int col , int * colp , int list ) { enum mandoc_esc esc ; const char * start , * end ; int emit ; again : if ( list && ' \0 ' != * p ) { while ( isspace ( ( unsigned char ) * p ) ) p ++ ; while ( ' \' ' == * p || ' ' == * p || ' ' == * p ) p ++ ; emit = isalpha ( ( unsigned char ) p [ 0 ] ) && isalpha ( ( unsigned char ) p [ 1 ] ) ; for ( start = p ; ' \0 ' != * p ; p ++ ) if ( ' \\ ' == * p ) { p ++ ; esc = mandoc_escape ( & p , NULL , NULL ) ; if ( ESCAPE_ERROR == esc ) return ; emit = 0 ; } else if ( isspace ( ( unsigned char ) * p ) ) break ; end = p - 1 ; while ( end > start ) if ( ' ' == * end || ' ' == * end || ' \' ' == * end || ' ' == * end || ' ' == * end || ' ' == * end || ' ' == * end || ' ' == * end || ' ' == * end ) end -- ; else break ; if ( emit && end - start >= 1 ) { for ( ; start <= end ; start ++ ) if ( ASCII_HYPH == * start ) putchar ( ' ' ) ; else putchar ( ( unsigned char ) * start ) ; putchar ( ' \n ' ) ; } if ( isspace ( ( unsigned char ) * p ) ) goto again ; return ; } while ( * colp < col ) { putchar ( ' ' ) ; ( * colp ) ++ ; } while ( ' \0 ' != * p ) if ( ' \\ ' == * p ) { p ++ ; esc = mandoc_escape ( & p , NULL , NULL ) ; if ( ESCAPE_ERROR == esc ) break ; } else { putchar ( ( unsigned char ) * p ++ ) ; ( * colp ) ++ ; } }
Strip the escapes out of a string, emitting the results.
Strip the escapes out of a string emitting the results .
/*
	 * Print as many column spaces til we achieve parity with the
	 * input document.
	 */ /*
	 * Print the input word, skipping any special characters.
	 */