summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorwlemb <wlemb>2002-04-05 11:50:03 +0000
committerwlemb <wlemb>2002-04-05 11:50:03 +0000
commitf905d1377bff63a3b5a6ed140181e05eb4fa4423 (patch)
treec387592266e6d331d34e034b95e2b40ee38008a7 /src
parentf477df3261e427216c4ee34d40ca1ab44c324357 (diff)
downloadgroff-f905d1377bff63a3b5a6ed140181e05eb4fa4423.tar.gz
* src/drivers/grops/psrm.cc (skip_possible_newline): New function.
(resource_manager::do_begin_binary, resource_manager::do_begin_data): Use it. * doc/texinfo.tex: Updated to version 4.2. * src/roff/troff/token.h: Add TOKEN_ZERO_WIDTH_BREAK for `\:'. (token::zero_width_break): New inline function. * src/roff/troff/input.cc (token::next): Use it. (token::description): Updated. (encode_char): Ignore `\%', `\&', `\)', and `\:'. (token::add_to_node_list, token::process): Use it. * NEWS, doc/groff.texinfo: Updated.
Diffstat (limited to 'src')
-rw-r--r--src/devices/grops/psrm.cc28
-rw-r--r--src/roff/troff/input.cc26
-rw-r--r--src/roff/troff/token.h7
3 files changed, 55 insertions, 6 deletions
diff --git a/src/devices/grops/psrm.cc b/src/devices/grops/psrm.cc
index 7e5c56df..ff2a59fa 100644
--- a/src/devices/grops/psrm.cc
+++ b/src/devices/grops/psrm.cc
@@ -724,6 +724,32 @@ int read_one_of(const char **ptr, const char **s, int n)
return -1;
}
+void skip_possible_newline(const char *ptr, FILE *fp, FILE *outfp)
+{
+ int c = getc(fp);
+ if (c == '\r') {
+ current_lineno++;
+ if (outfp)
+ putc(c, outfp);
+ int cc = getc(fp);
+ if (cc != '\n') {
+ if (cc != EOF)
+ ungetc(cc, fp);
+ }
+ else {
+ if (outfp)
+ putc(cc, outfp);
+ }
+ }
+ else if (c == '\n') {
+ current_lineno++;
+ if (outfp)
+ putc(c, outfp);
+ }
+ else if (c != EOF)
+ ungetc(c, fp);
+}
+
int resource_manager::do_begin_data(const char *ptr, int, FILE *fp,
FILE *outfp)
{
@@ -790,6 +816,7 @@ int resource_manager::do_begin_data(const char *ptr, int, FILE *fp,
}
} while ((unit == Bytes ? bytecount : linecount) < numberof);
}
+ skip_possible_newline();
char buf[PS_LINE_MAX + 2];
if (!ps_get_line(buf, fp)) {
error("missing %%%%EndData line");
@@ -831,6 +858,7 @@ int resource_manager::do_begin_binary(const char *ptr, int, FILE *fp,
else if (c == '\n')
current_lineno++;
}
+ skip_possible_newline();
char buf[PS_LINE_MAX + 2];
if (!ps_get_line(buf, fp)) {
error("missing %%%%EndBinary line");
diff --git a/src/roff/troff/input.cc b/src/roff/troff/input.cc
index d5edf824..19817f5e 100644
--- a/src/roff/troff/input.cc
+++ b/src/roff/troff/input.cc
@@ -1562,10 +1562,7 @@ void token::next()
return;
case ESCAPE_COLON:
ESCAPE_COLON:
- type = TOKEN_NODE;
- nd = new space_node(H0);
- nd->freeze_space();
- nd->is_escape_colon();
+ type = TOKEN_ZERO_WIDTH_BREAK;
return;
case ESCAPE_e:
ESCAPE_e:
@@ -2126,6 +2123,8 @@ const char *token::description()
return "`\\!'";
case TOKEN_TRANSPARENT_DUMMY:
return "`\\)'";
+ case TOKEN_ZERO_WIDTH_BREAK:
+ return "`\\:'";
case TOKEN_EOF:
return "end of input";
default:
@@ -4577,9 +4576,11 @@ static void encode_char(macro *mac, char c)
mac->append(')');
}
}
- else {
+ else if (!(tok.hyphen_indicator()
+ || tok.dummy()
+ || tok.transparent_dummy()
+ || tok.zero_width_break()))
error("%1 is invalid within \\X", tok.description());
- }
}
else {
if ((font::use_charnames_in_special) && (c == '\\')) {
@@ -5850,6 +5851,11 @@ int token::add_to_node_list(node **pp)
case TOKEN_TRANSPARENT_DUMMY:
n = new transparent_dummy_node;
break;
+ case TOKEN_ZERO_WIDTH_BREAK:
+ n = new space_node(H0);
+ n->freeze_space();
+ n->is_escape_colon();
+ break;
default:
return 0;
}
@@ -5941,6 +5947,14 @@ void token::process()
case TOKEN_TRANSPARENT_DUMMY:
curenv->add_node(new transparent_dummy_node);
break;
+ case TOKEN_ZERO_WIDTH_BREAK:
+ {
+ node *tmp = new space_node(H0);
+ tmp->freeze_space();
+ tmp->is_escape_colon();
+ curenv->add_node(tmp);
+ break;
+ }
default:
assert(0);
}
diff --git a/src/roff/troff/token.h b/src/roff/troff/token.h
index 3281e234..2f0c3ccc 100644
--- a/src/roff/troff/token.h
+++ b/src/roff/troff/token.h
@@ -57,6 +57,7 @@ class token {
TOKEN_TAB, // tab
TOKEN_TRANSPARENT, // \!
TOKEN_TRANSPARENT_DUMMY, // \)
+ TOKEN_ZERO_WIDTH_BREAK, // \:
TOKEN_EOF // end of file
} type;
public:
@@ -85,6 +86,7 @@ public:
int right_brace();
int page_ejector();
int hyphen_indicator();
+ int zero_width_break();
int operator==(const token &); // need this for delimiters, and for conditions
int operator!=(const token &); // ditto
unsigned char ch();
@@ -216,4 +218,9 @@ inline int token::hyphen_indicator()
return type == TOKEN_HYPHEN_INDICATOR;
}
+inline int token::zero_width_break()
+{
+ return type == TOKEN_ZERO_WIDTH_BREAK;
+}
+
int has_arg();