version 1.140, 2010/05/25 12:37:20 |
version 1.141, 2010/06/07 10:52:44 |
|
|
|
|
#include <assert.h> |
#include <assert.h> |
#include <ctype.h> |
#include <ctype.h> |
|
#include <stdint.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
|
#include "mdoc.h" |
#include "mdoc.h" |
#include "main.h" |
#include "main.h" |
|
|
static struct termp *term_alloc(enum termenc, size_t); |
static struct termp *term_alloc(char *, enum termenc); |
static void term_free(struct termp *); |
static void term_free(struct termp *); |
static void spec(struct termp *, const char *, size_t); |
static void spec(struct termp *, const char *, size_t); |
static void res(struct termp *, const char *, size_t); |
static void res(struct termp *, const char *, size_t); |
Line 46 static void encode(struct termp *, const char *, si |
|
Line 47 static void encode(struct termp *, const char *, si |
|
|
|
|
|
void * |
void * |
ascii_alloc(size_t width) |
ascii_alloc(char *outopts) |
{ |
{ |
|
|
return(term_alloc(TERMENC_ASCII, width)); |
return(term_alloc(outopts, TERMENC_ASCII)); |
} |
} |
|
|
|
|
Line 75 term_free(struct termp *p) |
|
Line 76 term_free(struct termp *p) |
|
|
|
|
|
static struct termp * |
static struct termp * |
term_alloc(enum termenc enc, size_t width) |
term_alloc(char *outopts, enum termenc enc) |
{ |
{ |
struct termp *p; |
struct termp *p; |
|
const char *toks[2]; |
|
char *v; |
|
size_t width; |
|
|
|
toks[0] = "width"; |
|
toks[1] = NULL; |
|
|
p = calloc(1, sizeof(struct termp)); |
p = calloc(1, sizeof(struct termp)); |
if (NULL == p) { |
if (NULL == p) { |
perror(NULL); |
perror(NULL); |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
} |
} |
|
|
p->tabwidth = 5; |
p->tabwidth = 5; |
p->enc = enc; |
p->enc = enc; |
|
width = 80; |
|
|
|
while (outopts && *outopts) |
|
switch (getsubopt(&outopts, UNCONST(toks), &v)) { |
|
case (0): |
|
width = atoi(v); |
|
break; |
|
default: |
|
break; |
|
} |
|
|
/* Enforce some lower boundary. */ |
/* Enforce some lower boundary. */ |
if (width < 60) |
if (width < 60) |
width = 60; |
width = 60; |