summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--error.c5
-rw-r--r--halibut.h1
-rw-r--r--input.c43
3 files changed, 37 insertions, 12 deletions
diff --git a/error.c b/error.c
index 0e90f0c..350e71a 100644
--- a/error.c
+++ b/error.c
@@ -117,6 +117,11 @@ static void do_error(int code, va_list ap) {
sprintf(error, "expected `}' after cross-reference");
flags = FILEPOS;
break;
+ case err_codequote:
+ fpos = *va_arg(ap, filepos *);
+ sprintf(error, "unable to nest \\q{...} within \\c{...} or \\cw{...}");
+ flags = FILEPOS;
+ break;
case err_missingrbrace:
fpos = *va_arg(ap, filepos *);
sprintf(error, "unclosed braces at end of paragraph");
diff --git a/halibut.h b/halibut.h
index dfd92c1..4c9a745 100644
--- a/halibut.h
+++ b/halibut.h
@@ -221,6 +221,7 @@ enum {
err_explbr, /* expected `{' after command */
err_commenteof, /* EOF inside braced comment */
err_kwexprbr, /* expected `}' after cross-ref */
+ err_codequote, /* \q within \c is not supported */
err_missingrbrace, /* unclosed braces at end of para */
err_missingrbrace2, /* unclosed braces at end of file */
err_nestedstyles, /* unable to nest text styles */
diff --git a/input.c b/input.c
index 59ea326..4eb1d8c 100644
--- a/input.c
+++ b/input.c
@@ -612,6 +612,7 @@ static void read_file(paragraph ***ret, input *in, indexdata *idx) {
word **whptr; /* to restore from \u alternatives */
word **idximplicit; /* to restore from \u alternatives */
filepos fpos;
+ int in_code;
} *sitem;
stack parsestk;
struct crossparaitem {
@@ -1201,21 +1202,39 @@ static void read_file(paragraph ***ret, input *in, indexdata *idx) {
if (t.type != tok_lbrace) {
error(err_explbr, &t.pos);
} else {
- wd.text = NULL;
- wd.type = toquotestyle(style);
- wd.alt = NULL;
- wd.aux = quote_Open;
- wd.fpos = t.pos;
- wd.breaks = FALSE;
- if (!indexing || index_visible)
- addword(wd, &whptr);
- if (indexing) {
- rdadd(&indexstr, L'"');
- addword(wd, &idximplicit);
+ /*
+ * Enforce that \q may not be used anywhere
+ * within \c. (It shouldn't be necessary
+ * since the whole point of \c should be
+ * that the user wants to exercise exact
+ * control over the glyphs used, and
+ * forbidding it has the useful effect of
+ * relieving some backends of having to
+ * make difficult decisions.)
+ */
+ int stype;
+
+ if (style != word_Code && style != word_WeakCode) {
+ wd.text = NULL;
+ wd.type = toquotestyle(style);
+ wd.alt = NULL;
+ wd.aux = quote_Open;
+ wd.fpos = t.pos;
+ wd.breaks = FALSE;
+ if (!indexing || index_visible)
+ addword(wd, &whptr);
+ if (indexing) {
+ rdadd(&indexstr, L'"');
+ addword(wd, &idximplicit);
+ }
+ stype = stack_quote;
+ } else {
+ error(err_codequote, &t.pos);
+ stype = stack_nop;
}
sitem = snew(struct stack_item);
sitem->fpos = t.pos;
- sitem->type = stack_quote;
+ sitem->type = stype;
stk_push(parsestk, sitem);
}
break;