Enforce that \q may not be used anywhere within \c. It shouldn't be
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 12 Jun 2004 21:53:26 +0000 (21:53 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 12 Jun 2004 21:53:26 +0000 (21:53 +0000)
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: it means the text backend doesn't have to nest
two pairs of identical quotes, and the paper backends don't have to
downgrade their quote characters if (as is perfectly plausible) the
fixed-pitch font doesn't support the same range as the body text
fonts.

git-svn-id: svn://svn.tartarus.org/sgt/halibut@4277 cda61777-01e9-0310-a592-d414129be87e

error.c
halibut.h
input.c

diff --git a/error.c b/error.c
index 0e90f0c..350e71a 100644 (file)
--- 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");
index dfd92c1..4c9a745 100644 (file)
--- 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 (file)
--- 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;