/* $Id: tbl_layout.c,v 1.41 2015/10/12 00:08:16 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "config.h"
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "mandoc.h"
#include "mandoc_aux.h"
#include "libmandoc.h"
#include "libroff.h"
struct tbl_phrase {
char name;
};
{ 'c', TBL_CELL_CENTRE },
{ 'r', TBL_CELL_RIGHT },
{ 'l', TBL_CELL_LEFT },
{ 'n', TBL_CELL_NUMBER },
{ 's', TBL_CELL_SPAN },
{ 'a', TBL_CELL_LONG },
{ '^', TBL_CELL_DOWN },
{ '-', TBL_CELL_HORIZ },
{ '_', TBL_CELL_HORIZ },
{ '=', TBL_CELL_DHORIZ }
};
int, const char *, int *);
int, const char *, int *);
enum tbl_cellt);
static void
{
char *endptr;
mod:
(*pos)++;
/* Row delimiters and cell specifiers end modifier lists. */
return;
/* Throw away parenthesised expression. */
if ('(' == p[*pos]) {
(*pos)++;
(*pos)++;
if (')' == p[*pos]) {
(*pos)++;
goto mod;
}
return;
}
/* Parse numerical spacing from modifier string. */
goto mod;
}
case 'b':
goto mod;
case 'd':
goto mod;
case 'e':
goto mod;
case 'f':
break;
case 'i':
goto mod;
case 'm':
goto mod;
case 'p':
case 'v':
(*pos)++;
(*pos)++;
goto mod;
case 't':
goto mod;
case 'u':
goto mod;
case 'w': /* XXX for now, ignore minimal column width */
goto mod;
case 'x':
goto mod;
case 'z':
goto mod;
case '|':
else
goto mod;
default:
goto mod;
}
/* Ignore parenthised font names for now. */
if (p[*pos] == '(')
goto mod;
/* Support only one-character font-names for now. */
if (p[*pos] != '\0')
(*pos)++;
if (p[*pos] != '\0')
(*pos)++;
goto mod;
}
switch (p[(*pos)++]) {
case '3':
case 'B':
goto mod;
case '2':
case 'I':
goto mod;
case '1':
case 'R':
goto mod;
default:
goto mod;
}
}
static void
{
int i;
enum tbl_cellt c;
/* Handle leading vertical lines */
if (p[*pos] == '|') {
else
}
(*pos)++;
}
(*pos)++;
return;
/* Parse the column position (`c', `l', `r', ...). */
for (i = 0; i < KEYS_MAX; i++)
break;
if (i == KEYS_MAX) {
(*pos)++;
goto again;
}
/* Special cases of spanners. */
if (c == TBL_CELL_SPAN) {
(*pos)++;
/* Allocate cell then parse its modifiers. */
}
void
{
for (;;) {
/* Skip whitespace before and after each cell. */
pos++;
switch (p[pos]) {
case ',': /* Next row on this input line. */
pos++;
continue;
case '\0': /* Next row on next input line. */
return;
case '.': /* End of layout. */
pos++;
/*
* When the layout is completely empty,
* default to one left-justified column.
*/
}
return;
}
/*
* Search for the widest line
* along the left and right margins.
*/
/* If the last line is empty, drop it. */
}
}
return;
default: /* Cell. */
break;
}
/*
* If the last line had at least one cell,
* start a new one; otherwise, continue it.
*/
else
} else
}
}
}
static struct tbl_cell *
{
p = mandoc_calloc(1, sizeof(*p));
} else
return p;
}