]> git.lyx.org Git - lyx.git/blobdiff - lib/examples/listerrors.lyx
Natbib authoryear uses (Ref1; Ref2) by default.
[lyx.git] / lib / examples / listerrors.lyx
index 429f5182b20751c4099f8a468b852990b41dbe5e..11e0383db39cb5b463b561ce67b88450b11c05cc 100644 (file)
@@ -1,8 +1,8 @@
-#LyX 1.4.0cvs created this file. For more info see http://www.lyx.org/
-\lyxformat 243
+#LyX 2.1 created this file. For more info see http://www.lyx.org/
+\lyxformat 448
 \begin_document
 \begin_header
-\textclass literate-article
+\textclass article
 \begin_preamble
 %
 % ps2pdf stuff
 \def\nwendcode{\endtrivlist \endgroup \vfil\penalty10\vfilneg}
 \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
-\fontscheme pslatex
+\fontencoding global
+\font_roman times
+\font_sans helvet
+\font_typewriter courier
+\font_math auto
+\font_default_family default
+\use_non_tex_fonts false
+\font_sc false
+\font_osf false
+\font_sf_scale 100
+\font_tt_scale 100
 \graphics default
+\default_output_format default
+\output_sync 0
+\bibtex_command default
+\index_command default
 \paperfontsize default
 \spacing single
+\use_hyperref false
 \papersize default
 \use_geometry false
-\use_amsmath 0
+\use_package amsmath 0
+\use_package amssymb 0
+\use_package esint 0
+\use_package mathdots 1
+\use_package mathtools 0
+\use_package mhchem 1
+\use_package undertilde 0
 \cite_engine basic
+\cite_engine_type numerical
+\biblio_style plain
 \use_bibtopic false
+\use_indices false
 \paperorientation portrait
+\suppress_date false
+\justification true
+\use_refstyle 0
+\index Index
+\shortcut idx
+\color #008000
+\end_index
 \secnumdepth 3
 \tocdepth 3
 \paragraph_separation indent
-\defskip medskip
+\paragraph_indentation default
 \quotes_language english
-\quotes_times 2
 \papercolumns 1
 \papersides 1
 \paperpagestyle default
 \tracking_changes false
-\output_changes true
+\output_changes false
+\html_math_output 0
+\html_css_as_file 0
+\html_be_strict false
 \end_header
 
 \begin_body
 
 \begin_layout Title
-
 LyX listerrors:
-\newline
+\begin_inset Newline newline
+\end_inset
+
 rewritten in Python
 \end_layout
 
 \begin_layout Author
-
 Kayvan A.
  Sylvan
-\newline
+\begin_inset Newline newline
+\end_inset
+
+
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
 
-\begin_inset LatexCommand \url{mailto:kayvan@sylvan.com}
+mailto:kayvan@sylvan.com
+\end_layout
 
 \end_inset
 
@@ -65,12 +112,10 @@ Kayvan A.
 \end_layout
 
 \begin_layout Date
-
 3/15/2002
 \end_layout
 
 \begin_layout Abstract
-
 The listerrors program used to be compiled as a C program and installed
  as 
 \emph on
@@ -82,9 +127,8 @@ BINDIR/listerrors
 \end_layout
 
 \begin_layout Standard
-
-
-\begin_inset LatexCommand \tableofcontents{}
+\begin_inset CommandInset toc
+LatexCommand tableofcontents
 
 \end_inset
 
@@ -92,20 +136,23 @@ BINDIR/listerrors
 \end_layout
 
 \begin_layout Section
-
 Introduction
 \end_layout
 
 \begin_layout Standard
-
-The motivation for this program was Bugzilla bug 190
+The motivation for this program was LyX bug 190
 \begin_inset Foot
 status collapsed
 
-\begin_layout Standard
-
+\begin_layout Plain Layout
 Visit 
