Add support for highlighting of multi-line C preprocessor statements. - enscript - GNU Enscript
 (HTM) git clone git://thinkerwim.org/enscript.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit f0a229189af7db47af5510f381fefc599fcd775a
 (DIR) parent 4933d0270baaa187b7d968ba7c82a5bd2ec14e4d
 (HTM) Author: Tim Retout <diocles@gnu.org>
       Date:   Tue,  1 Jan 2008 17:42:13 +0000
       
       Add support for highlighting of multi-line C preprocessor statements.
       
       Diffstat:
         M states/hl/ChangeLog                 |       7 +++++++
         M states/hl/c_ppline.st               |      32 ++++++++++++++++++++++++++++---
       
       2 files changed, 36 insertions(+), 3 deletions(-)
       ---
 (DIR) diff --git a/states/hl/ChangeLog b/states/hl/ChangeLog
       @@ -1,5 +1,12 @@
        2008-01-01  Tim Retout  <diocles@gnu.org>
        
       +        * c_ppline.st (c_ppline_comment): New state.
       +        (c_ppline, c_ppline_comments_strings_chars, c_ppline_tokensequence):
       +        Call c_ppline_comment rather than c_comment.
       +        (c_ppline, c_ppline_include, c_ppline_define)
       +        (c_ppline_comments_strings_chars, c_ppline_tokensequence): Treat
       +        backslash-escaped newlines as continuing the preprocessor line.
       +
                * c_ppline.st (c_ppline): Move dependency on C rules to top of file,
                to fix use of CHighlight.
        
 (DIR) diff --git a/states/hl/c_ppline.st b/states/hl/c_ppline.st
       @@ -11,7 +11,7 @@ state c_ppline extends CHighlight
          /\/\*/ {
            comment_face (true);
            language_print ($0);
       -    call (c_comment);
       +    call (c_ppline_comment);
            comment_face (false);
          }
          /* Include line. */
       @@ -50,6 +50,9 @@ state c_ppline extends CHighlight
            call (c_ppline_tokensequence);
            return;
          }
       +  /\\\\\n/ {
       +    language_print ($0);
       +  }
          /\n/ {
            language_print ($0);
            return;
       @@ -80,6 +83,9 @@ state c_ppline_include extends CHighlight
            call (c_ppline_comments_strings_chars);
            return;
          }
       +  /\\\\\n/ {
       +    language_print ($0);
       +  }
          /\n/ {
            language_print ($0);
            return;
       @@ -105,6 +111,9 @@ state c_ppline_define extends CHighlight
            call (c_ppline_comments_strings_chars);
            return;
          }
       +  /\\\\\n/ {
       +    language_print ($0);
       +  }
          /\n/ {
            language_print ($0);
            return;
       @@ -117,7 +126,7 @@ state c_ppline_comments_strings_chars extends CHighlight
          /\/\*/ {
            comment_face (true);
            language_print ($0);
       -    call (c_comment);
       +    call (c_ppline_comment);
            comment_face (false);
          }
          /* String constants. */
       @@ -133,6 +142,9 @@ state c_ppline_comments_strings_chars extends CHighlight
            language_print ($0);
            string_face (false);
          }
       +  /\\\\\n/ {
       +    language_print ($0);
       +  }
          /\n/ {
            language_print ($0);
            return;
       @@ -145,7 +157,7 @@ state c_ppline_tokensequence extends CHighlight
          /\/\*/ {
            comment_face (true);
            language_print ($0);
       -    call (c_comment);
       +    call (c_ppline_comment);
            comment_face (false);
          }
          /* String constants. */
       @@ -180,6 +192,20 @@ state c_ppline_tokensequence extends CHighlight
            language_print ($0);
            variable_name_face (false);
          }
       +  /\\\\\n/ {
       +    language_print ($0);
       +  }
       +  /\n/ {
       +    language_print ($0);
       +    return;
       +  }
       +}
       +
       +/* Comments within pre-processor directives need escaped newlines. */
       +state c_ppline_comment extends c_comment {
       +  /\\\\\n/ {
       +    language_print ($0);
       +  }
          /\n/ {
            language_print ($0);
            return;