On Sat, 31 Jul 1999 16:33:32 +1000 (GMT+1000), Allan Rae wrote:

>On 30 Jul 1999, Lars Gullik Bj°nnes wrote:
>
>> "Arnd Hanses" <[EMAIL PROTECTED]> writes:
>> 
>> | The reason for prefering to use a const function and an additional
>> | variable is:
>> 
>> As I said below this is a matter of style.
>> 
>> a) void foo(string &);
>> b) string foo(string const &);
>> 
>> I like b best since it does not change/modify its parameters.
>
>(b) also allows you to do stuff like:
>
>       bar(foo(str))
>
>There are also a few optimisation tricks the compiler can do in a case
>like this, especially if foo() is an inline function.

Ok, I tried to meet the challenge and to clean up my file-handling patch.

Besides numerous small changes to improve readability and supress unnnecessary 
parameters, I tried to 
wrap most system specific code into small 'inline static' helper functions, that take 
'const' 
parameters and get hopefully mostly optimized out, when the respective '#ifdef 
__EMX__' does not apply 
to your box. I moved LString method lowercase() and my later additions from LString 
class to non-member 
functions, so as not to 'clutter up LString even more'.

The one major change was an access warning with double try to remove LyX-tmp files. 
This is important 
in overcrowded and unresponsive networks and on small OS/2-EMX partitions with reduced 
free storage 
place. I found it especially annoying that EMX (in an effort to be a better unix than 
unix, as someone 
said) forbids LyX any access  (marking for deletion), if a tmp-file is previewed or 
otherwise accessed 
by any process. This always left me with extremely *huge* piles of garbage. Now the 
solution here is a 
warning to wake up the EMX-security officer, so to unlock the locked files and try to 
remove 
afterwards.

Though certainly it's still not perfect, I'll ask everybody to test it on UNIX and 
emx. Here on my box 
I did not experience problems of any kind with this patch. I did the diff against 103, 
but it should 
work wit cvs, too. The exception might be lyx_cb.C, where a bit cut and paste by hand 
should help.


