]> git.lyx.org Git - lyx.git/blobdiff - lib/examples/listerrors.lyx
Amend and extend 9f3518bc
[lyx.git] / lib / examples / listerrors.lyx
index 47e3e41186e56eaa38b839ff84bf625b5d24598c..b87d86b5cf85eb05316448998e6328f278cb4553 100644 (file)
@@ -1,8 +1,10 @@
-#LyX 2.0 created this file. For more info see http://www.lyx.org/
-\lyxformat 413
+#LyX 2.2 created this file. For more info see http://www.lyx.org/
+\lyxformat 508
 \begin_document
 \begin_header
-\textclass literate-article
+\save_transient_properties true
+\origin /systemlyxdir/examples/
+\textclass article
 \begin_preamble
 %
 % ps2pdf stuff
 \let\nwdocspar=\smallbreak
 \end_preamble
 \use_default_options false
+\begin_modules
+noweb
+\end_modules
 \maintain_unincluded_children false
 \language english
 \language_package default
 \inputencoding auto
 \fontencoding global
-\font_roman times
-\font_sans helvet
-\font_typewriter courier
+\font_roman "times" "default"
+\font_sans "helvet" "default"
+\font_typewriter "courier" "default"
+\font_math "auto" "auto"
 \font_default_family default
 \use_non_tex_fonts false
 \font_sc false
 \font_osf false
-\font_sf_scale 100
-\font_tt_scale 100
-
+\font_sf_scale 100 100
+\font_tt_scale 100 100
 \graphics default
-\default_output_format default
+\default_output_format pdf
 \output_sync 0
 \bibtex_command default
 \index_command default
 \use_hyperref false
 \papersize default
 \use_geometry false
-\use_amsmath 0
-\use_esint 0
-\use_mhchem 1
-\use_mathdots 1
+\use_package amsmath 0
+\use_package amssymb 0
+\use_package cancel 0
+\use_package esint 0
+\use_package mathdots 1
+\use_package mathtools 0
+\use_package mhchem 1
+\use_package stackrel 0
+\use_package stmaryrd 0
+\use_package undertilde 0
 \cite_engine basic
+\cite_engine_type default
+\biblio_style plain
 \use_bibtopic false
 \use_indices false
 \paperorientation portrait
 \suppress_date false
+\justification true
 \use_refstyle 0
 \index Index
 \shortcut idx
@@ -75,7 +89,8 @@
 \begin_body
 
 \begin_layout Title
-LyX listerrors:
+\SpecialChar LyX
+ listerrors:
 \begin_inset Newline newline
 \end_inset
 
@@ -112,7 +127,8 @@ The listerrors program used to be compiled as a C program and installed
 \emph on
 BINDIR/listerrors
 \emph default
- along with LyX in order to perform some simple re-formatting of noweb and
+ along with \SpecialChar LyX
+ in order to perform some simple re-formatting of noweb and
  GCC error messages.
  This document describes and implements the Python version of the same program.
 \end_layout
@@ -131,7 +147,8 @@ Introduction
 \end_layout
 
 \begin_layout Standard
-The motivation for this program was Bugzilla bug 190
+The motivation for this program was \SpecialChar LyX
+ bug 190
 \begin_inset Foot
 status collapsed
 
@@ -142,7 +159,7 @@ status collapsed
 
 \begin_layout Plain Layout
 
-http://bugzilla.lyx.org/show_bug.cgi?id=190
+http://www.lyx.org/trac/ticket/190
 \end_layout
 
 \end_inset
@@ -172,11 +189,15 @@ listerrors
 \begin_inset Quotes erd
 \end_inset
 
-? Usually, LyX has great support for parsing of error messages.
- For each error in the log file, LyX pops up an error box at that location
- in the LyX window.
+? Usually, \SpecialChar LyX
+ has great support for parsing of error messages.
+ For each error in the log file, \SpecialChar LyX
+ pops up an error box at that location
+ in the \SpecialChar LyX
+ window.
  The error scanning routines expect these errors to be in a certain format
- (similar to LaTeX errors).
+ (similar to \SpecialChar LaTeX
+ errors).
  When dealing with Literate Programs, you have 
 \begin_inset Quotes eld
 \end_inset
@@ -208,7 +229,8 @@ http://www.eecs.harvard.edu/~nr/noweb
 
  as well as gcc error messages (and potentially others).
  The listerrors program attempts to standardize these error messages to
- a format that LyX can parse and react to.
+ a format that \SpecialChar LyX
+ can parse and react to.
 \end_layout
 
 \begin_layout Standard