-\begin_inset LatexCommand \url{http://bugzilla.lyx.org/show_bug.cgi?id=190}
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
+
+http://www.lyx.org/trac/ticket/190
+\end_layout
 
 \end_inset
 
@@ -126,7 +173,6 @@ listerrors
 \end_layout
 
 \begin_layout Standard
-
 What is 
 \begin_inset Quotes eld
 \end_inset
@@ -148,10 +194,15 @@ noweb
 \begin_inset Foot
 status collapsed
 
-\begin_layout Standard
-
+\begin_layout Plain Layout
 See 
-\begin_inset LatexCommand \url{http://www.eecs.harvard.edu/~nr/noweb}
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
+
+http://www.eecs.harvard.edu/~nr/noweb
+\end_layout
 
 \end_inset
 
@@ -170,13 +221,11 @@ See
 \end_layout
 
 \begin_layout Standard
-
 In a nutshell, the problems with the old implementation of listerrors that
  bug 190 refers to were::
 \end_layout
 
 \begin_layout Enumerate
-
 It was a C program and it was installed in the user path in the same directory
  as LyX.
  Having such a generically named binary in, for example, 
@@ -187,7 +236,6 @@ It was a C program and it was installed in the user path in the same directory
 \end_layout
 
 \begin_layout Enumerate
-
 It required that noweb be installed on the compiling machine (the source
  was extracted by noweb from 
 \emph on
@@ -205,18 +253,15 @@ make install
 \end_layout
 
 \begin_layout Standard
-
 The new version deals with these problems in the following fashion:
 \end_layout
 
 \begin_layout Enumerate
-
 Both the example file (this document) and the program are to be added to
  the LyX CVS repository.
 \end_layout
 
 \begin_layout Enumerate
-
 The program itself will be installed in 
 \emph on
 SHAREDIR/lyx/scripts
@@ -225,7 +270,6 @@ SHAREDIR/lyx/scripts
 \end_layout
 
 \begin_layout Standard
-
 In the design and implementation of this new 
 \begin_inset Quotes eld
 \end_inset
@@ -238,10 +282,15 @@ listerrors
 \begin_inset Foot
 status collapsed
 
-\begin_layout Standard
-
+\begin_layout Plain Layout
 See the Python home page (
-\begin_inset LatexCommand \url{http://www.python.org}
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
+
+http://www.python.org
+\end_layout
 
 \end_inset
 
@@ -265,83 +314,161 @@ listerrors
  available for all other platforms.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Chunk
 
 <<listerrors>>=
-\newline
-#!/usr/bin/python
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+#!/usr/bin/python -tt
+\end_layout
+
+\begin_layout Chunk
+
 """reformat noweb and compiler errors for LyX.
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
 
-\newline
 Expects to read from stdin and output to stdout.
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 """
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
 
-\newline
 __author__ = "Kayvan A.
  Sylvan <kayvan@sylvan.com>"
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 __date__ = "$Date: 2005/07/18 09:42:26 $"
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 __version__ = "$Revision: 1.5 $"
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 __credits__ = """Edmar Wienskoski Jr.
  <edmar-w-jr@technologist.com>
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     original Literate support for LyX.
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 Bernard Michael Hurley <berhardh@westherts.ac.uk>
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     modifications to original listerrors."""
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 __copyright__ = "Copyright 2002 - Kayvan Sylvan."
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
 
-\newline
 import sys, string
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
 
-\newline
 <<Function Bodies>>
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
 
-\newline
 if __name__ == "__main__":
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   main()
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 @
 \end_layout
 
 \begin_layout Section
-
 LaTeX style error message
 \end_layout
 
 \begin_layout Standard
-
 The following function mimics the TeX error message format.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Chunk
 
 <<Function Bodies>>=
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 def write_error(msg, tool = "noweb", line_number = 1):
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   """Write out the given message in TeX error style.
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
 
-\newline
   called like: write_error(msg, tool, line_number)."""
-\newline
+\begin_inset Newline newline
+\end_inset
+
   print "! Build Error: ==> %s ==>
 \backslash
 n" % (tool),
-\newline
+\begin_inset Newline newline
+\end_inset
+
   print " ...
 \backslash
 n
@@ -349,31 +476,45 @@ n
 nl.%d ...
 \backslash
 n" % (line_number),
-\newline
+\begin_inset Newline newline
+\end_inset
+
   if type(msg) == type("str"): # simple string
-\newline
+\begin_inset Newline newline
+\end_inset
+
     print msg
-\newline
+\begin_inset Newline newline
+\end_inset
+
   else: # some kind of list (sequence or tuple)
-\newline
+\begin_inset Newline newline
+\end_inset
+
     for m in msg:
-\newline
+\begin_inset Newline newline
+\end_inset
+
         if m != "": print m,
-\newline
+\begin_inset Newline newline
+\end_inset
+
     print
-\newline
+\begin_inset Newline newline
+\end_inset
+
+
+\begin_inset Newline newline
+\end_inset
 
-\newline
 @ %def write_error
 \end_layout
 
 \begin_layout Section
-
 Filtering errors
 \end_layout
 
 \begin_layout Standard
-
 The only complication in our filtering code is that some parsers might need
  to push back lines that are read in to be read again later.
  We solve this problem by implementing a 
@@ -395,67 +536,128 @@ pushline
  set of functions:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Chunk
 
 <<Function Bodies>>=
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 __lines = [] # lines pushed back
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
 
-\newline
 def getline(file = sys.stdin):
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   """read a line from internal stack or from file.
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
 
-\newline
   optional file argument defaults to sys.stdin."""
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   global __lines
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   lines = __lines
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   if lines:
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     line = lines.pop()
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   else:
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     line = file.readline()
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   return line
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
 
-\newline
 @ %def getline
 \end_layout
 
 \begin_layout Standard
-
 And now for the corresponding pushline function:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Chunk
 
 <<Function Bodies>>=
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 def pushline(line):
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   "push a line onto the pushback stack."
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
+
   global __lines
-\newline
+\begin_inset Newline newline
+\end_inset
+
   lines = __lines
-\newline
+\begin_inset Newline newline
+\end_inset
+
   lines.append(line)
-\newline
+\begin_inset Newline newline
+\end_inset
+
+
+\begin_inset Newline newline
+\end_inset
 
-\newline
 @ %def pushline
 \end_layout
 
 \begin_layout Standard
-
 The main() entry point function is extremely simple.
  Note that this version of 
 \begin_inset Quotes eld
@@ -472,105 +674,171 @@ listerrors
  
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Chunk
 
 <<Function Bodies>>=
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 def main():
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   """Entry point for listerrors.
  Takes no options.
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
 
-\newline
   Reads stdin and writes to stdout.
  Filter errors"""
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
 
-\newline
   while 1:
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     line = getline()
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     if line == "": break
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     <<Check line against patterns and take action>>
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 @ %def main
 \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 Chunk
 
 <<Check line against patterns and take action>>=
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
+
 try_patterns_dispatch = [ noweb_try, gcc_try, xlc_try ]
-\newline
+\begin_inset Newline newline
+\end_inset
+
 for predicate in try_patterns_dispatch:
-\newline
+\begin_inset Newline newline
+\end_inset
+
   if predicate(line): break
-\newline
+\begin_inset Newline newline
+\end_inset
+
 @
 \end_layout
 
 \begin_layout Section
-
 Different Error Formats
 \end_layout
 
 \begin_layout Standard
-
 The following sections handle the various error message formats that we
  recognize in this program.
  
 \end_layout
 
 \begin_layout Subsection
-
 noweb errors
 \end_layout
 
 \begin_layout Standard
-
 Noweb errors are output on a single line, so examining just the current
  line is enough.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Chunk
 
 <<Function Bodies>>=
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 def noweb_try(line):
-\newline
-  """see if line is a noweb error.
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+  """see if line is a noweb error.
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
 
-\newline
   Returns 1 on success, 0 otherwise.
  Outputs on stdout."""
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   retval = 0
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   <<Look for the unescaped angle-brackets in documentation>>
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   <<Look for anything with double angle brackets>>
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   <<Last ditch effort scan for specific strings>>
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   return retval
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
 
-\newline
 @ %def noweb_try
 \end_layout
 
 \begin_layout Standard
-
 First, we look for the 
 \begin_inset Quotes eld
 \end_inset
@@ -583,243 +851,449 @@ unescaped < < in documentation chunk
  This is the only message with an associated line number from noweb.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
 
 <<Look for the unescaped angle-brackets in documentation>>=
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 if string.find(line, ": unescaped << in documentation chunk") != -1:
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   line_parts = string.split(line, ':')
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   num_str = line_parts[1]
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   num_len = len(num_str)
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   i = 0
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   while i < num_len and (num_str[i] in string.digits): i = i + 1
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   if i == num_len:
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     write_error(":" + line_parts[2], "noweb", int(num_str))
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     retval = 1
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 @
 \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 Chunk
 
 <<Look for anything with double angle brackets>>=
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
+
 if (not retval):
-\newline
+\begin_inset Newline newline
+\end_inset
+
   left = string.find(line, "<<")
-\newline
+\begin_inset Newline newline
+\end_inset
+
   if (left != -1) and ((left + 2) < len(line)) and 
 \backslash
 
-\newline
+\begin_inset Newline newline
+\end_inset
+
      (string.find(line[left+2:], ">>") != -1):
-\newline
+\begin_inset Newline newline
+\end_inset
+
     write_error(line, "noweb");
-\newline
+\begin_inset Newline newline
+\end_inset
+
     retval = 1;
-\newline
+\begin_inset Newline newline
+\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 Chunk
 
 <<Last ditch effort scan for specific strings>>=
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 if (not retval):
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   msgs_to_try = ("couldn't open file",
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     "couldn't open temporary file",
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     "error writing temporary file",
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     "ill-formed option",
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     "unknown option",
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     "Bad format sequence",
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     "Can't open output file",
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     "Can't open temporary file",
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     "Capacity exceeded:",
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     "Ignoring unknown option -",
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     "This can't happen:",
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     "non-numeric line number in")
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   for msg in msgs_to_try:
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     if string.find(line, msg) != -1:
-\newline
+\end_layout
+
+\begin_layout Chunk
+
       write_error(line, "noweb")
-\newline
+\end_layout
+
+\begin_layout Chunk
+
       retval = 1
-\newline
+\end_layout
+
+\begin_layout Chunk
+
       break
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 @
 \end_layout
 
 \begin_layout Subsection
-
 gcc errors
 \end_layout
 
 \begin_layout Standard
-
 The gcc errors can be multi-line, with the following format:
 \end_layout
 
 \begin_layout LyX-Code
-
 foo.c: In function `main': 
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 foo.c:3: `bar' undeclared (first use in this function) 
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 foo.c:3: (Each undeclared identifier is reported only once 
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
+
 foo.c:3: for each function it appears in.) 
-\newline
+\begin_inset Newline newline
+\end_inset
+
 foo.c:3: parse error before `x'
 \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 Chunk
 
 <<Function Bodies>>=
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 def gcc_try(line):
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   """See if line is a gcc error.
  Read ahead to handle all the lines.
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
 
-\newline
   Returns 1 on success, 0 otherwise.
  Outputs on stdout."""
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   retval = 0
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   <<Handle the gcc error message>>
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   return retval
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
 
-\newline
 @ %def gcc_try
 \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 Chunk
 
 <<Handle the gcc error message>>= 
-\newline
+\begin_inset Newline newline
+\end_inset
+
 first_space = string.find(line, ' ')
-\newline
+\begin_inset Newline newline
+\end_inset
+
 if first_space > 1: # The smallest would be "X: "
-\newline
+\begin_inset Newline newline
+\end_inset
+
   if line[first_space - 1] == ':':
-\newline
+\begin_inset Newline newline
+\end_inset
+
     header_to_see = line[:first_space - 1]
-\newline
+\begin_inset Newline newline
+\end_inset
+
     next_line = getline()
-\newline
+\begin_inset Newline newline
+\end_inset
+
     if next_line and next_line[:first_space - 1] == header_to_see:
-\newline
+\begin_inset Newline newline
+\end_inset
+
       num_end = first_space
-\newline
+\begin_inset Newline newline
+\end_inset
+
       while next_line[num_end] in string.digits: num_end = num_end + 1
-\newline
+\begin_inset Newline newline
+\end_inset
+
       if num_end > first_space: # good!
-\newline
+\begin_inset Newline newline
+\end_inset
+
         <<Accumulate gcc error lines and print it>>
-\newline
+\begin_inset Newline newline
+\end_inset
+
       else: # oops! Not a gcc error.
-\newline
+\begin_inset Newline newline
+\end_inset
+
         pushline(next_line)
-\newline
+\begin_inset Newline newline
+\end_inset
+
     elif next_line:
-\newline
+\begin_inset Newline newline
+\end_inset
+
       pushline(next_line) # return this line to input stream
-\newline
+\begin_inset Newline newline
+\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 Chunk
 
 <<Accumulate gcc error lines and print it>>=
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 num_str = next_line[first_space:num_end]
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 msgs = [line[first_space:]]
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 msgs.append(next_line[num_end + 1:])
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 header_to_see = next_line[:num_end]
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 next_line = getline()
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 while next_line and next_line[:num_end] == header_to_see:
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   msgs.append(next_line[num_end + 1:])
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   next_line = getline()
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 if next_line: pushline(next_line)
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 write_error(msgs, "gcc", int(num_str))
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 retval = 1
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 @
 \end_layout
 
 \begin_layout Subsection
-
 xlc errors
 \end_layout
 
 \begin_layout Standard
-
 A xlc error message is easy to identify.
  Every error message starts with a quoted string with no spaces, a comma,
  a space, the word 
@@ -845,56 +1319,115 @@ re
  
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
 
 <<Function Bodies>>=
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 def xlc_try(line):
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   """see if line is an xlc error.
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
 
-\newline
   Returns 1 on success, 0 otherwise.
  Outputs on stdout."""
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   retval = 0
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   if line[0] == '"': # This is the first character of all xlc errors
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     next_quote = string.find(line, '"', 1)
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     first_space = string.find(line, ' ')
-\newline
+\end_layout
+
+\begin_layout Chunk
+
     if (next_quote != -1) and (first_space > next_quote): # no space inisde
  quotes
-\newline
+\end_layout
+
+\begin_layout Chunk
+
       if line[first_space - 1:first_space + 6] == ", line ":
-\newline
+\end_layout
+
+\begin_layout Chunk
+
         num_start = num_end = first_space + 6
-\newline
+\end_layout
+
+\begin_layout Chunk
+
         while line[num_end] in string.digits: num_end = num_end + 1
-\newline
+\end_layout
+
+\begin_layout Chunk
+
         if num_end > num_start:
-\newline
+\end_layout
+
+\begin_layout Chunk
+
           write_error(line, "xlc", int(line[num_start : num_end]))
-\newline
+\end_layout
+
+\begin_layout Chunk
+
           retval = 1
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   return retval
-\newline
+\end_layout
+
+\begin_layout Chunk
+
   
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 @ %def xlc_try
 \end_layout
 
 \begin_layout Section
-
 Extracting the code
 \end_layout
 
 \begin_layout Standard
-
 This project can be tangled from LyX if you set your 
 \begin_inset Quotes eld
 \end_inset
@@ -903,7 +1436,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
@@ -912,54 +1445,70 @@ build-script
 \end_layout
 
 \begin_layout LyX-Code
-
 #!/bin/sh
-\newline
-notangle -Rbuild-script $1 | env NOWEB_SOURCE=$1 sh
 \end_layout
 
-\begin_layout Standard
+\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 Chunk
 
 <<build-script>>=
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 #!/bin/sh
-\newline
+\end_layout
+
+\begin_layout Chunk
+
 if [ -z "$NOWEB_SOURCE" ]; then NOWEB_SOURCE=listerrors.nw; fi
-\newline
-notangle -Rlisterrors ${NOWEB_SOURCE} > listerrors
-\newline
-chmod +x listerrors
-\newline
+\end_layout
+
+\begin_layout Chunk
+
+if [ -z "$NOWEB_OUTPUT_DIR" ]; then NOWEB_OUTPUT_DIR=.; fi
+\end_layout
+
+\begin_layout Chunk
+
+notangle -Rlisterrors ${NOWEB_SOURCE} > ${NOWEB_OUTPUT_DIR}/listerrors
+\end_layout
+
+\begin_layout Chunk
+
+chmod +x ${NOWEB_OUTPUT_DIR}/listerrors
+\end_layout
+
+\begin_layout Chunk
+
 @
 \end_layout
 
 \begin_layout Section
-
 Indices
 \end_layout
 
 \begin_layout Standard
-
 This section provides cross-references into the rest of the program.
 \end_layout
 
 \begin_layout Subsection
-
 Macros
 \end_layout
 
 \begin_layout Standard
-
-
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 
 \backslash
 nowebchunks
@@ -971,17 +1520,15 @@ nowebchunks
 \end_layout
 
 \begin_layout Subsection
-
 Identifiers
 \end_layout
 
 \begin_layout Standard
-
-
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 
 \backslash
 nowebindex