]> git.lyx.org Git - features.git/commitdiff
fix a bug in lyxstring
authorLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 2 Nov 1999 06:42:25 +0000 (06:42 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 2 Nov 1999 06:42:25 +0000 (06:42 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@271 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
src/support/filetools.C
src/support/lyxstring.C

index 2727b6760b43f0c51699c51d44c5151ee7aecf72..74512d914345ca98a7c9a6cba1fb60ea79065e26 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+1999-11-02  Lars Gullik Bjønnes  <larsbj@lyx.org>
+
+       * src/support/lyxstring.C (find): remove bogus assert and return
+       npos for the same condition.
+
 1999-11-01  Lars Gullik Bjønnes  <larsbj@lyx.org>
 
        * added patch for OS/2 from SMiyata.
index fe7c3d456cd7ca025fad31f1c94361c01a4814da..f54f05d4b16a82174452243d7e8e53561cd4e870 100644 (file)
@@ -73,7 +73,7 @@ string SpaceLess(string const & file)
        string path = OnlyPath(file);
        
        for (string::size_type i = 0; i < name.length(); ++i) {
-               name[i] &= 0x7f;
+               name[i] &= 0x7f; // set 8th bit to 0
                if (!isalnum(name[i]) && name[i] != '.')
                        name[i] = '_';
        }
@@ -137,7 +137,6 @@ int IsFileWriteable (string const & path)
        FilePtr fp(path, FilePtr::update);
        if (!fp()) {
                if ((errno == EACCES) || (errno == EROFS)) {
-                       //fp = FilePtr(path, FilePtr::read);
                        fp.reopen(path, FilePtr::read);
                        if (fp()) {
                                return 0;
@@ -191,7 +190,7 @@ string FileOpenSearch (string const & path, string const & name,
 {
        string real_file, path_element;
        bool notfound = true;
-       string tmppath=split(path, path_element, ';');
+       string tmppath = split(path, path_element, ';');
        
        while (notfound && !path_element.empty()) {
                path_element = CleanupPath(path_element);
@@ -338,9 +337,8 @@ bool PutEnvPath(string const & envstr)
 static
 int DeleteAllFilesInDir (string const & path)
 {
-       DIR * dir;
        struct dirent * de;
-       dir = opendir(path.c_str());
+       DIR * dir = opendir(path.c_str());
        if (!dir) {
                WriteFSAlert (_("Error! Cannot open directory:"), path);
                return -1;
@@ -856,10 +854,8 @@ string AddPath(string const & path, string const & path_2)
 
        if (!path2.empty()){
                int p2start = path2.find_first_not_of('/');
-               //while (path2[p2start] == '/') ++p2start;
 
                int p2end = path2.find_last_not_of('/');
-               //while (path2[p2end] == '/') --p2end;
 
                string tmp = path2.substr(p2start, p2end - p2start + 1);
                buf += tmp + '/';
@@ -950,6 +946,7 @@ string MakeDisplayPath (string const & path, unsigned int threshold)
        return prefix + relhome;
 }
 
+
 bool LyXReadLink(string const & File, string & Link)
 {
        char LinkBuffer[512];
index 49e15874e7360ce7097f12e1408383b66d54da8a..26705bb316a2917a092e345966228259e55e33ca 100644 (file)
@@ -921,9 +921,8 @@ lyxstring::size_type lyxstring::find(value_type const * ptr, size_type i,
 lyxstring::size_type lyxstring::find(value_type const * s, size_type i) const
 {
        Assert(s);
-       if (!rep->sz) return npos;
+       if (!rep->sz || i >= rep->sz) return npos;
        
-       Assert(i < rep->sz);
        TestlyxstringInvariant(this);
 
        if (!s || !*s) return npos;