@@ -218,7 +240,8 @@ In a nutshell, the problems with the old implementation of listerrors that
 
 \begin_layout Enumerate
 It was a C program and it was installed in the user path in the same directory
- as LyX.
+ as \SpecialChar LyX
+.
  Having such a generically named binary in, for example, 
 \emph on
 /usr/bin
@@ -249,7 +272,8 @@ The new version deals with these problems in the following fashion:
 
 \begin_layout Enumerate
 Both the example file (this document) and the program are to be added to
- the LyX CVS repository.
+ the \SpecialChar LyX
+ CVS repository.
 \end_layout
 
 \begin_layout Enumerate
@@ -257,7 +281,8 @@ The program itself will be installed in
 \emph on
 SHAREDIR/lyx/scripts
 \emph default
-, along with other LyX-specific helper scripts.
+, along with other \SpecialChar LyX
+-specific helper scripts.
 \end_layout
 
 \begin_layout Standard
@@ -305,138 +330,177 @@ listerrors
  available for all other platforms.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
 <<listerrors>>=
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 #!/usr/bin/python -tt
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 """reformat noweb and compiler errors for LyX.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 Expects to read from stdin and output to stdout.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 """
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 __author__ = "Kayvan A.
  Sylvan <kayvan@sylvan.com>"
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 __date__ = "$Date: 2005/07/18 09:42:26 $"
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 __version__ = "$Revision: 1.5 $"
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 __credits__ = """Edmar Wienskoski Jr.
  <edmar-w-jr@technologist.com>
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     original Literate support for LyX.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 Bernard Michael Hurley <berhardh@westherts.ac.uk>
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     modifications to original listerrors."""
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 __copyright__ = "Copyright 2002 - Kayvan Sylvan."
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 import sys, string
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 <<Function Bodies>>
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 if __name__ == "__main__":
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   main()
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 @
 \end_layout
 
+\end_inset
+
+
+\end_layout
+
 \begin_layout Section
-LaTeX style error message
+\SpecialChar LaTeX
+ style error message
 \end_layout
 
 \begin_layout Standard
-The following function mimics the TeX error message format.
+The following function mimics the \SpecialChar TeX
+ error message format.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
 <<Function Bodies>>=
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 def write_error(msg, tool = "noweb", line_number = 1):
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   """Write out the given message in TeX error style.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   called like: write_error(msg, tool, line_number)."""
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
   print "! Build Error: ==> %s ==>
 \backslash
 n" % (tool),
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
   print " ...
 \backslash
@@ -445,40 +509,52 @@ n
 nl.%d ...
 \backslash
 n" % (line_number),
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
   if type(msg) == type("str"): # simple string
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
     print msg
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
   else: # some kind of list (sequence or tuple)
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
     for m in msg:
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
         if m != "": print m,
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
     print
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
+\end_layout
 
-\begin_inset Newline newline
-\end_inset
+\begin_layout Plain Layout
 
 @ %def write_error
 \end_layout
 
+\end_inset
+
+
+\end_layout
+
 \begin_layout Section
 Filtering errors
 \end_layout
@@ -505,110 +581,148 @@ pushline
  set of functions:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
 <<Function Bodies>>=
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 __lines = [] # lines pushed back
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 def getline(file = sys.stdin):
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   """read a line from internal stack or from file.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   optional file argument defaults to sys.stdin."""
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   global __lines
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   lines = __lines
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   if lines:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     line = lines.pop()
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   else:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     line = file.readline()
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   return line
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 @ %def getline
 \end_layout
 
+\end_inset
+
+
+\end_layout
+
 \begin_layout Standard
 And now for the corresponding pushline function:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
 <<Function Bodies>>=
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 def pushline(line):
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   "push a line onto the pushback stack."
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   global __lines
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
   lines = __lines
-\begin_inset Newline newline
-\end_inset
+\end_layout
 
-  lines.append(line)
-\begin_inset Newline newline
-\end_inset
+\begin_layout Plain Layout
 
+lines.append(line)
+\end_layout
 
-\begin_inset Newline newline
-\end_inset
+\begin_layout Plain Layout
+
+\end_layout
+
+\begin_layout Plain Layout
 
 @ %def pushline
 \end_layout
 
+\end_inset
+
+
+\end_layout
+
 \begin_layout Standard
 The main() entry point function is extremely simple.
  Note that this version of 
@@ -626,81 +740,113 @@ listerrors
  
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
 <<Function Bodies>>=
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 def main():
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   """Entry point for listerrors.
  Takes no options.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   Reads stdin and writes to stdout.
  Filter errors"""
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   while 1:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     line = getline()
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     if line == "": break
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     <<Check line against patterns and take action>>
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 @ %def main
 \end_layout
 
