]> git.lyx.org Git - lyx.git/blobdiff - lib/examples/Literate.lyx
* bind/math.bind: shortcut for \psi
[lyx.git] / lib / examples / Literate.lyx
index 647af802ed108357b969a1c10c185de726ff2066..9ad85287ced8b5dab0d17146a3843c0f7544f948 100644 (file)
@@ -1,7 +1,7 @@
-#LyX 1.1 created this file. For more info see http://www.lyx.org/
-\lyxformat 2.16
+#LyX 1.2 created this file. For more info see http://www.lyx.org/
+\lyxformat 220
 \textclass literate-article
-\language default
+\language english
 \inputencoding default
 \fontscheme default
 \graphics default
@@ -11,6 +11,8 @@
 \paperpackage a4
 \use_geometry 0
 \use_amsmath 0
+\use_natbib 0
+\use_numerical_citations 0
 \paperorientation portrait
 \secnumdepth 3
 \tocdepth 3
@@ -32,19 +34,42 @@ An example program
 Edmar Wienskoski Jr.
 \newline 
 edmar-w-jr@technologist.com
-\begin_float footnote 
+\begin_inset Foot
+collapsed true
+
 \layout Standard
 
 Modified by Bernard Michael Hurley bernardh@westherts.ac.uk ---- Don't blame
  Edmar for any errors that have crept in!
-\end_float 
+\end_inset 
+
+
+\layout Abstract
+
+
+\series bold 
+Note:
+\series default 
+ This example program is provided for educational use only.
+ The functionality in this C program has been superceded by the equivalent
+ Python code in 
+\emph on 
+examples/listerrors.lyx
+\emph default 
+ which should be installed in the LyX scripts directory.
 \layout Date
 
 
-\latex latex 
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
 
 \backslash 
 today
+\end_inset 
+
+
 \layout Standard
 
 
@@ -185,14 +210,18 @@ buffer
 \family default 
 , a program name and line number.
  There is no special requirement on the input strings, they can be anything.
-\begin_float footnote 
+\begin_inset Foot
+collapsed true
+
 \layout Standard
 
 This function has been slightly changed from EW's original to make scanning
  a bit easier with LaTeX::scanLogFile().
  The test has been added because LyX can crash if empty lines are allowed
  here --- I can't figure out why! --- BMH
-\end_float 
+\end_inset 
+
+
 \layout Scrap
 
 <<Function bodies>>=
@@ -266,7 +295,7 @@ Both noweave and notangle routines, always output one single line for each
 \newline 
     if (noweb_try(0))
 \newline 
-      output_error(1, 0, "noweb");
+      output_error(1, err_line, "noweb");
 \newline 
   }
 \newline 
@@ -309,7 +338,15 @@ char *noweb_msgs[] = {
 \newline 
   "This can't happen:",
 \newline 
-  "non-numeric line number in" 
+  "non-numeric line number in"
+\newline 
+};
+\newline 
+
+\newline 
+char *noweb_msgs_mimic_gcc[] = {
+\newline 
+  ": unescaped << in documentation chunk"
 \newline 
 };
 \newline 
@@ -320,7 +357,7 @@ A noweb error message can be any string that contains a matching pair of
  < <\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-> >, or any of the above strings.
+> >, or any of the above strings
 \layout Scrap
 
 <<Function bodies>>=
@@ -331,13 +368,39 @@ noweb_try (int buf_line)
 \newline 
 {
 \newline 
-  char    *s, *b;
+  char    *s, *t, *b;
 \newline 
-  int     i;
+  int     i; 
 \newline 
+
 \newline 
   b = buffer[buf_line];
+\newline 
+  err_line = 0;
+\newline 
+
+\newline 
+  for (i=0; i<1; i++) {
+\newline 
+      s = (char *)strstr (b, noweb_msgs_mimic_gcc[i]);
+\newline 
+      if (s != NULL) {
+\newline 
+        t = (char *)strchr(buffer[buf_line], ':');
+\newline 
+        err_line = atoi(t+1);
+\newline 
+        t = buffer[buf_line];
+\newline 
+        ++s;
+\newline 
+        while (*(t++) = *(s++));
+\newline 
+        return 1;
+\newline 
+      }
+\newline 
+  }
 \newline 
   s = (char *)strstr(b, "<<");
 \newline 
@@ -345,25 +408,25 @@ noweb_try (int buf_line)
 \newline 
     s = (char *)strstr(s+2, ">>");
 \newline 
-    if (s != NULL)
+    if (s != NULL) {
 \newline 
       return 1;
 \newline 
-  } else {
+    }
 \newline 
-    for (i=0; i<12; i++) {
+  } else { 
 \newline 
-      s = (char *)strstr (b, noweb_msgs[i]);
+     for (i = 0; i < 12; ++i) {
 \newline 
-      if (s != NULL)
+        s = (char *)strstr (b, noweb_msgs[i]);
 \newline 
-        break;
+        if (s != NULL) {
 \newline 
-    }
+           return 1;
 \newline 
-    if (s != NULL)
+        }
 \newline 
-      return 1;
+    }
 \newline 
   }
 \newline 
@@ -677,13 +740,17 @@ cleans
 
  superfluous information from gcc messages, namely the name of the noweb
  file and the line number of the Error.
-\begin_float footnote 
+\begin_inset Foot
+collapsed true
+
 \layout Standard
 
 More could be done.
  For instance, some way of distinguishing between gcc Errors and Warnings
  should be devised.
-\end_float 
+\end_inset 
+
+
 \layout Scrap
 
 <<Function bodies>>=
@@ -761,7 +828,7 @@ To combine the scan of noweb error messages and xlc error messages is very
 \newline 
     if (noweb_try(0))
 \newline 
-      output_error(1, 0, "noweb");
+      output_error(1, err_line, "noweb");
 \newline 
     else if (xlc_try(0))
 \newline 
@@ -797,7 +864,7 @@ To combine the scan of noweb error messages and gcc error messages is simple
 \newline 
     if (last_buf_line == 0 && noweb_try(0)) {
 \newline 
-      output_error(1, 0, "noweb");
+      output_error(1, err_line, "noweb");
 \newline 
       continue;
 \newline 
@@ -896,9 +963,11 @@ listerrors.c
 
 <<build-script>>=
 \newline 
-#!/usr/local/bin/bash
+#!/bin/sh
+\newline 
+if [ -z "$NOWEB_SOURCE" ]; then NOWEB_SOURCE=Literate.nw; fi
 \newline 
-notangle -L -Rlisterrors.c Literate.nw > listerrors.c
+notangle -L -Rlisterrors.c ${NOWEB_SOURCE} > listerrors.c
 \newline 
 gcc -g -o listerrors listerrors.c
 \newline 
@@ -921,5 +990,7 @@ build-script
 
 #!/bin/sh
 \newline 
-notangle -Rbuild-script $1 | sh
+notangle -Rbuild-script $1 | env NOWEB_SOURCE=$1 sh
+\layout LyX-Code
+
 \the_end