Hi Jean-Marc,

Here is my latest followup to the listerrors fixes.

If you have not already done so, please apply this.

The backward-porting is important since many people don't have python-2.2
installed as /usr/bin/python.

The converter.C patch is important to allow people who have the
setting "parselog=listerrors" in their build-program convertor
to find "listerrors" without having to set an additional path element
outside of LyX. This would mean that the "listerrors" change has no
user-visible impact.

                        ---Kayvan
-- 
Kayvan A. Sylvan          | Proud husband of       | Father to my kids:
Sylvan Associates, Inc.   | Laura Isabella Sylvan  | Katherine Yelena (8/8/89)
http://sylvan.com/~kayvan | "crown of her husband" | Robin Gregory (2/28/92)
Index: lib/ChangeLog
===================================================================
RCS file: /cvs/lyx/lyx-devel/lib/ChangeLog,v
retrieving revision 1.189
diff -u -r1.189 ChangeLog
--- lib/ChangeLog       2002/03/21 19:26:18     1.189
+++ lib/ChangeLog       2002/03/21 19:48:24
@@ -6,6 +6,13 @@
 
        * ui/default.ui: Change "What's this?" to "Tooltips".
 
+2002-03-19  Kayvan A. Sylvan  <[EMAIL PROTECTED]>
+
+       * examples/listerrors.lyx: Fixed to run with python-1.5 as well
+       as with latest python-2.2
+       
+       * scripts/listerrors: Re-generated from listerrors.lyx
+
 2002-03-19  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
 
        * create_fonts_dir:
Index: lib/examples/listerrors.lyx
===================================================================
RCS file: /cvs/lyx/lyx-devel/lib/examples/listerrors.lyx,v
retrieving revision 1.1
diff -u -r1.1 listerrors.lyx
--- lib/examples/listerrors.lyx 2002/03/19 21:42:48     1.1
+++ lib/examples/listerrors.lyx 2002/03/21 19:48:24
@@ -259,7 +259,7 @@
 \newline 
 
 \newline 
-import sys
+import sys, string
 \newline 
 
 \newline 
@@ -363,10 +363,8 @@
 \newline 
   if lines:
 \newline 
-    line = lines[-1]
+    line = lines.pop()
 \newline 
-    lines = lines[:-1]
-\newline 
   else:
 \newline 
     line = file.readline()
@@ -391,7 +389,7 @@
 \newline 
   lines = __lines
 \newline 
-  lines += (line,) # push a list onto the stack, not individual letters
+  lines.append(line)
 \newline 
 
 \newline 
@@ -509,9 +507,9 @@
 
 <<Look for the unescaped angle-brackets in documentation>>=
 \newline 
-if line.find(": unescaped << in documentation chunk") != -1:
+if string.find(line, ": unescaped << in documentation chunk") != -1:
 \newline 
-  line_parts = line.split(':')
+  line_parts = string.split(line, ':')
 \newline 
   num_str = line_parts[1]
 \newline 
@@ -519,7 +517,7 @@
 \newline 
   i = 0
 \newline 
-  while i < num_len and num_str[i].isdigit(): i += 1
+  while i < num_len and (num_str[i] in string.digits): i = i + 1
 \newline 
   if i == num_len:
 \newline 
@@ -538,13 +536,13 @@
 \newline 
 if (not retval):
 \newline 
-  left = line.find("<<")
+  left = string.find(line, "<<")
 \newline 
   if (left != -1) and ((left + 2) < len(line)) and 
 \backslash 
 
 \newline 
-     (line[left+2:].find(">>") != -1):
+     (string.find(line[left+2:], ">>") != -1):
 \newline 
     write_error(line, "noweb");
 \newline 
@@ -586,7 +584,7 @@
 \newline 
   for msg in msgs_to_try:
 \newline 
-    if line.find(msg) != -1:
+    if string.find(line, msg) != -1:
 \newline 
       write_error(line, "noweb")
 \newline 
@@ -647,7 +645,7 @@
 
 <<Handle the gcc error message>>= 
 \newline 
-first_space = line.find(' ')
+first_space = string.find(line, ' ')
 \newline 
 if first_space > 1: # The smallest would be "X: "
 \newline 
@@ -661,7 +659,7 @@
 \newline 
       num_end = first_space
 \newline 
-      while next_line[num_end].isdigit(): num_end += 1
+      while next_line[num_end] in string.digits: num_end = num_end + 1
 \newline 
       if num_end > first_space: # good!
 \newline 
@@ -685,12 +683,10 @@
 <<Accumulate gcc error lines and print it>>=
 \newline 
 num_str = next_line[first_space:num_end]