BTW: I even looked again a bit into a C++-tutorial and (besides the notion: "I'll 
never understand all 
this stuff") I noticed, LyX is still not very standard C++ but reasonably C-ish. 
Otherwise this patch 
would have been impossible.

Cheers,

        Arnd


Included, the patch (80k uncompressed, this size is still tolerable, I hope)

--------------------snip---------------------
diff -p -N -r -U 4 -X excl.tmp src/original_LyX-1.0.3/filetools.C 
src/modified/filetools.C
--- src/original_LyX-1.0.3/filetools.C  Wed May 12 06:51:18 1999
+++ src/modified/filetools.C    Fri Aug  6 19:26:08 1999
@@ -16,20 +16,10 @@
 
 #include <config.h>
 
 #include <stdlib.h>
+#include <stdio.h>     // for remove() (AHanses)
 #include <ctype.h>
-#include <errno.h>        // I know it's OS/2 specific (SMiyata)
-
-#ifdef __GNUG__
-#pragma implementation "filetools.h"
-#endif
-
-#include "filetools.h"
-#include "lyx_gui_misc.h"
-#include "FileInfo.h"
-#include "pathstack.h"        // I know it's OS/2 specific (SMiyata)
-#include "gettext.h"
 
 // Which part of this is still necessary? (JMarc).
 #if HAVE_DIRENT_H
 # include <dirent.h>
@@ -47,110 +37,128 @@
 #  include <ndir.h>
 # endif
 #endif
 
+#ifdef HAVE_SYS_PARAM_H        // The following for MAXPATHLEN, etc.
+#include <sys/param.h> // (AHanses)
+#endif
+#ifdef HAVE_LIMITS_H 
+#include <limits.h>
+#endif                 // autoconf already checks for all of them
+
+#include <errno.h>     // I know it's OS/2 specific (SMiyata)
+#include <assert.h>    // bounds checks for extension list (AHanses)
+
+#ifdef __GNUG__
+#pragma implementation "filetools.h"
+#endif
+
+#include "LString.h"
+#include "filetools.h"
+#include "lyx_gui_misc.h"
+#include "FileInfo.h"
+#include "pathstack.h" // I know it's OS/2 specific (SMiyata)
+#include "gettext.h"
+
 //     $Id: filetools.C,v 1.4 1998/09/24 12:58:22 lasgoutt Exp $       
 
 #if !defined(lint) && !defined(WITH_WARNINGS)
 static char vcid[] = "$Id: filetools.C,v 1.4 1998/09/24 12:58:22 lasgoutt Exp $";
 #endif /* lint */
 
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 256
+#endif
+
+#ifndef PATH_MAX
+# ifdef _POSIX_PATH_MAX
+# define PATH_MAX _POSIX_PATH_MAX
+# else
+# define PATH_MAX 512
+# endif
+#endif
 
 extern LString system_lyxdir;
 extern LString build_lyxdir;
 extern LString user_lyxdir;
 extern LString system_tempdir;
 
 
-bool IsLyXFilename(LString const & filename)
-{
-       return filename.contains(".lyx");
-}
-
-
-bool IsSGMLFilename(LString const & filename)
-{
-       return filename.contains(".sgml");
-}
 
+// AHanses: for internal helpers to OS-ly correct handle files:
+       //Extensions for filename globbing; used in FileOpenSearch()
+       // Uses a string of paths separated by ";"s to open a file.
+       // Then try appending [on emx EXE_EXTENSION; REXX_EXTENSION;]
+       // BOURNE_SHELL_EXT; KSH_EXT, CSHELL_EXT and whatever 
+       // you want to add...
 
-// Substitutes spaces with underscores in filename (and path)
-LString SpaceLess(LString const & file)
-{
-       LString name = OnlyFilename(file);
-       LString path = OnlyPath(file);
-       // Substitute chars that LaTeX can't handle with safe ones
-       name.subst('~','-');
-       name.subst('$','S');
-       name.subst('%','_');
-       name.subst('\'','_');
-
-       // Substitute some more chars that LaTeX or /bin/sh can't handle   -ck-
-       name.subst('`', '_');
-       name.subst('"', '_');
-       name.subst('&', 'G');
-       name.subst('|', 'I');
-       name.subst(';', ':');
-       name.subst('(', 'c');
-       name.subst(')', 'C');
-       name.subst('<', 'k');
-       name.subst('>', 'K');
-       
-       LString temp = AddName(path, name);
-       // Replace spaces with underscores, also in directory
-       temp.subst(' ','_');
-
-       return temp;
-}
+       static LString const 
+ExtList[] =
+       {
+#ifdef __EMX__         /* just remove #ifdef if safe */
+        "exe",
+        "cmd",
+#endif                 /* just remove if safe */
+        "sh",
+        "ksh",
+        "csh",
+        "zsh",
+        "bash",
+        "bsh",
+        "perl",
+        "pl",
+        "tex",
+        "ltx",
+        "latex",
+        "toc",
+        "index",
+        "idx",
+        "lyx",
+        NULL
+       };
+
+/* SMiyata: AND 0x7f a string bitwise is more efficient than subst();
+   ISO-8859-x and EUC (Extended Unix Code) works just fine with this.
+   The only remaining problem is that Microsoft/IBM codepages, 
+   Shift-JIS and Big5 utilizes the region 0x80-0x9f which will be 
+   converted to non-printable control characters. 
+   AHanses: Used in 'toAsciiAlnum()'
+   */
+#define MASK_RANGE             127 /* LaTeX as such is '7-bit clean' */
+#define REPLACER               'x' /* Which is your favourite? */
+#define EXTENSION_MARKER       '.' /* Let through the 'full-stop' */
 
 
-/// Returns an unique name to be used as a temporary file. 
-LString TmpFileName(LString const & dir, LString const & mask)
-{// With all these temporary variables, it should be safe enough :-) (JMarc)
-       LString tmpdir; 
-       if (dir.empty())
-               tmpdir = system_tempdir;
-       else
-               tmpdir = dir;
-       LString tmpfl = AddName(tmpdir, mask);
 
-       // find a uniq postfix for the filename...
-       // using the pid, and...
-       tmpfl += int(getpid());
-       // a short string...
-       LString ret;
-       FileInfo fnfo;
-       for (int a='a'; a<= 'z'; a++)
-               for (int b='a'; b<= 'z'; b++)
-                       for (int c='a'; c<= 'z'; c++) {
-                               // if this is not enough I have no idea what
-                               // to do.
-                               ret = tmpfl + char(a) + char(b) + char(c);
-                               // check if the file exist
-                               if (!fnfo.newFile(ret).exist())
-                                       return ret;
-                       }
-       lyxerr.print("Not able to find a uniq tmpfile name.");
-       return LString();
-}
+/* OS-specific helpers. No public functions, so not declared 
+   in "filetools.h". They only improve code readability and may 
+   (hopefully) get mostly optimized out on unix (AHanses).
+ */
+       //An internal helper to better handle DOS-style paths
+inline static LString CleanupPath(LString const &path);
+       // Make safe names for picky parsers (shells/LaTeX)
+inline static LString toAsciiAlnum(LString const &string);
+       // For LyX-tmp files
+inline static LString CreateTmpDir (LString const & tempdir, LString const & mask);
+       // Really remove tmp files
+inline static int LyX_FilesRemove(char const *name);
+inline static int DeleteAllFilesInDir(LString const & oldpath);
+inline static int DestroyTmpDir (LString const & tmpdir, bool Allfiles);
 
 
-// Is a file readable ?
-bool IsFileReadable (LString const & path)
+// Wrappers around <dirent.h> functions; cf. "filetools.h":
+       bool 
+IsFileReadable (LString const & path)
 {
        FileInfo file(path);
        if (file.isOK() && file.readable())
                return true;
        else
                return false;
 }
 
-
-// Is a file read_only?
-// return 1 read-write
-//       0 read_only
-//      -1 error (doesn't exist, no access, anything else) 
-int IsFileWriteable (LString const & path)
+       int 
+IsFileWriteable (LString const & path)
 {
        FilePtr fp(path, FilePtr::update);
        if (!fp()) {
                if ((errno == EACCES) || (errno == EROFS)) {
@@ -164,13 +172,10 @@ int IsFileWriteable (LString const & pat
        }
        return 1;
 }
 
-
-//returns 1: dir writeable
-//       0: not writeable
-//      -1: error- couldn't find out
-int IsDirWriteable (LString const & path)
+       int 
+IsDirWriteable (LString const & path)
 {
         LString tmpfl = TmpFileName(path);
 
        if (tmpfl.empty()) {
@@ -190,127 +195,147 @@ int IsDirWriteable (LString const & path
                }
        }
                if (remove (tmpfl.c_str())) {
                        WriteFSAlert(_("LyX Internal Error!"), 
-                                   _("Created test file but cannot remove it?"));
+                       _("Created test file but cannot remove it?"));
                        return -1;
        }
        return 1;
 }
 
 
-// Uses a string of paths separated by ";"s to find a file to open.
-// Can't cope with pathnames with a ';' in them. Returns full path to file.
-// If path entry begins with $$LyX/, use system_lyxdir
-// If path entry begins with $$User/, use user_lyxdir
-// Example: "$$User/doc;$$LyX/doc"
-LString FileOpenSearch (LString const & path, LString const & name, 
-                       LString const & ext)
-{
-       LString real_file, path_element;
-       LString tmppath = path;
-       bool notfound = true;
-
-       tmppath.split(path_element, ';');
-       
-       while (notfound && !path_element.empty()) {
-
-               if (!path_element.suffixIs('/'))
-                       path_element+='/';
-               path_element.subst("$$LyX",system_lyxdir);
-               path_element.subst("$$User",user_lyxdir);
-               
-               real_file = FileSearch(path_element, name, ext);
+// A premium selection of fine OS specific hacks ;-)
+// wrapped here for a cleaner code base (AHanses):
 
-               if (real_file.empty()) {
-                 tmppath.split(path_element, ';');
-               } else {
-                 notfound = false;
-               }
-       }
-#ifdef __EMX__
-       if (ext.empty() && notfound) {
-               real_file = FileOpenSearch(path, name, "exe");
-               if (notfound) real_file = FileOpenSearch(path, name, "cmd");
+       // A helper function for name picky processors; AHanses
+/* SMiyata: AND 0x7f a string bitwise is more efficient than subst();
+** ISO-8859-x and EUC (Extended Unix Code) works just fine with this.
+** The only remaining problem is that Microsoft/IBM codepages, 
+** Shift-JIS and Big5 utilizes the region 0x80-0x9f which will be 
+** converted to non-printable control characters. 
+*/
+       inline static
+LString toAsciiAlnum(LString const &string)
+{
+       LString tmp(string);
+       for (int i = 0; i < tmp.length(); i++) {
+               tmp[i] &= MASK_RANGE;   /* make test result
+                                       ** foreseeable */
+               if ( !( isalnum(tmp[i]) ) && 
+                               tmp[i] != EXTENSION_MARKER )
+                       tmp[i] = REPLACER;
        }
-#endif
-       return real_file;
+        return tmp;
 }
 
-
-// Returns the real name of file name in directory path, with optional
-// extension ext.  
-LString FileSearch(LString const & path, LString const & name, 
-                  LString const & ext)
+       // Substitute chars that LaTeX or shell can't handle with safe ones
+LString SpaceLess(LString const & file)
 {
-        LString fullname;
-       LString tmp;
+       LString temp = toAsciiAlnum( OnlyFilename(file) );
+                       /* AHanses:  if >127, subtract
+                       ** 128, 256, etc., put REPLACER */
 
-       // if `name' is an absolute path, we ignore the setting of `path'
-       // Expand Environmentvariables in 'name'
-       LString tmpname = ReplaceEnvironmentPath(name);
-       fullname = MakeAbsPath(tmpname,path);
+       temp = AddName( OnlyPath(file), temp );
 
-       // search first without extension, then with it.
-       if (IsFileReadable(fullname))
-               return fullname;
-       else if(ext.empty()) 
-               return LString();
-       else { // Is it not more reasonable to use ChangeExtension()? (SMiyata)
-               fullname += '.';
-               fullname += ext;
-               if (IsFileReadable(fullname))
-                       return fullname;
-               else 
-                       return LString();
-       }
+       // Replace spaces with underscores, also in directory
+       temp.subst(' ','_');
+       return temp;
 }
 
+/// Returns an unique name to be used as a temporary file. 
+LString TmpFileName(LString const & dir, LString const & mask) {
+// With all these temporary variables, it should be safe enough :-) (JMarc)
+       LString tmpdir; 
+       if (dir.empty())
+               tmpdir = system_tempdir;
+       else
+               tmpdir = dir;
+       LString tmpfl = AddName(tmpdir, mask);
 
-// Search the file name.ext in the subdirectory dir of
-//   1) user_lyxdir
-//   2) build_lyxdir (if not empty)
-//   3) system_lyxdir
-LString LibFileSearch(LString const & dir, LString const & name, 
-                     LString const & ext)
-{
-        LString fullname = FileSearch(AddPath(user_lyxdir,dir), name,
-                                     ext); 
-       if (!fullname.empty())
-               return fullname;
+       // find a uniq postfix for the filename...
+       // using the pid, and...
+       tmpfl += int(getpid());
+       // a short string...
+       LString ret;
+       FileInfo fnfo;
+       for (int a='a'; a<= 'z'; a++)
+               for (int b='a'; b<= 'z'; b++)
+                       for (int c='a'; c<= 'z'; c++) {
+                               // if this is not enough I have no idea what
+                               // to do.
+                               ret = tmpfl + char(a) + char(b) + char(c);
+                               // check if the file exist
+                               if (!fnfo.newFile(ret).exist())
+                                       return ret;
+                       }
+       lyxerr.print("Not able to find a uniq tmpfile name.");
+       return LString();
+}
 
-       if (!build_lyxdir.empty()) 
-         fullname = FileSearch(AddPath(build_lyxdir,dir), 
-                               name, ext);
-       if (!fullname.empty())
-               return fullname;
 
-       return FileSearch(AddPath(system_lyxdir,dir), name, ext);
+
+       //An internal helper to better handle DOS-style paths
+       inline static 
+LString CleanupPath(LString const &path) 
+{
+#ifdef __EMX__   /* SMiyata: This should fix searchpath bug. */
+       LString temppath( lowercase(path) );
+       temppath.subst('\\', '/');
+       return temppath;
+#else // On unix, nothing to do
+       return path;
+#endif
 }
 
-LString i18nLibFileSearch(LString const & dir, LString const & name, 
-                         LString const & ext)
+       //AHanses: An internal helper for OS-ly correct removal of files
+       inline static int 
+LyX_FilesRemove(char const *name)
 {
-       LString lang = LString(getenv("LANG")).token('_',0);
-
-       if (lang.empty())
-               return LibFileSearch(dir, name, ext);
-       else {
-               LString tmp = LibFileSearch(dir, lang + '_' + name,
-                                           ext);
-               if (!tmp.empty())
-                       return tmp;
-               else
-                       return LibFileSearch(dir, name, ext);
+       if (remove(name))
+       {
+#ifdef __EMX__ //This is a hack around a (%?!*@) special 'feature' of emx
+               if (errno == EACCES)    /* Yes, indeed: When previewing LyX' own */
+               { /* tmp-file is locked (forbidden) for LyX! EMX-Doc's say: 
+                  * "If the file is open in any process, remove() sets errno to
+                  *  EACCESS (Nr. 13: Permission denied!) and returns -1
+                  * */
+                       WriteFSAlert(
+       _("File locked! Waiting...: First close all previewers for:"),  name
+                       );
+                       /* Let user call the security officer for getting access */
+                       lyxerr.print("EACCES: remove(): File is open in any process! 
+Sleepin'...");
+                       /* Wait 'til he knows LyX's allowed to delete own files  */
+                       sleep(2);
+               
+                       if (remove(name) && errno == EACCES) 
+                       {
+                               WriteFSAlert( 
+       _("Still locked! Try at first to really close all viewers for:"), name
+                               );
+                               sleep(2);
+                       lyxerr.print("EACCES: remove(): File still open! Sleepin' 
+again...");
+                               if (remove(name) && errno == EACCES) {
+                                       lyxerr.print (
+       "remove(): EACCES: Still open! Givin' up for now..."
+                                       );
+                                       return -1;
+                               }
+                               return 0;
+                       }
+               }
+#endif //AHanses: virtually no overhead on unix
+       return -1;
        }
+return 0;
 }
 
 
-static
-int DeleteAllFilesInDir (LString const & path)
+       inline static int 
+DeleteAllFilesInDir (LString const & oldpath)
 {
-       DIR * dir;
+       DIR *dir;
        struct dirent *de;
+       LString const path = CleanupPath(oldpath);
        dir = opendir(path.c_str());
        if (!dir) {
                WriteFSAlert (_("Error! Cannot open directory:"), path);
                return -1;
@@ -322,18 +347,22 @@ int DeleteAllFilesInDir (LString const &
                LString unlinkpath = AddName (path, temp);
 
                lyxerr.debug("Deleting file: " + unlinkpath);
 
-               if (remove (unlinkpath.c_str()))
-                       WriteFSAlert (_("Error! Could not remove file:"), 
-                                     unlinkpath);
-        }
+               for (int i = 0; i < 2; i++) /* try to clean up 2x (AHanses) */
+               {                       //This is important if space (quota) is limited
+                       if( LyX_FilesRemove(unlinkpath.c_str()) )
+                               
+                               WriteFSAlert ( _("Error! Could not remove file:"), 
+                                                               unlinkpath );
+                       else break;
+               }
+       }
        closedir (dir);
        return 0;
 }
 
-
-static
+       inline static
 LString CreateTmpDir (LString const & tempdir, LString const & mask)
 {
        LString tmpfl = TmpFileName(tempdir, mask);
        
@@ -345,10 +374,10 @@ LString CreateTmpDir (LString const & te
        return MakeAbsPath(tmpfl);
 }
 
 
-static
-int DestroyTmpDir (LString const & tmpdir, bool Allfiles)
+       inline static int 
+DestroyTmpDir (LString const & tmpdir, bool Allfiles)
 {
        if ((Allfiles) && (DeleteAllFilesInDir (tmpdir))) return -1;
        if (rmdir(tmpdir.c_str())) { 
 #ifdef __EMX__
@@ -370,9 +399,10 @@ LString CreateBufferTmpDir (LString cons
        return CreateTmpDir (pathfor, "lyx_bufrtmp");
 }
 
 
-int DestroyBufferTmpDir (LString const & tmpdir)
+       int
+DestroyBufferTmpDir (LString const & tmpdir)
 {
        return DestroyTmpDir (tmpdir, true);
 }
 
@@ -405,18 +435,23 @@ LString CreateLyXTmpDir (LString const &
        }
 }
 
 
-int DestroyLyXTmpDir (LString const & tmpdir)
+       int
+DestroyLyXTmpDir (LString const & tmpdir)
 {
-       return DestroyTmpDir (tmpdir, false); // Why false?
+#ifndef __EMX__
+       return DestroyTmpDir (tmpdir, false); // Why false...?
+#else
+       return DestroyTmpDir (tmpdir, true); // AHanses: false...?
+#endif
 }
 
 
-// Creates directory. Returns true if succesfull
+       // Creates directory. Returns true if succesfull
 bool createDirectory(LString const & path, int permission)
 {
-       LString temp = path;
+       LString temp = CleanupPath(path); // Cleaner is better...
        
        // Cut off trailing /s
        temp.strip('/');
 
@@ -433,12 +468,12 @@ bool createDirectory(LString const & pat
        return true;
 }
 
 
-// Returns current working directory
-LString GetCWD ()
+       // Returns current working directory
+LString GetCWD()
 {
-       int n = 256;    // Assume path is less than 256 chars
+       int n = MAXPATHLEN;     // Assume path is less than MAXPATHLEN chars
        char * err;
        char * tbuf = new char [n];
        LString result;
        
@@ -451,60 +486,88 @@ LString GetCWD ()
        }
 
        if (err) result = tbuf;
        delete[] tbuf;
-       return result;
+       return CleanupPath(result); /* AHanses: Just for paranoia, 
+                               ** for getcwd(), cf. "os2_defines.h" */
 }
 
 
 // Strip filename from path name
-LString OnlyPath(LString const &Filename)
+LString OnlyPath(LString const &oldname)
 {
        // If empty filename, return empty
-       if (Filename.empty()) return Filename;
+       if (oldname.empty()) return oldname;
 
        // Find last / or start of filename
-       int j = Filename.length() - 1;
-       for (; j > 0 && Filename[j] != '/'; j--);
+       LString const name = CleanupPath(oldname); // Cleaner is better...
+       int j = name.length() - 1;
+       for (; j > 0 && name[j] != '/'; j--);
 
-       if (Filename[j] != '/')
+       if (name[j] != '/')
                return "./";
        else {
                // Strip to pathname
-               LString temp = Filename;
+               LString temp = name;
                return temp.substring(0, j);
        }
 }
 
 
-// Convert relative path into absolute path based on a basepath.
-// If relpath is absolute, just use that.
+// Is a (clean; AHanses) filename/path absolute?
+       bool
+AbsolutePath(LString const &path)
+{
+#ifndef __EMX__
+       return (!path.empty() && path[0]=='/');
+#else
+       LString const cleanpath = CleanupPath(path);
+       return (
+               !cleanpath.empty() && (
+                       cleanpath[0]=='/' || (
+                               isalpha( (unsigned char)cleanpath[0] )
+                               && cleanpath[1] == ':'
+                       )
+               )
+       );
+#endif
+}
+
+
+// Convert (cleaned) relative path into absolute path based on
+// a (cleaned) basepath. If relpath is absolute, just use that.
 // If basepath is empty, use CWD as base.
-LString MakeAbsPath(LString const &RelPath, LString const &BasePath)
+/* Note: EMX-hacks are very complicated here; is it possible to 
+   move them all to a library that fakes a POSIX FS: '/mnt/c:', 
+   '/mnt/d:',..., etc.? (AHanses).
+   */
+LString MakeAbsPath(LString const &oldRelPath, 
+                               LString const &oldBasePath)
 {
+       LString const RelPath  = CleanupPath(oldRelPath);
+       LString const BasePath = CleanupPath(oldBasePath);
+
        // checks for already absolute path
        if (AbsolutePath(RelPath))
-#ifdef __EMX__
-               if(RelPath[0]!='/')
+#ifdef __EMX__ /* We may stick in wrong current drive! */
+               if (RelPath[0] != '/')
 #endif
-               return RelPath;
+                       return RelPath;
 
        // Copies given paths
-       LString TempRel = RelPath;
-
-       LString TempBase;
+       LString TempBase, TempRel = RelPath;
 
        if (!BasePath.empty()) {
 #ifndef __EMX__
                TempBase = BasePath;
 #else
-               char* with_drive = new char[_MAX_PATH];
+               char *with_drive = new char[_MAX_PATH];
                _abspath(with_drive, BasePath.c_str(), _MAX_PATH);
                TempBase = with_drive;
                delete[] with_drive;
 #endif
        } else
-               TempBase = GetCWD(); //safer_getcwd();
+               TempBase = GetCWD(); // safer_getcwd();
 #ifdef __EMX__
        if (AbsolutePath(TempRel))
                return TempBase.substring(0,1) + TempRel;
 #endif
@@ -549,133 +612,178 @@ LString MakeAbsPath(LString const &RelPa
        return TempBase;        
 }
 
 
-// Correctly append filename to the pathname.
-// If pathname is '.', then don't use pathname.
-// Chops any path of filename.
-LString AddName(LString const &Path, LString const &FileName)
+// Uses a string of paths separated by ";"s to find a file to open.
+// Can't cope with pathnames with a ';' in them. Returns full path to
+// file.
+// If path entry begins with $$LyX/, use system_lyxdir
+// If path entry begins with $$User/, use user_lyxdir
+// Example: "$$User/doc;$$LyX/doc"
+// [On OS/2 (emx)] then try [EXE_EXTENSION; REXX_EXTENSION;]
+// BOURNE_SHELL_EXT; KSH_EXT, CSHELL_EXT; and whatever you want to add...
+LString FileOpenSearch(LString const & path, LString const & oldname, 
+                       LString const & ext)
 {
-       // Get basename
-       LString Basename = OnlyFilename(FileName);
+       LString path_element, real_file;
+       LString const name = CleanupPath(oldname);
+       bool notfound = true;
+       
+       LString tmppath = CleanupPath(path);
+       tmppath.split(path_element, ';');
 
-       LString buf;
+       while (notfound && !path_element.empty()) {
 
-       if (Path != "." && Path != "./" && !Path.empty()) {
-               buf = Path;
-               if (!Path.suffixIs('/'))
-                       buf += '/';
-       }
+               if (!path_element.suffixIs('/'))
+                       path_element += '/';
+               path_element.subst("$$LyX", system_lyxdir);
+               path_element.subst("$$User", user_lyxdir);
+               
+               real_file = FileSearch(path_element, name, ext);
 
-       return buf + Basename;
+               if (real_file.empty()) {
+                 tmppath.split(path_element, ';');
+               } else {
+                 notfound = false;
+               }
+       
+               if (ext.empty() && notfound) {
+                       assert( ExtList[( 
+                           sizeof(ExtList) / ( sizeof(ExtList[0]) )
+                         ) -1
+                       ] == NULL);                     // bounds check (AHanses)
+
+                       for ( LString const *EL_p = ExtList; !((*EL_p).empty());
+                                        EL_p++ )
+                       {
+                               real_file = FileSearch(path_element, name, *EL_p);
+                                                       
+                               if ( !(real_file.empty()) ) {
+                                       notfound = false;
+                                       break;  /* Why do I always forget
+                                               ** the break? ;) (AHanses) */
+                               }
+                       }
+               }
+       }
+       return real_file;
 }
 
 
-// Strips path from filename
-LString OnlyFilename(LString const &Filename)
+// Returns the real name of file `name' in directory `dirpath', with
+// optional extension ext.  
+LString FileSearch(LString const & dirpath, LString const & name, 
+                  LString const & ext)
 {
-       // If empty filename, return empty
-       if (Filename.empty()) return Filename;
+       // if `name' is an absolute path, we ignore the setting of `dirpath'
+       // Expand Environmentvariables in 'name'; path cleanup (Arnd)
+       // LString const name = ReplaceEnvironmentPath(oldname);
+       LString fullname = MakeAbsPath( ReplaceEnvironmentPath(name), dirpath );
 
-       int j;
-       // Find last / or start of filename
-       for (j=Filename.length()-1; Filename[j] != '/' && j>0; j--);
-
-       // Skip potential /
-       if (j!=0) j++;
-
-       // Strip to basename
-       LString temp = Filename;
-       return temp.substring(j, temp.length()-1);
+       // search first without extension, then with it.
+       if (IsFileReadable(fullname))
+               return fullname;
+       else if(ext.empty()) 
+               return LString();
+       else { 
+#warning Is it not more reasonable to use ChangeExtension()? (SMiyata)
+               fullname += '.';
+               fullname += ext;
+               if (IsFileReadable(fullname))
+                       return fullname;
+               else 
+                       return LString();
+       }
 }
 
 
-// Is a filename/path absolute?
-bool AbsolutePath(LString const &path)
+// Search the file name.ext in the subdirectory dir of
+//   1) user_lyxdir
+//   2) build_lyxdir (if not empty)
+//   3) system_lyxdir
+LString LibFileSearch(LString const & dir, LString const & oldname, 
+                     LString const & ext)
 {
-#ifndef __EMX__
-       return (!path.empty() && path[0]=='/');
-#else
-       return (!path.empty() && (path[0]=='/' || (isalpha((unsigned char) path[0]) && 
path[1]==':')));
-#endif
-}
+       LString const name = CleanupPath(oldname);
+       LString fullname = FileSearch(AddPath(user_lyxdir,dir), name,
+                                ext);      
+       if (!fullname.empty())
+               return fullname;
 
+       if (!build_lyxdir.empty()) 
+         fullname = FileSearch(AddPath(build_lyxdir,dir), 
+                               name, ext);
+       if (!fullname.empty())
+               return fullname;
 
-// Create absolute path. If impossible, don't do anything
-// Supports ./ and ~/. Later we can add support for ~logname/. (Asger)
-LString ExpandPath(LString const &path)
+       return FileSearch(AddPath(system_lyxdir,dir), name, ext);
+}
+
+LString i18nLibFileSearch(LString const & dir, LString const & oldname, 
+                         LString const & ext)
 {
-       // checks for already absolute path
-       LString RTemp = ReplaceEnvironmentPath(path);
-       if (AbsolutePath(RTemp))
-               return RTemp;
+       LString const name = CleanupPath(oldname);
+       LString const lang = LString(getenv("LANG")).token('_',0);
 
-       LString Temp;
-       LString copy(RTemp);
+       if (lang.empty())
+               return LibFileSearch(dir, name, ext);
+       else {
+               LString tmp = LibFileSearch(dir, lang + '_' + name,
+                                           ext);
+               if (!tmp.empty())
+                       return tmp;
+               else
+                       return LibFileSearch(dir, name, ext);
+       }
+}
 
-       // Split by next /
-       RTemp.split(Temp, '/');
+       // Strips (cleaned; AHanses) path from filename
+LString OnlyFilename(LString const &oldname)
+{
+       // If empty filename, return empty
+       if (oldname.empty()) return oldname;
 
-       if (Temp==".") {
-               return GetCWD() + '/' + RTemp;
-       } else if (Temp=="~") {
-               return getEnvPath("HOME") + '/' + RTemp;
-       } else if (Temp=="..") {
-               return MakeAbsPath(copy);
-       } else
-               // Don't know how to handle this
-               return copy;
+       // Find last / or start of filename
+       LString const name = CleanupPath(oldname);
+       int j;
+       for (j = name.length() -1; name[j] != '/' && j > 0; j--);
+                               
+       // Skip potential /
+       if (j != 0) j++;
+
+       // Strip to basename
+       LString temp = name;
+       return temp.substring( j, temp.length() -1 );
 }
 
 
-// Normalize a path
-// Constracts path/../path
-// Can't handle "../../" or "/../" (Asger)
-LString NormalizePath(LString const &path)
+// Correctly append filename to the pathname after cleanup.
+// If pathname is '.', then don't use pathname.
+// Chops any path of filename.
+LString AddName(LString const &oldPath, LString const &fileName)
 {
-       LString TempBase;
-       LString RTemp;
-       LString Temp;
+       // Get basename
+       LString const baseName = OnlyFilename(fileName); // cleanup too (AHanses)
+       LString const path = CleanupPath(oldPath);
 
-       if (AbsolutePath(path))
-               RTemp = path;
-       else
-               // Make implicit current directory explicit
-               RTemp = "./" +path;
+       LString buf;
 
-       while (!RTemp.empty()) {
-               // Split by next /
-               RTemp.split(Temp, '/');
-               
-               if (Temp==".") {
-                       TempBase = "./";
-               } else if (Temp=="..") {
-                       // Remove one level of TempBase
-                       int i = TempBase.length()-2;
-                       while (i>0 && TempBase[i] != '/')
-                               i--;
-                       if (i>=0 && TempBase[i] == '/')
-                               TempBase.substring(0, i);
-                       else
-                               TempBase = "../";
-               } else {
-                       TempBase += Temp + '/';
-               }
+       if (path != "." && path != "./" && !path.empty()) {
+               buf = path;
+               if (!path.suffixIs('/'))
+                       buf += '/';
        }
-
-       // returns absolute path
-       return TempBase;        
+       return buf + baseName;
 }
 
 
 //
 // Search ${...} as Variable-Name inside the string and replace it with
 // the denoted environmentvariable
-// Allow Variables according to 
-//  variable :=  '$' '{' [A-Za-z_]{[A-Za-z_0-9]*} '}'
-//
-
-LString ReplaceEnvironmentPath(LString const &path)
+       // Allow Variables according to 
+       // variable :=  '$' '{' [A-Za-z_]{[A-Za-z_0-9]*} '}'
+       // Return empty or cleaned path (AHanses)
+LString ReplaceEnvironmentPath(LString const &oldPath)
 {
 // 
 // CompareChar: Environmentvariables starts with this character
 // PathChar:    Next path component start with this character
@@ -683,22 +791,24 @@ LString ReplaceEnvironmentPath(LString c
 //       Split String with PathChar
 //      Search Environmentvariable
 //      if found: Replace Strings
 //
-       const char CompareChar = '$';
-       const char FirstChar = '{'; 
-       const char EndChar = '}'; 
-       const char UnderscoreChar = '_'; 
+       const char CompareChar =                COMPARE_CHAR;
+       const char FirstChar =                  FIRST_CHAR; 
+       const char EndChar =                            END_CHAR;
+       const char UnderscoreChar =     UNDERSCORE_CHAR;
        const LString EndString(EndChar);
        const LString FirstString(FirstChar);
        const LString CompareString(CompareChar);
-       const LString RegExp("*}*"); // Exist EndChar inside a String?
+       const LString RegExp(REGEX); // Exist EndChar inside a String?
 
-       if (path.empty()) return path; // nothing to do.
+       if (oldPath.empty()) return oldPath; // nothing to do.
+
+       LString const path = CleanupPath(oldPath);
 
 // first: Search for a '$' - Sign.
        LString copy(path);
-    LString result1(copy);    // for split-calls
+       LString result1(copy);    // for split-calls
        LString result0 = copy.split(result1, CompareChar);
        while (!result0.empty()) {
                LString copy1(result0); // contains String after $
                
@@ -761,19 +871,89 @@ LString ReplaceEnvironmentPath(LString c
        return result1;
 }  // ReplaceEnvironmentPath
 
 
-// Make relative path out of two absolute paths
-LString MakeRelPath(LString const & abspath, LString const & basepath)
+// Create (clean; AHanses) absolute path. If impossible, don't do anything
+// Supports ./ and ~/. Later we can add support for ~logname/. (Asger)
+LString ExpandPath(LString const &path)
+{
+       // checks for already absolute path
+       LString RTemp = ReplaceEnvironmentPath(path);
+       if (AbsolutePath(RTemp))
+               return RTemp;
+
+       LString Temp;
+       LString copy(RTemp);
+
+       // Split by next /
+       RTemp.split(Temp, '/');
+
+       if (Temp==".") {
+               return GetCWD() + '/' + RTemp;
+       } else if (Temp=="~") {
+               return CleanupPath(getEnvPath("HOME")) + '/' + RTemp;
+       } else if (Temp=="..") {
+               return MakeAbsPath(copy);
+       } else
+               // Don't know how to handle this
+               return copy;
+}
+
+
+// Normalize a (cleaned; AHanses) path
+       // Constracts path/../path
+       // Can't handle "../../" or "/../" (Asger)
+LString NormalizePath(LString const &oldPath)
+{
+       LString const path = CleanupPath(oldPath);
+       LString TempBase, RTemp, Temp;
+
+       if (AbsolutePath(path))
+               RTemp = path;
+       else
+               // Make implicit current directory explicit
+               RTemp = "./" + path;
+
+       while (!RTemp.empty()) {
+               // Split by next /
+               RTemp.split(Temp, '/');
+               
+               if (Temp==".") {
+                       TempBase = "./";
+               } else if (Temp=="..") {
+                       // Remove one level of TempBase
+                       int i = TempBase.length()-2;
+                       while (i>0 && TempBase[i] != '/')
+                               i--;
+                       if (i>=0 && TempBase[i] == '/')
+                               TempBase.substring(0, i);
+                       else
+                               TempBase = "../";
+               } else {
+                       TempBase += Temp + '/';
+               }
+       }
+
+       // returns absolute path
+       return TempBase;        
+}
+
+
+       // Make relative path out of two (cleaned) absolute paths
+LString MakeRelPath(LString const & oldAbsPath, LString const & OldBasePath)
+
 // Makes relative path out of absolute path. If it is deeper than basepath,
 // it's easy. If basepath and abspath share something (they are all deeper
 // than some directory), it'll be rendered using ..'s. If they are completely
 // different, then the absolute path will be used as relative path.
 {
        // This is a hack. It should probaly be done in another way. Lgb.
-       if (abspath.empty())
+       if (oldAbsPath.empty())
                return "<unknown_path>";
 
+       LString const abspath = CleanupPath(oldAbsPath);
+       LString const basepath = CleanupPath(OldBasePath);
+
        const int abslen = abspath.length();
        const int baselen = basepath.length();
        
        // Find first different character
@@ -820,10 +1000,12 @@ LString MakeRelPath(LString const & absp
 }
 
 
 // Append sub-directory(ies) to a path in an intelligent way
-LString AddPath(LString const & path, LString const & path2)
+LString AddPath(LString const & oldPath, LString const & oldPath2)
 {
+       LString const path  = CleanupPath(oldPath);
+       LString const path2 = CleanupPath(oldPath2);
        LString buf;
 
        if (!path.empty() && path != "." && path != "./") {
                buf = path;
@@ -863,12 +1045,13 @@ LString ChangeExtension(LString const & 
                ext = "." + extension;
        else
                ext = extension;
 
+       LString const name = CleanupPath(oldname);
        // Go back to the first dot not crossing any /
-       for (dot=n; dot>=0 && oldname[dot]!='.' && oldname[dot]!='/'; dot--);
+       for (dot=n; dot>=0 && name[dot] != '.' && name[dot] != '/'; dot--);
    
-       if (dot==-1 || oldname[dot]!='.')
+       if (dot==-1 || name[dot]!='.')
                // If no extension was found, we use the end of the string
                dot = n;
        else
                // Remove the dot, because the new extension includes it
@@ -876,30 +1059,30 @@ LString ChangeExtension(LString const & 
 
        // "path" points to last / or 0 if path is wanted
        int path = 0;
        if (no_path) {
-               for (path=dot; path && oldname[path]!='/';path--);
-               if (oldname[path]=='/')
+               for (path = dot; path && name[path] != '/'; path--);
+               if (name[path] == '/')
                        path++;
        } else 
                path = 0;
 
-       LString result = oldname;
+       LString result = name;
        result.substring(path,dot);
        if (!ext.empty())
                result += ext;
        return result;
 }
 
 
-// Creates a nice compact path for displaying
+       // Creates a nice compact (cleaned) path for displaying
 LString MakeDisplayPath (LString const & path, int threshold)
 {
        const int l1 = path.length();
 
        // First, we try a relative path compared to home
-       LString home = getEnvPath("HOME");
-       LString relhome = MakeRelPath(path, home);
+       LString home = CleanupPath(getEnvPath("HOME"));
+       LString relhome = MakeRelPath(path, home); // Already clean
 
        int l2 = relhome.length();
 
        LString prefix;
@@ -907,9 +1090,9 @@ LString MakeDisplayPath (LString const &
        // If we backup from home or don't have a relative path,
        // this try is no good
        if (relhome.prefixIs("../") || AbsolutePath(relhome)) {
                // relative path was no good, just use the original path
-               relhome = path;
+               relhome = CleanupPath(path);
                l2 = l1;
        } else {
                prefix = "~/";
        }
@@ -927,9 +1110,9 @@ LString MakeDisplayPath (LString const &
                // Did we shortend everything away?
                if (relhome.empty()) {
                        // Yes, filename in itself is too long.
                        // Pick the start and the end of the filename.
-                       relhome = OnlyFilename(path);
+                       relhome = OnlyFilename(path); // Already clean
                        LString head = relhome;
                        head.substring(0, threshold/2 - 3);
 
                        LString tail = relhome;
@@ -943,10 +1126,11 @@ LString MakeDisplayPath (LString const &
 }
 
 bool LyXReadLink(LString const & File, LString & Link)
 {
-       char LinkBuffer[512];
+       char LinkBuffer[PATH_MAX];      // 512 as fallback
                 // Should be PATH_MAX but that needs autconf support
+               // AHanses: Cf. beginning filetools.C
        int nRead;
        nRead = readlink(File.c_str(), LinkBuffer,sizeof(LinkBuffer)-1);
        if (nRead <= 0)
                return false;
diff -p -N -r -U 4 -X excl.tmp src/original_LyX-1.0.3/filetools.h 
src/modified/filetools.h
--- src/original_LyX-1.0.3/filetools.h  Wed May 12 06:51:22 1999
+++ src/modified/filetools.h    Wed Jul 28 06:17:06 1999
@@ -78,35 +78,41 @@ private:
        void do_open(LString const &name, file_mode mode) {
                char modestr[3];
                
                switch(mode) {
-                       // do appropiate #ifdef here so support EMX
-#ifndef __EMX__
-               case read: strcpy(modestr, "r"); break;
-               case write: strcpy(modestr, "w"); break;
-#else
-               case read: strcpy(modestr,"rt"); break; // Can read both DOS & UNIX 
text files.
-               case write: strcpy(modestr,"w"); break; // Write UNIX text files.
-#endif
-                       
-               case update: strcpy(modestr, "r+"); break;
+// AHanses: DOS text mode 't' support: 't' should be correctly 
+// ignored by all Unices with ANSI compatible compilers
+               // Can read both DOS & UNIX text files.
+               case read: strcpy(modestr,"rt"); break;
+               // Write UNIX text files. 
+               case write: strcpy(modestr,"w"); break;
+               // Can read both DOS & UNIX text files.
+               case update: strcpy(modestr, "r+t"); break;
                case truncate: strcpy(modestr, "w+"); break;
                }
                // Should probably be rewritten to use open(2)
-               if((p = fopen(name.c_str(), modestr))) {
+               if((p = fopen(name.c_str(), modestr)))
+               {
                        // file succesfully opened.
-                       if (fcntl(fileno(p),F_SETFD,FD_CLOEXEC) == -1) {
+                       if (fcntl(fileno(p), F_SETFD, FD_CLOEXEC) == -1)
+                       {
                                p = 0;
                        }
                } else {
                        // we have an error let's check what it is.
                        switch(errno) {
                        case EINVAL:
                                // Internal LyX error.
-                               lyxerr.print("FilePtr: Wrong parameter given to 
fopen.");
+                               lyxerr.print (
+                               "FilePtr: fopen(): Wrong parameter."
+                               );
                                break;
                        default:
                                // unknown error
+                               lyxerr.print 
+                               (
+                               "FilePtr: fopen(): Unknown error."
+                               );
                                break;
                        }
                }
        }
@@ -133,21 +139,26 @@ int DestroyBufferTmpDir (LString const &
 int DestroyLyXTmpDir (LString const & tmpdir);
 
 /** Find file by searching several directories.
   Uses a string of paths separated by ";"s to find a file to open.
-    Can't cope with pathnames with a ';' in them. Returns full path to file.
+  Can't cope with pathnames with a ';' in them. Returns full path to
+  file.
     If path entry begins with $$LyX/, use system_lyxdir.
     If path entry begins with $$User/, use user_lyxdir.
     Example: "$$User/doc;$$LyX/doc".
-*/
+ */
 LString FileOpenSearch (LString const & path, LString const & name, 
                        LString const & ext = LString());
 
 /** Returns the real name of file name in directory path, with optional
   extension ext.
   The file is searched in the given path (unless it is an absolute
   file name), first directly, and then with extension .ext (if given).
+  [On OS/2 (emx)] then try [EXE_EXTENSION; REXX_EXTENSION;] BOURNE_SHELL_EXT;
+  KSH_EXT, CSHELL_EXT; and whatever you want to add...
   */
+
+
 LString FileSearch(LString const & path, LString const & name, 
                   LString const & ext = LString());
 
 /** Is directory read only?
@@ -184,9 +195,9 @@ bool IsSGMLFilename(LString const & file
     \item build_lyxdir (if not empty)
     \item system_lyxdir
   \end{enumerate}
     The third parameter `ext' is optional.
-*/
+ */
 LString LibFileSearch(LString const & dir, LString const & name, 
                      LString const & ext = LString());
 
 /** Same as LibFileSearch(), but tries first to find an
@@ -214,13 +225,13 @@ LString AddName(LString const &Path, LSt
 
 /// Append sub-directory(ies) to path in an intelligent way
 LString AddPath(LString const & path, LString const & path2);
 
-/** Change extension of oldname to extension.
- If no_path is true, the path is stripped from the filename.
- If oldname does not have an extension, it is appended.
- If the extension is empty, any extension is removed from the name.
- */
+/* Change extension of oldname to extension.
+** If no_path is true, the path is stripped from the filename.
+** If oldname does not have an extension, it is appended.
+** If the extension is empty, any extension is removed from the name.
+*/
 LString ChangeExtension(LString const & oldname, LString const & extension, 
                        bool no_path);
 
 /// Create absolute path. If impossible, don't do anything
@@ -228,8 +239,25 @@ LString ExpandPath(LString const &path);
 
 /// gets current working directory
 LString GetCWD();
 
+
+//OS specific hacks wrapped here to get a cleaner code base:
+
+//Should fix DOS-style path handling.
+inline 
+LString CleanupPath(LString const &path) 
+{
+#ifdef __EMX__   /* SMiyata: This should fix searchpath bug. */
+       LString temppath(path);
+       temppath.subst('\\', '/');
+       temppath.lowercase();
+       return temppath;
+#else // On unix, nothing to do
+       return path;
+#endif
+}
+
 /// A helper function.
 inline LString getEnvPath(char const *name)
 {
        LString pathlist;
@@ -276,8 +304,25 @@ LString OnlyFilename(LString const &File
     Replaces all occurences of these, if they are found in the
     environment.
     Variables are defined by Var := '${' [a-zA-Z_][a-zA-Z_0-9]* '}'
 */
+// 
+// CompareChar: Environmentvariables starts with this character
+// PathChar:    Next path component start with this character
+// while CompareChar found do:
+//       Split String with PathChar
+//      Search Environmentvariable
+//      if found: Replace Strings
+//
+// first: Search for a '$' - Sign.
+#define        COMPARE_CHAR    '$'
+#define FIRST_CHAR     '{'
+
+// Check, if there is an EndChar inside original String.
+#define END_CHAR       '}'
+#define UNDERSCORE_CHAR        '_'
+#define        REGEX   "*}*" // Exist EndChar inside a String?
+
 LString ReplaceEnvironmentPath(LString const &path);
 
 /* Set Link to the path File Points to as a symbolic link.
    Return True if succesfull, False other wise */
diff -p -N -r -U 4 -X excl.tmp src/original_LyX-1.0.3/insetbib.C 
src/modified/insetbib.C
--- src/original_LyX-1.0.3/insetbib.C   Mon Apr 12 18:52:54 1999
+++ src/modified/insetbib.C     Tue Aug  3 22:26:00 1999
@@ -412,10 +412,12 @@ LString InsetBibtex::getKeys()
                                if ( c == '\n') {
                                        if ( linebuf.prefixIs("@") ) {
                                                linebuf.subst('{','(');
                                                linebuf.split(tmp,'(');
-                                               tmp.lowercase();
-                                               if ( ! tmp.prefixIs("@string") && 
!tmp.prefixIs("@preamble") ) {
+                                               tmp = lowercase(tmp);
+                                               if ( ! tmp.prefixIs("@string") &&
+                                                       !tmp.prefixIs("@preamble") )
+                                               {
                                                        linebuf.split(tmp,',');
                                                        if (!tmp.empty())
                                                                keys +=tmp.strip()+",";
                                                }
diff -p -N -r -U 4 -X excl.tmp src/original_LyX-1.0.3/LString.C src/modified/LString.C
--- src/original_LyX-1.0.3/LString.C    Mon Oct 26 15:17:18 1998
+++ src/modified/LString.C      Tue Aug  3 22:15:14 1999
@@ -521,16 +521,8 @@ LString& LString::subst(char const * old
        return *this=lstr;
 }
 
 
-LString& LString::lowercase()
-{
-       for (int i=0; i<length() ; i++)
-               p->s[i] = tolower((unsigned char) p->s[i]);
-       return *this;
-}
-
-
 bool LString::regexMatch(LString const & pattern) const
 {
        if (pattern.empty())
                return true;
diff -p -N -r -U 4 -X excl.tmp src/original_LyX-1.0.3/LString.h src/modified/LString.h
--- src/original_LyX-1.0.3/LString.h    Mon Oct 26 15:17:20 1998
+++ src/modified/LString.h      Thu Aug  5 01:34:10 1999
@@ -26,8 +26,12 @@
 // should go (JMarc)
 #include <strings.h>
 #else
 #include <string.h>
+# ifdef __EMX__ /* AHanses: Macros handling most (non-ASCII) chars 
+               ** correctly according to locale; not DBCS(*)-safe */
+#  include <sys/nls.h>         // Cf. (*) DBCS-footnote [1] at the end
+# endif
 #endif
 
 /** A string class for LyX
   
@@ -219,11 +223,8 @@ public:
          The only element allowed is "*" for any string of characters
          */
        bool regexMatch(LString const & pattern) const;
 
-       /// Lowercases a string
-       LString& lowercase();
-
        /// Counts how many of character c there is in string
        int countChar(const char c) const;
 
        /// Position of the character c from the beggining
@@ -392,5 +393,36 @@ inline int LString::charPos(const char c
        }
         return -1;
 }
         
+/// Lowercases a string
+inline LString lowercase(LString const &str)
+{
+       LString tmp(str);
+
+       for (int i = 0; i < tmp.length(); i++)
+
+#ifdef _EMX_   /* AHanses: This macro handles most (non-ASCII) characters 
+               ** according to locale. DBCS[1] unsafe */
+
+               tmp[i] = _nls_tolower((unsigned char) tmp[i]); 
+#else /* unix */
+               tmp[i] = tolower((unsigned char) tmp[i]);
 #endif
+
+       return tmp;
+}
+
+
+#endif /* LString.h */
+
+
+/* Some problems with special (not 8 bit) codepages:
+**
+** [1] 'DBCS': (*) If a double byte codepage is used, OS/2 allows 'Double
+** Byte Code characterS' in the path. Beware: In 'Shift-JIS' and 'Big5'
+** codepages, which are used in asian countries on many PC OS's, the 
+** second byte of a double byte code character may be '\', '/', ':' or 
+** ';'. LyX should handle all those double or (triple) byte codes 
+** correctly; XFree86 4.0 with X-TT-Server patch (Aoi) supports fonts with
+** those code pages.
+*/
\ No newline at end of file
diff -p -N -r -U 4 -X excl.tmp src/original_LyX-1.0.3/lyx_cb.C src/modified/lyx_cb.C
--- src/original_LyX-1.0.3/lyx_cb.C     Tue Jun  1 15:43:56 1999
+++ src/modified/lyx_cb.C       Thu Aug  5 03:18:34 1999
@@ -563,49 +563,59 @@ int MakeDVIOutput(Buffer *buffer)
 /* wait == false means don't wait for termination */
 /* wait == true means wait for termination       */
 // The bool should be placed last on the argument line. (Lgb)
 // Returns false if we fail.
-bool RunScript(Buffer *buffer, bool wait,
+bool 
+RunScript(Buffer *buffer, bool wait,
               LString const & command, LString const & orgname = LString(),
               bool need_shell=true)
 {
-       LString path;
-       LString cmd;
-       LString name= orgname;
-       int result;
+       LString name = orgname;
        
        if (MakeDVIOutput(buffer) > 0)
                return false;
        /* get DVI-Filename */
        if (name.empty())
                name = ChangeExtension(buffer->getFileName(),
                                       ".dvi", true);
 
-       path = OnlyPath(name);
+       LString path = OnlyPath(name);
        if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
                path = buffer->tmppath;
        }
        PathPush(path);
 
-       cmd = command + ' ' + SpaceLess(name);
+       LString cmd = command + ' ' + SpaceLess(name);
        Systemcalls one;
 
-       if (need_shell) {
-#ifndef __EMX__
+       int result;
+       if (need_shell)
+       {
                if (!wait)
-                       cmd += " &";
-#else
-               // OS/2 cmd.exe has another use for '&'
-               if (!wait) {
-                       LString sh = getenv ("EMXSHELL");
+               {
+#ifdef __EMX__
+/* OS/2 standard shell 'cmd.exe' uses '&' like Bourne's ';'
+       ** The following hacks around EMX's DOS (or better CP/M)
+       ** compatible legacy file handling, where 'x:\fOo/BaR' and
+       ** 'X:/FoO\bAr' are valid and *identical* file names!
+       */
+/* non portable EMX C Library fn, should handle DBCS[*] too */
+                       LString sh = _getname( getenv("EMXSHELL") );
+
                        if (sh.empty())
-                               sh = getenv ("COMSPEC");
-                       if (sh.contains("cmd.exe"))
-                               cmd = "start /min/n " + cmd;
+                       {
+                               sh = _getname( getenv("COMSPEC"));
+/* dito */
+                               if (sh.empty()) /* shouldnt' happen */
+                                       sh = "cmd.exe";
+                       }
+                       sh = lowercase(sh); 
+                       if (sh.contains("cmd") || sh.contains("4os2"))
+                               cmd = "START/MIN/N " + cmd;
                        else
+#endif
                                cmd += " &";
                }
-#endif
                // It seems that, if wait is false, we never get back
                // the return code of the command. This means that all
                // the code I added in PrintApplyCB is currently
                // useless...
@@ -2279,9 +2289,8 @@ void CopyCB()
                minibuffer->Set(_("Copy"));
        }
 }
 
-
 void CutCB()
 {
        if (current_view->available()) {
                current_view->getScreen()->HideCursor();
@@ -2291,9 +2300,8 @@ void CutCB()
                minibuffer->Set(_("Cut"));
        }
 }
 
-
 void PasteCB()
 {
        if (!current_view->available()) return;
        
@@ -2313,9 +2321,8 @@ void PasteCB()
        current_view->currentBuffer()->text->ClearSelection();
        current_view->currentBuffer()->update(-2);
 }
 
-
 void MeltCB(FL_OBJECT *, long)
 {
        if (!current_view->available()) return;
        
@@ -2326,17 +2333,15 @@ void MeltCB(FL_OBJECT *, long)
        current_view->currentBuffer()->text->MeltFootnoteEnvironment();
        current_view->currentBuffer()->update(1);
 }
 
-
 // Change environment depth.
 // if decInc == 0, depth change taking mouse button number into account
 // if decInc == 1, increment depth
 // if decInc == -1, decrement depth
 void DepthCB(FL_OBJECT *ob, long decInc)
 {
        int button = 1;
-
        /* When decInc != 0, fake a mouse button. This allows us to
           implement depth-plus and depth-min commands. RVDK_PATCH_5. */
        /* check out wether ob is defined, too (Matthias) */ 
        if ( decInc < 0 )
@@ -2357,33 +2362,29 @@ void DepthCB(FL_OBJECT *ob, long decInc)
                                  " (in possible range, maybe not)"));
        }
 }
 
-
 // This is both GUI and LyXFont dependent. Don't know where to put it. (Asger)
 // Well, it's mostly GUI dependent, so I guess it will stay here. (Asger)
 LyXFont UserFreeFont()
 {
        LyXFont font(LyXFont::ALL_IGNORE);
        int pos;
-
        pos = fl_get_choice(fd_form_character->choice_family);
        switch(pos) {
        case 1: font.setFamily(LyXFont::IGNORE_FAMILY); break;
        case 2: font.setFamily(LyXFont::ROMAN_FAMILY); break;
        case 3: font.setFamily(LyXFont::SANS_FAMILY); break;
        case 4: font.setFamily(LyXFont::TYPEWRITER_FAMILY); break;
        case 5: font.setFamily(LyXFont::INHERIT_FAMILY); break;
        }
-
        pos = fl_get_choice(fd_form_character->choice_series);
        switch(pos) {
        case 1: font.setSeries(LyXFont::IGNORE_SERIES); break;
        case 2: font.setSeries(LyXFont::MEDIUM_SERIES); break;
        case 3: font.setSeries(LyXFont::BOLD_SERIES); break;
        case 4: font.setSeries(LyXFont::INHERIT_SERIES); break;
        }
-
        pos = fl_get_choice(fd_form_character->choice_shape);
        switch(pos) {
        case 1: font.setShape(LyXFont::IGNORE_SHAPE); break;
        case 2: font.setShape(LyXFont::UP_SHAPE); break;
@@ -2391,9 +2392,8 @@ LyXFont UserFreeFont()
        case 4: font.setShape(LyXFont::SLANTED_SHAPE); break;
        case 5: font.setShape(LyXFont::SMALLCAPS_SHAPE); break;
        case 6: font.setShape(LyXFont::INHERIT_SHAPE); break;
        }
-
        pos = fl_get_choice(fd_form_character->choice_size);
        switch(pos) {
        case 1: font.setSize(LyXFont::IGNORE_SIZE); break;
        case 2: font.setSize(LyXFont::SIZE_TINY); break;
@@ -2409,9 +2409,8 @@ LyXFont UserFreeFont()
        case 12: font.setSize(LyXFont::INCREASE_SIZE); break;
        case 13: font.setSize(LyXFont::DECREASE_SIZE); break;
        case 14: font.setSize(LyXFont::INHERIT_SIZE); break;
        }
-
        pos = fl_get_choice(fd_form_character->choice_bar);
        switch(pos) {
        case 1: font.setEmph(LyXFont::IGNORE);
                font.setUnderbar(LyXFont::IGNORE);
@@ -2427,9 +2426,8 @@ LyXFont UserFreeFont()
                font.setNoun(LyXFont::INHERIT);
                font.setLatex(LyXFont::INHERIT);
                break;
        }
-
        pos = fl_get_choice(fd_form_character->choice_color);
        switch(pos) {
        case 1: font.setColor(LyXFont::IGNORE_COLOR); break;
        case 2: font.setColor(LyXFont::NONE); break;
@@ -2442,19 +2440,16 @@ LyXFont UserFreeFont()
        case 9: font.setColor(LyXFont::MAGENTA); break;
        case 10: font.setColor(LyXFont::YELLOW); break;
        case 11: font.setColor(LyXFont::INHERIT_COLOR); break;
        }
-
        return font; 
 }
 
-
 void FreeCB()
 {
        ToggleAndShow(UserFreeFont());
 }
 
-
 /* callbacks for form form_title */
 void TimerCB(FL_OBJECT *, long)
 {
        // only if the form still exists
@@ -2466,18 +2461,14 @@ void TimerCB(FL_OBJECT *, long)
                fd_form_title->form_title = NULL;
        }
 }
 
-
 /* callbacks for form form_paragraph */
-
 void ParagraphVSpaceCB(FL_OBJECT* obj, long )
 {
        // "Synchronize" the choices and input fields, making it
        // impossible to commit senseless data.
-
        const FD_form_paragraph* fp = fd_form_paragraph;
-
        if (obj == fp->choice_space_above) {
                if (fl_get_choice (fp->choice_space_above) != 7) {
                        fl_set_input (fp->input_space_above, "");
                        ActivateParagraphButtons();
@@ -2488,9 +2479,8 @@ void ParagraphVSpaceCB(FL_OBJECT* obj, l
                        ActivateParagraphButtons();
                }
        } else if (obj == fp->input_space_above) {
                LString input = fl_get_input (fp->input_space_above);
-
                if (input.empty()) {
                        fl_set_choice (fp->choice_space_above, 1);
                        ActivateParagraphButtons();
                }
@@ -2503,9 +2493,8 @@ void ParagraphVSpaceCB(FL_OBJECT* obj, l
                        DeactivateParagraphButtons();
                }
        } else if (obj == fp->input_space_below) {
                LString input = fl_get_input (fp->input_space_below);
-
                if (input.empty()) {
                        fl_set_choice (fp->choice_space_below, 1);
                        ActivateParagraphButtons();
                }
@@ -2519,9 +2508,8 @@ void ParagraphVSpaceCB(FL_OBJECT* obj, l
                }
        }
 }
 
-
 void ParagraphApplyCB(FL_OBJECT *, long)
 {
        if (!current_view->available())
                return;
@@ -2531,9 +2519,8 @@ void ParagraphApplyCB(FL_OBJECT *, long)
        VSpace space_top, space_bottom;
        char align;
        LString labelwidthstring;
        bool noindent;
-
        // If a vspace kind is "Length" but there's no text in
        // the input field, reset the kind to "None". 
        if (fl_get_choice (fd_form_paragraph->choice_space_above) == 7
            && !*(fl_get_input (fd_form_paragraph->input_space_above))) {
@@ -2569,9 +2556,8 @@ void ParagraphApplyCB(FL_OBJECT *, long)
        case 7: space_bottom = VSpace(LyXGlueLength (fl_get_input 
(fd_form_paragraph->input_space_below))); break;
        }
        if (fl_get_button (fd_form_paragraph->check_space_below))
          space_bottom.setKeep (true);
-
        if (fl_get_button(fd_form_paragraph->radio_align_left))
                align = LYX_ALIGN_LEFT;
        else if (fl_get_button(fd_form_paragraph->radio_align_right))
                align = LYX_ALIGN_RIGHT;
@@ -2595,24 +2581,20 @@ void ParagraphApplyCB(FL_OBJECT *, long)
        current_view->currentBuffer()->update(1);
        minibuffer->Set(_("Paragraph layout set"));
 }
 
-
 void ParagraphCancelCB(FL_OBJECT *, long)
 {
        fl_hide_form(fd_form_paragraph->form_paragraph);
 }
 
-
 void ParagraphOKCB(FL_OBJECT *ob, long data)
 {
        ParagraphApplyCB(ob, data);
        ParagraphCancelCB(ob, data);
 }
 
-
 /* callbacks for form form_character */
-
 void CharacterApplyCB(FL_OBJECT *, long)
 {
        // we set toggleall locally here, since it should be true for
        // all other uses of ToggleAndShow() (JMarc)
@@ -2620,24 +2602,20 @@ void CharacterApplyCB(FL_OBJECT *, long)
        ToggleAndShow( UserFreeFont());
        toggleall = true;
 }
 
-
 void CharacterCloseCB(FL_OBJECT *, long)
 {
        fl_hide_form(fd_form_character->form_character);
 }
 
-
 void CharacterOKCB(FL_OBJECT *ob, long data)
 {
        CharacterApplyCB(ob,data);
        CharacterCloseCB(ob,data);
 }
 
-
 /* callbacks for form form_document */
-
 void UpdateDocumentButtons(BufferParams const &params) 
 {
        fl_set_choice(fd_form_document->choice_pagestyle, 1);
        
@@ -2657,9 +2635,8 @@ void UpdateDocumentButtons(BufferParams 
        fl_set_counter_value(fd_form_document->slider_tocdepth, 
                             params.tocdepth);
        
 }
-
 void ChoiceClassCB(FL_OBJECT *ob, long)
 {
        ProhibitInput();
        if (lyxstyle.Load(fl_get_choice(ob)-1)) {
@@ -2682,24 +2659,20 @@ void ChoiceClassCB(FL_OBJECT *ob, long)
        }
        AllowInput();
 }
 
-
 void DocumentDefskipCB(FL_OBJECT *obj, long)
 {
        // "Synchronize" the choice and the input field, so that it
        // is impossible to commit senseless data.
        const FD_form_document* fd = fd_form_document;
-
        if (obj == fd->choice_default_skip) {
                if (fl_get_choice (fd->choice_default_skip) != 4) {
                        fl_set_input (fd->input_default_skip, "");
                        ActivateDocumentButtons();
                }
        } else if (obj == fd->input_default_skip) {
-
                const char* input = fl_get_input (fd->input_default_skip);
-
                if (!*input) {
                        fl_set_choice (fd->choice_default_skip, 2);
                        ActivateDocumentButtons();
                } else if (isValidGlueLength (input)) {
@@ -2711,45 +2684,38 @@ void DocumentDefskipCB(FL_OBJECT *obj, l
                }
        }
 }
 
-
 void DocumentSpacingCB(FL_OBJECT *obj, long)
 {
        // "Synchronize" the choice and the input field, so that it
        // is impossible to commit senseless data.
        const FD_form_document* fd = fd_form_document;
-
        if (obj == fd->choice_spacing
            && fl_get_choice (fd->choice_spacing) != 4) {
                fl_set_input(fd->input_spacing, "");
        } else if (obj == fd->input_spacing) {
-
                const char* input = fl_get_input (fd->input_spacing);
-
                if (!*input) {
                        fl_set_choice (fd->choice_spacing, 1);
                } else {
                        fl_set_choice (fd->choice_spacing, 4);
                }
        }
 }
 
-
 void DocumentApplyCB(FL_OBJECT *, long)
 {
        bool redo = false;
        BufferParams *params = &(current_view->currentBuffer()->params);
        current_view->currentBuffer()->params.language =
                combo_language->getline();
-
        // If default skip is a "Length" but there's no text in the
        // input field, reset the kind to "Medskip", which is the default.
        if (fl_get_choice (fd_form_document->choice_default_skip) == 4
            && !*(fl_get_input (fd_form_document->input_default_skip))) {
                fl_set_choice (fd_form_document->choice_default_skip, 2);
        }
-
        /* this shouldn't be done automatically IMO. For example I write german
         * documents with an american keyboard very often. Matthias */
    
        /* ChangeKeymap(buffer->parameters.language, TRUE, false,
@@ -2768,9 +2734,8 @@ void DocumentApplyCB(FL_OBJECT *, long)
                fl_get_button(fd_form_document->check_use_amsmath);
    
        if (!current_view->available())
                return;
-
        char new_class = fl_get_choice(fd_form_document->choice_class) - 1;
        if (params->textclass != new_class) {
                // try to load new_class
                if (lyxstyle.Load(new_class)) {
@@ -2783,9 +2748,8 @@ void DocumentApplyCB(FL_OBJECT *, long)
                                                            params.textclass,
                                                            new_class,
                                                            
current_view->currentBuffer()->
                                                            paragraph);
-
                        if (ret){
                                LString s;
                                if (ret==1)
                                        s= _("One paragraph couldn't be converted");
@@ -2795,9 +2759,8 @@ void DocumentApplyCB(FL_OBJECT *, long)
                                }
                                WriteAlert(_("Conversion Errors!"),s,
                                           _("into chosen document class"));
                        }
-
                        params->textclass = new_class;
                } else {
                        // problem changing class -- warn user and retain old style
                        WriteAlert(_("Conversion Errors!"),
@@ -2805,9 +2768,8 @@ void DocumentApplyCB(FL_OBJECT *, long)
                                   _("Reverting to original document class."));
                        fl_set_choice(fd_form_document->choice_class, 
params->textclass + 1);
                }
        }
-
        char tmpsep = params->paragraph_separation;
        if (fl_get_button(fd_form_document->radio_indent))
                params->paragraph_separation = LYX_PARSEP_INDENT;
        else
@@ -2828,18 +2790,16 @@ void DocumentApplyCB(FL_OBJECT *, long)
        default: params->setDefSkip(VSpace(VSpace::MEDSKIP)); break;
        }
        if (!(tmpdefskip == params->getDefSkip()))
                redo = true;
-
        if (fl_get_button(fd_form_document->radio_columns_two))
                params->columns = 2;
        else
                params->columns = 1;
        if (fl_get_button(fd_form_document->radio_sides_two))
                params->sides = 2;
        else
                params->sides = 1;
-
        Spacing tmpSpacing = params->spacing;
        switch(fl_get_choice(fd_form_document->choice_spacing)) {
        case 1:
                lyxerr.debug("Spacing: SINGLE");
@@ -2869,47 +2829,39 @@ void DocumentApplyCB(FL_OBJECT *, long)
        params->secnumdepth = tmpchar;
    
        params->tocdepth = (signed char) 
                fl_get_counter_value(fd_form_document->slider_tocdepth);;
-
        params->float_placement =
                fl_get_input(fd_form_document->input_float_placement);
-
        // More checking should be done to ensure the string doesn't have
        // spaces or illegal placement characters in it. (thornley)
-
        if (redo)
                current_view->redoCurrentBuffer();
    
        minibuffer->Set(_("Document layout set"));
        current_view->currentBuffer()->markDirty();
-
         params->options =
                fl_get_input(fd_form_document->input_extra);
    
 }
 
-
 void DocumentCancelCB(FL_OBJECT *, long)
 {
        fl_hide_form(fd_form_document->form_document);
 }
 
-
 void DocumentOKCB(FL_OBJECT *ob, long data)
 {
        DocumentCancelCB(ob,data);
        DocumentApplyCB(ob,data);
 }
 
-
 void DocumentBulletsCB(FL_OBJECT *, long)
 {
        bulletForm();
        // bullet callbacks etc. in bullet_panel.C -- ARRae
 }
 
-
 void GotoNote()
 {
        if (!current_view->getScreen())
                return;
@@ -2942,25 +2894,20 @@ void GotoNote()
        current_view->currentBuffer()->text->sel_cursor =
                current_view->currentBuffer()->text->cursor;
 }
 
-
 void InsertCorrectQuote()
 {
        Buffer *cbuffer = current_view->currentBuffer();
        char c;
-
        if  (cbuffer->text->cursor.pos )
                c = cbuffer->text->cursor.par->GetChar(cbuffer->text->cursor.pos - 1);
        else 
                c = ' ';
-
        cbuffer->insertInset(new InsetQuotes(c, cbuffer->params));
 }
 
-
 /* callbacks for form form_quotes */
-
 void QuotesApplyCB(FL_OBJECT *, long)
 {
        if (!current_view->available())
                return;
@@ -2997,31 +2944,26 @@ void QuotesApplyCB(FL_OBJECT *, long)
                current_view->currentBuffer()->
                        params.quotes_times = InsetQuotes::DoubleQ;
 }
 
-
 void QuotesCancelCB(FL_OBJECT *, long)
 {
        fl_hide_form(fd_form_quotes->form_quotes);
 }
 
-
 void QuotesOKCB(FL_OBJECT *ob, long data)
 {
        QuotesApplyCB(ob, data);
        QuotesCancelCB(ob, data);
 }
 
 
-
 /* callbacks for form form_preamble */
-
 void PreambleCancelCB(FL_OBJECT *, long)
 {
        fl_hide_form(fd_form_preamble->form_preamble);
 }
 
-
 void PreambleApplyCB(FL_OBJECT *, long)
 {
        if (!current_view->available())
                return;
@@ -3030,19 +2972,16 @@ void PreambleApplyCB(FL_OBJECT *, long)
                fl_get_input(fd_form_preamble->input_preamble);
        current_view->currentBuffer()->markDirty();
        minibuffer->Set(_("LaTeX preamble set"));
 }
-
    
 void PreambleOKCB(FL_OBJECT *ob, long data)
 {
        PreambleApplyCB(ob, data);
        PreambleCancelCB(ob, data);
 }
 
-
 /* callbacks for form form_table */
-
 void TableApplyCB(FL_OBJECT *, long)
 {
        int xsize,ysize;
        if (!current_view->getScreen())
@@ -3056,9 +2995,8 @@ void TableApplyCB(FL_OBJECT *, long)
                return;
        }
  
        minibuffer->Set(_("Inserting table..."));
-
        ysize = (int)(fl_get_slider_value(fd_form_table->slider_columns) + 0.5);
        xsize = (int)(fl_get_slider_value(fd_form_table->slider_rows) + 0.5);
    
    
@@ -3067,9 +3005,8 @@ void TableApplyCB(FL_OBJECT *, long)
        current_view->currentBuffer()->update(-2);
    
        current_view->currentBuffer()->text->SetCursorParUndo(); 
        current_view->currentBuffer()->text->FreezeUndo();
-
        current_view->currentBuffer()->text->BreakParagraph();
        current_view->currentBuffer()->update(-1);
    
        if (current_view->currentBuffer()->text->cursor.par->Last()) {
@@ -3077,9 +3014,8 @@ void TableApplyCB(FL_OBJECT *, long)
       
                current_view->currentBuffer()->text->BreakParagraph();
                current_view->currentBuffer()->update(-1);
        }
-
        current_view->currentBuffer()->text->current_font.setLatex(LyXFont::OFF);
        //if (!fl_get_button(fd_form_table->check_latex)){
        // insert the new wysiwy table
        current_view->currentBuffer()->text->SetLayout(0); // standard layout
@@ -3105,9 +3041,8 @@ void TableApplyCB(FL_OBJECT *, long)
                                                                  VSpace(VSpace::NONE),
                                           LYX_ALIGN_CENTER, 
                                           LString(),
                                           0);
-
        current_view->currentBuffer()->text->cursor.par->table = new LyXTable(xsize, 
ysize);
        int i;
        for (i=0; i<xsize * ysize - 1; i++)
                
current_view->currentBuffer()->text->cursor.par->InsertChar(0,LYX_META_NEWLINE);
@@ -3118,49 +3053,40 @@ void TableApplyCB(FL_OBJECT *, long)
        current_view->currentBuffer()->update(1);
        minibuffer->Set(_("Table inserted"));
 }
 
-
 void TableCancelCB(FL_OBJECT *, long)
 {
        fl_hide_form(fd_form_table->form_table);
 }
 
-
 void TableOKCB(FL_OBJECT *ob, long data)
 {
        TableApplyCB(ob,data);
        TableCancelCB(ob,data);
 }
 
-
 /* callbacks for form form_print */
-
 void PrintCancelCB(FL_OBJECT *, long)
 {
        fl_hide_form(fd_form_print->form_print);
 }
-
 static bool LStringOnlyContains (LString const & LStr, const char * cset)
 {
        const char * cstr = LStr.c_str() ;
-
        return strspn(cstr,cset) == strlen(cstr) ;
 }
-
 void PrintApplyCB(FL_OBJECT *, long)
 {
        if (!current_view->available())
                return;
         Buffer *buffer = current_view->currentBuffer();
         LString path = OnlyPath(buffer->getFileName());
-
        LString pageflag;
        if (fl_get_button(fd_form_print->radio_even_pages))
                pageflag = lyxrc->print_evenpage_flag + ' ';
        else if (fl_get_button(fd_form_print->radio_odd_pages))
                pageflag = lyxrc->print_oddpage_flag + ' ';
-
 // Changes by Stephan Witt ([EMAIL PROTECTED]), 19-Jan-99
 // User may give a page (range) list
 // User may print multiple (unsorted) copies
        LString pages = fl_get_input(fd_form_print->input_pages);
@@ -3204,9 +3130,8 @@ void PrintApplyCB(FL_OBJECT *, long)
                else
                        pageflag += lyxrc->print_collcopies_flag;
                pageflag += " " + copies + ' ' ;
        }
-
        LString reverseflag;
        if (fl_get_button(fd_form_print->radio_order_reverse))
                reverseflag = lyxrc->print_reverse_flag + ' ';
    
@@ -3216,18 +3141,16 @@ void PrintApplyCB(FL_OBJECT *, long)
    
        LString ps_file = SpaceLess(fl_get_input(fd_form_print->input_file));
        LString printer = fl_get_input(fd_form_print->input_printer);
        printer.strip();
-
        LString printerflag;
        if (lyxrc->print_adapt_output // printer name should be passed to dvips
            && ! printer.empty()) // a printer name has been given
                printerflag = lyxrc->print_to_printer + printer + ' ';
      
        LString extraflags;
        if (!lyxrc->print_extra_options.empty())
                extraflags = lyxrc->print_extra_options + ' ';
-
        LString command = lyxrc->print_command + ' ' 
                + printerflag + pageflag + reverseflag 
                + orientationflag + extraflags;
  
@@ -3243,9 +3166,8 @@ void PrintApplyCB(FL_OBJECT *, long)
         if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
                path = buffer->tmppath;
         }
         PathPush(path);
-
        bool result;
        if (!lyxrc->print_spool_command.empty() && 
            !fl_get_button(fd_form_print->radio_file)) {
                LString command2 = lyxrc->print_spool_command + ' ';
@@ -3258,30 +3180,25 @@ void PrintApplyCB(FL_OBJECT *, long)
                }
         } else
                result = RunScript(buffer, false, command);
         PathPop();
-
        if (!result)
                WriteAlert(_("Error:"),
                           _("Unable to print"),
                           _("Check that your parameters are correct"));
 }
 
-
 void PrintOKCB(FL_OBJECT *ob, long data)
 {
        PrintCancelCB(ob, data);  
        PrintApplyCB(ob,data);
 }
 
-
 /* callbacks for form form_figure */
-
 void FigureApplyCB(FL_OBJECT *, long)
 {
        if (!current_view->available())
                return;
-
        Buffer * buffer = current_view->currentBuffer();
        if(buffer->isReadonly()) // paranoia
                return;
        
@@ -3300,9 +3217,8 @@ void FigureApplyCB(FL_OBJECT *, long)
        BeforeChange();
       
        buffer->text->SetCursorParUndo(); 
        buffer->text->FreezeUndo();
-
        buffer->text->BreakParagraph();
        buffer->update(-1);
       
        if (buffer->text->cursor.par->Last()) {
@@ -3310,9 +3226,8 @@ void FigureApplyCB(FL_OBJECT *, long)
         
                buffer->text->BreakParagraph();
                buffer->update(-1);
        }
-
        // The standard layout should always be numer 0;
        buffer->text->SetLayout(0);
        
        if (buffer->text->cursor.par->footnoteflag ==
@@ -3344,22 +3259,19 @@ void FigureApplyCB(FL_OBJECT *, long)
        buffer->update(0);
        minibuffer->Set(_("Figure inserted"));
        buffer->text->UnFreezeUndo();
 }
-
    
 void FigureCancelCB(FL_OBJECT *, long)
 {
        fl_hide_form(fd_form_figure->form_figure);
 }
 
-
 void FigureOKCB(FL_OBJECT *ob, long data)
 {
        FigureApplyCB(ob,data);
        FigureCancelCB(ob,data);
 }
-
 void ScreenApplyCB(FL_OBJECT *, long)
 {
        lyxrc->roman_font_name = fl_get_input(fd_form_screen->input_roman);
        lyxrc->sans_font_name = fl_get_input(fd_form_screen->input_sans);
@@ -3369,31 +3281,26 @@ void ScreenApplyCB(FL_OBJECT *, long)
        fontloader.update();
    
        // All buffers will need resize
        bufferlist.resize();
-
        minibuffer->Set(_("Screen options set"));
 }
 
-
 void ScreenCancelCB(FL_OBJECT *, long)
 {
        fl_hide_form(fd_form_screen->form_screen);
 }
 
-
 void ScreenOKCB(FL_OBJECT *ob, long data)
 {
        ScreenCancelCB(ob,data);
        ScreenApplyCB(ob,data);
 }
 
-
 void LaTeXOptions()
 {
        if (!current_view->available())
                return;
-
        fl_set_button(fd_latex_options->accents,
                      (int)current_view->currentBuffer()->params.allowAccents);
        
        if (fd_latex_options->LaTeXOptions->visible) {
@@ -3404,15 +3311,13 @@ void LaTeXOptions()
                             _("LaTeX Options"));
        }
 }
 
-
 // This function runs "configure" and then rereads lyx.defaults to
 // reconfigure the automatic settings.
 void Reconfigure()
 {
        minibuffer->Set(_("Running configure..."));
-
        // Run configure in user lyx directory
        PathPush(user_lyxdir);
        Systemcalls one(Systemcalls::System, 
                           AddName(system_lyxdir,"configure"));
@@ -3423,9 +3328,8 @@ void Reconfigure()
                   _("You need to restart LyX to make use of any"),
                   _("updated document class specifications."));
 }
 
-
 /* these functions are for the spellchecker */ 
 char* NextWord(float &value)
 {
        if (!current_view->available()){
@@ -3433,12 +3337,10 @@ char* NextWord(float &value)
                return NULL;
        }
    
        char* string =  current_view->currentBuffer()->text->SelectNextWord(value);
-
        return string;
 }
-
   
 void SelectLastWord()
 {
        if (!current_view->available())
@@ -3450,9 +3352,8 @@ void SelectLastWord()
        current_view->getScreen()->ToggleSelection(false);
        current_view->currentBuffer()->update(0);
 }
 
-
 void EndOfSpellCheck()
 {
        if (!current_view->available())
                return;
@@ -3463,14 +3364,12 @@ void EndOfSpellCheck()
        current_view->currentBuffer()->text->ClearSelection();
        current_view->currentBuffer()->update(0);
 }
 
-
 void ReplaceWord(LString const & replacestring)
 {
        if (!current_view->getScreen())
                return;
-
        current_view->getScreen()->HideCursor();
        current_view->currentBuffer()->update(-2);
    
        /* clear the selection (if there is any) */ 
@@ -3478,9 +3377,8 @@ void ReplaceWord(LString const & replace
        current_view->currentBuffer()->text->
                ReplaceSelectionWithString(replacestring.c_str());
    
        
current_view->currentBuffer()->text->SetSelectionOverString(replacestring.c_str());
-
        // Go back so that replacement string is also spellchecked
        for (int i=-1; i< replacestring.length(); i++) {
                current_view->currentBuffer()->text->CursorLeftIntern();
        }
@@ -3488,40 +3386,33 @@ void ReplaceWord(LString const & replace
 }
 // End of spellchecker stuff
 
 
-
 //
 // Table of Contents
 //
-
 struct TocList {
        char counter[6];
        bool appendix;
        TocList *next;
 };
 
-
 static TocList* toclist = NULL;
 
-
 void TocSelectCB(FL_OBJECT *ob, long)
 {
        if (!current_view->available())
                return;
    
        TocList* tmptoclist = toclist;
        int i = fl_get_browser(ob);
        int a = 0;
-
        for (a=1; a<i && tmptoclist->next; a++){
                tmptoclist = tmptoclist->next;
        }
-
        if (!tmptoclist)
                return;
      
-
        LyXParagraph *par = current_view->currentBuffer()->paragraph;
        while (par && (par->GetCounter(0) != tmptoclist->counter[0] ||
                       par->GetCounter(1) != tmptoclist->counter[1] ||
                       par->GetCounter(2) != tmptoclist->counter[2] ||
@@ -3546,15 +3437,13 @@ void TocSelectCB(FL_OBJECT *ob, long)
        }
          
 }
 
-
 void TocCancelCB(FL_OBJECT *, long)
 {
        fl_hide_form(fd_form_toc->form_toc);
 }
 
-
 void TocUpdateCB(FL_OBJECT *, long)
 {
        static LyXParagraph* stapar = NULL;
        TocList *tmptoclist = NULL;
@@ -3569,9 +3458,8 @@ void TocUpdateCB(FL_OBJECT *, long)
        }
        toclist = NULL;
        tmptoclist = toclist;
 
-
        fl_clear_browser(fd_form_toc->browser_toc);
        if (!current_view->available()) {
                fl_add_browser_line(fd_form_toc->browser_toc, _("*** No Document 
***"));
                return;
@@ -3656,24 +3544,21 @@ void TocUpdateCB(FL_OBJECT *, long)
        fl_set_browser_topline(fd_form_toc->browser_toc, topline);
        fl_show_object(fd_form_toc->browser_toc);
 }
 
-
 /* callbacks for form form_ref */
 void RefSelectCB(FL_OBJECT *, long data)
 {
        if (!current_view->available())
                return;
-
        LString s =
                fl_get_browser_line(fd_form_ref->browser_ref,
                                    fl_get_browser(fd_form_ref->browser_ref));
        LString u = fl_get_input(fd_form_ref->ref_name);
        u.strip();
        u.frontStrip();
        if (s.empty())
                return;
-
         if (data==2) {
                 current_view->getOwner()->getLyXFunc()->Dispatch(LFUN_REFGOTO, 
s.c_str());
                return;
        }
@@ -3682,38 +3567,30 @@ void RefSelectCB(FL_OBJECT *, long data)
        if (data==0)
                t += "\\ref";
        else
                t += "\\pageref";
-
        if(current_view->currentBuffer()->isLinuxDoc())
                t += "[" + u + "]" + "{" + s + "}";
        else
                t += "{" + s + "}";
-
        Inset *new_inset =
                new InsetRef(t, current_view->currentBuffer());
        current_view->currentBuffer()->insertInset(new_inset);
 }
 
-
 void RefUpdateCB(FL_OBJECT *, long)
 {
        if (!current_view->available()) {
                fl_clear_browser(fd_form_ref->browser_ref);
                return;
        }
-
        FL_OBJECT * brow = fd_form_ref->browser_ref;
-
        // Get the current line, in order to restore it later
        LString currentstr = fl_get_browser_line(brow,
                                                 fl_get_browser(brow));
-
        fl_clear_browser(brow);
-
        LString refs = current_view->currentBuffer()->getReferenceList('\n');
        int topline = 1;
-
 #if FL_REVISION > 85
        fl_addto_browser_chars(brow,refs.c_str());
        int total_lines = fl_get_browser_maxline(brow);
        for (int i = 1; i <= total_lines ; i++) {
@@ -3735,9 +3612,8 @@ void RefUpdateCB(FL_OBJECT *, long)
                fl_add_browser_line(brow,curr_ref.c_str());
                ref_num++;
        }
 #endif
-
        if (!fl_get_browser_maxline(brow)) {
                fl_add_browser_line(brow, 
                                    _("*** No labels found in document ***"));
                fl_deactivate_object(brow);
@@ -3759,20 +3635,17 @@ void RefUpdateCB(FL_OBJECT *, long)
                fl_set_object_lcol(fd_form_ref->ref_name, FL_BLACK);
        }
 }
 
-
 void RefHideCB(FL_OBJECT *, long)
 {
        fl_hide_form(fd_form_ref->form_ref);
 }
 
-
 void UpdateInset(Inset* inset, bool mark_dirty)
 {
        if (!inset)
                return;
-
        /* very first check for locking insets*/
        if (current_view->currentBuffer()->the_locking_inset == inset){
                if (current_view->currentBuffer()->text->UpdateInset(inset)){
                        current_view->update();
@@ -3800,12 +3673,10 @@ void UpdateInset(Inset* inset, bool mark
        }
   
        // check all buffers
        bufferlist.updateInset(inset, mark_dirty);
-
 }
 
-
 /* these functions return 1 if an error occured, 
    otherwise 0 */
 int LockInset(UpdatableInset* inset)
 {
@@ -3815,9 +3686,8 @@ int LockInset(UpdatableInset* inset)
        }
        return 1;
 }
 
-
 void ShowLockedInsetCursor(long x, long y, int asc, int desc)
 {
        if (current_view->currentBuffer()->the_locking_inset &&
            current_view->getScreen()){
@@ -3826,9 +3696,8 @@ void ShowLockedInsetCursor(long x, long 
                                                            asc, desc);
        }
 }
 
-
 void HideLockedInsetCursor(long x, long y, int asc, int desc)
 {
        if (current_view->currentBuffer()->the_locking_inset &&
            current_view->getScreen()){
@@ -3837,9 +3706,8 @@ void HideLockedInsetCursor(long x, long 
                                                            asc, desc);
        }
 }
 
-
 void FitLockedInsetCursor(long x, long y, int asc, int desc)
 {
        if (current_view->currentBuffer()->the_locking_inset &&
            current_view->getScreen()){
@@ -3848,9 +3716,8 @@ void FitLockedInsetCursor(long x, long y
                        current_view->updateScrollbar();
        }
 }
 
-
 int UnlockInset(UpdatableInset* inset)
 {
        if (inset &&
            current_view->currentBuffer()->the_locking_inset == inset){
@@ -3861,9 +3728,8 @@ int UnlockInset(UpdatableInset* inset)
        }
        return bufferlist.unlockInset(inset);
 }
 
-
 void LockedInsetStoreUndo(Undo::undo_kind kind)
 {
        if (!current_view->currentBuffer()->the_locking_inset)
                return; // shouldn't happen
@@ -3875,9 +3741,8 @@ void LockedInsetStoreUndo(Undo::undo_kin
                              current_view->currentBuffer()->text->cursor.par->
                              
ParFromPos(current_view->currentBuffer()->text->cursor.pos)->next); 
 }
 
-
 void PutInsetIntoInsetUpdateList(Inset* inset)
 {
        if (inset) {
                InsetUpdateStruct* tmp = new InsetUpdateStruct();
@@ -3886,9 +3751,8 @@ void PutInsetIntoInsetUpdateList(Inset* 
                InsetUpdateList = tmp;
        }
 }
 
-
 void UpdateInsetUpdateList()
 {
        InsetUpdateStruct *tmp = InsetUpdateList;
        while (tmp) {
@@ -3904,5 +3768,5 @@ void UpdateInsetUpdateList()
        }
        InsetUpdateList = NULL;
 }
 
-
+/* [*] For DBCS see note at end of LString.h (AHanses) */
diff -p -N -r -U 4 -X excl.tmp src/original_LyX-1.0.3/lyxfont.C src/modified/lyxfont.C
--- src/original_LyX-1.0.3/lyxfont.C    Tue Nov 10 10:00:58 1998
+++ src/modified/lyxfont.C      Tue Aug  3 22:06:26 1999
@@ -377,10 +377,9 @@ LString LyXFont::stateText() const
 
 // Set family according to lyx format string
 LyXFont& LyXFont::setLyXFamily(LString const & fam)
 {
-       LString s = fam;
-       s.lowercase();
+       LString s = lowercase(fam);
        int i=0;
        while (s != LyXFamilyNames[i] && LyXFamilyNames[i] != "error") i++;
        if (s == LyXFamilyNames[i]) {
                setFamily(LyXFont::FONT_FAMILY(i));
@@ -392,10 +391,9 @@ LyXFont& LyXFont::setLyXFamily(LString c
 
 // Set series according to lyx format string
 LyXFont& LyXFont::setLyXSeries(LString const & ser)
 {
-       LString s = ser;
-       s.lowercase();
+       LString s = lowercase(ser);
        int i=0;
        while (s != LyXSeriesNames[i] && LyXSeriesNames[i] != "error") i++;
        if (s == LyXSeriesNames[i]) {
                setSeries(LyXFont::FONT_SERIES(i));
@@ -407,10 +405,9 @@ LyXFont& LyXFont::setLyXSeries(LString c
 
 // Set shape according to lyx format string
 LyXFont& LyXFont::setLyXShape(LString const & sha)
 {
-       LString s = sha;
-       s.lowercase();
+       LString s = lowercase(sha);
        int i=0;
        while (s != LyXShapeNames[i] && LyXShapeNames[i] != "error") i++;
        if (s == LyXShapeNames[i]) {
                setShape(LyXFont::FONT_SHAPE(i));
@@ -422,10 +419,9 @@ LyXFont& LyXFont::setLyXShape(LString co
 
 // Set size according to lyx format string
 LyXFont& LyXFont::setLyXSize(LString const & siz)
 {
-       LString s = siz;
-       s.lowercase();
+       LString s = lowercase(siz);
        int i=0;
        while (s != LyXSizeNames[i] && LyXSizeNames[i] != "error") i++;
        if (s == LyXSizeNames[i]) {
                setSize(LyXFont::FONT_SIZE(i));
@@ -436,10 +432,9 @@ LyXFont& LyXFont::setLyXSize(LString con
 
 // Set size according to lyx format string
 LyXFont::FONT_MISC_STATE LyXFont::setLyXMisc(LString const & siz)
 {
-       LString s = siz;
-       s.lowercase();
+       LString s = lowercase(siz);
        int i=0;
        while (s != LyXMiscNames[i] && LyXMiscNames[i] != "error") i++;
        if (s == LyXMiscNames[i])
                return FONT_MISC_STATE(i);
@@ -449,10 +444,9 @@ LyXFont::FONT_MISC_STATE LyXFont::setLyX
 
 /// Sets color after LyX text format
 LyXFont& LyXFont::setLyXColor(LString const & col)
 {
-       LString s = col;
-       s.lowercase();
+       LString s = lowercase(col);
        int i=0;
        while (s != LyXColorNames[i] && LyXColorNames[i] != "error") i++;
        if (s == LyXColorNames[i]) {
                setColor(LyXFont::FONT_COLOR(i));
@@ -464,10 +458,9 @@ LyXFont& LyXFont::setLyXColor(LString co
 
 /// Sets size after GUI name
 LyXFont& LyXFont::setGUISize(LString const & siz)
 {
-       LString s = siz;
-       s.lowercase();
+       LString s = lowercase(siz);
        int i=0;
        while (!lGUISizeNames[i].empty() &&
               s != _(lGUISizeNames[i].c_str()))
          i++;
@@ -493,10 +486,9 @@ LyXFont & LyXFont::lyxRead(LyXLex & lex)
        bool error = false;
        bool finished = false;
        while (!finished && lex.IsOK() && !error) {
                lex.next();
-               LString tok = lex.GetString();
-               tok.lowercase();
+               LString tok = lowercase(lex.GetString());
 
                if (tok.empty()) {
                        continue;
                } else if (tok == "endfont") {
@@ -518,10 +510,9 @@ LyXFont & LyXFont::lyxRead(LyXLex & lex)
                        LString tok = lex.GetString();
                        setLyXSize(tok);
                } else if (tok == "latex") {
                        lex.next();
-                       LString tok = lex.GetString();
-                       tok.lowercase();
+                       LString tok = lowercase(lex.GetString());
 
                        if (tok == "no_latex") {
                                setLatex(OFF);
                        } else if (tok == "latex") {
@@ -530,10 +521,9 @@ LyXFont & LyXFont::lyxRead(LyXLex & lex)
                                lex.printError("Illegal LaTeX type`$$Token'");
                        }
                } else if (tok == "misc") {
                        lex.next();
-                       LString tok = lex.GetString();
-                       tok.lowercase();
+                       LString tok = lowercase(lex.GetString());
 
                        if (tok == "no_bar") {
                                setUnderbar(OFF);
                        } else if (tok == "no_emph") {
diff -p -N -r -U 4 -X excl.tmp src/original_LyX-1.0.3/lyxrc.C src/modified/lyxrc.C
--- src/original_LyX-1.0.3/lyxrc.C      Wed Feb 17 04:34:16 1999
+++ src/modified/lyxrc.C        Tue Aug  3 22:11:54 1999
@@ -508,10 +508,9 @@ int LyXRC::Read(LString const &filename)
                        break;
 
                case RC_DEFAULT_PAPERSIZE:
                         if (lexrc.next()) {
-                               LString size = lexrc.GetString();
-                               size.lowercase();
+                               LString size = lowercase(lexrc.GetString());
                                if (size == "usletter")
                                        default_papersize = PAPER_USLETTER;
                                else if (size == "legal")
                                        default_papersize = PAPER_LEGALPAPER;

Reply via email to