version 1.106, 2009/10/18 13:34:17 |
version 1.113, 2009/10/26 17:05:44 |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
#include <time.h> |
|
|
#include "chars.h" |
#include "chars.h" |
|
#include "out.h" |
#include "term.h" |
#include "term.h" |
#include "man.h" |
#include "man.h" |
#include "mdoc.h" |
#include "mdoc.h" |
#include "main.h" |
#include "main.h" |
#include "out.h" |
|
|
|
/* FIXME: accomodate non-breaking, non-collapsing white-space. */ |
/* FIXME: accomodate non-breaking, non-collapsing white-space. */ |
/* FIXME: accomodate non-breaking, collapsing white-space. */ |
/* FIXME: accomodate non-breaking, collapsing white-space. */ |
|
|
term_flushln(struct termp *p) |
term_flushln(struct termp *p) |
{ |
{ |
int i, j; |
int i, j; |
size_t vbl, vsz, vis, maxvis, mmax, bp, os; |
size_t vbl, vsz, vis, maxvis, mmax, bp; |
static int overstep = 0; |
static int overstep = 0; |
|
|
/* |
/* |
Line 143 term_flushln(struct termp *p) |
|
Line 144 term_flushln(struct termp *p) |
|
assert(p->offset < p->rmargin); |
assert(p->offset < p->rmargin); |
assert((int)(p->rmargin - p->offset) - overstep > 0); |
assert((int)(p->rmargin - p->offset) - overstep > 0); |
|
|
/* Save the overstep. */ |
|
os = (size_t)overstep; |
|
|
|
maxvis = /* LINTED */ |
maxvis = /* LINTED */ |
p->rmargin - p->offset - overstep; |
p->rmargin - p->offset - overstep; |
mmax = /* LINTED */ |
mmax = /* LINTED */ |
Line 153 term_flushln(struct termp *p) |
|
Line 151 term_flushln(struct termp *p) |
|
|
|
bp = TERMP_NOBREAK & p->flags ? mmax : maxvis; |
bp = TERMP_NOBREAK & p->flags ? mmax : maxvis; |
vis = 0; |
vis = 0; |
overstep = 0; |
|
|
|
/* |
/* |
* If in the standard case (left-justified), then begin with our |
* If in the standard case (left-justified), then begin with our |
Line 208 term_flushln(struct termp *p) |
|
Line 205 term_flushln(struct termp *p) |
|
vis = 0; |
vis = 0; |
} |
} |
/* Remove the overstep width. */ |
/* Remove the overstep width. */ |
bp += os; |
bp += (int)/* LINTED */ |
os = 0; |
overstep; |
|
overstep = 0; |
} else { |
} else { |
for (j = 0; j < (int)vbl; j++) |
for (j = 0; j < (int)vbl; j++) |
putchar(' '); |
putchar(' '); |
Line 226 term_flushln(struct termp *p) |
|
Line 224 term_flushln(struct termp *p) |
|
} |
} |
vis += vsz; |
vis += vsz; |
} |
} |
|
|
p->col = 0; |
p->col = 0; |
|
overstep = 0; |
|
|
if ( ! (TERMP_NOBREAK & p->flags)) { |
if ( ! (TERMP_NOBREAK & p->flags)) { |
putchar('\n'); |
putchar('\n'); |
Line 548 encode(struct termp *p, char c) |
|
Line 548 encode(struct termp *p, char c) |
|
{ |
{ |
|
|
if (' ' != c) { |
if (' ' != c) { |
if (p->bold) { |
|
buffer(p, c); |
|
buffer(p, 8); |
|
} |
|
if (p->under) { |
if (p->under) { |
buffer(p, '_'); |
buffer(p, '_'); |
buffer(p, 8); |
buffer(p, 8); |
} |
} |
|
if (p->bold) { |
|
buffer(p, c); |
|
buffer(p, 8); |
|
} |
} |
} |
buffer(p, c); |
buffer(p, c); |
} |
} |
|
|
|
|
int |
size_t |
a2height(const char *p) |
term_vspan(const struct roffsu *su) |
{ |
{ |
struct roffsu su; |
|
double r; |
double r; |
|
|
if ( ! a2roffsu(p, &su)) |
switch (su->unit) { |
return(-1); |
|
|
|
switch (su.unit) { |
|
case (SCALE_CM): |
case (SCALE_CM): |
r = su.scale * 2; |
r = su->scale * 2; |
break; |
break; |
case (SCALE_IN): |
case (SCALE_IN): |
r = su.scale * 6; |
r = su->scale * 6; |
break; |
break; |
case (SCALE_PC): |
case (SCALE_PC): |
r = su.scale; |
r = su->scale; |
break; |
break; |
case (SCALE_PT): |
case (SCALE_PT): |
r = su.scale / 8; |
r = su->scale / 8; |
break; |
break; |
case (SCALE_MM): |
case (SCALE_MM): |
r = su.scale / 1000; |
r = su->scale / 1000; |
break; |
break; |
case (SCALE_VS): |
case (SCALE_VS): |
r = su.scale; |
r = su->scale; |
break; |
break; |
default: |
default: |
r = su.scale - 1; |
r = su->scale - 1; |
break; |
break; |
} |
} |
|
|
if (r < 0.0) |
if (r < 0.0) |
r = 0.0; |
r = 0.0; |
return(/* LINTED */(int) |
return(/* LINTED */(size_t) |
r); |
r); |
} |
} |
|
|
|
|
int |
size_t |
a2width(const char *p) |
term_hspan(const struct roffsu *su) |
{ |
{ |
struct roffsu su; |
|
double r; |
double r; |
|
|
if ( ! a2roffsu(p, &su)) |
/* XXX: CM, IN, and PT are approximations. */ |
return(-1); |
|
|
|
switch (su.unit) { |
switch (su->unit) { |
case (SCALE_CM): |
case (SCALE_CM): |
r = (4 * su.scale) + 2; /* FIXME: double-check. */ |
r = 4 * su->scale; |
break; |
break; |
case (SCALE_IN): |
case (SCALE_IN): |
r = (10 * su.scale) + 2; /* FIXME: double-check. */ |
/* XXX: this is an approximation. */ |
|
r = 10 * su->scale; |
break; |
break; |
case (SCALE_PC): |
case (SCALE_PC): |
r = (10 * su.scale) / 6; /* FIXME: double-check. */ |
r = (10 * su->scale) / 6; |
break; |
break; |
case (SCALE_PT): |
case (SCALE_PT): |
r = (10 * su.scale) / 72; /* FIXME: double-check. */ |
r = (10 * su->scale) / 72; |
break; |
break; |
case (SCALE_MM): |
case (SCALE_MM): |
r = su.scale / 1000; /* FIXME: double-check. */ |
r = su->scale / 1000; /* FIXME: double-check. */ |
break; |
break; |
case (SCALE_VS): |
case (SCALE_VS): |
r = su.scale * 2 - 1; /* FIXME: double-check. */ |
r = su->scale * 2 - 1; /* FIXME: double-check. */ |
break; |
break; |
default: |
default: |
r = su.scale + 2; |
r = su->scale; |
break; |
break; |
} |
} |
|
|
if (r < 0.0) |
if (r < 0.0) |
r = 0.0; |
r = 0.0; |
return((int)/* LINTED */ |
return((size_t)/* LINTED */ |
r); |
r); |
} |
} |
|
|