version 1.19, 2019/05/02 04:12:18 |
version 1.21, 2019/05/20 20:08:26 |
Line 130 macro_addarg(struct format *f, const char *arg, int fl |
|
Line 130 macro_addarg(struct format *f, const char *arg, int fl |
|
flags &= ~ ARG_SPACE; |
flags &= ~ ARG_SPACE; |
} |
} |
|
|
|
/* For XML entities, skip escaping. */ |
|
|
|
if (flags & ARG_RAW) { |
|
fputs(arg, stdout); |
|
break; |
|
} |
|
|
/* Escape us if we look like a macro. */ |
/* Escape us if we look like a macro. */ |
|
|
if ((flags & (ARG_QUOTED | ARG_UPPER)) == 0 && |
if ((flags & (ARG_QUOTED | ARG_UPPER)) == 0 && |
Line 186 macro_addnode(struct format *f, struct pnode *n, int f |
|
Line 193 macro_addnode(struct format *f, struct pnode *n, int f |
|
TAILQ_NEXT(nc, child) == NULL) |
TAILQ_NEXT(nc, child) == NULL) |
n = nc; |
n = nc; |
|
|
if (n->node == NODE_TEXT || n->node == NODE_ESCAPE) { |
switch (n->node) { |
|
case NODE_ESCAPE: |
|
flags |= ARG_RAW; |
|
/* FALLTHROUGH */ |
|
case NODE_TEXT: |
macro_addarg(f, n->b, flags); |
macro_addarg(f, n->b, flags); |
f->parastate = PARA_MID; |
f->parastate = PARA_MID; |
return; |
return; |
|
default: |
|
break; |
} |
} |
|
|
/* |
/* |
Line 248 macro_nodeline(struct format *f, const char *name, str |
|
Line 261 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) |
{ |
{ |
|
int ateos, inword; |
|
|
para_check(f); |
para_check(f); |
switch (f->linestate) { |
switch (f->linestate) { |
case LINE_NEW: |
case LINE_NEW: |
Line 262 print_text(struct format *f, const char *word, int fla |
|
Line 277 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'); |