2019-03-22 00:13:23 +00:00
#LyX 2.4 created this file. For more info see https://www.lyx.org/
2022-12-25 17:48:19 +00:00
\lyxformat 614
2005-07-18 09:42:29 +00:00
\begin_document
\begin_header
2016-01-12 21:30:37 +00:00
\save_transient_properties true
2019-03-25 15:32:27 +00:00
\origin /systemlyxdir/examples/Modules/
2012-11-28 11:54:34 +00:00
\textclass article
2011-06-15 01:02:15 +00:00
\use_default_options false
2012-11-28 11:54:34 +00:00
\begin_modules
noweb
\end_modules
2020-12-29 17:03:05 +00:00
\maintain_unincluded_children no
2000-11-03 11:21:37 +00:00
\language english
2011-06-15 01:02:15 +00:00
\language_package default
2019-05-08 17:59:57 +00:00
\inputencoding utf8
2020-12-29 17:03:05 +00:00
\fontencoding auto
2019-03-22 00:13:23 +00:00
\font_roman "lmodern" "default"
2015-11-13 18:14:45 +00:00
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
2007-07-24 17:45:46 +00:00
\font_default_family default
2011-06-15 01:02:15 +00:00
\use_non_tex_fonts false
2007-07-24 17:45:46 +00:00
\font_sc false
2021-06-02 23:55:40 +00:00
\font_roman_osf false
2020-12-29 17:03:05 +00:00
\font_sans_osf false
\font_typewriter_osf false
2015-11-13 18:14:45 +00:00
\font_sf_scale 100 100
\font_tt_scale 100 100
2017-04-24 04:03:19 +00:00
\use_microtype false
\use_dash_ligatures false
1999-09-27 18:44:28 +00:00
\graphics default
2011-06-15 01:02:15 +00:00
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
1999-09-27 18:44:28 +00:00
\paperfontsize default
2003-01-17 13:50:11 +00:00
\spacing single
2008-10-01 20:26:35 +00:00
\use_hyperref false
2005-07-18 09:42:29 +00:00
\papersize default
\use_geometry false
2017-10-19 12:47:51 +00:00
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
2012-10-01 15:31:08 +00:00
\use_package mathdots 1
2017-10-19 12:47:51 +00:00
\use_package mathtools 1
2012-10-01 15:31:08 +00:00
\use_package mhchem 1
2017-10-19 12:47:51 +00:00
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
2005-07-18 09:42:29 +00:00
\cite_engine basic
2013-12-03 07:15:08 +00:00
\cite_engine_type default
2012-10-01 15:31:08 +00:00
\biblio_style plain
2005-07-18 09:42:29 +00:00
\use_bibtopic false
2011-06-15 01:02:15 +00:00
\use_indices false
1999-09-27 18:44:28 +00:00
\paperorientation portrait
2017-11-18 16:34:35 +00:00
\suppress_date true
2012-10-01 15:31:08 +00:00
\justification true
2011-06-15 01:02:15 +00:00
\use_refstyle 0
2017-11-18 16:20:12 +00:00
\use_minted 0
2020-12-29 17:03:05 +00:00
\use_lineno 0
2011-06-15 01:02:15 +00:00
\index Index
\shortcut idx
\color #008000
\end_index
1999-09-27 18:44:28 +00:00
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
2011-06-15 01:02:15 +00:00
\paragraph_indentation default
2017-04-24 04:03:19 +00:00
\is_math_indent 0
2017-08-14 06:31:24 +00:00
\math_numbering_side default
2017-04-24 04:03:19 +00:00
\quotes_style english
2017-11-18 16:20:12 +00:00
\dynamic_quotes 0
1999-09-27 18:44:28 +00:00
\papercolumns 1
\papersides 1
\paperpagestyle default
2021-06-02 23:55:40 +00:00
\tablestyle default
2005-07-18 09:42:29 +00:00
\tracking_changes false
2007-07-24 17:45:46 +00:00
\output_changes false
2021-06-02 23:55:40 +00:00
\change_bars false
\postpone_fragile_content false
2011-06-15 01:02:15 +00:00
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
2021-06-02 23:55:40 +00:00
\docbook_table_output 0
\docbook_mathml_prefix 1
2005-07-18 09:42:29 +00:00
\end_header
1999-09-27 18:44:28 +00:00
2005-07-18 09:42:29 +00:00
\begin_body
\begin_layout Title
2016-01-13 01:51:42 +00:00
\SpecialChar LyX
2015-11-13 18:14:45 +00:00
and Literate Programming
2008-10-01 20:26:35 +00:00
\begin_inset Newline newline
\end_inset
1999-09-27 18:44:28 +00:00
An example program
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Author
1999-09-27 18:44:28 +00:00
Edmar Wienskoski Jr.
2008-10-01 20:26:35 +00:00
\begin_inset Newline newline
\end_inset
1999-09-27 18:44:28 +00:00
edmar-w-jr@technologist.com
2002-03-13 13:25:45 +00:00
\begin_inset Foot
2005-07-18 09:42:29 +00:00
status collapsed
2002-03-13 13:25:45 +00:00
2008-10-01 20:26:35 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
Modified by Bernard Michael Hurley bernardh@westherts.ac.uk —
- Don't blame Edmar for any errors that have crept in!
2005-07-18 09:42:29 +00:00
\end_layout
\end_inset
2002-03-13 13:25:45 +00:00
2005-07-18 09:42:29 +00:00
\end_layout
2016-08-09 03:43:15 +00:00
\begin_layout Abstract
\series bold
Note:
2022-12-11 16:12:05 +00:00
2016-08-09 03:43:15 +00:00
\series default
This example program is provided for educational use only.
2022-12-11 16:12:05 +00:00
The functionality in this C program has been superceded by the equivalent Python code in
2016-08-09 03:43:15 +00:00
\emph on
2021-06-04 08:51:48 +00:00
scripts/listerrors
2016-08-09 03:43:15 +00:00
\emph default
which should be installed in the \SpecialChar LyX
scripts directory.
\end_layout
2005-07-18 09:42:29 +00:00
\begin_layout Standard
2008-10-01 20:26:35 +00:00
\begin_inset CommandInset toc
LatexCommand tableofcontents
1999-09-27 18:44:28 +00:00
2005-07-18 09:42:29 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
2005-07-18 09:42:29 +00:00
\end_layout
1999-09-27 18:44:28 +00:00
2005-07-18 09:42:29 +00:00
\begin_layout Section
1999-09-27 18:44:28 +00:00
Introduction
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Standard
2022-12-11 16:12:05 +00:00
After typesetting a document,
\SpecialChar LyX
2016-01-13 01:51:42 +00:00
scans the \SpecialChar LaTeX
2015-11-13 18:14:45 +00:00
log file looking for errors.
2022-12-11 16:12:05 +00:00
For each error found,
the line number is obtained and a error box is displayed in the \SpecialChar LyX
2015-11-13 18:14:45 +00:00
screen at that position.
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Standard
2022-12-11 16:12:05 +00:00
To use this feature to view compilation errors while working with literate documents,
we need a program that filters the compilation errors and puts them in a format suitable for \SpecialChar LyX
2015-11-13 18:14:45 +00:00
reading it.
1999-09-27 18:44:28 +00:00
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Standard
2022-12-11 16:12:05 +00:00
In this document we present a filter that recognizes compilation error messages from noweb,
gnu C,
and the IBM C compiler (xlc).
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Standard
2022-12-11 16:12:05 +00:00
The filter is required to read from standard input,
parse for error messages and copy the error messages to the standard output.
During the output process,
the filter must present the error messages in a format that \SpecialChar LyX
can interpret,
currently,
the \SpecialChar LaTeX
2015-11-13 18:14:45 +00:00
error message format.
2022-12-11 16:12:05 +00:00
Of course,
nothing will prevent future \SpecialChar LyX
releases from being able to read other formats as well (like gcc error messages for example).
This mechanism is necessary to fully explore the literate programming tool's capabilities.
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Section
1999-09-27 18:44:28 +00:00
Algorithm
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Standard
\begin_inset Flex Chunk
status open
\begin_layout Plain Layout
\begin_inset Argument 1
status open
\begin_layout Plain Layout
2017-11-18 16:20:12 +00:00
2013-12-03 07:15:08 +00:00
Function bodies
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
int
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
main (int argc,
char **argv)
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
{
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
if (argc == 2) {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
switch (argv[1][0]) {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
case 'n':
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
<<Scan input for noweb error messages>>
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
break;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
case 'x':
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
<<Scan input for xlc error messages>>
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
break;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
case 'a':
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
<<AIX system using both noweb and xlc>>
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
break;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
case 's':
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
case 'b':
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
<<Solaris and Linux systems using both noweb and gcc>>
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
break;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
case 'g':
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
default:
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
<<Scan input for gcc error messages>>
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
break;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
} else {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
<<Scan input for gcc error messages>>
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Standard
\begin_inset Flex Chunk
status open
\begin_layout Plain Layout
\begin_inset Argument 1
status open
\begin_layout Plain Layout
2017-11-18 16:20:12 +00:00
2013-12-03 07:15:08 +00:00
Function prototypes
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2022-12-11 16:12:05 +00:00
int main (int argc,
char **argv);
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Section
1999-09-27 18:44:28 +00:00
Data Structures
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Standard
2022-12-11 16:12:05 +00:00
We resort to some global variables to allow access from several different routines.
These are the buffer and related pointers used during the parse of the input.
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
<<Global variables>>=
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
char buffer[200][200];
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-12 13:24:24 +00:00
int last_buf_line;
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-12 13:24:24 +00:00
int last_err_line;
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2021-06-03 00:03:48 +00:00
int err_line;
\end_layout
\begin_layout Plain Layout
@
2013-12-03 07:15:08 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
\end_inset
2013-12-03 07:15:08 +00:00
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Section
1999-09-27 18:44:28 +00:00
The output format
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Standard
2016-01-13 01:51:42 +00:00
The output format mimics the \SpecialChar TeX
2015-11-13 18:14:45 +00:00
error messages format.
2022-12-11 16:12:05 +00:00
This function prints a number of lines residing in the global variable
2005-07-18 09:42:29 +00:00
\family typewriter
1999-09-27 18:44:28 +00:00
buffer
2005-07-18 09:42:29 +00:00
\family default
2022-12-11 16:12:05 +00:00
,
a program name and line number.
There is no special requirement on the input strings,
they can be anything.
2002-03-13 13:25:45 +00:00
\begin_inset Foot
2005-07-18 09:42:29 +00:00
status collapsed
2002-03-13 13:25:45 +00:00
2008-10-01 20:26:35 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
This function has been slightly changed from EW's original to make scanning a bit easier with \SpecialChar LaTeX
2015-11-13 18:14:45 +00:00
::scanLogFile().
2016-01-13 01:51:42 +00:00
The test has been added because \SpecialChar LyX
2022-12-11 16:12:05 +00:00
can crash if empty lines are allowed here —
I can't figure out why!
—
BMH
2005-07-18 09:42:29 +00:00
\end_layout
\end_inset
2002-03-13 13:25:45 +00:00
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Standard
\begin_inset Flex Chunk
status open
\begin_layout Plain Layout
\begin_inset Argument 1
status open
\begin_layout Plain Layout
2017-11-18 16:20:12 +00:00
2013-12-03 07:15:08 +00:00
Function bodies
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
void
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
output_error (int buf_size,
int error_line,
char *tool)
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
{
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
int i;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
fprintf(stdout,
"!
Build Error:
==> %s ==>
2005-07-18 09:42:29 +00:00
\backslash
2022-12-11 16:12:05 +00:00
n",
tool);
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
fprintf(stdout,
" ...
2005-07-18 09:42:29 +00:00
\backslash
1999-09-27 18:44:28 +00:00
n
2005-07-18 09:42:29 +00:00
\backslash
1999-09-27 18:44:28 +00:00
nl.%d ...
2005-07-18 09:42:29 +00:00
\backslash
2022-12-11 16:12:05 +00:00
n",
error_line);
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
for (i=0;
i<buf_size;
i++)
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
if (strlen(buffer[i]) != 0)
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
fprintf(stdout,
"%s",
buffer[i]);
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
fprintf(stdout,
"
2005-07-18 09:42:29 +00:00
\backslash
2000-07-12 13:24:24 +00:00
n");
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Standard
\begin_inset Flex Chunk
status open
\begin_layout Plain Layout
\begin_inset Argument 1
status open
\begin_layout Plain Layout
2017-11-18 16:20:12 +00:00
2013-12-03 07:15:08 +00:00
Function prototypes
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2022-12-11 16:12:05 +00:00
void output_error (int buf_size,
int error_line,
char *tool);
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Section
1999-09-27 18:44:28 +00:00
Functions Implementation
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Standard
2022-12-11 16:12:05 +00:00
Both noweave and notangle routines,
always output one single line for each error found,
thus to scan the buffer for noweb error messages is enough to exam one input line at a time.
Note that the noweb software does not provide a line error number,
so all errors boxes related to noweb messages will be displayed at the beginning of the file.
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Standard
\begin_inset Flex Chunk
status open
\begin_layout Plain Layout
\begin_inset Argument 1
status open
\begin_layout Plain Layout
2017-11-18 16:20:12 +00:00
2013-12-03 07:15:08 +00:00
Scan input for noweb error messages
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
{
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
last_buf_line = 0;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
while (fgets(buffer[0],
200,
stdin)) {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
if (noweb_try(0))
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
output_error(1,
err_line,
"noweb");
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Standard
1999-09-27 18:44:28 +00:00
The examination itself is very inefficient.
2022-12-11 16:12:05 +00:00
Unfortunately noweb doesn't have any characteristic that would help to identify one of its error messages.
The solution is to collect all possible output messages in an array of strings,
and turn the examination process into a linear search in this array.
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Standard
\begin_inset Flex Chunk
status open
\begin_layout Plain Layout
2011-06-15 01:02:15 +00:00
2021-06-03 00:03:48 +00:00
\begin_inset Argument 1
status open
2011-06-15 01:02:15 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2021-06-03 00:03:48 +00:00
Global variables
\end_layout
\end_inset
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
char *noweb_msgs[] = {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
"couldn't open file",
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
"couldn't open temporary file",
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
"error writing temporary file",
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
"ill-formed option",
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
"unknown option",
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
"Bad format sequence",
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
"Can't open output file",
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
"Can't open temporary file",
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
"Capacity exceeded:",
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
"Ignoring unknown option -",
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
"This can't happen:",
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-13 09:38:34 +00:00
"non-numeric line number in"
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-13 09:38:34 +00:00
};
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2011-06-15 01:02:15 +00:00
\end_layout
2000-07-13 09:38:34 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-13 09:38:34 +00:00
char *noweb_msgs_mimic_gcc[] = {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
":
unescaped << in documentation chunk"
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
};
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Standard
2022-12-11 16:12:05 +00:00
A noweb error message can be any string that contains a matching pair of < <
2008-10-01 20:26:35 +00:00
\begin_inset space ~
\end_inset
\begin_inset space ~
\end_inset
\begin_inset space ~
\end_inset
2022-12-11 16:12:05 +00:00
> >,
or any of the above strings
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Standard
\begin_inset ERT
status open
2011-06-15 01:02:15 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2011-06-15 01:02:15 +00:00
1999-09-27 18:44:28 +00:00
<<Function bodies>>=
2013-12-03 07:15:08 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
int noweb_try (int buf_line)
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
1999-09-27 18:44:28 +00:00
{
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2022-12-11 16:12:05 +00:00
char *s,
*t,
*b;
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2022-12-11 16:12:05 +00:00
int i;
2013-12-03 07:15:08 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2000-07-13 09:38:34 +00:00
2000-07-12 13:24:24 +00:00
b = buffer[buf_line];
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-13 09:38:34 +00:00
err_line = 0;
2013-12-03 07:15:08 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2000-07-13 09:38:34 +00:00
2022-12-11 16:12:05 +00:00
for (i=0;
i<1;
i++) {
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2022-12-11 16:12:05 +00:00
s = (char *)strstr (b,
noweb_msgs_mimic_gcc[i]);
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-13 09:38:34 +00:00
if (s != NULL) {
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2022-12-11 16:12:05 +00:00
t = (char *)strchr(buffer[buf_line],
':');
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-13 09:38:34 +00:00
err_line = atoi(t+1);
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-13 09:38:34 +00:00
t = buffer[buf_line];
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-13 09:38:34 +00:00
++s;
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-13 09:38:34 +00:00
while (*(t++) = *(s++));
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-13 09:38:34 +00:00
return 1;
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-13 09:38:34 +00:00
}
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-13 09:38:34 +00:00
}
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2022-12-11 16:12:05 +00:00
s = (char *)strstr(b,
"<<");
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-12 13:24:24 +00:00
if (s != NULL) {
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2022-12-11 16:12:05 +00:00
s = (char *)strstr(s+2,
">>");
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
if (s != NULL) {
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-12 13:24:24 +00:00
return 1;
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-13 09:38:34 +00:00
}
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-13 09:38:34 +00:00
} else {
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2022-12-11 16:12:05 +00:00
for (i = 0;
i < 12;
++i) {
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2022-12-11 16:12:05 +00:00
s = (char *)strstr (b,
noweb_msgs[i]);
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-13 09:38:34 +00:00
if (s != NULL) {
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-13 09:38:34 +00:00
return 1;
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-13 09:38:34 +00:00
}
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-13 09:38:34 +00:00
}
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-12 13:24:24 +00:00
}
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2000-07-12 13:24:24 +00:00
return 0;
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
1999-09-27 18:44:28 +00:00
}
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
1999-09-27 18:44:28 +00:00
@
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\end_inset
\end_layout
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
<<Function prototypes>>=
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
int noweb_try (int buf_line);
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
@
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\end_inset
\end_layout
2005-07-18 09:42:29 +00:00
\begin_layout Standard
2022-12-11 16:12:05 +00:00
The xlc compiler always outputs one single line for each error found,
thus to scan the buffer for xlc error messages it is enough to exam one input line at a time.
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Standard
\begin_inset Flex Chunk
status open
\begin_layout Plain Layout
\begin_inset Argument 1
status open
\begin_layout Plain Layout
2017-11-18 16:20:12 +00:00
2013-12-03 07:15:08 +00:00
Scan input for xlc error messages
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
{
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
last_buf_line = 0;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
while (fgets(buffer[last_buf_line],
200,
stdin)) {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
if (xlc_try(0))
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
output_error(1,
err_line,
"xlc");
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Standard
1999-09-27 18:44:28 +00:00
A xlc error message is easy to identify.
2022-12-11 16:12:05 +00:00
Every error message starts with a quoted string with no spaces,
a comma,
a space,
the word
1999-09-27 18:44:28 +00:00
\begin_inset Quotes eld
2005-07-18 09:42:29 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
line
\begin_inset Quotes erd
2005-07-18 09:42:29 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
2022-12-11 16:12:05 +00:00
,
a space,
and some variable text.
1999-09-27 18:44:28 +00:00
The following routine tests if a given buffer line matches this criteria:
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Standard
\begin_inset Flex Chunk
status open
\begin_layout Plain Layout
2011-06-15 01:02:15 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2011-06-15 01:02:15 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2021-06-03 00:03:48 +00:00
\begin_inset Argument 1
status open
\begin_layout Plain Layout
Function bodies
\end_layout
\end_inset
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
int
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
xlc_try (int buf_line)
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
{
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
char *s,
*t;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
t = buffer[buf_line];
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
s = t+1;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
while (*s != '"' && *s != ' ' && *s != '
2005-07-18 09:42:29 +00:00
\backslash
1999-09-27 18:44:28 +00:00
0')
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
s++;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
if (*t != '"' || *s != '"' || strncmp(s+1,
",
line ",
7) != 0)
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
return 0;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
s += 8;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
err_line = atoi(s);
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
return 1;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Standard
\begin_inset Flex Chunk
status open
\begin_layout Plain Layout
\begin_inset Argument 1
status open
\begin_layout Plain Layout
2017-11-18 16:20:12 +00:00
2013-12-03 07:15:08 +00:00
Function prototypes
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
int xlc_try (int buf_line);
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Standard
1999-09-27 18:44:28 +00:00
The gcc compiler error messages are more complicated to scan.
Each error can span more than one line in the buffer.
The good news is that every buffer line on each error has the same pattern,
and share the same line number.
2022-12-11 16:12:05 +00:00
Thus the strategy will be to accumulate lines in the buffer while the reported line number is still the same.
At the time they differ,
all the accumulated lines,
except the last one,
will belong to one single error message,
which now can be output-ed to \SpecialChar LyX
2015-11-13 18:14:45 +00:00
.
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Standard
1999-09-27 18:44:28 +00:00
Every gcc error message contains a string with no space followed by a
\begin_inset Quotes eld
2005-07-18 09:42:29 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
:
\begin_inset Quotes eld
2005-07-18 09:42:29 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
.
2022-12-11 16:12:05 +00:00
If the next character is a space,
then this line is a header of a error message and the next line will detail the line number of the source code where the error was found.
Otherwise,
the next thing is a integer number followed by another
1999-09-27 18:44:28 +00:00
\begin_inset Quotes eld
2005-07-18 09:42:29 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
:
\begin_inset Quotes eld
2005-07-18 09:42:29 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
.
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Standard
\begin_inset Flex Chunk
status open
\begin_layout Plain Layout
\begin_inset Argument 1
status open
\begin_layout Plain Layout
2017-11-18 16:20:12 +00:00
2013-12-03 07:15:08 +00:00
Scan input for gcc error messages
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
{
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
char *s,
*t;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
last_buf_line = 0;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
while (fgets(buffer[last_buf_line],
200,
stdin)) {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
/****** Skip lines until I find an error */
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
s = (char *)strpbrk(buffer[last_buf_line],
" :");
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
if (s == NULL || *s == ' ')
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
continue;
/* No gcc error found here */
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
do {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
<<gcc error message criteria is to find a "...:999:" or a "...:
">>
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
/****** OK It is an error message,
get line number */
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
err_line = atoi(s+1);
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
if (last_err_line == 0 || last_err_line == err_line) {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
last_err_line = err_line;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
continue;
/* It's either a header or a continuation,
don't output yet */
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
/****** Completed the scan of one error message,
output it to LyX */
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
discharge_buffer(1);
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
break;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
} while (fgets(buffer[last_buf_line],
200,
stdin));
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
/****** EOF completes the scan of whatever was being scanned */
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
discharge_buffer(0);
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Standard
\begin_inset Flex Chunk
status open
\begin_layout Plain Layout
\begin_inset Argument 1
status open
\begin_layout Plain Layout
2017-11-18 16:20:12 +00:00
2022-12-11 16:12:05 +00:00
gcc error message criteria is to find a "...:999:" or a "...:
"
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
/****** Search first ":" in the error number */
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
s = (char *)strpbrk(buffer[last_buf_line],
" :");
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
last_buf_line++;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
if (s == NULL || *s == ' ')
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
<<No gcc error found here,
but it might terminate the scanning of a previous one>>
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
/****** Search second ":" in the error number */
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2022-12-11 16:12:05 +00:00
t = (char *)strpbrk(s+1,
" :");if (t == NULL || *t == ' ') <<No gcc error found here,
but it might terminate the scanning of a previous one>>/****** Verify if is all digits between ":" */if (t != s+1+strspn(s+1,
"0123456789")) <<No gcc error found here,
but it might terminate the scanning of a previous one>>@
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2011-06-15 01:02:15 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2011-06-15 01:02:15 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
<<No gcc error found here,
but it might terminate the scanning of a previous one>>=
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
{
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
err_line = 0;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
discharge_buffer(1);
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
continue;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Standard
2022-12-11 16:12:05 +00:00
As we mentioned,
when the scan of one gcc error message is completed everything in the buffer except the last line is one single error message.
But if the scan terminates with a EOF or through finding one line that does not match the gcc error message criteria,
then there is no
1999-09-27 18:44:28 +00:00
\begin_inset Quotes eld
2005-07-18 09:42:29 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
last line
\begin_inset Quotes erd
2005-07-18 09:42:29 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
in the buffer to be concerned with.
In those cases we empty the buffer completely.
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Standard
\begin_inset Flex Chunk
status open
\begin_layout Plain Layout
2011-06-15 01:02:15 +00:00
2021-06-03 00:03:48 +00:00
\begin_inset Argument 1
status open
2011-06-15 01:02:15 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2011-06-15 01:02:15 +00:00
2021-06-03 00:03:48 +00:00
Function bodies
2011-06-15 01:02:15 +00:00
\end_layout
2021-06-03 00:03:48 +00:00
\end_inset
2013-12-03 07:15:08 +00:00
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
void
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
discharge_buffer (int save_last)
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
{
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
if (last_err_line != 0) {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
clean_gcc_messages();
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
if (save_last != 0) {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
output_error(last_buf_line-1,
last_err_line,
"gcc");
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
strcpy (buffer[0],
buffer[last_buf_line-1]);
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
last_err_line = err_line;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
last_buf_line = 1;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
} else {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
++last_buf_line;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
clean_gcc_messages();
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
output_error(last_buf_line-1,
last_err_line,
"gcc");
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
last_err_line = 0;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
last_buf_line = 0;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
}
\end_layout
\begin_layout Plain Layout
}
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Flex Chunk
status open
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_inset Argument 1
status open
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2017-11-18 16:20:12 +00:00
2013-12-03 07:15:08 +00:00
Function prototypes
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\end_inset
2008-10-01 20:26:35 +00:00
2000-07-12 13:24:24 +00:00
void discharge_buffer (int save_last);
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Standard
2000-07-12 13:24:24 +00:00
The next function
\begin_inset Quotes eld
2005-07-18 09:42:29 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
2000-07-12 13:24:24 +00:00
cleans
\begin_inset Quotes erd
2005-07-18 09:42:29 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
2022-12-11 16:12:05 +00:00
superfluous information from gcc messages,
namely the name of the noweb file and the line number of the Error.
2002-03-13 13:25:45 +00:00
\begin_inset Foot
2005-07-18 09:42:29 +00:00
status collapsed
2002-03-13 13:25:45 +00:00
2008-10-01 20:26:35 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
More could be done.
2022-12-11 16:12:05 +00:00
For instance,
some way of distinguishing between gcc Errors and Warnings should be devised.
2005-07-18 09:42:29 +00:00
\end_layout
2002-03-13 13:25:45 +00:00
2005-07-18 09:42:29 +00:00
\end_inset
2002-03-13 13:25:45 +00:00
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Standard
\begin_inset Flex Chunk
status open
\begin_layout Plain Layout
\begin_inset Argument 1
status open
\begin_layout Plain Layout
2017-11-18 16:20:12 +00:00
2013-12-03 07:15:08 +00:00
Function bodies
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2000-07-12 13:24:24 +00:00
void
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
clean_gcc_messages ()
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
{
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
int index;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
char search [30];
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
char *tail,
*head;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
int search_len = sprintf(search,
".nw:%d:",
last_err_line);
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
for (index = 0;
index < last_buf_line-1;
index++) {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
tail = (char *)strstr (buffer[index],
search);
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
if ( tail == NULL) {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
tail = (char *) strstr (buffer[index],
".nw:");
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
if (tail) {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
tail += 4;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
} else {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
tail += search_len;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
if (tail != NULL) {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
head = buffer[index];
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
while (*(head++) = *(tail++));
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Standard
\begin_inset Flex Chunk
status open
\begin_layout Plain Layout
\begin_inset Argument 1
status open
\begin_layout Plain Layout
2017-11-18 16:20:12 +00:00
2013-12-03 07:15:08 +00:00
Function prototypes
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2000-07-12 13:24:24 +00:00
void clean_gcc_messages ();
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Standard
2022-12-11 16:12:05 +00:00
To combine the scan of noweb error messages and xlc error messages is very simple.
1999-09-27 18:44:28 +00:00
We just try each one for every input line:
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
<<AIX system using both noweb and xlc>>=
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
{
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
last_buf_line = 0;
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2022-12-11 16:12:05 +00:00
while (fgets(buffer[0],
200,
stdin)) {
2013-12-03 07:15:08 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
if (noweb_try(0))
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
2022-12-11 16:12:05 +00:00
output_error(1,
err_line,
"noweb");
2013-12-03 07:15:08 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
else if (xlc_try(0))
\end_layout
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
output_error(1,
err_line,
"xlc");
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
}
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
1999-09-27 18:44:28 +00:00
}
2013-12-03 07:15:08 +00:00
\end_layout
\begin_layout Plain Layout
2008-10-01 20:26:35 +00:00
1999-09-27 18:44:28 +00:00
@
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\end_inset
\end_layout
2005-07-18 09:42:29 +00:00
\begin_layout Standard
2022-12-11 16:12:05 +00:00
To combine the scan of noweb error messages and gcc error messages is simple if we realize that it is not possible to find a noweb error message in the middle of a gcc error message.
So we just repeat the gcc procedure and test for noweb error messages in the beginning of the scan:
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Standard
\begin_inset Flex Chunk
status open
\begin_layout Plain Layout
\begin_inset Argument 1
status open
\begin_layout Plain Layout
2017-11-18 16:20:12 +00:00
2013-12-03 07:15:08 +00:00
Solaris and Linux systems using both noweb and gcc
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
{
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
char *s,
*t;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
last_buf_line = 0;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
while (fgets(buffer[last_buf_line],
200,
stdin)) {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
/****** Skip lines until I find an error */
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
if (last_buf_line == 0 && noweb_try(0)) {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
output_error(1,
err_line,
"noweb");
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
continue;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
s = (char *)strpbrk(buffer[last_buf_line],
" :");
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
if (s == NULL || *s == ' ')
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
continue;
/* No gcc error found here */
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
do {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
<<gcc error message criteria is to find a "...:999:" or a "...:
">>
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
/****** OK It is an error,
get line number */
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
err_line = atoi(s+1);
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
if (last_err_line == 0 || last_err_line == err_line) {
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
last_err_line = err_line;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
continue;
/* It's either a header or a continuation,
don't output yet */
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
/****** Completed the scan of one error message,
output it to LyX */
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
discharge_buffer(1);
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
break;
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
} while (fgets(buffer[last_buf_line],
200,
stdin));
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
/****** EOF completes the scan of whatever was being scanned */
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
discharge_buffer(0);
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
}
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Section
1999-09-27 18:44:28 +00:00
Wrapping the code into a file
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Standard
\begin_inset Flex Chunk
status open
\begin_layout Plain Layout
\begin_inset Argument 1
status open
\begin_layout Plain Layout
2017-11-18 16:20:12 +00:00
2013-12-03 07:15:08 +00:00
listerrors.c
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
#include <stdio.h>
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
#include <strings.h>
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2000-07-12 13:24:24 +00:00
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
<<Global variables>>
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
<<Function prototypes>>
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
<<Function bodies>>
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Standard
2022-12-11 16:12:05 +00:00
To build this program,
we want to add the
1999-09-27 18:44:28 +00:00
\begin_inset Quotes eld
2005-07-18 09:42:29 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
-L
\begin_inset Quotes erd
2005-07-18 09:42:29 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
2008-10-01 20:26:35 +00:00
option in the tangle command to force gdb to load the file
2005-07-18 09:42:29 +00:00
\family typewriter
1999-09-27 18:44:28 +00:00
Literate.nw
2005-07-18 09:42:29 +00:00
\family default
2008-10-01 20:26:35 +00:00
instead of
2005-07-18 09:42:29 +00:00
\family typewriter
1999-09-27 18:44:28 +00:00
listerrors.c
2005-07-18 09:42:29 +00:00
\family default
1999-09-27 18:44:28 +00:00
.
2022-12-11 16:12:05 +00:00
In accordance with this,
we pass the
1999-09-27 18:44:28 +00:00
\begin_inset Quotes eld
2005-07-18 09:42:29 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
-g
\begin_inset Quotes erd
2005-07-18 09:42:29 +00:00
\end_inset
1999-09-27 18:44:28 +00:00
option to gcc.
2005-07-18 09:42:29 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Standard
\begin_inset Flex Chunk
status open
\begin_layout Plain Layout
\begin_inset Argument 1
status open
\begin_layout Plain Layout
2017-11-18 16:20:12 +00:00
2013-12-03 07:15:08 +00:00
build-script
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2002-03-13 13:25:45 +00:00
#!/bin/sh
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
if [ -z "$NOWEB_SOURCE" ];
then NOWEB_SOURCE=Literate.nw;
fi
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2022-12-11 16:12:05 +00:00
if [ -z "$NOWEB_OUTPUT_DIR" ];
then NOWEB_OUTPUT_DIR=.;
fi
2012-10-01 15:31:08 +00:00
\end_layout
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
2012-10-01 15:31:08 +00:00
notangle -L -Rlisterrors.c ${NOWEB_SOURCE} > ${NOWEB_OUTPUT_DIR}/listerrors.c
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\begin_layout Plain Layout
1999-09-27 18:44:28 +00:00
gcc -g -o listerrors listerrors.c
2011-06-15 01:02:15 +00:00
\end_layout
2008-10-01 20:26:35 +00:00
2013-12-03 07:15:08 +00:00
\end_inset
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout Standard
2016-01-13 01:51:42 +00:00
This project can be tangled and compiled from \SpecialChar LyX
2015-11-13 18:14:45 +00:00
if you set
2005-07-18 09:42:29 +00:00
\family typewriter
1999-09-27 18:44:28 +00:00
2005-07-18 09:42:29 +00:00
\backslash
1999-09-27 18:44:28 +00:00
build_command
2005-07-18 09:42:29 +00:00
\family default
2012-11-28 11:54:34 +00:00
to call a generic script that always extracts a chunk named
2005-07-18 09:42:29 +00:00
\family typewriter
1999-09-27 18:44:28 +00:00
build-script
2005-07-18 09:42:29 +00:00
\family default
1999-09-27 18:44:28 +00:00
and executes it.
Here is a example of such generic script:
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout LyX-Code
1999-09-27 18:44:28 +00:00
#!/bin/sh
2008-10-01 20:26:35 +00:00
\begin_inset Newline newline
\end_inset
2012-10-01 15:31:08 +00:00
notangle -Rbuild-script $1 | env NOWEB_SOURCE=$1 NOWEB_OUTPUT_DIR=$r sh
2005-07-18 09:42:29 +00:00
\end_layout
\begin_layout LyX-Code
\end_layout
2000-07-13 09:38:34 +00:00
2005-07-18 09:42:29 +00:00
\end_body
\end_document