Annotation of mandoc/out.c, Revision 1.1
1.1 ! kristaps 1: /* $Id: html.c,v 1.40 2009/09/20 19:44:16 kristaps Exp $ */
! 2: /*
! 3: * Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
! 4: *
! 5: * Permission to use, copy, modify, and distribute this software for any
! 6: * purpose with or without fee is hereby granted, provided that the above
! 7: * copyright notice and this permission notice appear in all copies.
! 8: *
! 9: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
! 10: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
! 11: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
! 12: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
! 13: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
! 14: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
! 15: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
! 16: */
! 17: #include <sys/types.h>
! 18:
! 19: #include <assert.h>
! 20: #include <ctype.h>
! 21: #include <stdlib.h>
! 22: #include <string.h>
! 23:
! 24: #include "mdoc.h"
! 25: #include "man.h"
! 26: #include "out.h"
! 27:
! 28: int
! 29: out_a2list(const struct mdoc_node *n)
! 30: {
! 31: int i;
! 32:
! 33: assert(MDOC_BLOCK == n->type && MDOC_Bl == n->tok);
! 34: assert(n->args);
! 35:
! 36: for (i = 0; i < (int)n->args->argc; i++)
! 37: switch (n->args->argv[i].arg) {
! 38: case (MDOC_Enum):
! 39: /* FALLTHROUGH */
! 40: case (MDOC_Dash):
! 41: /* FALLTHROUGH */
! 42: case (MDOC_Hyphen):
! 43: /* FALLTHROUGH */
! 44: case (MDOC_Bullet):
! 45: /* FALLTHROUGH */
! 46: case (MDOC_Tag):
! 47: /* FALLTHROUGH */
! 48: case (MDOC_Hang):
! 49: /* FALLTHROUGH */
! 50: case (MDOC_Inset):
! 51: /* FALLTHROUGH */
! 52: case (MDOC_Diag):
! 53: /* FALLTHROUGH */
! 54: case (MDOC_Item):
! 55: /* FALLTHROUGH */
! 56: case (MDOC_Column):
! 57: /* FALLTHROUGH */
! 58: case (MDOC_Ohang):
! 59: return(n->args->argv[i].arg);
! 60: default:
! 61: break;
! 62: }
! 63:
! 64: abort();
! 65: /* NOTREACHED */
! 66: }
! 67:
! 68:
! 69: int
! 70: out_a2width(const char *p)
! 71: {
! 72: int i, len;
! 73:
! 74: if (0 == (len = (int)strlen(p)))
! 75: return(0);
! 76: for (i = 0; i < len - 1; i++)
! 77: if ( ! isdigit((u_char)p[i]))
! 78: break;
! 79:
! 80: if (i == len - 1)
! 81: if ('n' == p[len - 1] || 'm' == p[len - 1])
! 82: return(atoi(p) + 2);
! 83:
! 84: return(len + 2);
! 85: }
! 86:
! 87:
! 88: int
! 89: out_a2offs(const char *p, int indent)
! 90: {
! 91: int len, i;
! 92:
! 93: if (0 == strcmp(p, "left"))
! 94: return(0);
! 95: if (0 == strcmp(p, "indent"))
! 96: return(indent + 1);
! 97: if (0 == strcmp(p, "indent-two"))
! 98: return((indent + 1) * 2);
! 99:
! 100: if (0 == (len = (int)strlen(p)))
! 101: return(0);
! 102:
! 103: for (i = 0; i < len - 1; i++)
! 104: if ( ! isdigit((u_char)p[i]))
! 105: break;
! 106:
! 107: if (i == len - 1)
! 108: if ('n' == p[len - 1] || 'm' == p[len - 1])
! 109: return(atoi(p));
! 110:
! 111: return(len);
! 112: }
! 113:
CVSweb