From aba5e8132ea132abd0254e345ddeef842030f4da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Tue, 2 Nov 1999 06:42:25 +0000 Subject: [PATCH] fix a bug in lyxstring git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@271 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 5 +++++ src/support/filetools.C | 11 ++++------- src/support/lyxstring.C | 3 +-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2727b6760b..74512d9143 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +1999-11-02 Lars Gullik Bjønnes + + * src/support/lyxstring.C (find): remove bogus assert and return + npos for the same condition. + 1999-11-01 Lars Gullik Bjønnes * added patch for OS/2 from SMiyata. diff --git a/src/support/filetools.C b/src/support/filetools.C index fe7c3d456c..f54f05d4b1 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -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]; diff --git a/src/support/lyxstring.C b/src/support/lyxstring.C index 49e15874e7..26705bb316 100644 --- a/src/support/lyxstring.C +++ b/src/support/lyxstring.C @@ -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;