-\newline 
-msgs = []
 \newline 
-msgs += (line[first_space:],)
+msgs = [line[first_space:]]
 \newline 
-msgs += (next_line[num_end + 1:],)
+msgs.append(next_line[num_end + 1:])
 \newline 
 header_to_see = next_line[:num_end]
 \newline 
@@ -698,7 +694,7 @@
 \newline 
 while next_line and next_line[:num_end] == header_to_see:
 \newline 
-  msgs += (next_line[num_end + 1:],)
+  msgs.append(next_line[num_end + 1:])
 \newline 
   next_line = getline()
 \newline 
@@ -754,9 +750,9 @@
 \newline 
   if line[0] == '"': # This is the first character of all xlc errors
 \newline 
-    next_quote = line.find('"', 1)
+    next_quote = string.find(line, '"', 1)
 \newline 
-    first_space = line.find(' ')
+    first_space = string.find(line, ' ')
 \newline 
     if (next_quote != -1) and (first_space > next_quote): # no space inisde
  quotes
@@ -765,7 +761,7 @@
 \newline 
         num_start = num_end = first_space + 6
 \newline 
-        while line[num_end].isdigit(): num_end += 1
+        while line[num_end] in string.digits: num_end = num_end + 1
 \newline 
         if num_end > num_start:
 \newline 
Index: lib/scripts/listerrors
===================================================================
RCS file: /cvs/lyx/lyx-devel/lib/scripts/listerrors,v
retrieving revision 1.1
diff -u -r1.1 listerrors
--- lib/scripts/listerrors      2002/03/19 21:42:48     1.1
+++ lib/scripts/listerrors      2002/03/21 19:48:25
@@ -13,7 +13,7 @@
     modifications to original listerrors."""
 __copyright__ = "Copyright 2002 - The LyX team."
 
-import sys
+import sys, string
 
 def write_error(msg, tool = "noweb", line_number = 1):
   """Write out the given message in TeX error style.
@@ -37,8 +37,7 @@
   global __lines
   lines = __lines
   if lines:
-    line = lines[-1]
-    lines = lines[:-1]
+    line = lines.pop()
   else:
     line = file.readline()
   return line
@@ -47,7 +46,7 @@
   "push a line onto the pushback stack."
   global __lines
   lines = __lines
-  lines += (line,) # push a list onto the stack, not individual letters
+  lines.append(line)
 
 def main():
   """Entry point for listerrors. Takes no options.
@@ -65,19 +64,19 @@
 
   Returns 1 on success, 0 otherwise. Outputs on stdout."""
   retval = 0
-  if line.find(": unescaped << in documentation chunk") != -1:
-    line_parts = line.split(':')
+  if string.find(line, ": unescaped << in documentation chunk") != -1:
+    line_parts = string.split(line, ':')
     num_str = line_parts[1]
     num_len = len(num_str)
     i = 0
-    while i < num_len and num_str[i].isdigit(): i += 1
+    while i < num_len and (num_str[i] in string.digits): i = i + 1
     if i == num_len:
       write_error(":" + line_parts[2], "noweb", int(num_str))
       retval = 1
   if (not retval):
-    left = line.find("<<")
+    left = string.find(line, "<<")
     if (left != -1) and ((left + 2) < len(line)) and \
-       (line[left+2:].find(">>") != -1):
+       (string.find(line[left+2:], ">>") != -1):
       write_error(line, "noweb");
       retval = 1;
   if (not retval):
@@ -94,7 +93,7 @@
       "This can't happen:",
       "non-numeric line number in")
     for msg in msgs_to_try:
-      if line.find(msg) != -1:
+      if string.find(line, msg) != -1:
         write_error(line, "noweb")
         retval = 1
         break
@@ -105,23 +104,22 @@
 
   Returns 1 on success, 0 otherwise. Outputs on stdout."""
   retval = 0
-  first_space = line.find(' ')
+  first_space = string.find(line, ' ')
   if first_space > 1: # The smallest would be "X: "
     if line[first_space - 1] == ':':
       header_to_see = line[:first_space - 1]
       next_line = getline()
       if next_line and next_line[:first_space - 1] == header_to_see:
         num_end = first_space
-        while next_line[num_end].isdigit(): num_end += 1
+        while next_line[num_end] in string.digits: num_end = num_end + 1
         if num_end > first_space: # good!
           num_str = next_line[first_space:num_end]
-          msgs = []
-          msgs += (line[first_space:],)
-          msgs += (next_line[num_end + 1:],)
+          msgs = [line[first_space:]]
+          msgs.append(next_line[num_end + 1:])
           header_to_see = next_line[:num_end]
           next_line = getline()
           while next_line and next_line[:num_end] == header_to_see:
-            msgs += (next_line[num_end + 1:],)
+            msgs.append(next_line[num_end + 1:])
             next_line = getline()
           if next_line: pushline(next_line)
           write_error(msgs, "gcc", int(num_str))
@@ -138,12 +136,12 @@
   Returns 1 on success, 0 otherwise. Outputs on stdout."""
   retval = 0
   if line[0] == '"': # This is the first character of all xlc errors