+\end_inset
+
+
+\end_layout
+
 \begin_layout Standard
 For each line read in, we need to find out if it matches any of our tools
  (noweb, gcc, etc.) and act accordingly.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
 <<Check line against patterns and take action>>=
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 try_patterns_dispatch = [ noweb_try, gcc_try, xlc_try ]
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
 for predicate in try_patterns_dispatch:
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
   if predicate(line): break
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
 @
 \end_layout
 
+\end_inset
+
+
+\end_layout
+
 \begin_layout Section
 Different Error Formats
 \end_layout
@@ -720,55 +866,74 @@ Noweb errors are output on a single line, so examining just the current
  line is enough.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
 <<Function Bodies>>=
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 def noweb_try(line):
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   """see if line is a noweb error.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   Returns 1 on success, 0 otherwise.
  Outputs on stdout."""
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   retval = 0
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   <<Look for the unescaped angle-brackets in documentation>>
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   <<Look for anything with double angle brackets>>
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   <<Last ditch effort scan for specific strings>>
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   return retval
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 @ %def noweb_try
 \end_layout
 
+\end_inset
+
+
+\end_layout
+
 \begin_layout Standard
 First, we look for the 
 \begin_inset Quotes eld
@@ -782,181 +947,247 @@ unescaped < < in documentation chunk
  This is the only message with an associated line number from noweb.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 <<Look for the unescaped angle-brackets in documentation>>=
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 if string.find(line, ": unescaped << in documentation chunk") != -1:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   line_parts = string.split(line, ':')
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   num_str = line_parts[1]
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   num_len = len(num_str)
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   i = 0
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   while i < num_len and (num_str[i] in string.digits): i = i + 1
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   if i == num_len:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     write_error(":" + line_parts[2], "noweb", int(num_str))
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     retval = 1
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 @
 \end_layout
 
+\end_inset
+
+
+\end_layout
+
 \begin_layout Standard
-Some noweb messages are simply about undefined scraps.
+Some noweb messages are simply about undefined chunks.
  These can be seen by looking for matching double-angle-brackets.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
 <<Look for anything with double angle brackets>>=
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 if (not retval):
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
   left = string.find(line, "<<")
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
   if (left != -1) and ((left + 2) < len(line)) and 
 \backslash
 
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
      (string.find(line[left+2:], ">>") != -1):
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
     write_error(line, "noweb");
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
     retval = 1;
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
 @
 \end_layout
 
+\end_inset
+
+
+\end_layout
+
 \begin_layout Standard
 Finally, here is an additional list of explicit strings to check for.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
 <<Last ditch effort scan for specific strings>>=
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 if (not retval):
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   msgs_to_try = ("couldn't open file",
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     "couldn't open temporary file",
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     "error writing temporary file",
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     "ill-formed option",
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     "unknown option",
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     "Bad format sequence",
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     "Can't open output file",
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     "Can't open temporary file",
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     "Capacity exceeded:",
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     "Ignoring unknown option -",
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     "This can't happen:",
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     "non-numeric line number in")
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   for msg in msgs_to_try:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     if string.find(line, msg) != -1:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
       write_error(line, "noweb")
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
       retval = 1
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
       break
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 @
 \end_layout
 
+\end_inset
+
+
+\end_layout
+
 \begin_layout Subsection
 gcc errors
 \end_layout
