version 1.143, 2010/06/07 21:03:02 |
version 1.145, 2010/06/08 13:22:37 |
|
|
|
|
#include <assert.h> |
#include <assert.h> |
#include <ctype.h> |
#include <ctype.h> |
|
#include <getopt.h> |
#include <stdint.h> |
#include <stdint.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
|
|
#define PS_CHAR_BOTMARG 24 |
#define PS_CHAR_BOTMARG 24 |
#define PS_CHAR_BOT (PS_CHAR_BOTMARG + 36) |
#define PS_CHAR_BOT (PS_CHAR_BOTMARG + 36) |
|
|
static struct termp *alloc(char *, enum termenc, enum termtype); |
|
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); |
static void buffera(struct termp *, const char *, size_t); |
static void buffera(struct termp *, const char *, size_t); |
Line 61 static void pageopen(struct termp *); |
|
Line 60 static void pageopen(struct termp *); |
|
void * |
void * |
ascii_alloc(char *outopts) |
ascii_alloc(char *outopts) |
{ |
{ |
|
struct termp *p; |
|
const char *toks[2]; |
|
char *v; |
|
|
return(alloc(outopts, TERMENC_ASCII, TERMTYPE_CHAR)); |
if (NULL == (p = term_alloc(TERMENC_ASCII))) |
} |
return(NULL); |
|
|
|
p->type = TERMTYPE_CHAR; |
|
|
void * |
toks[0] = "width"; |
ps_alloc(void) |
toks[1] = NULL; |
{ |
|
|
|
return(alloc(NULL, TERMENC_ASCII, TERMTYPE_PS)); |
while (outopts && *outopts) |
|
switch (getsubopt(&outopts, UNCONST(toks), &v)) { |
|
case (0): |
|
p->defrmargin = (size_t)atoi(v); |
|
break; |
|
default: |
|
break; |
|
} |
|
|
|
/* Enforce a lower boundary. */ |
|
if (p->defrmargin < 58) |
|
p->defrmargin = 58; |
|
|
|
return(p); |
} |
} |
|
|
|
|
void |
void |
terminal_free(void *arg) |
ascii_free(void *arg) |
{ |
{ |
|
|
term_free((struct termp *)arg); |
term_free((struct termp *)arg); |
} |
} |
|
|
|
|
static void |
void |
term_free(struct termp *p) |
term_free(struct termp *p) |
{ |
{ |
|
|
Line 90 term_free(struct termp *p) |
|
Line 105 term_free(struct termp *p) |
|
free(p->buf); |
free(p->buf); |
if (p->symtab) |
if (p->symtab) |
chars_free(p->symtab); |
chars_free(p->symtab); |
|
|
free(p); |
free(p); |
} |
} |
|
|
Line 289 advance(struct termp *p, size_t len) |
|
Line 305 advance(struct termp *p, size_t len) |
|
} |
} |
|
|
|
|
static struct termp * |
struct termp * |
alloc(char *outopts, enum termenc enc, enum termtype type) |
term_alloc(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->type = type; |
|
p->tabwidth = 5; |
p->tabwidth = 5; |
p->enc = enc; |
p->enc = enc; |
|
p->defrmargin = 78; |
width = 80; |
|
|
|
while (outopts && *outopts) |
|
switch (getsubopt(&outopts, UNCONST(toks), &v)) { |
|
case (0): |
|
width = (size_t)atoi(v); |
|
break; |
|
default: |
|
break; |
|
} |
|
|
|
/* Enforce some lower boundary. */ |
|
if (width < 60) |
|
width = 60; |
|
p->defrmargin = width - 2; |
|
return(p); |
return(p); |
} |
} |
|
|