Difference between revisions of "Linecon"

From Mailutils
Jump to navigationJump to search
 
(2 intermediate revisions by the same user not shown)
Line 7: Line 7:
 
This option enables the [[line number information facility]].  This facility emits current input line number (prefixed with ''STR'') after each contiguous sequence of one or more removed newline characters.  It is useful for implementing parsers which are normally supposed to identify eventual erroneous lines with their input line numbers.  The following example creates a read-only instance of this filter with the line number information facility enabled:
 
This option enables the [[line number information facility]].  This facility emits current input line number (prefixed with ''STR'') after each contiguous sequence of one or more removed newline characters.  It is useful for implementing parsers which are normally supposed to identify eventual erroneous lines with their input line numbers.  The following example creates a read-only instance of this filter with the line number information facility enabled:
  
<source lang="C">
+
<syntaxhighlight lang="C">
 
   int rc;          /* Return code */
 
   int rc;          /* Return code */
 
   mu_stream_t flt; /* Filter stream */
 
   mu_stream_t flt; /* Filter stream */
Line 14: Line 14:
  
 
   initialize_input_stream (&stream);
 
   initialize_input_stream (&stream);
   rc = mu_filter_stream_create_args (&flt, input, argv[0], MU_FILTER_DECODE, MU_STREAM_READ, 3, argv);
+
   rc = mu_filter_create_args (&flt, input, argv[0], 3, argv, MU_FILTER_DECODE, MU_STREAM_READ);
</source>
+
</syntaxhighlight>
  
 
[[Category:Filters]]
 
[[Category:Filters]]
 +
[[Category:C API]]

Latest revision as of 13:25, 16 October 2023

Linecon is a Mailutils filter implementing a familiar UNIX line-continuation facility. It removes from the input stream any newline character immediately preceded by a backslash. This filter operates only in decode mode.

The creation sequence allows for the following option:

-i STR

This option enables the line number information facility. This facility emits current input line number (prefixed with STR) after each contiguous sequence of one or more removed newline characters. It is useful for implementing parsers which are normally supposed to identify eventual erroneous lines with their input line numbers. The following example creates a read-only instance of this filter with the line number information facility enabled:

  int rc;          /* Return code */
  mu_stream_t flt; /* Filter stream */
  mu_stream_t input; /* Input stream */
  char *argv[] = { "linecon", "-i", "#line ", NULL },

  initialize_input_stream (&stream);
  rc = mu_filter_create_args (&flt, input, argv[0], 3, argv, MU_FILTER_DECODE, MU_STREAM_READ);