version 1.15, 2019/04/23 21:09:42 |
version 1.20, 2019/05/02 12:40:42 |
|
|
*/ |
*/ |
|
|
void |
void |
macro_open(struct format *f, const char *name) |
para_check(struct format *f) |
{ |
{ |
if (f->parastate == PARA_WANT) { |
if (f->parastate != PARA_WANT) |
if (f->linestate != LINE_NEW) { |
return; |
putchar('\n'); |
if (f->linestate != LINE_NEW) { |
f->linestate = LINE_NEW; |
putchar('\n'); |
} |
f->linestate = LINE_NEW; |
puts(".Pp"); |
|
} |
} |
|
puts(".Pp"); |
|
f->parastate = PARA_HAVE; |
|
} |
|
|
|
void |
|
macro_open(struct format *f, const char *name) |
|
{ |
|
para_check(f); |
switch (f->linestate) { |
switch (f->linestate) { |
case LINE_MACRO: |
case LINE_MACRO: |
if (f->flags & FMT_NOSPC) { |
if (f->flags & FMT_NOSPC) { |
fputs(" Ns ", stdout); |
fputs(" Ns ", stdout); |
break; |
break; |
} |
} |
if (f->flags & (FMT_CHILD | FMT_IMPL)) { |
if (f->nofill || f->flags & (FMT_CHILD | FMT_IMPL)) { |
putchar(' '); |
putchar(' '); |
break; |
break; |
} |
} |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case LINE_TEXT: |
case LINE_TEXT: |
|
if (f->nofill && f->linestate == LINE_TEXT) |
|
fputs(" \\c", stdout); |
putchar('\n'); |
putchar('\n'); |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case LINE_NEW: |
case LINE_NEW: |
Line 213 macro_addnode(struct format *f, struct pnode *n, int f |
|
Line 222 macro_addnode(struct format *f, struct pnode *n, int f |
|
nc = TAILQ_NEXT(nc, child); |
nc = TAILQ_NEXT(nc, child); |
if (nc == NULL || pnode_class(nc->node) != CLASS_TEXT) |
if (nc == NULL || pnode_class(nc->node) != CLASS_TEXT) |
is_text = 0; |
is_text = 0; |
if (is_text && !nc->spc) |
if (is_text && (nc->flags & NFLAG_SPC) == 0) |
flags &= ~ARG_SPACE; |
flags &= ~ARG_SPACE; |
else |
else |
flags |= ARG_SPACE; |
flags |= ARG_SPACE; |
Line 239 macro_nodeline(struct format *f, const char *name, str |
|
Line 248 macro_nodeline(struct format *f, const char *name, str |
|
void |
void |
print_text(struct format *f, const char *word, int flags) |
print_text(struct format *f, const char *word, int flags) |
{ |
{ |
if (f->parastate == PARA_WANT) { |
int ateos, inword; |
if (f->linestate != LINE_NEW) { |
|
putchar('\n'); |
para_check(f); |
f->linestate = LINE_NEW; |
|
} |
|
puts(".Pp"); |
|
} |
|
switch (f->linestate) { |
switch (f->linestate) { |
case LINE_NEW: |
case LINE_NEW: |
break; |
break; |
Line 259 print_text(struct format *f, const char *word, int fla |
|
Line 264 print_text(struct format *f, const char *word, int fla |
|
} |
} |
if (f->linestate == LINE_NEW && (*word == '.' || *word == '\'')) |
if (f->linestate == LINE_NEW && (*word == '.' || *word == '\'')) |
fputs("\\&", stdout); |
fputs("\\&", stdout); |
|
ateos = inword = 0; |
while (*word != '\0') { |
while (*word != '\0') { |
|
if (f->nofill == 0) { |
|
switch (*word) { |
|
case ' ': |
|
if (ateos == 0) { |
|
inword = 0; |
|
break; |
|
} |
|
ateos = inword = 0; |
|
/* Handle the end of a sentence. */ |
|
while (*word == ' ') |
|
word++; |
|
switch (*word) { |
|
case '\0': |
|
break; |
|
case '\'': |
|
case '.': |
|
fputs("\n\\&", stdout); |
|
break; |
|
default: |
|
putchar('\n'); |
|
break; |
|
} |
|
continue; |
|
/* Detect the end of a sentence. */ |
|
case '!': |
|
case '.': |
|
case '?': |
|
if (inword > 1 && |
|
(word[-2] != 'n' || word[-1] != 'c') && |
|
(word[-2] != 'v' || word[-1] != 's')) |
|
ateos = 1; |
|
/* FALLTHROUGH */ |
|
case '"': |
|
case '\'': |
|
case ')': |
|
case ']': |
|
inword = 0; |
|
break; |
|
default: |
|
if (isalnum((unsigned char)*word)) |
|
inword++; |
|
ateos = 0; |
|
break; |
|
} |
|
} |
putchar(*word); |
putchar(*word); |
if (*word++ == '\\') |
if (*word++ == '\\') |
putchar('e'); |
putchar('e'); |