-    next_quote = line.find('"', 1)
-    first_space = line.find(' ')
+    next_quote = string.find(line, '"', 1)
+    first_space = string.find(line, ' ')
     if (next_quote != -1) and (first_space > next_quote): # no space inisde quotes
       if line[first_space - 1:first_space + 6] == ", line ":
         num_start = num_end = first_space + 6
-        while line[num_end].isdigit(): num_end += 1
+        while line[num_end] in string.digits: num_end = num_end + 1
         if num_end > num_start:
           write_error(line, "xlc", int(line[num_start : num_end]))
           retval = 1
Index: src/ChangeLog
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/ChangeLog,v
retrieving revision 1.642
diff -u -r1.642 ChangeLog
--- src/ChangeLog       2002/03/21 17:25:07     1.642
+++ src/ChangeLog       2002/03/21 19:48:25
@@ -16,6 +16,11 @@
        * Makefile.am (LYX_CONV_LIBS): select libs depending on partial
        linking or not.
 
+2002-03-20  Kayvan A. Sylvan  <[EMAIL PROTECTED]>
+
+       * convertor.C (convert): Fix path to add scripts directory before
+       calling convertor programs.
+
 2002-03-19  Juergen Vigna  <[EMAIL PROTECTED]>
 
        * text2.C (clearSelection): reset also xsel_cache.
Index: src/converter.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/converter.C,v
retrieving revision 1.46
diff -u -r1.46 converter.C
--- src/converter.C     2002/03/21 17:25:09     1.46
+++ src/converter.C     2002/03/21 19:48:26
@@ -568,6 +568,16 @@
                         string const & from_format, string const & to_format,
                         string & to_file)
 {
+       // Add system_lyxdir/scripts/ to PATH for convertors
+       //
+       static int path_changed = 0;
+       if (!path_changed) {
+               extern string system_lyxdir;
+               string scripts_dir = AddPath(system_lyxdir, "scripts");
+               AddToExecPath(scripts_dir);
+               path_changed = 1;
+       }
+
        to_file = ChangeExtension(to_file_base,
                                  formats.extension(to_format));
 
Index: src/support/ChangeLog
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/support/ChangeLog,v
retrieving revision 1.89
diff -u -r1.89 ChangeLog
--- src/support/ChangeLog       2002/03/21 17:06:34     1.89
+++ src/support/ChangeLog       2002/03/21 19:48:27
@@ -8,6 +8,12 @@
 
        * Makefile.am (libsupport.la): special rules if partial linking
 
+2002-03-19  Kayvan A. Sylvan <[EMAIL PROTECTED]>
+
+       * filetools.h: Added AddToExecPath prototype
+       * filetools.C (AddToExecPath): helper function to add a path to
+       the PATH environment variable.
+
 2002-03-14  Angus Leeming  <[EMAIL PROTECTED]>
 
        * forkedcontr.C: turn the timer off when their are no longer any
Index: src/support/filetools.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/support/filetools.C,v
retrieving revision 1.110
diff -u -r1.110 filetools.C
--- src/support/filetools.C     2002/03/21 17:06:35     1.110
+++ src/support/filetools.C     2002/03/21 19:48:27
@@ -395,6 +395,11 @@
        return PutEnv(envstr);
 }
 
+bool AddToExecPath(string const & path)
+{
+       string new_path = "PATH=" + path + ":" + GetEnv("PATH");
+       return PutEnv(new_path);
+}
 
 namespace {
 
Index: src/support/filetools.h
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/support/filetools.h,v
retrieving revision 1.32
diff -u -r1.32 filetools.h
--- src/support/filetools.h     2002/03/21 17:06:35     1.32
+++ src/support/filetools.h     2002/03/21 19:48:27
@@ -108,6 +108,9 @@
 bool PutEnv(string const & envstr);
 
 ///
+bool AddToExecPath(string const & path);
+
+///
 bool PutEnvPath(string const & envstr);
 
 /// Substitutes active latex characters with underscores in filename

Attachment: msg35178/pgp00000.pgp
Description: PGP signature

Reply via email to