[BACK]Return to tbl.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Annotation of mandoc/tbl.c, Revision 1.1

1.1     ! kristaps    1: /*     $Id: tbl.c,v 1.14 2009/09/12 16:05:34 kristaps Exp $ */
        !             2: /*
        !             3:  * Copyright (c) 2009, 2010 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 <assert.h>
        !            18: #include <stdlib.h>
        !            19: #include <string.h>
        !            20: #include <time.h>
        !            21:
        !            22: #include "mandoc.h"
        !            23: #include "roff.h"
        !            24: #include "libmandoc.h"
        !            25: #include "libroff.h"
        !            26:
        !            27: enum   tbl_part {
        !            28:        TBL_PART_OPTS, /* in options (first line) */
        !            29:        TBL_PART_LAYOUT, /* describing layout */
        !            30:        TBL_PART_DATA  /* creating data rows */
        !            31: };
        !            32:
        !            33:
        !            34: struct tbl {
        !            35:        enum tbl_part    part;
        !            36: };
        !            37:
        !            38: static void             tbl_init(struct tbl *);
        !            39: static void             tbl_clear(struct tbl *);
        !            40:
        !            41: static void
        !            42: tbl_clear(struct tbl *tbl)
        !            43: {
        !            44:
        !            45: }
        !            46:
        !            47: static void
        !            48: tbl_init(struct tbl *tbl)
        !            49: {
        !            50:
        !            51:        tbl->part = TBL_PART_OPTS;
        !            52: }
        !            53:
        !            54: enum rofferr
        !            55: tbl_read(struct tbl *tbl, int ln, const char *p, int offs)
        !            56: {
        !            57:        int              len;
        !            58:        const char      *cp;
        !            59:
        !            60:        cp = &p[offs];
        !            61:        len = (int)strlen(cp);
        !            62:
        !            63:        if (len && TBL_PART_OPTS == tbl->part)
        !            64:                if (';' != cp[len - 1])
        !            65:                        tbl->part = TBL_PART_LAYOUT;
        !            66:
        !            67:        return(1);
        !            68: }
        !            69:
        !            70: struct tbl *
        !            71: tbl_alloc(void)
        !            72: {
        !            73:        struct tbl      *p;
        !            74:
        !            75:        p = mandoc_malloc(sizeof(struct tbl));
        !            76:        tbl_init(p);
        !            77:        return(p);
        !            78: }
        !            79:
        !            80: void
        !            81: tbl_free(struct tbl *p)
        !            82: {
        !            83:
        !            84:        tbl_clear(p);
        !            85:        free(p);
        !            86: }
        !            87:
        !            88: void
        !            89: tbl_reset(struct tbl *tbl)
        !            90: {
        !            91:
        !            92:        tbl_clear(tbl);
        !            93:        tbl_init(tbl);
        !            94: }

CVSweb