@@ -969,199 +1200,276 @@ The gcc errors can be multi-line, with the following format:
 foo.c: In function `main': 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
 foo.c:3: `bar' undeclared (first use in this function) 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 foo.c:3: (Each undeclared identifier is reported only once 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 foo.c:3: for each function it appears in.) 
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
 foo.c:3: parse error before `x'
 \end_layout
 
+\end_inset
+
+
+\end_layout
+
 \begin_layout Standard
 In order to parse this, the gcc error handler has to look ahead and return
  any and all lines that do not match the expected pattern.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
 <<Function Bodies>>=
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 def gcc_try(line):
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   """See if line is a gcc error.
  Read ahead to handle all the lines.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   Returns 1 on success, 0 otherwise.
  Outputs on stdout."""
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   retval = 0
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   <<Handle the gcc error message>>
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   return retval
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 @ %def gcc_try
 \end_layout
 
+\end_inset
+
+
+\end_layout
+
 \begin_layout Standard
 The error message starts with a gcc header (as above) without an associated
  line number.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
 <<Handle the gcc error message>>= 
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
 first_space = string.find(line, ' ')
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
 if first_space > 1: # The smallest would be "X: "
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
   if line[first_space - 1] == ':':
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
     header_to_see = line[:first_space - 1]
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
     next_line = getline()
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
     if next_line and next_line[:first_space - 1] == header_to_see:
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
       num_end = first_space
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
       while next_line[num_end] in string.digits: num_end = num_end + 1
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
       if num_end > first_space: # good!
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
         <<Accumulate gcc error lines and print it>>
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
       else: # oops! Not a gcc error.
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
         pushline(next_line)
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
     elif next_line:
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
       pushline(next_line) # return this line to input stream
-\begin_inset Newline newline
-\end_inset
+\end_layout
+
+\begin_layout Plain Layout
 
 @
 \end_layout
 
+\end_inset
+
+
+\end_layout
+
 \begin_layout Standard
 At the point in the code that we know that we are in the middle of an error
  message, we do the following:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
 <<Accumulate gcc error lines and print it>>=
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 num_str = next_line[first_space:num_end]
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 msgs = [line[first_space:]]
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 msgs.append(next_line[num_end + 1:])
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 header_to_see = next_line[:num_end]
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 next_line = getline()
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 while next_line and next_line[:num_end] == header_to_see:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   msgs.append(next_line[num_end + 1:])
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   next_line = getline()
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 if next_line: pushline(next_line)
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 write_error(msgs, "gcc", int(num_str))
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 retval = 1
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 @
 \end_layout
 
+\end_inset
+
+
+\end_layout
+
 \begin_layout Subsection
 xlc errors
 \end_layout
  
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 <<Function Bodies>>=
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 def xlc_try(line):
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   """see if line is an xlc error.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   Returns 1 on success, 0 otherwise.
  Outputs on stdout."""
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   retval = 0
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   if line[0] == '"': # This is the first character of all xlc errors
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     next_quote = string.find(line, '"', 1)
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     first_space = string.find(line, ' ')
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
     if (next_quote != -1) and (first_space > next_quote): # no space inisde
  quotes
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
       if line[first_space - 1:first_space + 6] == ", line ":
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
         num_start = num_end = first_space + 6
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
         while line[num_end] in string.digits: num_end = num_end + 1
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
         if num_end > num_start:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
           write_error(line, "xlc", int(line[num_start : num_end]))
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
           retval = 1
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   return retval
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
   
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 @ %def xlc_try
 \end_layout
 
+\end_inset
+
+
+\end_layout
+
 \begin_layout Section
 Extracting the code
 \end_layout
 
 \begin_layout Standard
-This project can be tangled from LyX if you set your 
+This project can be tangled from \SpecialChar LyX
+ if you set your 
 \begin_inset Quotes eld
 \end_inset
 
@@ -1291,7 +1627,7 @@ Program
 \begin_inset Quotes erd
 \end_inset
 
- convertor to call a generic script that always extracts a scrap named 
+ convertor to call a generic script that always extracts a chunk named 
 \family typewriter
 build-script
 \family default
@@ -1301,40 +1637,60 @@ build-script
 
 \begin_layout LyX-Code
 #!/bin/sh
-\begin_inset Newline newline
-\end_inset
+\end_layout
 
-notangle -Rbuild-script $1 | env NOWEB_SOURCE=$1 sh
+\begin_layout LyX-Code
+notangle -Rbuild-script $1 | env NOWEB_SOURCE=$1 NOWEB_OUTPUT_DIR=$2 sh
 \end_layout
 
 \begin_layout Standard
 This section defines our build-script, which extracts the code.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
 <<build-script>>=
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 #!/bin/sh
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
 if [ -z "$NOWEB_SOURCE" ]; then NOWEB_SOURCE=listerrors.nw; fi
 \end_layout
 
-\begin_layout Scrap
-notangle -Rlisterrors ${NOWEB_SOURCE} > listerrors
+\begin_layout Plain Layout
+
+if [ -z "$NOWEB_OUTPUT_DIR" ]; then NOWEB_OUTPUT_DIR=.; fi
 \end_layout
 
-\begin_layout Scrap
-chmod +x listerrors
+\begin_layout Plain Layout
+
+notangle -Rlisterrors ${NOWEB_SOURCE} > ${NOWEB_OUTPUT_DIR}/listerrors
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
+chmod +x ${NOWEB_OUTPUT_DIR}/listerrors
+\end_layout
+
+\begin_layout Plain Layout
+
 @
 \end_layout
 
+\end_inset
+
+
+\end_layout
+
 \begin_layout Section
 Indices
 \end_layout