Groffistas,

lurking around in troff's source code I've found a nice method to get
string comparison.  You already know that in

  .if "..."..."

the left and right part is processed in protected environments
(without creating real output), and the resulting node lists are
compared.  In particular, this expression

  .if "\f[BI]""

is evaluated as true, which is probably not expected by everyone (the
reason is that no actual output is produced).  Additionally, it is not
possible to have incomplete input.  For example, this

  .if "\["\["

yields a bunch of error messages:

  missing `]'
  invalid base glyph `"\["' in composite glyph name
  warning: can't find special character `'
  warning: missing closing delimiter

Now enters `\?'.  This is a remedy to all of the above described
problems.  Both

  .if "\?\[\?"\?\[\?"

and

  .if "\?\f[BI]\?""

work and return the expected result, since the data embedded between
the \? escapes is read in copy-in mode, without further processing.

This method can also be used to compare macros and diversions, but
this is of limited use.


    Werner


_______________________________________________
Groff mailing list
Groff@gnu.org
http://lists.gnu.org/mailman/listinfo/groff

Reply via email to