1 #LyX 2.4 created this file. For more info see https://www.lyx.org/
5 \save_transient_properties true
6 \origin /systemlyxdir/examples/Modules/
8 \use_default_options false
12 \maintain_unincluded_children no
14 \language_package default
17 \font_roman "lmodern" "default"
18 \font_sans "default" "default"
19 \font_typewriter "default" "default"
20 \font_math "auto" "auto"
21 \font_default_family default
22 \use_non_tex_fonts false
25 \font_typewriter_osf false
27 \font_sf_scale 100 100
28 \font_tt_scale 100 100
30 \use_dash_ligatures false
32 \default_output_format default
34 \bibtex_command default
35 \index_command default
36 \paperfontsize default
41 \use_package amsmath 1
42 \use_package amssymb 1
45 \use_package mathdots 1
46 \use_package mathtools 1
48 \use_package stackrel 1
49 \use_package stmaryrd 1
50 \use_package undertilde 1
52 \cite_engine_type default
56 \paperorientation portrait
68 \paragraph_separation indent
69 \paragraph_indentation default
71 \math_numbering_side default
76 \paperpagestyle default
77 \tracking_changes false
78 \postpone_fragile_content false
89 and Literate Programming
90 \begin_inset Newline newline
98 \begin_inset Newline newline
101 edmar-w-jr@technologist.com
105 \begin_layout Plain Layout
106 Modified by Bernard Michael Hurley bernardh@westherts.ac.uk —- Don't blame
107 Edmar for any errors that have crept in!
115 \begin_layout Abstract
120 This example program is provided for educational use only.
121 The functionality in this C program has been superceded by the equivalent
124 examples/listerrors.lyx
126 which should be installed in the \SpecialChar LyX
130 \begin_layout Standard
131 \begin_inset CommandInset toc
132 LatexCommand tableofcontents
139 \begin_layout Section
143 \begin_layout Standard
144 After typesetting a document, \SpecialChar LyX
145 scans the \SpecialChar LaTeX
146 log file looking for errors.
147 For each error found, the line number is obtained and a error box is displayed
148 in the \SpecialChar LyX
149 screen at that position.
152 \begin_layout Standard
153 To use this feature to view compilation errors while working with literate
154 documents, we need a program that filters the compilation errors and puts
155 them in a format suitable for \SpecialChar LyX
160 \begin_layout Standard
161 In this document we present a filter that recognizes compilation error messages
162 from noweb, gnu C, and the IBM C compiler (xlc).
165 \begin_layout Standard
166 The filter is required to read from standard input, parse for error messages
167 and copy the error messages to the standard output.
168 During the output process, the filter must present the error messages in
169 a format that \SpecialChar LyX
170 can interpret, currently, the \SpecialChar LaTeX
171 error message format.
172 Of course, nothing will prevent future \SpecialChar LyX
173 releases from being able to read
174 other formats as well (like gcc error messages for example).
175 This mechanism is necessary to fully explore the literate programming tool's
179 \begin_layout Section
183 \begin_layout Standard
184 \begin_inset Flex Chunk
187 \begin_layout Plain Layout
189 \begin_inset Argument 1
192 \begin_layout Plain Layout
202 \begin_layout Plain Layout
204 main (int argc, char **argv)
207 \begin_layout Plain Layout
212 \begin_layout Plain Layout
217 \begin_layout Plain Layout
219 switch (argv[1][0]) {
222 \begin_layout Plain Layout
227 \begin_layout Plain Layout
229 <<Scan input for noweb error messages>>
232 \begin_layout Plain Layout
237 \begin_layout Plain Layout
242 \begin_layout Plain Layout
244 <<Scan input for xlc error messages>>
247 \begin_layout Plain Layout
252 \begin_layout Plain Layout
257 \begin_layout Plain Layout
259 <<AIX system using both noweb and xlc>>
262 \begin_layout Plain Layout
267 \begin_layout Plain Layout
272 \begin_layout Plain Layout
277 \begin_layout Plain Layout
279 <<Solaris and Linux systems using both noweb and gcc>>
282 \begin_layout Plain Layout
287 \begin_layout Plain Layout
292 \begin_layout Plain Layout
297 \begin_layout Plain Layout
299 <<Scan input for gcc error messages>>
302 \begin_layout Plain Layout
307 \begin_layout Plain Layout
312 \begin_layout Plain Layout
317 \begin_layout Plain Layout
319 <<Scan input for gcc error messages>>
322 \begin_layout Plain Layout
327 \begin_layout Plain Layout
337 \begin_layout Standard
338 \begin_inset Flex Chunk
341 \begin_layout Plain Layout
343 \begin_inset Argument 1
346 \begin_layout Plain Layout
353 int main (int argc, char **argv);
361 \begin_layout Section
365 \begin_layout Standard
366 We resort to some global variables to allow access from several different
368 These are the buffer and related pointers used during the parse of the
372 \begin_layout Standard
376 \begin_layout Plain Layout
378 <<Global variables>>=
381 \begin_layout Plain Layout
383 char buffer[200][200];
386 \begin_layout Plain Layout
391 \begin_layout Plain Layout
396 \begin_layout Plain Layout
406 \begin_layout Section
410 \begin_layout Standard
411 The output format mimics the \SpecialChar TeX
412 error messages format.
413 This function prints a number of lines residing in the global variable
418 , a program name and line number.
419 There is no special requirement on the input strings, they can be anything.
423 \begin_layout Plain Layout
424 This function has been slightly changed from EW's original to make scanning
425 a bit easier with \SpecialChar LaTeX
427 The test has been added because \SpecialChar LyX
428 can crash if empty lines are allowed here
429 — I can't figure out why! — BMH
437 \begin_layout Standard
438 \begin_inset Flex Chunk
441 \begin_layout Plain Layout
443 \begin_inset Argument 1
446 \begin_layout Plain Layout
456 \begin_layout Plain Layout
458 output_error (int buf_size, int error_line, char *tool)
461 \begin_layout Plain Layout
466 \begin_layout Plain Layout
471 \begin_layout Plain Layout
476 \begin_layout Plain Layout
478 fprintf(stdout, "! Build Error: ==> %s ==>
483 \begin_layout Plain Layout
485 fprintf(stdout, " ...
494 \begin_layout Plain Layout
499 \begin_layout Plain Layout
501 for (i=0; i<buf_size; i++)
504 \begin_layout Plain Layout
506 if (strlen(buffer[i]) != 0)
509 \begin_layout Plain Layout
511 fprintf(stdout, "%s", buffer[i]);
514 \begin_layout Plain Layout
519 \begin_layout Plain Layout
526 \begin_layout Plain Layout
536 \begin_layout Standard
537 \begin_inset Flex Chunk
540 \begin_layout Plain Layout
542 \begin_inset Argument 1
545 \begin_layout Plain Layout
552 void output_error (int buf_size, int error_line, char *tool);
560 \begin_layout Section
561 Functions Implementation
564 \begin_layout Standard
565 Both noweave and notangle routines, always output one single line for each
566 error found, thus to scan the buffer for noweb error messages is enough
567 to exam one input line at a time.
568 Note that the noweb software does not provide a line error number, so all
569 errors boxes related to noweb messages will be displayed at the beginning
573 \begin_layout Standard
574 \begin_inset Flex Chunk
577 \begin_layout Plain Layout
579 \begin_inset Argument 1
582 \begin_layout Plain Layout
584 Scan input for noweb error messages
592 \begin_layout Plain Layout
597 \begin_layout Plain Layout
599 while (fgets(buffer[0], 200, stdin)) {
602 \begin_layout Plain Layout
607 \begin_layout Plain Layout
609 output_error(1, err_line, "noweb");
612 \begin_layout Plain Layout
617 \begin_layout Plain Layout
627 \begin_layout Standard
628 The examination itself is very inefficient.
629 Unfortunately noweb doesn't have any characteristic that would help to
630 identify one of its error messages.
631 The solution is to collect all possible output messages in an array of
632 strings, and turn the examination process into a linear search in this
636 \begin_layout Standard
637 \begin_inset Flex Chunk
640 \begin_layout Plain Layout
644 \begin_layout Plain Layout
646 <<Global variables>>=
649 \begin_layout Plain Layout
651 char *noweb_msgs[] = {
654 \begin_layout Plain Layout
656 "couldn't open file",
659 \begin_layout Plain Layout
661 "couldn't open temporary file",
664 \begin_layout Plain Layout
666 "error writing temporary file",
669 \begin_layout Plain Layout
674 \begin_layout Plain Layout
679 \begin_layout Plain Layout
681 "Bad format sequence",
684 \begin_layout Plain Layout
686 "Can't open output file",
689 \begin_layout Plain Layout
691 "Can't open temporary file",
694 \begin_layout Plain Layout
696 "Capacity exceeded:",
699 \begin_layout Plain Layout
701 "Ignoring unknown option -",
704 \begin_layout Plain Layout
706 "This can't happen:",
709 \begin_layout Plain Layout
711 "non-numeric line number in"
714 \begin_layout Plain Layout
719 \begin_layout Plain Layout
723 \begin_layout Plain Layout
725 char *noweb_msgs_mimic_gcc[] = {
728 \begin_layout Plain Layout
730 ": unescaped << in documentation chunk"
733 \begin_layout Plain Layout
743 \begin_layout Standard
744 A noweb error message can be any string that contains a matching pair of
757 > >, or any of the above strings
760 \begin_layout Standard
764 \begin_layout Plain Layout
769 \begin_layout Plain Layout
771 int noweb_try (int buf_line)
774 \begin_layout Plain Layout
779 \begin_layout Plain Layout
784 \begin_layout Plain Layout
789 \begin_layout Plain Layout
793 \begin_layout Plain Layout
795 b = buffer[buf_line];
798 \begin_layout Plain Layout
803 \begin_layout Plain Layout
807 \begin_layout Plain Layout
809 for (i=0; i<1; i++) {
812 \begin_layout Plain Layout
814 s = (char *)strstr (b, noweb_msgs_mimic_gcc[i]);
817 \begin_layout Plain Layout
822 \begin_layout Plain Layout
824 t = (char *)strchr(buffer[buf_line], ':');
827 \begin_layout Plain Layout
829 err_line = atoi(t+1);
832 \begin_layout Plain Layout
834 t = buffer[buf_line];
837 \begin_layout Plain Layout
842 \begin_layout Plain Layout
844 while (*(t++) = *(s++));
847 \begin_layout Plain Layout
852 \begin_layout Plain Layout
857 \begin_layout Plain Layout
862 \begin_layout Plain Layout
864 s = (char *)strstr(b, "<<");
867 \begin_layout Plain Layout
872 \begin_layout Plain Layout
874 s = (char *)strstr(s+2, ">>");
877 \begin_layout Plain Layout
882 \begin_layout Plain Layout
887 \begin_layout Plain Layout
892 \begin_layout Plain Layout
897 \begin_layout Plain Layout
899 for (i = 0; i < 12; ++i) {
902 \begin_layout Plain Layout
904 s = (char *)strstr (b, noweb_msgs[i]);
907 \begin_layout Plain Layout
912 \begin_layout Plain Layout
917 \begin_layout Plain Layout
922 \begin_layout Plain Layout
927 \begin_layout Plain Layout
932 \begin_layout Plain Layout
937 \begin_layout Plain Layout
942 \begin_layout Plain Layout
952 \begin_layout Standard
956 \begin_layout Plain Layout
958 <<Function prototypes>>=
961 \begin_layout Plain Layout
963 int noweb_try (int buf_line);
966 \begin_layout Plain Layout
976 \begin_layout Standard
977 The xlc compiler always outputs one single line for each error found, thus
978 to scan the buffer for xlc error messages it is enough to exam one input
982 \begin_layout Standard
983 \begin_inset Flex Chunk
986 \begin_layout Plain Layout
988 \begin_inset Argument 1
991 \begin_layout Plain Layout
993 Scan input for xlc error messages
1001 \begin_layout Plain Layout
1006 \begin_layout Plain Layout
1008 while (fgets(buffer[last_buf_line], 200, stdin)) {
1011 \begin_layout Plain Layout
1016 \begin_layout Plain Layout
1018 output_error(1, err_line, "xlc");
1021 \begin_layout Plain Layout
1026 \begin_layout Plain Layout
1036 \begin_layout Standard
1037 A xlc error message is easy to identify.
1038 Every error message starts with a quoted string with no spaces, a comma,
1040 \begin_inset Quotes eld
1044 \begin_inset Quotes erd
1047 , a space, and some variable text.
1048 The following routine tests if a given buffer line matches this criteria:
1051 \begin_layout Standard
1052 \begin_inset Flex Chunk
1055 \begin_layout Plain Layout
1059 \begin_layout Plain Layout
1063 \begin_layout Plain Layout
1065 <<Function bodies>>=
1068 \begin_layout Plain Layout
1073 \begin_layout Plain Layout
1075 xlc_try (int buf_line)
1078 \begin_layout Plain Layout
1083 \begin_layout Plain Layout
1088 \begin_layout Plain Layout
1093 \begin_layout Plain Layout
1095 t = buffer[buf_line];
1098 \begin_layout Plain Layout
1103 \begin_layout Plain Layout
1105 while (*s != '"' && *s != ' ' && *s != '
1110 \begin_layout Plain Layout
1115 \begin_layout Plain Layout
1117 if (*t != '"' || *s != '"' || strncmp(s+1, ", line ", 7) != 0)
1120 \begin_layout Plain Layout
1125 \begin_layout Plain Layout
1130 \begin_layout Plain Layout
1135 \begin_layout Plain Layout
1140 \begin_layout Plain Layout
1150 \begin_layout Standard
1151 \begin_inset Flex Chunk
1154 \begin_layout Plain Layout
1156 \begin_inset Argument 1
1159 \begin_layout Plain Layout
1166 int xlc_try (int buf_line);
1174 \begin_layout Standard
1175 The gcc compiler error messages are more complicated to scan.
1176 Each error can span more than one line in the buffer.
1177 The good news is that every buffer line on each error has the same pattern,
1178 and share the same line number.
1179 Thus the strategy will be to accumulate lines in the buffer while the reported
1180 line number is still the same.
1181 At the time they differ, all the accumulated lines, except the last one,
1182 will belong to one single error message, which now can be output-ed to
1187 \begin_layout Standard
1188 Every gcc error message contains a string with no space followed by a
1189 \begin_inset Quotes eld
1193 \begin_inset Quotes eld
1197 If the next character is a space, then this line is a header of a error
1198 message and the next line will detail the line number of the source code
1199 where the error was found.
1200 Otherwise, the next thing is a integer number followed by another
1201 \begin_inset Quotes eld
1205 \begin_inset Quotes eld
1211 \begin_layout Standard
1212 \begin_inset Flex Chunk
1215 \begin_layout Plain Layout
1217 \begin_inset Argument 1
1220 \begin_layout Plain Layout
1222 Scan input for gcc error messages
1230 \begin_layout Plain Layout
1235 \begin_layout Plain Layout
1240 \begin_layout Plain Layout
1245 \begin_layout Plain Layout
1247 while (fgets(buffer[last_buf_line], 200, stdin)) {
1250 \begin_layout Plain Layout
1252 /****** Skip lines until I find an error */
1255 \begin_layout Plain Layout
1257 s = (char *)strpbrk(buffer[last_buf_line], " :");
1260 \begin_layout Plain Layout
1262 if (s == NULL || *s == ' ')
1265 \begin_layout Plain Layout
1267 continue; /* No gcc error found here */
1270 \begin_layout Plain Layout
1275 \begin_layout Plain Layout
1277 <<gcc error message criteria is to find a "...:999:" or a "...: ">>
1280 \begin_layout Plain Layout
1282 /****** OK It is an error message, get line number */
1285 \begin_layout Plain Layout
1287 err_line = atoi(s+1);
1290 \begin_layout Plain Layout
1292 if (last_err_line == 0 || last_err_line == err_line) {
1295 \begin_layout Plain Layout
1297 last_err_line = err_line;
1300 \begin_layout Plain Layout
1302 continue; /* It's either a header or a continuation, don't output
1306 \begin_layout Plain Layout
1311 \begin_layout Plain Layout
1313 /****** Completed the scan of one error message, output it to LyX
1317 \begin_layout Plain Layout
1319 discharge_buffer(1);
1322 \begin_layout Plain Layout
1327 \begin_layout Plain Layout
1329 } while (fgets(buffer[last_buf_line], 200, stdin));
1332 \begin_layout Plain Layout
1337 \begin_layout Plain Layout
1339 /****** EOF completes the scan of whatever was being scanned */
1342 \begin_layout Plain Layout
1344 discharge_buffer(0);
1347 \begin_layout Plain Layout
1357 \begin_layout Standard
1358 \begin_inset Flex Chunk
1361 \begin_layout Plain Layout
1363 \begin_inset Argument 1
1366 \begin_layout Plain Layout
1368 gcc error message criteria is to find a "...:999:" or a "...: "
1373 /****** Search first ":" in the error number */
1376 \begin_layout Plain Layout
1378 s = (char *)strpbrk(buffer[last_buf_line], " :");
1381 \begin_layout Plain Layout
1386 \begin_layout Plain Layout
1388 if (s == NULL || *s == ' ')
1391 \begin_layout Plain Layout
1393 <<No gcc error found here, but it might terminate the scanning of a previous
1397 \begin_layout Plain Layout
1399 /****** Search second ":" in the error number */
1402 \begin_layout Plain Layout
1404 t = (char *)strpbrk(s+1, " :");if (t == NULL || *t == ' ') <<No gcc error
1405 found here, but it might terminate the scanning of a previous one>>/******
1406 Verify if is all digits between ":" */if (t != s+1+strspn(s+1, "0123456789"))
1407 <<No gcc error found here, but it might terminate the scanning of a previous
1411 \begin_layout Plain Layout
1415 \begin_layout Plain Layout
1419 \begin_layout Plain Layout
1421 <<No gcc error found here, but it might terminate the scanning of a previous
1425 \begin_layout Plain Layout
1430 \begin_layout Plain Layout
1435 \begin_layout Plain Layout
1437 discharge_buffer(1);
1440 \begin_layout Plain Layout
1445 \begin_layout Plain Layout
1455 \begin_layout Standard
1456 As we mentioned, when the scan of one gcc error message is completed everything
1457 in the buffer except the last line is one single error message.
1458 But if the scan terminates with a EOF or through finding one line that
1459 does not match the gcc error message criteria, then there is no
1460 \begin_inset Quotes eld
1464 \begin_inset Quotes erd
1467 in the buffer to be concerned with.
1468 In those cases we empty the buffer completely.
1471 \begin_layout Standard
1472 \begin_inset Flex Chunk
1475 \begin_layout Plain Layout
1479 \begin_layout Plain Layout
1483 \begin_layout Plain Layout
1485 <<Function bodies>>=
1488 \begin_layout Plain Layout
1493 \begin_layout Plain Layout
1495 discharge_buffer (int save_last)
1498 \begin_layout Plain Layout
1503 \begin_layout Plain Layout
1505 if (last_err_line != 0) {
1508 \begin_layout Plain Layout
1510 clean_gcc_messages();
1513 \begin_layout Plain Layout
1515 if (save_last != 0) {
1518 \begin_layout Plain Layout
1520 output_error(last_buf_line-1, last_err_line, "gcc");
1523 \begin_layout Plain Layout
1525 strcpy (buffer[0], buffer[last_buf_line-1]);
1528 \begin_layout Plain Layout
1530 last_err_line = err_line;
1533 \begin_layout Plain Layout
1538 \begin_layout Plain Layout
1543 \begin_layout Plain Layout
1548 \begin_layout Plain Layout
1550 clean_gcc_messages();
1553 \begin_layout Plain Layout
1555 output_error(last_buf_line-1, last_err_line, "gcc");
1558 \begin_layout Plain Layout
1563 \begin_layout Plain Layout
1568 \begin_layout Plain Layout
1573 \begin_layout Plain Layout
1578 \begin_layout Plain Layout
1588 \begin_layout Standard
1589 \begin_inset Flex Chunk
1592 \begin_layout Plain Layout
1594 \begin_inset Argument 1
1597 \begin_layout Plain Layout
1604 void discharge_buffer (int save_last);
1612 \begin_layout Standard
1614 \begin_inset Quotes eld
1618 \begin_inset Quotes erd
1621 superfluous information from gcc messages, namely the name of the noweb
1622 file and the line number of the Error.
1626 \begin_layout Plain Layout
1628 For instance, some way of distinguishing between gcc Errors and Warnings
1637 \begin_layout Standard
1638 \begin_inset Flex Chunk
1641 \begin_layout Plain Layout
1643 \begin_inset Argument 1
1646 \begin_layout Plain Layout
1656 \begin_layout Plain Layout
1658 clean_gcc_messages ()
1661 \begin_layout Plain Layout
1666 \begin_layout Plain Layout
1671 \begin_layout Plain Layout
1676 \begin_layout Plain Layout
1681 \begin_layout Plain Layout
1683 int search_len = sprintf(search, ".nw:%d:", last_err_line);
1686 \begin_layout Plain Layout
1691 \begin_layout Plain Layout
1693 for (index = 0; index < last_buf_line-1; index++) {
1696 \begin_layout Plain Layout
1698 tail = (char *)strstr (buffer[index], search);
1701 \begin_layout Plain Layout
1703 if ( tail == NULL) {
1706 \begin_layout Plain Layout
1708 tail = (char *) strstr (buffer[index], ".nw:");
1711 \begin_layout Plain Layout
1716 \begin_layout Plain Layout
1721 \begin_layout Plain Layout
1726 \begin_layout Plain Layout
1731 \begin_layout Plain Layout
1736 \begin_layout Plain Layout
1741 \begin_layout Plain Layout
1746 \begin_layout Plain Layout
1748 head = buffer[index];
1751 \begin_layout Plain Layout
1753 while (*(head++) = *(tail++));
1756 \begin_layout Plain Layout
1761 \begin_layout Plain Layout
1766 \begin_layout Plain Layout
1776 \begin_layout Standard
1777 \begin_inset Flex Chunk
1780 \begin_layout Plain Layout
1782 \begin_inset Argument 1
1785 \begin_layout Plain Layout
1792 void clean_gcc_messages ();
1800 \begin_layout Standard
1801 To combine the scan of noweb error messages and xlc error messages is very
1803 We just try each one for every input line:
1806 \begin_layout Standard
1810 \begin_layout Plain Layout
1812 <<AIX system using both noweb and xlc>>=
1815 \begin_layout Plain Layout
1820 \begin_layout Plain Layout
1825 \begin_layout Plain Layout
1827 while (fgets(buffer[0], 200, stdin)) {
1830 \begin_layout Plain Layout
1835 \begin_layout Plain Layout
1837 output_error(1, err_line, "noweb");
1840 \begin_layout Plain Layout
1842 else if (xlc_try(0))
1845 \begin_layout Plain Layout
1847 output_error(1, err_line, "xlc");
1850 \begin_layout Plain Layout
1855 \begin_layout Plain Layout
1860 \begin_layout Plain Layout
1870 \begin_layout Standard
1871 To combine the scan of noweb error messages and gcc error messages is simple
1872 if we realize that it is not possible to find a noweb error message in
1873 the middle of a gcc error message.
1874 So we just repeat the gcc procedure and test for noweb error messages in
1875 the beginning of the scan:
1878 \begin_layout Standard
1879 \begin_inset Flex Chunk
1882 \begin_layout Plain Layout
1884 \begin_inset Argument 1
1887 \begin_layout Plain Layout
1889 Solaris and Linux systems using both noweb and gcc
1897 \begin_layout Plain Layout
1902 \begin_layout Plain Layout
1907 \begin_layout Plain Layout
1912 \begin_layout Plain Layout
1914 while (fgets(buffer[last_buf_line], 200, stdin)) {
1917 \begin_layout Plain Layout
1919 /****** Skip lines until I find an error */
1922 \begin_layout Plain Layout
1924 if (last_buf_line == 0 && noweb_try(0)) {
1927 \begin_layout Plain Layout
1929 output_error(1, err_line, "noweb");
1932 \begin_layout Plain Layout
1937 \begin_layout Plain Layout
1942 \begin_layout Plain Layout
1944 s = (char *)strpbrk(buffer[last_buf_line], " :");
1947 \begin_layout Plain Layout
1949 if (s == NULL || *s == ' ')
1952 \begin_layout Plain Layout
1954 continue; /* No gcc error found here */
1957 \begin_layout Plain Layout
1962 \begin_layout Plain Layout
1964 <<gcc error message criteria is to find a "...:999:" or a "...: ">>
1967 \begin_layout Plain Layout
1969 /****** OK It is an error, get line number */
1972 \begin_layout Plain Layout
1974 err_line = atoi(s+1);
1977 \begin_layout Plain Layout
1979 if (last_err_line == 0 || last_err_line == err_line) {
1982 \begin_layout Plain Layout
1984 last_err_line = err_line;
1987 \begin_layout Plain Layout
1989 continue; /* It's either a header or a continuation, don't output
1993 \begin_layout Plain Layout
1998 \begin_layout Plain Layout
2000 /****** Completed the scan of one error message, output it to LyX
2004 \begin_layout Plain Layout
2006 discharge_buffer(1);
2009 \begin_layout Plain Layout
2014 \begin_layout Plain Layout
2016 } while (fgets(buffer[last_buf_line], 200, stdin));
2019 \begin_layout Plain Layout
2024 \begin_layout Plain Layout
2026 /****** EOF completes the scan of whatever was being scanned */
2029 \begin_layout Plain Layout
2031 discharge_buffer(0);
2034 \begin_layout Plain Layout
2044 \begin_layout Section
2045 Wrapping the code into a file
2048 \begin_layout Standard
2049 \begin_inset Flex Chunk
2052 \begin_layout Plain Layout
2054 \begin_inset Argument 1
2057 \begin_layout Plain Layout
2067 \begin_layout Plain Layout
2069 #include <strings.h>
2072 \begin_layout Plain Layout
2077 \begin_layout Plain Layout
2079 <<Global variables>>
2082 \begin_layout Plain Layout
2084 <<Function prototypes>>
2087 \begin_layout Plain Layout
2097 \begin_layout Standard
2098 To build this program, we want to add the
2099 \begin_inset Quotes eld
2103 \begin_inset Quotes erd
2106 option in the tangle command to force gdb to load the file
2115 In accordance with this, we pass the
2116 \begin_inset Quotes eld
2120 \begin_inset Quotes erd
2126 \begin_layout Standard
2127 \begin_inset Flex Chunk
2130 \begin_layout Plain Layout
2132 \begin_inset Argument 1
2135 \begin_layout Plain Layout
2145 \begin_layout Plain Layout
2147 if [ -z "$NOWEB_SOURCE" ]; then NOWEB_SOURCE=Literate.nw; fi
2150 \begin_layout Plain Layout
2152 if [ -z "$NOWEB_OUTPUT_DIR" ]; then NOWEB_OUTPUT_DIR=.; fi
2155 \begin_layout Plain Layout
2157 notangle -L -Rlisterrors.c ${NOWEB_SOURCE} > ${NOWEB_OUTPUT_DIR}/listerrors.c
2160 \begin_layout Plain Layout
2162 gcc -g -o listerrors listerrors.c
2170 \begin_layout Standard
2171 This project can be tangled and compiled from \SpecialChar LyX
2178 to call a generic script that always extracts a chunk named
2183 Here is a example of such generic script:
2186 \begin_layout LyX-Code
2188 \begin_inset Newline newline
2191 notangle -Rbuild-script $1 | env NOWEB_SOURCE=$1 NOWEB_OUTPUT_DIR=$r sh
2194 \begin_layout LyX-Code