indent(1): remove troff output support
The troff output in indent was invented at Sun and the online documentation for some post-SunOS operating system includes this: The usual way to get a troffed listing is with the command indent -troff program.c | troff -mindent The indent manual page in FreeBSD 1.0 already lacks that information and troff -mindent complains about not being able to find the macro file. It seems that the file did exist on SunOS and was supposed to be imported into 4.3BSD together with the feature, but that has never happened. Removal of troff output support simplifies a lot of indent's code. vgrind(1) seems to be a promising replacement.
This commit is contained in:
parent
7c5f6031fe
commit
1479f36d8e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=334574
@ -62,7 +62,6 @@ __FBSDID("$FreeBSD$");
|
||||
#define PRO_SPECIAL 1 /* special case */
|
||||
#define PRO_BOOL 2 /* boolean */
|
||||
#define PRO_INT 3 /* integer */
|
||||
#define PRO_FONT 4 /* troff font */
|
||||
|
||||
/* profile specials for booleans */
|
||||
#define ON 1 /* turn it on */
|
||||
@ -119,15 +118,9 @@ struct pro {
|
||||
{"d", PRO_INT, 0, 0, &ps.unindent_displace},
|
||||
{"eei", PRO_BOOL, false, ON, &extra_expression_indent},
|
||||
{"ei", PRO_BOOL, true, ON, &ps.else_if},
|
||||
{"fbc", PRO_FONT, 0, 0, (int *) &blkcomf},
|
||||
{"fbs", PRO_BOOL, true, ON, &function_brace_split},
|
||||
{"fbx", PRO_FONT, 0, 0, (int *) &boxcomf},
|
||||
{"fb", PRO_FONT, 0, 0, (int *) &bodyf},
|
||||
{"fc1", PRO_BOOL, true, ON, &format_col1_comments},
|
||||
{"fcb", PRO_BOOL, true, ON, &format_block_comments},
|
||||
{"fc", PRO_FONT, 0, 0, (int *) &scomf},
|
||||
{"fk", PRO_FONT, 0, 0, (int *) &keywordf},
|
||||
{"fs", PRO_FONT, 0, 0, (int *) &stringf},
|
||||
{"ip", PRO_BOOL, true, ON, &ps.indent_parameters},
|
||||
{"i", PRO_INT, 8, 0, &ps.ind_size},
|
||||
{"lc", PRO_INT, 0, 0, &block_comment_max_col},
|
||||
@ -167,7 +160,6 @@ struct pro {
|
||||
{"st", PRO_SPECIAL, 0, STDIN, 0},
|
||||
{"ta", PRO_BOOL, false, ON, &auto_typedefs},
|
||||
{"ts", PRO_INT, 8, 0, &tabsize},
|
||||
{"troff", PRO_BOOL, false, ON, &troff},
|
||||
{"ut", PRO_BOOL, true, ON, &use_tabs},
|
||||
{"v", PRO_BOOL, false, ON, &verbose},
|
||||
/* whew! */
|
||||
@ -259,7 +251,7 @@ set_defaults(void)
|
||||
*/
|
||||
ps.case_indent = 0.0; /* -cli0.0 */
|
||||
for (p = pro; p->p_name; p++)
|
||||
if (p->p_type != PRO_SPECIAL && p->p_type != PRO_FONT)
|
||||
if (p->p_type != PRO_SPECIAL)
|
||||
*p->p_obj = p->p_default;
|
||||
}
|
||||
|
||||
@ -328,10 +320,6 @@ set_option(char *arg)
|
||||
*p->p_obj = atoi(param_start);
|
||||
break;
|
||||
|
||||
case PRO_FONT:
|
||||
parsefont((struct fstate *) p->p_obj, param_start);
|
||||
break;
|
||||
|
||||
default:
|
||||
errx(1, "set_option: internal error: p_type %d", p->p_type);
|
||||
}
|
||||
|
@ -84,7 +84,6 @@
|
||||
.Ek
|
||||
.Op Fl \&st
|
||||
.Op Fl \&ta
|
||||
.Op Fl troff
|
||||
.Op Fl ts Ns Ar n
|
||||
.Op Fl U Ns Ar file
|
||||
.Op Fl ut | Fl nut
|
||||
@ -453,16 +452,6 @@ language and
|
||||
cannot find all
|
||||
instances of
|
||||
.Ic typedef .
|
||||
.It Fl troff
|
||||
Causes
|
||||
.Nm
|
||||
to format the program for processing by
|
||||
.Xr troff 1 .
|
||||
It will produce a fancy
|
||||
listing in much the same spirit as
|
||||
.Xr vgrind 1 .
|
||||
If the output file is not specified, the default is standard output,
|
||||
rather than formatting in place.
|
||||
.It Fl ts Ns Ar n
|
||||
Assumed distance between tab stops.
|
||||
The default is 8.
|
||||
|
@ -240,7 +240,7 @@ main(int argc, char **argv)
|
||||
if (input == NULL)
|
||||
input = stdin;
|
||||
if (output == NULL) {
|
||||
if (troff || input == stdin)
|
||||
if (input == stdin)
|
||||
output = stdout;
|
||||
else {
|
||||
out_name = in_name;
|
||||
@ -260,26 +260,6 @@ main(int argc, char **argv)
|
||||
|
||||
if (ps.com_ind <= 1)
|
||||
ps.com_ind = 2; /* dont put normal comments before column 2 */
|
||||
if (troff) {
|
||||
if (bodyf.font[0] == 0)
|
||||
parsefont(&bodyf, "R");
|
||||
if (scomf.font[0] == 0)
|
||||
parsefont(&scomf, "I");
|
||||
if (blkcomf.font[0] == 0)
|
||||
blkcomf = scomf, blkcomf.size += 2;
|
||||
if (boxcomf.font[0] == 0)
|
||||
boxcomf = blkcomf;
|
||||
if (stringf.font[0] == 0)
|
||||
parsefont(&stringf, "L");
|
||||
if (keywordf.font[0] == 0)
|
||||
parsefont(&keywordf, "B");
|
||||
writefdef(&bodyf, 'B');
|
||||
writefdef(&scomf, 'C');
|
||||
writefdef(&blkcomf, 'L');
|
||||
writefdef(&boxcomf, 'X');
|
||||
writefdef(&stringf, 'S');
|
||||
writefdef(&keywordf, 'K');
|
||||
}
|
||||
if (block_comment_max_col <= 0)
|
||||
block_comment_max_col = max_col;
|
||||
if (ps.local_decl_indent < 0) /* if not specified by user, set this */
|
||||
@ -307,15 +287,7 @@ main(int argc, char **argv)
|
||||
if (col > ps.ind_size)
|
||||
ps.ind_level = ps.i_l_follow = col / ps.ind_size;
|
||||
}
|
||||
if (troff) {
|
||||
const char *p = in_name,
|
||||
*beg = in_name;
|
||||
|
||||
while (*p)
|
||||
if (*p++ == '/')
|
||||
beg = p;
|
||||
fprintf(output, ".Fn \"%s\"\n", beg);
|
||||
}
|
||||
/*
|
||||
* START OF MAIN LOOP
|
||||
*/
|
||||
@ -596,13 +568,7 @@ main(int argc, char **argv)
|
||||
if (ps.in_decl && !ps.block_init && !ps.dumped_decl_indent &&
|
||||
ps.procname[0] == '\0' && ps.paren_level == 0) {
|
||||
/* function pointer declarations */
|
||||
if (troff) {
|
||||
sprintf(e_code, "\n.Du %dp+\200p \"%s\"\n", dec_ind * 7, token);
|
||||
e_code += strlen(e_code);
|
||||
}
|
||||
else {
|
||||
indent_declaration(dec_ind, tabs_to_var);
|
||||
}
|
||||
indent_declaration(dec_ind, tabs_to_var);
|
||||
ps.dumped_decl_indent = true;
|
||||
}
|
||||
else if (ps.want_blank && *token != '[' &&
|
||||
@ -614,8 +580,7 @@ main(int argc, char **argv)
|
||||
ps.keyword + Bill_Shannon > 2))
|
||||
*e_code++ = ' ';
|
||||
ps.want_blank = false;
|
||||
if (!troff)
|
||||
*e_code++ = token[0];
|
||||
*e_code++ = token[0];
|
||||
ps.paren_indents[ps.p_l_follow - 1] = count_spaces_until(1, s_code, e_code) - 1;
|
||||
if (sp_sw && ps.p_l_follow == 1 && extra_expression_indent
|
||||
&& ps.paren_indents[0] < 2 * ps.ind_size)
|
||||
@ -673,33 +638,22 @@ main(int argc, char **argv)
|
||||
if (!ps.dumped_decl_indent && ps.in_decl && !ps.block_init &&
|
||||
ps.procname[0] == '\0' && ps.paren_level == 0) {
|
||||
/* pointer declarations */
|
||||
if (troff) {
|
||||
if (ps.want_blank)
|
||||
*e_code++ = ' ';
|
||||
sprintf(e_code, "\n.Du %dp+\200p \"%s\"\n", dec_ind * 7,
|
||||
token);
|
||||
e_code += strlen(e_code);
|
||||
}
|
||||
else {
|
||||
/* if this is a unary op in a declaration, we should
|
||||
* indent this token */
|
||||
for (i = 0; token[i]; ++i)
|
||||
/* find length of token */;
|
||||
indent_declaration(dec_ind - i, tabs_to_var);
|
||||
}
|
||||
|
||||
/*
|
||||
* if this is a unary op in a declaration, we should indent
|
||||
* this token
|
||||
*/
|
||||
for (i = 0; token[i]; ++i)
|
||||
/* find length of token */;
|
||||
indent_declaration(dec_ind - i, tabs_to_var);
|
||||
ps.dumped_decl_indent = true;
|
||||
}
|
||||
else if (ps.want_blank)
|
||||
*e_code++ = ' ';
|
||||
{
|
||||
const char *res = token;
|
||||
|
||||
if (troff && token[0] == '-' && token[1] == '>')
|
||||
res = "\\(->";
|
||||
for (t_ptr = res; *t_ptr; ++t_ptr) {
|
||||
CHECK_SIZE_CODE;
|
||||
*e_code++ = *t_ptr;
|
||||
}
|
||||
for (t_ptr = token; *t_ptr; ++t_ptr) {
|
||||
CHECK_SIZE_CODE;
|
||||
*e_code++ = *t_ptr;
|
||||
}
|
||||
ps.want_blank = false;
|
||||
break;
|
||||
@ -707,34 +661,9 @@ main(int argc, char **argv)
|
||||
case binary_op: /* any binary operation */
|
||||
if (ps.want_blank)
|
||||
*e_code++ = ' ';
|
||||
{
|
||||
const char *res = token;
|
||||
|
||||
if (troff)
|
||||
switch (token[0]) {
|
||||
case '<':
|
||||
if (token[1] == '=')
|
||||
res = "\\(<=";
|
||||
break;
|
||||
case '>':
|
||||
if (token[1] == '=')
|
||||
res = "\\(>=";
|
||||
break;
|
||||
case '!':
|
||||
if (token[1] == '=')
|
||||
res = "\\(!=";
|
||||
break;
|
||||
case '|':
|
||||
if (token[1] == '|')
|
||||
res = "\\(br\\(br";
|
||||
else if (token[1] == 0)
|
||||
res = "\\(br";
|
||||
break;
|
||||
}
|
||||
for (t_ptr = res; *t_ptr; ++t_ptr) {
|
||||
CHECK_SIZE_CODE;
|
||||
*e_code++ = *t_ptr; /* move the operator */
|
||||
}
|
||||
for (t_ptr = token; *t_ptr; ++t_ptr) {
|
||||
CHECK_SIZE_CODE;
|
||||
*e_code++ = *t_ptr; /* move the operator */
|
||||
}
|
||||
ps.want_blank = true;
|
||||
break;
|
||||
@ -1044,14 +973,7 @@ main(int argc, char **argv)
|
||||
else if (!ps.block_init && !ps.dumped_decl_indent &&
|
||||
ps.paren_level == 0) { /* if we are in a declaration, we
|
||||
* must indent identifier */
|
||||
|
||||
if (troff) {
|
||||
if (ps.want_blank)
|
||||
*e_code++ = ' ';
|
||||
sprintf(e_code, "\n.De %dp+\200p\n", dec_ind * 7);
|
||||
e_code += strlen(e_code);
|
||||
} else
|
||||
indent_declaration(dec_ind, tabs_to_var);
|
||||
indent_declaration(dec_ind, tabs_to_var);
|
||||
ps.dumped_decl_indent = true;
|
||||
ps.want_blank = false;
|
||||
}
|
||||
@ -1066,20 +988,10 @@ main(int argc, char **argv)
|
||||
copy_id:
|
||||
if (ps.want_blank)
|
||||
*e_code++ = ' ';
|
||||
if (troff && ps.keyword) {
|
||||
e_code = chfont(&bodyf, &keywordf, e_code);
|
||||
for (t_ptr = token; *t_ptr; ++t_ptr) {
|
||||
CHECK_SIZE_CODE;
|
||||
*e_code++ = keywordf.allcaps && islower((unsigned char)*t_ptr)
|
||||
? toupper(*t_ptr) : *t_ptr;
|
||||
}
|
||||
e_code = chfont(&keywordf, &bodyf, e_code);
|
||||
for (t_ptr = token; *t_ptr; ++t_ptr) {
|
||||
CHECK_SIZE_CODE;
|
||||
*e_code++ = *t_ptr;
|
||||
}
|
||||
else
|
||||
for (t_ptr = token; *t_ptr; ++t_ptr) {
|
||||
CHECK_SIZE_CODE;
|
||||
*e_code++ = *t_ptr;
|
||||
}
|
||||
if (type_code != funcname)
|
||||
ps.want_blank = true;
|
||||
break;
|
||||
@ -1145,8 +1057,6 @@ main(int argc, char **argv)
|
||||
fill_buffer();
|
||||
switch (*e_lab++) {
|
||||
case BACKSLASH:
|
||||
if (troff)
|
||||
*e_lab++ = BACKSLASH;
|
||||
if (!in_comment) {
|
||||
*e_lab++ = *buf_ptr++;
|
||||
if (buf_ptr >= buf_end)
|
||||
|
@ -43,9 +43,7 @@ void diag4(int, const char *, int, int);
|
||||
void dump_line(void);
|
||||
void fill_buffer(void);
|
||||
void parse(int);
|
||||
void parsefont(struct fstate *, const char *);
|
||||
void pr_comment(void);
|
||||
void set_defaults(void);
|
||||
void set_option(char *);
|
||||
void set_profile(const char *);
|
||||
void writefdef(struct fstate *f, int);
|
||||
|
@ -166,7 +166,6 @@ int cuddle_else; /* true if else should cuddle up to '}' */
|
||||
int star_comment_cont; /* true iff comment continuation lines should
|
||||
* have stars at the beginning of each line. */
|
||||
int comment_delimiter_on_blankline;
|
||||
int troff; /* true iff were generating troff input */
|
||||
int procnames_start_line; /* if true, the names of procedures
|
||||
* being defined get placed in column
|
||||
* 1 (ie. a newline is placed between
|
||||
@ -218,29 +217,10 @@ int auto_typedefs; /* set true to recognize identifiers
|
||||
int space_after_cast; /* "b = (int) a" vs "b = (int)a" */
|
||||
int tabsize; /* the size of a tab */
|
||||
|
||||
/* -troff font state information */
|
||||
|
||||
struct fstate {
|
||||
char font[4];
|
||||
char size;
|
||||
int allcaps:1;
|
||||
} __aligned(sizeof(int));
|
||||
char *chfont(struct fstate *, struct fstate *, char *);
|
||||
|
||||
struct fstate
|
||||
keywordf, /* keyword font */
|
||||
stringf, /* string font */
|
||||
boxcomf, /* Box comment font */
|
||||
blkcomf, /* Block comment font */
|
||||
scomf, /* Same line comment font */
|
||||
bodyf; /* major body font */
|
||||
|
||||
|
||||
#define STACKSIZE 256
|
||||
|
||||
struct parser_state {
|
||||
int last_token;
|
||||
struct fstate cfont; /* Current font */
|
||||
int p_stack[STACKSIZE]; /* this is the parsers stack */
|
||||
int il[STACKSIZE]; /* this stack stores indentation levels */
|
||||
float cstk[STACKSIZE];/* used to store case stmt indentation levels */
|
||||
|
@ -68,13 +68,6 @@ dump_line(void)
|
||||
static int not_first_line;
|
||||
|
||||
if (ps.procname[0]) {
|
||||
if (troff) {
|
||||
if (comment_open) {
|
||||
comment_open = 0;
|
||||
fprintf(output, ".*/\n");
|
||||
}
|
||||
fprintf(output, ".Pr \"%s\"\n", ps.procname);
|
||||
}
|
||||
ps.ind_level = 0;
|
||||
ps.procname[0] = 0;
|
||||
}
|
||||
@ -163,99 +156,38 @@ dump_line(void)
|
||||
putc(*p, output);
|
||||
cur_col = count_spaces(cur_col, s_code);
|
||||
}
|
||||
if (s_com != e_com) {
|
||||
if (troff) {
|
||||
int all_here = 0;
|
||||
char *p;
|
||||
if (s_com != e_com) { /* print comment, if any */
|
||||
int target = ps.com_col;
|
||||
char *com_st = s_com;
|
||||
|
||||
if (e_com[-1] == '/' && e_com[-2] == '*')
|
||||
e_com -= 2, all_here++;
|
||||
while (e_com > s_com && e_com[-1] == ' ')
|
||||
e_com--;
|
||||
*e_com = 0;
|
||||
p = s_com;
|
||||
while (*p == ' ')
|
||||
p++;
|
||||
if (p[0] == '/' && p[1] == '*')
|
||||
p += 2, all_here++;
|
||||
else if (p[0] == '*')
|
||||
p += p[1] == '/' ? 2 : 1;
|
||||
while (*p == ' ')
|
||||
p++;
|
||||
if (*p == 0)
|
||||
goto inhibit_newline;
|
||||
if (comment_open < 2 && ps.box_com) {
|
||||
comment_open = 0;
|
||||
fprintf(output, ".*/\n");
|
||||
}
|
||||
if (comment_open == 0) {
|
||||
if ('a' <= *p && *p <= 'z')
|
||||
*p = *p + 'A' - 'a';
|
||||
if (e_com - p < 50 && all_here == 2) {
|
||||
char *follow = p;
|
||||
fprintf(output, "\n.nr C! \\w\1");
|
||||
while (follow < e_com) {
|
||||
switch (*follow) {
|
||||
case '\n':
|
||||
putc(' ', output);
|
||||
case 1:
|
||||
break;
|
||||
case '\\':
|
||||
putc('\\', output);
|
||||
/* add a backslash to escape the '\' */
|
||||
default:
|
||||
putc(*follow, output);
|
||||
}
|
||||
follow++;
|
||||
}
|
||||
putc(1, output);
|
||||
}
|
||||
fprintf(output, "\n./* %dp %d %dp\n",
|
||||
ps.com_col * 7,
|
||||
(s_code != e_code || s_lab != e_lab) - ps.box_com,
|
||||
target_col * 7);
|
||||
}
|
||||
comment_open = 1 + ps.box_com;
|
||||
while (*p) {
|
||||
if (*p == BACKSLASH)
|
||||
putc(BACKSLASH, output);
|
||||
putc(*p++, output);
|
||||
}
|
||||
}
|
||||
else { /* print comment, if any */
|
||||
int target = ps.com_col;
|
||||
char *com_st = s_com;
|
||||
|
||||
target += ps.comment_delta;
|
||||
while (*com_st == '\t') /* consider original indentation in
|
||||
* case this is a box comment */
|
||||
com_st++, target += tabsize;
|
||||
while (target <= 0)
|
||||
if (*com_st == ' ')
|
||||
target++, com_st++;
|
||||
else if (*com_st == '\t')
|
||||
target = tabsize * (1 + (target - 1) / tabsize) + 1, com_st++;
|
||||
else
|
||||
target = 1;
|
||||
if (cur_col > target) { /* if comment can't fit on this line,
|
||||
* put it on next line */
|
||||
putc('\n', output);
|
||||
cur_col = 1;
|
||||
++ps.out_lines;
|
||||
}
|
||||
while (e_com > com_st && isspace((unsigned char)e_com[-1]))
|
||||
e_com--;
|
||||
(void)pad_output(cur_col, target);
|
||||
fwrite(com_st, e_com - com_st, 1, output);
|
||||
ps.comment_delta = ps.n_comment_delta;
|
||||
++ps.com_lines; /* count lines with comments */
|
||||
target += ps.comment_delta;
|
||||
while (*com_st == '\t') /* consider original indentation in
|
||||
* case this is a box comment */
|
||||
com_st++, target += tabsize;
|
||||
while (target <= 0)
|
||||
if (*com_st == ' ')
|
||||
target++, com_st++;
|
||||
else if (*com_st == '\t')
|
||||
target = tabsize * (1 + (target - 1) / tabsize) + 1, com_st++;
|
||||
else
|
||||
target = 1;
|
||||
if (cur_col > target) { /* if comment can't fit on this line,
|
||||
* put it on next line */
|
||||
putc('\n', output);
|
||||
cur_col = 1;
|
||||
++ps.out_lines;
|
||||
}
|
||||
while (e_com > com_st && isspace((unsigned char)e_com[-1]))
|
||||
e_com--;
|
||||
(void)pad_output(cur_col, target);
|
||||
fwrite(com_st, e_com - com_st, 1, output);
|
||||
ps.comment_delta = ps.n_comment_delta;
|
||||
++ps.com_lines; /* count lines with comments */
|
||||
}
|
||||
if (ps.use_ff)
|
||||
putc('\014', output);
|
||||
else
|
||||
putc('\n', output);
|
||||
inhibit_newline:
|
||||
++ps.out_lines;
|
||||
if (ps.just_saw_decl == 1 && blanklines_after_declarations) {
|
||||
prefix_blankline_requested = 1;
|
||||
@ -460,26 +392,22 @@ pad_output(int current, int target)
|
||||
/* current: the current column value */
|
||||
/* target: position we want it at */
|
||||
{
|
||||
int curr; /* internal column pointer */
|
||||
|
||||
if (troff)
|
||||
fprintf(output, "\\h'|%dp'", (target - 1) * 7);
|
||||
else {
|
||||
int curr; /* internal column pointer */
|
||||
if (current >= target)
|
||||
return (current); /* line is already long enough */
|
||||
curr = current;
|
||||
if (use_tabs) {
|
||||
int tcur;
|
||||
|
||||
if (current >= target)
|
||||
return (current); /* line is already long enough */
|
||||
curr = current;
|
||||
if (use_tabs) {
|
||||
int tcur;
|
||||
|
||||
while ((tcur = tabsize * (1 + (curr - 1) / tabsize) + 1) <= target) {
|
||||
putc('\t', output);
|
||||
curr = tcur;
|
||||
}
|
||||
}
|
||||
while (curr++ < target)
|
||||
putc(' ', output); /* pad with final blanks */
|
||||
while ((tcur = tabsize * (1 + (curr - 1) / tabsize) + 1) <= target) {
|
||||
putc('\t', output);
|
||||
curr = tcur;
|
||||
}
|
||||
}
|
||||
while (curr++ < target)
|
||||
putc(' ', output); /* pad with final blanks */
|
||||
|
||||
return (target);
|
||||
}
|
||||
|
||||
@ -593,77 +521,3 @@ diag2(int level, const char *msg)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
writefdef(struct fstate *f, int nm)
|
||||
{
|
||||
fprintf(output, ".ds f%c %s\n.nr s%c %d\n",
|
||||
nm, f->font, nm, f->size);
|
||||
}
|
||||
|
||||
char *
|
||||
chfont(struct fstate *of, struct fstate *nf, char *s)
|
||||
{
|
||||
if (of->font[0] != nf->font[0]
|
||||
|| of->font[1] != nf->font[1]) {
|
||||
*s++ = '\\';
|
||||
*s++ = 'f';
|
||||
if (nf->font[1]) {
|
||||
*s++ = '(';
|
||||
*s++ = nf->font[0];
|
||||
*s++ = nf->font[1];
|
||||
}
|
||||
else
|
||||
*s++ = nf->font[0];
|
||||
}
|
||||
if (nf->size != of->size) {
|
||||
*s++ = '\\';
|
||||
*s++ = 's';
|
||||
if (nf->size < of->size) {
|
||||
*s++ = '-';
|
||||
*s++ = '0' + of->size - nf->size;
|
||||
}
|
||||
else {
|
||||
*s++ = '+';
|
||||
*s++ = '0' + nf->size - of->size;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
void
|
||||
parsefont(struct fstate *f, const char *s0)
|
||||
{
|
||||
const char *s = s0;
|
||||
int sizedelta = 0;
|
||||
|
||||
memset(f, '\0', sizeof(*f));
|
||||
while (*s) {
|
||||
if (isdigit((unsigned char)*s))
|
||||
f->size = f->size * 10 + *s - '0';
|
||||
else if (isupper((unsigned char)*s))
|
||||
if (f->font[0])
|
||||
f->font[1] = *s;
|
||||
else
|
||||
f->font[0] = *s;
|
||||
else if (*s == 'c')
|
||||
f->allcaps = 1;
|
||||
else if (*s == '+')
|
||||
sizedelta++;
|
||||
else if (*s == '-')
|
||||
sizedelta--;
|
||||
else {
|
||||
errx(1, "bad font specification: %s", s0);
|
||||
}
|
||||
s++;
|
||||
}
|
||||
if (f->font[0] == 0)
|
||||
f->font[0] = 'R';
|
||||
if (bodyf.size == 0)
|
||||
bodyf.size = 11;
|
||||
if (f->size == 0)
|
||||
f->size = bodyf.size + sizedelta;
|
||||
else if (sizedelta > 0)
|
||||
f->size += bodyf.size;
|
||||
else
|
||||
f->size = bodyf.size - f->size;
|
||||
}
|
||||
|
@ -418,12 +418,6 @@ lexi(struct parser_state *state)
|
||||
case '\'': /* start of quoted character */
|
||||
case '"': /* start of string */
|
||||
qchar = *token;
|
||||
if (troff) {
|
||||
e_token[-1] = '`';
|
||||
if (qchar == '"')
|
||||
*e_token++ = '`';
|
||||
e_token = chfont(&bodyf, &stringf, e_token);
|
||||
}
|
||||
do { /* copy the string */
|
||||
while (1) { /* move one character or [/<char>]<char> */
|
||||
if (*buf_ptr == '\n') {
|
||||
@ -439,11 +433,6 @@ lexi(struct parser_state *state)
|
||||
if (*e_token == BACKSLASH) { /* if escape, copy extra char */
|
||||
if (*buf_ptr == '\n') /* check for escaped newline */
|
||||
++line_no;
|
||||
if (troff) {
|
||||
*++e_token = BACKSLASH;
|
||||
if (*buf_ptr == BACKSLASH)
|
||||
*++e_token = BACKSLASH;
|
||||
}
|
||||
*++e_token = *buf_ptr++;
|
||||
++e_token; /* we must increment this again because we
|
||||
* copied two chars */
|
||||
@ -454,11 +443,6 @@ lexi(struct parser_state *state)
|
||||
break; /* we copied one character */
|
||||
} /* end of while (1) */
|
||||
} while (*e_token++ != qchar);
|
||||
if (troff) {
|
||||
e_token = chfont(&stringf, &bodyf, e_token - 1);
|
||||
if (qchar == '"')
|
||||
*e_token++ = '\'';
|
||||
}
|
||||
stop_lit:
|
||||
code = ident;
|
||||
break;
|
||||
|
@ -201,9 +201,6 @@ pr_comment(void)
|
||||
*e_com++ = ' ', *e_com++ = '*', *e_com++ = ' ';
|
||||
}
|
||||
|
||||
if (troff)
|
||||
adj_max_col = 80;
|
||||
|
||||
/* Start to copy the comment */
|
||||
|
||||
while (1) { /* this loop will go until the comment is
|
||||
|
Loading…
Reference in New Issue
Block a user