On Sun, 23 Feb 2003, Dekel Tsur wrote:
> It doesn't compile: > g++ -DHAVE_CONFIG_H -I. -I. -I. -I../boost -isystem /usr/X11R6/include -O > -fno-exceptions -W -Wall -Winline -c -o bufferlist.o test -f bufferlist.C || > echo './'bufferlist.C > bufferlist.C: In member function Buffer* > BufferList::getBufferFromTmppath(const std::string&)': > bufferlist.C:424: no matching function for call to std::basic_string<char, > std::char_traits<char>, std::allocator<char> >::compare(std::string&, int, > size_t) const' I don't have this problem with gcc 2.95.4. What is the version of your gcc? > I suggest using prefixIs(), and changing BufferList::getBufferFromTmppath to: > for (; it != end; ++it) { > if (prefixIs(s, (*it)->tmppath)) > return *it; > } > return 0; Anyway, it is better this way (it is more generic since it catches no only files inside tmpdir, but also files inside directories under tmpdir). A new patch follows. Please, try it. > Also, try implementing forward search. I'm trying! This one will no be so trivial. Thank you, Dekel. Joao. PS. I will be off for about a week and then continue to work on these patches.
Index: src/ChangeLog =================================================================== RCS file: /cvs/lyx/lyx-devel/src/ChangeLog,v retrieving revision 1.1048 diff -u -r1.1048 ChangeLog --- src/ChangeLog 2003/02/22 20:05:10 1.1048 +++ src/ChangeLog 2003/02/24 13:28:03 @@ -1,3 +1,11 @@ +2003-02-22 Joao Luis Meloni Assirati <[EMAIL PROTECTED]> + + * bufferlist.C: + * bufferlist.h: add a new function getBufferFromTmppath, analogous to + getBuffer, that will select a buffer given its temporary directory. + * lyxfunc.C: modify the function LFUN_GOTOFILEROW to treat the case of + files in the temporary directory. + 2003-02-22 John Levon <[EMAIL PROTECTED]> * toc.h: Index: src/bufferlist.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/bufferlist.C,v retrieving revision 1.96 diff -u -r1.96 bufferlist.C --- src/bufferlist.C 2003/02/15 19:21:11 1.96 +++ src/bufferlist.C 2003/02/24 13:28:04 @@ -417,6 +417,21 @@ } +Buffer * BufferList::getBufferFromTmppath(string const & s) +{ + BufferStorage::iterator it = bstore.begin(); + BufferStorage::iterator end = bstore.end(); + for (; it != end; ++it) { + if (prefixIs(s, (*it)->tmppath)) { + string::size_type tmppath_s = (*it)->tmppath.size(); + if(s.size() == tmppath_s || s.at(tmppath_s) == '/') + return *it; + } + } + return 0; +} + + Buffer * BufferList::newFile(string const & name, string tname, bool isNamed) { // get a free buffer Index: src/bufferlist.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/bufferlist.h,v retrieving revision 1.36 diff -u -r1.36 bufferlist.h --- src/bufferlist.h 2003/02/15 19:21:11 1.36 +++ src/bufferlist.h 2003/02/24 13:28:04 @@ -82,6 +82,9 @@ /// returns a pointer to the buffer with the given number. Buffer * getBuffer(unsigned int); + /// returns a pointer to the buffer with the given tmppath + Buffer * getBufferFromTmppath(string const & s); + /// reset current author for all buffers void setCurrentAuthor(string const & name, string const & email); Index: src/lyxfunc.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lyxfunc.C,v retrieving revision 1.401 diff -u -r1.401 lyxfunc.C --- src/lyxfunc.C 2003/02/21 12:22:24 1.401 +++ src/lyxfunc.C 2003/02/24 13:28:08 @@ -1295,11 +1295,17 @@ // Must replace extension of the file to be .lyx and get full path string const s(ChangeExtension(file_name, ".lyx")); - // Either change buffer or load the file - if (bufferlist.exists(s)) { - view()->buffer(bufferlist.getBuffer(s)); + // Check wether the path is in the temp dir + if (prefixIs(s, system_tempdir)) { + lyxerr[Debug::INFO] << "Gotofilerow in tmpdir" << endl; + view()->buffer(bufferlist.getBufferFromTmppath(s)); } else { - view()->buffer(bufferlist.loadLyXFile(s)); + // Either change buffer or load the file + if (bufferlist.exists(s)) { + view()->buffer(bufferlist.getBuffer(s)); + } else { + view()->buffer(bufferlist.loadLyXFile(s)); + } } view()->setCursorFromRow(row);