=================================================================== RCS file: /cvs/docbook2mdoc/docbook2mdoc.c,v retrieving revision 1.45 retrieving revision 1.49 diff -u -p -r1.45 -r1.49 --- docbook2mdoc/docbook2mdoc.c 2019/03/08 10:04:01 1.45 +++ docbook2mdoc/docbook2mdoc.c 2019/03/22 15:54:42 1.49 @@ -1,4 +1,4 @@ -/* $Id: docbook2mdoc.c,v 1.45 2019/03/08 10:04:01 schwarze Exp $ */ +/* $Id: docbook2mdoc.c,v 1.49 2019/03/22 15:54:42 schwarze Exp $ */ /* * Copyright (c) 2014 Kristaps Dzonsons * @@ -41,7 +41,7 @@ struct parse { unsigned int flags; /* document-wide flags */ struct pnode *root; /* root of parse tree */ struct pnode *cur; /* current node in tree */ - char *b; /* nil-terminated buffer for pre-print */ + char *b; /* NUL-terminated buffer for pre-print */ size_t bsz; /* current length of b */ size_t mbsz; /* max bsz allocation */ int newln; /* output: are we on a fresh line */ @@ -225,7 +225,7 @@ xml_char(void *arg, const XML_Char *p, int sz) */ if (NODE_TEXT != ps->node) { for (i = 0; i < sz; i++) - if ( ! isspace((int)p[i])) + if ( ! isspace((unsigned char)p[i])) break; if (i == sz) return; @@ -265,7 +265,7 @@ pnode_trim(struct pnode *pn) assert(NODE_TEXT == pn->node); for ( ; pn->bsz > 0; pn->bsz--) - if ( ! isspace((int)pn->b[pn->bsz - 1])) + if ( ! isspace((unsigned char)pn->b[pn->bsz - 1])) break; } @@ -327,20 +327,8 @@ xml_elem_start(void *arg, const XML_Char *name, const XML_GetCurrentColumnNumber(ps->xml)); ps->stop = 1; return; - } else if (NODE_ROOT == ps->node && NODE_REFENTRY != node) { + } else if (NODE_ROOT == ps->node && NODE_REFENTRY != node) return; - } else if ( ! isparent(node, ps->node)) { - fprintf(stderr, "%s:%zu:%zu: bad parent \"%s\" " - "of node \"%s\"\n", - ps->fname, XML_GetCurrentLineNumber(ps->xml), - XML_GetCurrentColumnNumber(ps->xml), - NULL == nodes[ps->node].name ? - "(none)" : nodes[ps->node].name, - NULL == nodes[node].name ? - "(none)" : nodes[node].name); - ps->stop = 1; - return; - } if (NODE_INLINEEQUATION == node) ps->flags |= PARSE_EQN; @@ -378,29 +366,10 @@ xml_elem_start(void *arg, const XML_Char *name, const XML_GetCurrentColumnNumber(ps->xml), *att); continue; - } else if ( ! isattrkey(node, key)) { - if (warn) - fprintf(stderr, "%s:%zu:%zu: warning: " - "bad attribute \"%s\"\n", - ps->fname, - XML_GetCurrentLineNumber(ps->xml), - XML_GetCurrentColumnNumber(ps->xml), - *att); - continue; } for (val = 0; val < ATTRVAL__MAX; val++) if (0 == strcmp(*(att + 1), attrvals[val])) break; - if (ATTRVAL__MAX != val && ! isattrval(key, val)) { - if (warn) - fprintf(stderr, "%s:%zu:%zu: warning: " - "bad attribute value \"%s\"\n", - ps->fname, - XML_GetCurrentLineNumber(ps->xml), - XML_GetCurrentColumnNumber(ps->xml), - *(att + 1)); - continue; - } pattr = calloc(1, sizeof(struct pattr)); pattr->key = key; pattr->val = val; @@ -505,7 +474,7 @@ bufclear(struct parse *p) /* * Append NODE_TEXT contents to the current buffer, reallocating its * size if necessary. - * The buffer is ALWAYS nil-terminated. + * The buffer is ALWAYS NUL-terminated. */ static void bufappend(struct parse *p, struct pnode *pn) @@ -580,27 +549,27 @@ pnode_printmacrolinetext(struct parse *p, struct pnode /* Convert all space to spaces. */ for (cp = p->b; '\0' != *cp; cp++) - if (isspace((int)*cp)) + if (isspace((unsigned char)*cp)) *cp = ' '; - for (cp = p->b; isspace((int)*cp); cp++) + for (cp = p->b; isspace((unsigned char)*cp); cp++) /* Spin past whitespace (XXX: necessary?) */ ; for ( ; '\0' != *cp; cp++) { /* Escape us if we look like a macro. */ if ((cp == p->b || ' ' == *(cp - 1)) && - isupper((int)*cp) && + isupper((unsigned char)*cp) && '\0' != *(cp + 1) && - islower((int)*(cp + 1)) && + islower((unsigned char)*(cp + 1)) && ('\0' == *(cp + 2) || ' ' == *(cp + 2) || - (islower((int)*(cp + 2)) && + (islower((unsigned char)*(cp + 2)) && ('\0' == *(cp + 3) || ' ' == *(cp + 3))))) fputs("\\&", stdout); if (MACROLINE_UPPER & fl) - putchar(toupper((int)*cp)); + putchar(toupper((unsigned char)*cp)); else - putchar((int)*cp); + putchar(*cp); /* If we're a character escape, escape us. */ if ('\\' == *cp) putchar('e'); @@ -672,7 +641,7 @@ pnode_printmclosepunct(struct parse *p, struct pnode * /* Only do this for the comma/period. */ if (pn->bsz > 0 && (',' == pn->b[0] || '.' == pn->b[0]) && - (1 == pn->bsz || isspace((int)pn->b[1]))) { + (1 == pn->bsz || isspace((unsigned char)pn->b[1]))) { putchar(' '); putchar(pn->b[0]); pn->b++; @@ -1455,8 +1424,8 @@ pnode_print(struct parse *p, struct pnode *pn) for (last = '\n'; '\0' != *cp; ) { if ('\n' == last) { /* Consume all whitespace. */ - if (isspace((int)*cp)) { - while (isspace((int)*cp)) + if (isspace((unsigned char)*cp)) { + while (isspace((unsigned char)*cp)) cp++; continue; } else if ('\'' == *cp || '.' == *cp)