Re: The LyX licence

2005-02-24 Thread Ben Stanley
Angus,

You have my permission to change the license of my contribution to the
GNU GPL version 2 or later.

Please note the change of email address (please check the headers - I'm
not quoting it here for the spam-bots to find.).
Ben Stanley.


On Wed, 2005-02-23 at 01:55, Angus Leeming wrote:
> In light of all this, I'm asking whether I can have your permission to add 
> your names to http://www.lyx.org/blanket-permission.txt:
> 
> "The following people hereby grant permission to licence their contributions
> to LyX under the Gnu General Public Licence, version 2 or later."




Re: Float Counters

2002-11-19 Thread Ben Stanley
On Wed, 2002-11-20 at 02:49, Martin Vermeer wrote:

> Don't ask :-(

I take it that you beat your head against this for a while then...

> 
> Suggestion: have a look at all the textclass.counters().reset
> statements in text2.C. Somehow I didn't get the float counters *not*
> to be reset while resetting the other (sectioning) counters at the
> start of the document. A good start could be to identify which reset
> is being called there, and how to suppress it being called when
> entering a float. IIRC. I remember it wasn't trivial.
> 

It appears that all the counters get reset before traversing the
document and incrementing the counters as appropriate. This seems to be
correct to me, as not resetting the float counters at the beginning of
the document would mean that the previously existing counts would be
used as the base values. However, I can't see where any counter for the
various float types would be added. I added my own (but haven't compiled
or run it yet).

The other place that the counters get reset is when you hit the
appendices. I'm wondering if there are some document styles which will
require figure numbers 1,2,3,4,..., even through the appendix, in which
case the float counters should not be reset. I'll have to check what
happens with the various document styles.

I would normally check all of this out at run-time with a debugger, but
my gdb seems to be unable to work with lyx. It shows me symbols in the
wrong location, so I suspect a gdb bug at the moment. I'm looking into
it. When I get it working, I'll be able to get a better idea of which
classes are actively used, and which are not.

I was thinking that I would have to add extra code to make the float
counters get incremented, as the existing code is focused on the section
counters. Thus I was thinking of adding a new label type for floats to
be able to handle the difference correctly.

Ben.

-- 
Ben Stanley, PhD candidate
School of Information Technology and Computer Science
University of Wollongong




Re: Float Counters

2002-11-18 Thread Ben Stanley
On Tue, 2002-11-19 at 17:01, Ben Stanley wrote:
> 4) Translating the float type (figure, algorithm, program, etc) into the
> display name ("Figure", "Algorithm", "Program", etc, with localisation).
> I suppose this is a .layout issue, to be dealt with by LyXTextClass?

It seems that the code already deals with this, through
internationalisation strings, at least for standard types.

Ben.





Float Counters

2002-11-18 Thread Ben Stanley
Hi,

I'm thinking about implementing float counters while I grope around
inside LyX. (Was also thinking about equation numbers, but I'll do one
thing at a time.)

I looked in InsetCaption, where the float counter is drawn
(insets/insetcaption.C:87). There are some comments there describing a
way of finding the type of float (and hence drawing "Figure x.y", or
"Algorithm x.y"). I'm mostly thinking about drawing the right counter
number. This requires an instance of Counter, with the same name as the
float type, to be registered with Counters (counters.[hC]).

So far as I can see, each different kind of float environment (which
would be numbered separately) has its own instance of Floating
(Floating.[hC]). Thus the Floating constructor should register a new
counter with Counters.

The counter also needs to be updated properly. It appears that section
counters are updated by LyXText::updateCounters, which iterates through
the paragraphs calling LyXText::setCounter. I'm not sure how to update a
float environment counter.

Then InsetCaption has to be able to access the right number to draw it.
The code currently in InsetCaption::draw attempts to obtain an
InsetFloat using owner()->owner() and then casting the pointer to
InsetFloat*, assuming that this will always be correct. This looks risky
to me, but that's the way the code is. (In fact there is a dereference
of an unchecked pointer as well.)

The InsetFloat knows what type of float it is, so this can be used to
look up the counter type once a reference to Counters is obtained.
(Counters is owned by LyXTextClass, which manages the layout of the
document.)

Thus the main problems are:
1) Connections between the various pieces of required information.
a) Floating has no reference to LyXTextClass or Counters.
2) Properly updating the float counters. (no ideas here.)
3) Accessing the counter value at InsetCaption::draw() time (means
finding a reference to LyXTextClass).
4) Translating the float type (figure, algorithm, program, etc) into the
display name ("Figure", "Algorithm", "Program", etc, with localisation).
I suppose this is a .layout issue, to be dealt with by LyXTextClass?

Ideas welcome.

I'm still working through commenting Inset.h as well, but this requires
some understanding of the entire Inset inheritance tree, which is taking
some time to acquire.

Ben.

-- 
Ben Stanley, PhD candidate
School of Information Technology and Computer Science
University of Wollongong




Re: possible bug

2002-11-12 Thread Ben Stanley
I am writing to let it be known that I consider this bug affects me as 
well, and that I consider it to be rather serious. Could you please 
re-consider the back-porting issue?

Ben.

Jean-Marc Lasgouttes wrote:

"btz64" == btz64  <[EMAIL PROTECTED]> writes


btz64> when you insert a eps image in a figure float. You compile once
btz64> to view the ps document and everything is working fine. BUT if
btz64> you update the eps file, and recompile the lyx file to ps
btz64> document again, the eps image has not been updated in the
btz64> postscript document.

btz64> You have to exit lyx and reopen the file
btz64> foo.lyx so that when you compile your lyx document to ps , the
btz64> update of the eps image is taken into account.


Actually, it is sufficient to close the document and then re-open it.


I think the problem was already in 1.2.0, actually. It will be fixed
in 1.3.0, but the fix is a bit too large to be backported safely to
1.2.x.
 






Thinking about Insets, Paragraphs, and iterators.

2002-11-07 Thread Ben Stanley


I'm trying to distill the rules for insets and paragraphs...

* Inset classescan only hold a single inset object.
* Paragraph objects are not an inset, but may contain more than one
inset.
* Paragraph objects may be inserted into an inset tree using an
InsetText object.

All this must make it rather difficult to traverse the object tree.
Surely we need a CompundInset or similar, the father of all insets which
can contain more than one sub-inset. This simplifies ieterators
enormously.BNut then what happens to the text between the insets?
Perhaps a new inset is required for straight text.

I am reminded of the design patterns book here, which has an extensive
example of one way of doing this. if this has been discussed here
before, could people point me to the discussion?

Thinking aloud,
Ben.




\floatstyle{} latex errors

2002-11-07 Thread Ben Stanley
current cvs LyX wrote the following in the preamble for a document with
figures: (document style IEEEtran, but it's written in the layout
independent part)

-

%% LyX specific LaTeX commands.
\providecommand{\LyX}{L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@}
\newcommand{\lyxarrow}{\leavevmode\,$\triangleright$\,\allowbreak}
%% Bold symbol macro for standard LaTeX users
\newcommand{\boldsymbol}[1]{\mbox{\boldmath $#1$}}

%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}
\floatstyle{}
\newfloat{}{}{}
\floatname{}{}
\floatstyle{}
\newfloat{}{}{}
\floatname{}{}


--

LaTeX chokes on the \floatstyle{} command.

What's going on?

Ben.





Re: autoconf-2.53

2002-11-07 Thread Ben Stanley
On Fri, 2002-11-08 at 00:23, Jean-Marc Lasgouttes wrote:
> >>>>> "Ben" == Ben Stanley <[EMAIL PROTECTED]> writes:
> 
> Ben> On Thu, 2002-11-07 at 01:15, Lars Gullik Bjønnes wrote:
> >> Ben Stanley <[EMAIL PROTECTED]> writes:
> >> 
> >> But I compile on RH-8.0 all the time and have no problems.
> >> 
> 
> Ben> I just did a complete
> 
> Ben> cvs checkout lyx-devel
> 
> Ben> and then autogen.sh ./configure --with-frontend=qt
> Ben> --prefix=/packages/lyx-1.3.0cvs make
> 
> Ben> and the new src/config.h displays the same symptoms as before.
> Ben> However, it now compiles and runs.
> 
> Can you send your config.h? I cannot see anything strange in mine now
> (and I used to).
> 
> JMarc

strange things are:

1) does not define HAVE_STRERROR, but my system has it.
2) does not define HAVE_DECL_MKSTEMP, but my system has it.

strange is that LyX compiles in this situation...

Ben.


/* src/config.h.  Generated by configure.  */
/* src/config.h.in.  Generated from configure.ac by autoheader.  */


/* -*- C++ -*- */
/* This is the compilation configuration file for LyX. It was generated by
   autoconf's configure. You might want to change some of the defaults if
   something goes wrong during the compilation

   * This file is part of
   * ==
   *
   *   LyX, the High Level Word Processor
   *
   *   Copyright 1995 Matthias Ettrich
   *   Copyright 1995-2001 The LyX Team.
   *
   *==*/

#ifndef _CONFIG_H
#define _CONFIG_H


/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
   systems. This function is required for `alloca.c' support on those systems.
   */
/* #undef CRAY_STACKSEG_END */

/* Define if your C++ compiler puts C library functions in the global
   namespace */
/* #undef CXX_GLOBAL_CSTD */

/* Define to 1 if using `alloca.c'. */
/* #undef C_ALLOCA */

/* Define if you are building a development version of LyX */
#define DEVEL_VERSION 1

/* Define if you want assertions to be enabled in the code */
#define ENABLE_ASSERTIONS 1

/* Define to 1 if translation of program messages to the user's native
   language is requested. */
#define ENABLE_NLS 1

/* define this to the location of forms.h to be used with #include, e.g.
*/
/* #undef FORMS_H_LOCATION */

/* Define to 1 if you have `alloca', as a function or macro. */
#define HAVE_ALLOCA 1

/* Define to 1 if you have  and it should be used (not on Ultrix).
   */
#define HAVE_ALLOCA_H 1

/* Define to 1 if you have the  header file. */
#define HAVE_ARGZ_H 1

/* Define to 1 if you have the `dcgettext' function. */
#define HAVE_DCGETTEXT 1

/* Define to 1 if you have the  header file, and it defines `DIR'.
   */
#define HAVE_DIRENT_H 1

/* Define to 1 if you have the  header file. */
#define HAVE_DLFCN_H 1

/* Define to 1 if you have the `feof_unlocked' function. */
#define HAVE_FEOF_UNLOCKED 1

/* Define to 1 if you have the `fgets_unlocked' function. */
#define HAVE_FGETS_UNLOCKED 1

/* Define to 1 if you have the `flimage_enable_jpeg' function. */
/* #undef HAVE_FLIMAGE_ENABLE_JPEG */

/* Define to 1 if you have the `flimage_enable_ps' function. */
/* #undef HAVE_FLIMAGE_ENABLE_PS */

/* Define to 1 if you have the  header file. */
/* #undef HAVE_FLIMAGE_H */

/* Define to 1 if you have the `getcwd' function. */
#define HAVE_GETCWD 1

/* Define to 1 if you have the `getegid' function. */
#define HAVE_GETEGID 1

/* Define to 1 if you have the `geteuid' function. */
#define HAVE_GETEUID 1

/* Define to 1 if you have the `getgid' function. */
#define HAVE_GETGID 1

/* Define to 1 if you have the `getpagesize' function. */
#define HAVE_GETPAGESIZE 1

/* Define if the GNU gettext() function is already present or preinstalled. */
#define HAVE_GETTEXT 1

/* Define to 1 if you have the `getuid' function. */
#define HAVE_GETUID 1

/* Define if you have the iconv() function. */
#define HAVE_ICONV 1

/* Define to 1 if you have the  header file. */
#define HAVE_INTTYPES_H 1

/* Define to 1 if you have the  header file. */
#define HAVE_ISTREAM 1

/* Define this if you have the kpsewhich program working on your system. */
#define HAVE_KPSEWHICH 1

/* Define if you have  and nl_langinfo(CODESET). */
#define HAVE_LANGINFO_CODESET 1

/* Define if your  file defines LC_MESSAGES. */
#define HAVE_LC_MESSAGES 1

/* Define this if you have the AikSaurus library */
/* #undef HAVE_LIBAIKSAURUS */

/* Define to 1 if you have the `c' library (-lc). */
#define HAVE_LIBC 1

/* Define to 1 if you have the `m' library (-lm). */
#define HAVE_LIBM 1

/* Define to 1 if you have the  header file. */
#define HAVE_LIMITS 1

/* Define to 1 if you have the  header file. */
#define HAVE_L

[patch] Re: lyxtextclass comments

2002-11-07 Thread Ben Stanley
On Fri, 2002-11-08 at 00:00, Andre Poenitz wrote:
>  Ben wrote
> > I will make a new patch.
> 
> Thank you.
> 
> Andr'e

Here it is. 

I think I could also move several methods in LyXtextclass from public to
private.

I intend next to do similar documentation on some other classes,
specifically things like LyXParagraph and related insets, and any
iterators.

I now intend to pragmatically set aside at arms length the ideal and
noble notions described previously and to understand and document the
non-ideal code!
Ben.


Index: src/ChangeLog
===
RCS file: /cvs/lyx/lyx-devel/src/ChangeLog,v
retrieving revision 1.972
diff -u -3 -p -u -r1.972 ChangeLog
--- src/ChangeLog	2002/11/07 00:37:08	1.972
+++ src/ChangeLog	2002/11/07 13:01:51
@@ -1,3 +1,7 @@
+2002-11-07  Ben Stanley  <[EMAIL PROTECTED]>
+
+	* lyxtextclass.[Ch]: revise and add doxygen comments
+
 2002-11-07  John Levon  <[EMAIL PROTECTED]>
 
 	* text.C: fix progress value for spellchecker 
Index: src/lyxtextclass.h
===
RCS file: /cvs/lyx/lyx-devel/src/lyxtextclass.h,v
retrieving revision 1.10
diff -u -3 -p -u -r1.10 lyxtextclass.h
--- src/lyxtextclass.h	2002/09/11 07:39:55	1.10
+++ src/lyxtextclass.h	2002/11/07 13:01:52
@@ -30,25 +30,25 @@ class LyXLex;
 class Counters;
 class FloatList;
 
-///
+/// Stores the layout specification of a LyX document class.
 class LyXTextClass {
 public:
-	///
+	/// The individual styles comprising the document class
 	typedef std::vector LayoutList;
-	///
+	/// Enumerate the paragraph styles.
 	typedef LayoutList::const_iterator const_iterator;
-	///
+	/// Construct a layout with default values. Actual values loaded later.
 	explicit
 	LyXTextClass(string const & = string(),
 		 string const & = string(),
 		 string const & = string());
 
-	///
+	/// paragraph styles begin iterator.
 	const_iterator begin() const { return layoutlist_.begin(); }
-	///
+	/// paragraph styles end iterator
 	const_iterator end() const { return layoutlist_.end(); }
 
-	///
+	/// Performs the read of the layout file.
 	bool Read(string const & filename, bool merge = false);
 	///
 	void readOutputType(LyXLex &);
@@ -69,11 +69,11 @@ public:
 	/// Sees to that the textclass structure has been loaded
 	bool load() const;
 
-	/// the list of floats defined in the class
+	/// the list of floats defined in the document class
 	FloatList & floats();
-	/// the list of floats defined in the class
+	/// the list of floats defined in the document class
 	FloatList const & floats() const;
-	/// The Counters present in this textclass.
+	/// The Counters present in this document class.
 	Counters & counters() const;
 	///
 	string const & defaultLayoutName() const;
@@ -128,7 +128,7 @@ public:
 	///
 	int tocdepth() const;
 
-	///
+	/// Can be LaTeX, LinuxDoc, etc.
 	OutputType outputType() const;
 
 	///
@@ -148,11 +148,11 @@ private:
 	bool delete_layout(string const &);
 	///
 	bool do_readStyle(LyXLex &, LyXLayout &);
-	///
+	/// Layout file name
 	string name_;
-	///
+	/// document class name
 	string latexname_;
-	///
+	/// document class description
 	string description_;
 	/// Specific class options
 	string opt_fontsize_;
@@ -164,19 +164,19 @@ private:
 	string pagestyle_;
 	///
 	string defaultlayout_;
-	///
+	/// preamble text to support layout styles
 	string preamble_;
-	///
+	/// latex packages loaded by document class.
 	Provides provides_;
 	///
 	unsigned int columns_;
 	///
 	PageSides sides_;
-	///
+	/// header depth to have numbering
 	int secnumdepth_;
-	///
+	/// header depth to appear in table of contents
 	int tocdepth_;
-	///
+	/// Can be LaTeX, LinuxDoc, etc.
 	OutputType outputType_;
 	/** Base font. The paragraph and layout fonts are resolved against
 	this font. This has to be fully instantiated. Attributes
@@ -189,16 +189,16 @@ private:
 
 	/// Text that dictates how wide the right margin is on the screen
 	string rightmargin_;
-	///
+	/// highest header level used in this layout.
 	int maxcounter_; // add approp. signedness
 
-	///
+	/// Paragraph styles used in this layout
 	LayoutList layoutlist_;
 
-	///
+	/// available types of float, eg. figure, algorithm.
 	boost::shared_ptr floatlist_;
 
-	///
+	/// Types of counters, eg. sections, eqns, figures, avail. in document class.
 	boost::shared_ptr ctrs_;
 
 	/// Has this layout file been loaded yet?
@@ -206,7 +206,7 @@ private:
 };
 
 
-///
+/// Merge two different provides flags into one bit field record
 inline
 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
 {
@@ -214,7 +214,7 @@ void operator|=(LyXTextClass::Provides &
 }
 
 
-///
+/// convert page sides option to text 1 or 2
 std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);
 
 #endif



Re: autoconf-2.53

2002-11-07 Thread Ben Stanley
On Thu, 2002-11-07 at 01:15, Lars Gullik Bjønnes wrote:
> Ben Stanley <[EMAIL PROTECTED]> writes:
> 
> But I compile on RH-8.0 all the time and have no problems.
> 

I just did a complete 

cvs checkout lyx-devel

and then 
autogen.sh
./configure --with-frontend=qt --prefix=/packages/lyx-1.3.0cvs
make

and the new src/config.h displays the same symptoms as before. However,
it now compiles and runs.

Perhaps there was some old stuff in my old cvs directory.

Ben.






Re: lyxtextclass comments

2002-11-07 Thread Ben Stanley
On Thu, 2002-11-07 at 21:05, Andre Poenitz wrote:
> On Thu, Nov 07, 2002 at 12:34:56PM +1100, Ben Stanley wrote:
> > I will try to separate these things then, or at least put in \todo
> > comments where the code looks iffy and then go back to clean code later.
> > Doxygen can generate a page of \todo items, which makes these things
> > easy to find.
> 
> I believe people are more likely to do a 'grep TODO *.C' than to run
> doxygen and look at .html files containing exacly the same information...
Fine, people can do that. The doxygen code to grep for is \todo .

> 
> >  * Load the LyX document file, stored in .lyx format.
> >  * After loading, the document is completely represented in memory  
> >  * using the internal LyX representation.
> >  * \param filename the name of the file to read, with complete path.
> >  * \return true if any error occurred
> >  * \author someone who wrote this function
> >  */
> 
> > The first style is a summary comment, and I use these in class
> > declarations, i.e. header files. The second comment type is the in depth
> > documentation, which I place above the function definition.
> 
> Ok... I think I have to revert my initial positive response to the idea
> then. Adding these "in depth documentation" is BAD for the following
> reasons:
> 
>   - there is no way for the compiler to check whether the code does
> what the comment says.

There is no way for the compiler to check that the subroutine does what
it was supposed to do, either. And there is no way for the reader of the
code to guess why something was done in a particular way unless it was
documented.
> 
>   - the comments eat real screen estate and do not add anything to the
> understanding of the code
> 
> Keeping comment and code onsistent is impossible without using a very
> strict commit policy, which in turn would be a pain in the ... to establish
> and to follow. Moreover, it eats developer's time and is NO FUN.
> 
> If comments are out-of-sync with the code, they are worse than no comments.
Agreed. That is why the comments should say what the code cannot - the
why, the in and the out, and leave the *how* to the code itself.

> 
> IMNSHO the only reason to put comments in the .C are to document
> weird tricks where behaviour is non-obvious, and to temporarily disable
> debug code.
This does not aid a programmer who is looking to *use* a function or to
rapidly grasp the purpose of a class or method.

> 
> The "real screen estate" issue is important, too. I can only grasp what I
> see. If I have to scroll, I have a puzzle - an additional burden.

This problem is addressed by the documentation scheme I originally
proposed. The header retains concise, compact comments, and the longer
stuff is placed in the .C file where you usually have to scroll to read
the code anyway.

> 
> > Placing the documentation closer to the code which it describes means
> > that it is also more likely to be maintained as the code is modified.
> > This is an important consideration.
> 
> Code does not have to be described, it has to describe itself. So if you
> want to pass an absolute path, call that thing 'string const &
> absolute_path' and be done.

I tend to agree with this statement; my example was contrived. However,
variables are often poorly named. There are often pre-conditions which
should exist before calling a method. How the method fits into the big
picture is useful. These things are not, and can not be, described by
the code.

Please remember that I am doing this so that I can understand the code
and obtain feedback on my understanding of how things in LyX work. So
far there has been a lot more words spent on the nature of comments and
whether they are worthwhile at all. For example, I do not yet know if my
understanding of LyXTextClass is correct or way off the mark. The fact
that there are several possible interpretations of the aim of the code
(especially viewing just the header file) further invalidates the narrow
view of comments described above.

Based on feedback here, I will aim for fairly complete short comments,
i.e. /// style, in the header file. These should be adequate to the
requirements expressed here. 

I would like to have *some* longer comments describing the quirks of
methods, where necessary, in the .C files. I do not aim to make these
comments complete. To those who prefer to see documentation in the .h
file, I refer them to the short comments I will put there.

I will make a new patch.

Ben.





Re: lyxtextclass comments

2002-11-06 Thread Ben Stanley
> Andre Poenitz <[EMAIL PROTECTED]> writes:
> 
> | I think it would be prudent to split patches into "documentation stuff"
> | and "small code changes", maybe even to abstain from the small code changes
> | at all.

I will try to separate these things then, or at least put in \todo
comments where the code looks iffy and then go back to clean code later.
Doxygen can generate a page of \todo items, which makes these things
easy to find.

On Thu, 2002-11-07 at 04:17, Lars Gullik Bjønnes wrote:
> Also, until now we have said to document the interfaces in .h and
> implementation in .C. If we are still going to follow that, and I
> think we should, the patch must be redone and move the comments to the
> .h file.

I do not feel that this is sensible. Please let me explain.

Doxygen provides for two levels of comments. Let me provide examples:

short form:
/// Load a lyx document file

long form:
/**
 * Load the LyX document file, stored in .lyx format.
 * After loading, the document is completely represented in memory  
 * using the internal LyX representation.
 * \param filename the name of the file to read, with complete path.
 * \return true if any error occurred
 * \author someone who wrote this function
 */

The first style is a summary comment, and I use these in class
declarations, i.e. header files. The second comment type is the in depth
documentation, which I place above the function definition. When viewing
the HTML documentation provided by Doxygen, the class API is first
described in summary form, using the /// comments, and later each
function is described in depth using the /** ... */ form. There is a
hyperlink from the short to the long.

Placing the documentation closer to the code which it describes means
that it is also more likely to be maintained as the code is modified.
This is an important consideration.

It is possible to place the /** */ form in the header file, but then the
headers will become quite bloated, and this will increase compilation
time. The long form of documentation is quite easily accessible through
the doxygen documentation, when and as required.

In my experience with doxygen, the arrangement of short comments in the
header with longer comments in the source works better than placing long
comments in the header files. I find the doxygen api documentation is
much easier to browse than the source when looking things up.

Ben.





[PATCH] lyxtextclass comments

2002-11-06 Thread Ben Stanley
Hi,

I'm trying to get an overview of the LyX code again, and I thought I'd
try to clean up the documentation while I'm doing it. I started with
LyXTextClass (no particular reason for choosing that file).

I'm trying to figure out what each function/member does by reading
through the code. I'd appreciate it if people could let me know when I
get things wrong, as I inevitably will with the documentation in the
state its in.

The comments are formatted for doxygen. At the moment I'm using my own
custom doxygen configuration file, which also shows me graphical include
and inheritance relationships. Very nice! (This requires the dot
program, which comes in the graphviz package.)

Ben.



Index: src/ChangeLog
===
RCS file: /cvs/lyx/lyx-devel/src/ChangeLog,v
retrieving revision 1.970
diff -u -3 -p -u -r1.970 ChangeLog
--- src/ChangeLog	2002/11/05 18:25:53	1.970
+++ src/ChangeLog	2002/11/06 15:49:23
@@ -1,3 +1,7 @@
+2002-11-07  Ben Stanley  <[EMAIL PROTECTED]>
+
+	* lyxtextclass.[hC]: add and clean up doxygen comments
+
 2002-11-05  Lars Gullik Bjønnes  <[EMAIL PROTECTED]>
 
 	* text2.C (updateCounters): fix bug 668
Index: src/lyxtextclass.C
===
RCS file: /cvs/lyx/lyx-devel/src/lyxtextclass.C,v
retrieving revision 1.21
diff -u -3 -p -u -r1.21 lyxtextclass.C
--- src/lyxtextclass.C	2002/09/11 07:39:55	1.21
+++ src/lyxtextclass.C	2002/11/06 15:49:23
@@ -47,7 +47,14 @@ struct compare_name {
 
 } // anon
 
-
+/**
+ Construct a LyXTextClass and initialise to default values.
+ The actual .layout file is loaded later.
+ 
+ \param fn the name of the .layout file.
+ \param cln the LaTeX document class name.
+ \param desc the description of the document class.
+ */
 LyXTextClass::LyXTextClass(string const & fn, string const & cln,
 			   string const & desc)
 	: name_(fn), latexname_(cln), description_(desc),
@@ -111,7 +118,17 @@ enum TextClassTags {
 };
 
 
-// Reads a textclass structure from file.
+/**
+ * Reads a textclass structure from file. May call itself recursively
+ * to read other included layout files.
+ * \param filename the name of the file to be loaded.
+ * \param merge If false, extra checks are made to ensure that the textclass is complete.
+ * The top level call must set merge to false (the default). Only recursive calls set it to true.
+ * \return true on error while reading the input files.
+ *
+ * \todo could this method be private?
+ * It's called by load, and it calls itself recursively.
+ */
 bool LyXTextClass::Read(string const & filename, bool merge)
 {
 	keyword_item textClassTags[] = {
@@ -744,7 +761,10 @@ bool LyXTextClass::delete_layout(string 
 }
 
 
-// Load textclass info if not loaded yet
+/**
+ * Load textclass info if not loaded yet.
+ * \return false if any error loading the textclass.
+ */
 bool LyXTextClass::load() const
 {
 	if (loaded)
@@ -760,8 +780,9 @@ bool LyXTextClass::load() const
 		   << "')\nCheck your installation and "
 			"try Options/Reconfigure..." << endl;
 		loaded = false;
+	} else {
+		loaded = true;
 	}
-	loaded = true;
 	return loaded;
 }
 
@@ -786,7 +807,7 @@ Counters & LyXTextClass::counters() cons
 
 string const & LyXTextClass::defaultLayoutName() const
 {
-	// This really should come from the actual layout... (Lgb)
+	// \todo This really should come from the actual layout... (Lgb)
 	return defaultlayout_;
 }
 
Index: src/lyxtextclass.h
===
RCS file: /cvs/lyx/lyx-devel/src/lyxtextclass.h,v
retrieving revision 1.10
diff -u -3 -p -u -r1.10 lyxtextclass.h
--- src/lyxtextclass.h	2002/09/11 07:39:55	1.10
+++ src/lyxtextclass.h	2002/11/06 15:49:23
@@ -17,20 +17,21 @@
 #endif
 
 #include "lyxlayout.h"
-#include "LString.h"
 #include "lyxlayout_ptr_fwd.h"
 
 #include "support/types.h"
 
-#include 
-
-#include 
-
 class LyXLex;
 class Counters;
 class FloatList;
 
-///
+/// Manages a LyX document.
+/** 
+ * Contains all of the information required to display, edit and process a LyX document.
+ * This includes the document text, figures, formulae and other insets, the fonts used,
+ * the paper size, the screen layout used (as defined by the .layout file), and extra
+ * LaTeX packages which are required by the document.
+*/
 class LyXTextClass {
 public:
 	///
@@ -66,7 +67,7 @@ public:
 	///
 	LyXLayout_ptr const & operator[](string const & vname) const;
 
-	/// Sees to that the textclass structure has been loaded
+	/// Ensures that the textclass structure has been loaded
 	bool load() const;
 
 	/// the list of floats defined in the class
@@ -114,18 +115,16 @@ public:
 
 	///
 	unsigned int columns() const;
-	///
+	/// Use one or two sides of the page?
 	enum PageSides {
-		///
 		OneSide,
-		///
 		TwoSides
 	};
 	///
 	

Re: autoconf-2.53

2002-11-06 Thread Ben Stanley
On Thu, 2002-11-07 at 00:37, Jean-Marc Lasgouttes wrote:
> >>>>> "Ben" == Ben Stanley <[EMAIL PROTECTED]> writes:
> 
> Ben> OK, I did a cvs up, and tested the build... and I *still* get
> Ben> failures on duplicate declarations of strerror and mkstemp.
> 
> Are you sure you ran autogen.sh?
> 
> JMarc
> 
Yes, I removed config.status and ran autogen.sh again and then 
configure and make just to be sure.

Ben.




Re: autoconf-2.53

2002-11-06 Thread Ben Stanley
On Wed, 2002-11-06 at 21:19, Jean-Marc Lasgouttes wrote:
> > "Lars" == Lars Gullik Bjønnes <[EMAIL PROTECTED]> writes:
> 
> Lars> Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes: |
> Lars> > "Lars" == Lars Gullik Bjønnes <[EMAIL PROTECTED]> writes:
> Lars> | 
> Lars> | Lars> I already did it.
> Lars> | 
> Lars> | Excellent.
> 

OK, I did a cvs up, and tested the build... and I *still* get failures
on duplicate declarations of strerror and mkstemp.

The strerror problem can be fixed by putting in

AC_CHECK_FUNCS(strerror)

which causes HAVE_STRERROR to be defined in src/config.h when strerror
is present, as required.

The mkstemp problem is caused by the macro HAVE_DECL_MKSTEMP not being
defined, when it should be. This should be defined through the actions
of 

LYX_CHECK_DECL_HDRS(mkstemp,[unistd.h stdlib.h]) 

, but it fails to define HAVE_DECL_MKSTEMP, despite succeeding in
finding the declaration (as reported in config.log). I have verified
that manually inserting #define HAVE_DECL_MKSTEMP into src/config.h
causes the build to proceed.

I'm unsure of how to properly fix the mkstemp problem.

So while some changes have been made to config/autoconf.ac , they have
not fixed either problem reported so far.

Ben.






autoconf-2.53

2002-11-05 Thread Ben Stanley

Hi,

I'm trying to compile LyX 1.3.0cvs on RedHat 8.0, and I found that I got
a double declaration of strerror. This is primarily caused by there
being no *test* for strerror, but there is a macro which declares
strerror if HAVE_STRERROR is not defined.

I fixed this problem by adding

AC_CHECK_FUNCS(strerror)

to config/autoconf.ac . Then I ran into another problem, that mkstemp
was declared more than once. 

Investigation reveals that the following code provides the redundant
declaration:

#ifdef HAVE_MKSTEMP
#ifndef HAVE_DECL_MKSTEMP
#if defined(__cplusplus)
extern "C"
#endif
int mkstemp(char*);
#endif
#endif

The macro HAVE_MKSTEMP is defined further up src/config.h, but
HAVE_DECL_MKSTEMP is never defined. In config.log I found

configure:17585: checking if mkstemp is declared by header unistd.h
configure:17615: result: yes

Thus it appears that there is something wrong with LYX_CHECK_DECL, which
should have defined HAVE_DECL_MKSTEMP when it found the function.

Has anyone else had success with cvs lyx and autoconf 2.53? What did you
do?

Ben.
Returning to lyx-devel after a long period of absence, during which I
have completed and submitted my thesis. Thanks to all lyx authors who
made it possible!







[Fwd: Re: Fixed Ghostscript rpms for RH7.2]

2001-12-30 Thread Ben Stanley



--- Begin Message ---

On Mon, Dec 31, 2001 at 02:55:19PM +1100, Ben Stanley wrote:
> Kayvan A. Sylvan wrote:
> 
> >>Kayvan A. Sylvan wrote:
> >>
> >>>Put it in my ftp.sylvan.com/incoming/forlyx directory (a temporary
> >>>place that will disappear when you tell me the download is complete).
> >>>
> Finished.

Great. Moved to ftp.sylvan.com:/pub/lyx

-- 
Kayvan A. Sylvan  | Proud husband of   | Father to my kids:
Sylvan Associates, Inc.   | Laura Isabella Sylvan  | Katherine Yelena (8/8/89)
http://sylvan.com/~kayvan | "crown of her husband" | Robin Gregory (2/28/92)

--- End Message ---


Re: Fixed Ghostscript rpms for RH7.2

2001-12-30 Thread Ben Stanley

John Levon wrote:

>Good move. I'm sure Kayvan can host it at the ftp site.
>
OK, Kayvan, where would you like it? I don't have enough space to make 
it publicly available to you, and it seems too large to email.

BTW, I just noticed that the preview graphics quality on photographs 
gets quite a boost by upgrading to this rpm...

Ben.






Fixed Ghostscript rpms for RH7.2

2001-12-29 Thread Ben Stanley

Hi,

I made up an rpm of ghostscript for RH7.2 with the patch (see 
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=55772) applied 
which fixes the rendering problem with LyX preview figures.

If there is a place to put it, I can upload it somewhere.

I have a .src.rpm (14.5Mb) and a .i386.rpm (7Mb).

Ben.





Re: RFC: Sound Approach?

2001-12-29 Thread Ben Stanley

Lars,

I had look at the patch... Seems that the Paragraph::next and 
Paragraph::previous are still in use. How do you plan to remove them? I 
suppose that once you have encapsulated them inside the iterator and 
removed all uses from the rest of the code that it will be an easy 
matter to remove them from the Paragraph class.

However, I am still curious as to why LyX is full of Iterator-this and 
Iterator-that classes, when the STL provides iterators for all of it's 
containers. Wouldn't it be more sensible to use an STL list, vector or 
even deque to contain the Paragraph pointers? Even better, use an STL 
container of reference counted paragraph pointers, eg

typedef vector > ParagraphList;

Of course, your choice of vector or list depends on what iterator 
properties you want; vector gives you random access, whereas list only 
gives you bidirectional iterators (this is all we are currently using).

The shared pointer approach here works because it's the container that 
contains the shared pointer, not the paragraphs.

The problem with this is that paragraph methods which iterate will need 
to be changed to accept iterator arguments, as they cannot reference 
Paragraph::next to do the iterating any more. (But this is a cleanup 
that needed to happen anyway.)

Using a vector like this would require all of the changes to the code to 
be made in one go, as it would require removing Paragraph::next and 
Paragraph::previous when the implementation starts, so the changeover 
would be less graceful.

Benefit of this approach is that we have fewer custom container and 
iterator classes to write and maintain (and remember).

Ben.

Lars Gullik Bjønnes wrote:

>I have begin leffling with the paragraph-linked-list rewrite, part of
>this is of course to remove the Paragraph::next and
>Paragraph::previous.
>
>I have introduced a new class ParagraphList with accompanying
>Iterator.
>
>So far I have only the header file for this, and have converted class
>buffer to use it (the attached diff).
>
>I'd like to have some comments on if this approach seems sound. (It
>surely is a _lot_ of work.)
>
Yes, but I'm glad to see that it's starting. I could probably help a bit 
here with some creative grepping or sed scripts...




[PATCH] DepTable

2001-12-14 Thread Ben Stanley

John Levon wrote:

>oh, and ben says you all suck for not applying his mmap deptable patch [1]
>
>john
>[1] not really
>
Um, I was just wondering if it went to > /dev/null. Here it is again, 
for 1.2cvs.

This patch fixes errors which will cause excessive numbers of LaTeX 
runs, and makes the new deptable file compatible with previous versions 
of Lyx (and vice versa).

Ben.




--- lyx-devel-orig/src/ChangeLogWed Dec 12 09:26:32 2001
+++ lyx-devel/src/ChangeLog Wed Dec 12 09:24:51 2001
@@ -1,3 +1,9 @@
+2001-12-12  Ben Stanley  <[EMAIL PROTECTED]>
+
+   * DepTable.h
+   * DepTable.C: Implement mtime checking to reduce time
+   spent doing CRCs.
+
 2001-12-10  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
 
* tabular-old.C (getTokenValue): 
--- lyx-devel-orig/src/DepTable.h   Tue Nov 27 13:56:55 2001
+++ lyx-devel/src/DepTable.hFri Dec  7 13:01:06 2001
@@ -8,6 +8,7 @@
  *
  *   This file is Copyright 1996-2001
  *   Lars Gullik Bjønnes
+ *   Ben Stanley
  *
  * == 
  */
@@ -29,9 +30,7 @@
  filename. Should we insert files with .sty .cls etc as
  extension? */
void insert(string const & f,
-   bool upd = false,
-   unsigned long one = 0,
-   unsigned long two = 0);
+   bool upd = false);
///
void update();
 
@@ -47,14 +46,23 @@
bool extchanged(string const & ext) const;
///
bool exist(string const & fil) const;
+   /// returns true if any files with ext exist
+   bool ext_exist(string const& ext) const;
///
void remove_files_with_extension(string const &);
+   ///
+   void remove_file(string const &);
 private:
///
struct dep_info {
-   unsigned long first;
-   unsigned long second;
-   long mtime;
+   /// Previously calculated CRC value
+   unsigned long crc_prev;
+   /// Current CRC value - only re-computed if mtime has changed.
+   unsigned long crc_cur;
+   /// mtime from last time current CRC was calculated.
+   long mtime_cur;
+   ///
+   bool changed() const;
};
///
typedef std::map DepList;
@@ -63,3 +71,4 @@
 };
 
 #endif
+
--- lyx-devel-orig/src/DepTable.C   Thu Dec  6 10:57:59 2001
+++ lyx-devel/src/DepTable.CWed Dec 12 08:31:26 2001
@@ -7,6 +7,7 @@
  *
  *   This file is Copyright 1996-2001
  *   Lars Gullik Bjønnes
+ *   Ben Stanley
  *
  * == 
  */
@@ -35,69 +36,78 @@
 using std::ifstream;
 using std::endl;
 
+inline bool DepTable::dep_info::changed() const
+{
+   return crc_prev != crc_cur && crc_cur != 0;
+}
+
 void DepTable::insert(string const & fi,
- bool upd,
- unsigned long one,
- unsigned long two)
+ bool upd)
 {
// not quite sure if this is the correct place for MakeAbsPath
string f = MakeAbsPath(fi);
if (deplist.find(f) == deplist.end()) {
-   long mtime = 0;
+   dep_info di;
+   di.crc_prev = 0;
if (upd) {
-   one = two;
-   two = lyx::sum(f);
+   lyxerr[Debug::DEPEND] << " CRC..." << flush;
+   di.crc_cur = lyx::sum(f);
+   lyxerr[Debug::DEPEND] << "done." << endl;
struct stat f_info;
stat(fi.c_str(), &f_info);
-   mtime = f_info.st_mtime;
+   di.mtime_cur = f_info.st_mtime;
+   } else {
+   di.crc_cur = 0;
+   di.mtime_cur = 0;
}
-   dep_info di;
-   di.first = one;
-   di.second = two;
-   di.mtime = mtime;
-#if 0  
-   deplist[f] = make_pair(one, two);
-#else
deplist[f] = di;
-#endif
+   } else {
+   lyxerr[Debug::DEPEND] << " Already in DepTable" << endl;
}
 }

 
 void DepTable::update()
 {
-   for (DepList::iterator itr = deplist.begin();
-   itr != deplist.end();
-   ++itr) {
-   unsigned long const one = itr->second.second;
-   unsigned long two = one;
-   long mtime = itr->second.mtime;
-   struct stat f_info;
-   stat(itr->first.c_str(), &f_info);
+   lyxerr[Debug::DEPEND] << "Updating DepTable..." << endl;
+   time_t start_time = time(0);
 
-  

Re: Undo & leaking

2001-12-14 Thread Ben Stanley

Jean-Marc Lasgouttes wrote:

>So you will be able to insert a paragraph in a paragraph. How will
>that look like? You need some kind of wrapper around it, and it's
>called an inset nowadays. 
>
I think a paragraph should be an inset. Yes, inserting a paragraph in a 
paragraph doesn't make much sense, but the code can control what gets 
created where... Just because the architecture supports that happening 
doesn't mean we have to write the code so it *can* happen.

My error reporting code would have been simpler if I hadn't have had to 
deal with paragraphs being a separate entity.

Ben.





Re: Visitor ...

2001-12-13 Thread Ben Stanley

Allan Rae wrote:

>
>I'll check my copy of, of, ummm,  I've forgotten the name.
>It's about implementing patterns as templates.
>
>Allan. (ARRae)
>
Been there, tried that, but John and I didn't succeed. Good luck.

I thought that we could use the Barton and Nackman trick (see Scientific 
and Engineering C++, by same authors, named after a pattern that was 
used extensively in that book), but you can't re-define a virtual method 
by inheriting it through another base class.

Ben.





Re: Inset Visitors...

2001-12-13 Thread Ben Stanley

John Levon wrote:

>On Fri, Dec 14, 2001 at 02:07:05PM +1100, Ben Stanley wrote:
>
>>John Leveon asked me  how you would specify that one kind of inset is 
>>searchable but not spell-checkable, and that another kind of inset is 
>>spell-checkable and not searchable. Here is a complete self-contained 
>>example.
>>
>
>OK, I get it now, the method lookup does the type inspection via the parameter type
>matching. 
>
Uh, by the function name, but could name them all the same and do it by 
parameter type. The type lookup is really by the virtual Accept function 
in all the insets.

>That was the crucial point I was missing :)
>
>And I like it, I think. Not sure about the other example though ...
>
Oh, didn't you like it? The contents of the visitor's methods would be 
pretty much the same as the current WriteAsText (or equivalent) methods 
dotted all over the Inset code... It just collects it all into one 
place. And where the WriteAsText method would call a sub-inset's 
WriteAsText method to get it to write itself out, the Visitor's method 
would call
inset.Accept(*this);
to do the same thing and correctly virtually dispatch it.

Then all the WriteAsText code is collected into one file, all together, 
easier to maintain and make sure it's all consistent.

Ben.






Re: Inset Visitors...

2001-12-13 Thread Ben Stanley

John Leveon asked me  how you would specify that one kind of inset is 
searchable but not spell-checkable, and that another kind of inset is 
spell-checkable and not searchable. Here is a complete self-contained 
example.

class InsetVisitor;

class Inset {
// blah blah
   virtual void Accept(InsetVisitor&) = 0;
};

class InsetSpellCheckable : public Inset {
// blah blah
   virtual void Accept(InsetVisitor& iv ) { iv.VisitInsetA(*this); }
};

class InsetSearchable : public Inset {
// blah blah
   virtual void Accept(InsetVisitor& iv ) { iv.VisitInsetB(*this); }
};


class InsetVisitor {
// blah blah
   virtual void VisitInsetSpellCheckable( InsetSpellCheckable& ) = 0;
   virtual void VisitInsetSearchable( InsetSearchable& ) = 0;
};

// Once-off infrastructure
class InsetVisitorNOP : public InsetVisitor {
   virtual void VisitInsetSpellCheckable( InsetSpellCheckable& ) {}
   virtual void VisitInsetSearchable( InsetSearchable& ) {}
};

class SpellCheckInsetVisitor : public InsetVisitorNOP {
// blah blah
public:
   virtual void VisitInsetSpellCheckable( InsetSpellCheckable& i ) {
   // Carry out spellcheck on contents of InsetSpellcheckable
}
};

class SearchableInsetVisitor : public InsetVisitorNOP {
// blah blah
public:
virtual void VisitInsetSearchable( InsetSearchable& i ) {
// Carry out search on contents of InsetSearchable
}
};

Note that only one set of Accepts methods is necessary in the Insets to 
support both (and any other) kinds of visitors.

Furthermore, you may define a modular exporter:

// Export to text file
class WriteAsTextInsetVisitor
: public  InsetVisitor // Compiler will give errors if new class is 
added that we didn't visit.
{
 public:
virtual void VisitInsetSearchable( InsetSearchable& i ) {
// Write out an InsetSearchable as text format, including any 
sub-insets...
}
virtual void VisitInsetSpellCheckable( InsetSpellCheckable& i ) {
// Write out an InsetSpellCheckable as text format, including 
any sub-insets...
}
};

Note that this visitor could be placed into a dynamic link library if 
required, or conditionally compiled, or whatever... it has completely 
removed the export code from all of the insets. It could be a new 
feature you are adding for testing (without touching any existing inset 
code).

Ben.





Re: Inset Visitors...

2001-12-13 Thread Ben Stanley

John Levon wrote:

>On Fri, Dec 14, 2001 at 12:48:23PM +1100, Ben Stanley wrote:
>
>>>what's the point in calling back like this ? This looks like it requires
>>>an VisitInsetX for every class X ? And furthermore, one that must be
>>>public.
>>>
>>The point of calling back is that it gives you the virtual dispatch. 
>>It's the whole point of the scheme. Yes, it does require a VisitInsetX 
>>for every class X, but if you inherit from an InsetVisitorNOP class 
>>which provides default implementations for VisitInsetX for every class X 
>>which are empty, then this point is moot.
>>
>
>this also applies to an iterator scheme with allowSpellCheck().
>
*** With the visitor scheme, the spell check method would actually be 
done in the visitor, not the Inset.

This removes all spell check code from the inset.

*** All the inset needs to provide is a way of accessing it's 
characters. This also facilitates other external methods anyway.


If, for some strange reason, you had to build a LyX without 
spellchecking code, it would be easy - just don't include the spell 
check visitor file in the compilation, and it's gone.

So this scheme allows you to easily add/remove features without changing 
the inset code (once you've added Accept methods to every inset). This 
allows for easier addition of new features without touching/breaking 
unrelated code.

>>>OK, ugly, but we are doing RTTI here. Having inner spell code public (or friended,
>>>which is not much nicer) is also ugly ...
>>>
I'm saying the spell check code doesn't belong in the inset, it belongs 
in the visitor. That way, all the different ways of spell checking 
insets are in the same place (if any insets need to have it done 
differently).

>>It also means that every time you want to add a new fandangled operation 
>>on an inset, you have to
>>a) modify Inset to have an allowX() method
>>b) modify the class(es) of interest to support the new fandangled operation.
>>
>>This way, all the mods are done in one place, without ever touching the 
>>Inset classes (apart from adding the visitor support infrastructure in 
>>the first place).
>>
>
>iterator way: for new operations, add a new Accept() (or similar) for each inset
>  that wants it (also use virtual where possible to avoid this)
>
and modify the base class, and have to re-compile the whole inset tree, 
and anything else that uses it.

>your way: for new operations, add a new Accept() for inset that needs it (also use
>  virtual where possible to avoid this) PLUS a new thing in the calling class for
>  every type
>
No, Add Accept once only per inset.

Subsequently only add a method to your visitor class. Only re-compile 
the visitor class - test quickly.





Re: Inset Visitors...

2001-12-13 Thread Ben Stanley

John Levon wrote:

>On Fri, Dec 14, 2001 at 11:02:51AM +1100, Ben Stanley wrote:
>
>>class InsetA : public Inset {
>>// blah blah
>>   virtual void Accept(InsetVisitor& iv ) { iv.VisitInsetA(*this); }
>>};
>>
>>class InsetVisitor {
>>// blah blah
>>   virtual void VisitInsetA( InsetA& ) = 0;
>>};
>>
>
>what's the point in calling back like this ? This looks like it requires
>an VisitInsetX for every class X ? And furthermore, one that must be
>public.
>
The point of calling back is that it gives you the virtual dispatch. 
It's the whole point of the scheme. Yes, it does require a VisitInsetX 
for every class X, but if you inherit from an InsetVisitorNOP class 
which provides default implementations for VisitInsetX for every class X 
which are empty, then this point is moot.

>
>
>What is wrong with :
>
>  for (InsetIterator i = insets.begin(); i != insets.end(); ++i) {
>   if (i->allowSpellcheck()) {
>   spellcheckInset(*i); // private method of Spell class
>   } else if (i->somethingSpecial()) {
>   spellcheckSpecialInset(*i);
>   }
>  }
>
>exactly ?
>
Well, firstly you have to typecast the inset in 
spellcheckInset(typecast-here(*i))...

It also means that every time you want to add a new fandangled operation 
on an inset, you have to
a) modify Inset to have an allowX() method
b) modify the class(es) of interest to support the new fandangled operation.

This way, all the mods are done in one place, without ever touching the 
Inset classes (apart from adding the visitor support infrastructure in 
the first place).

>
>
>this centralises the spellchecking code, and reduces public code.
>
>Note: everyone agrees the current method of not using an iterator isn't good ...
>
The iterator isn't the point, but this scheme can be used to support a 
global recursive inset iterator as well, without hacking the insets 
themselves.

>>(I usually define some fancier ways of doing this so that information 
>>can be passed to the spell checker object, but this is simplest for 
>>illustration.)
>>
>
>which is another disadvantage of your scheme ...
>
Not really...
Here it is:

class InsetVisitorNOP : public InsetVisitor {
virtual void VisitInsetA( InsetA& ) {}
virtual void VisitInsetB( InsetB& ) {}
};

class SpellCheckInsetVisitor : public InsetVisitorNOP {

result_type operator()( Inset& i, FancyType _someSpellCheckInfo ) {
someSpellCheckInfo = _someSpellCheckInfo;
i.Accept(*this);
return result;
}

virtual void VisitInsetA( InsetA& i ) {
// use someSpellCheckInfo with InsetA
// set result
}

private:
FancyType someSpellCheckInfo;
result_type result;
};

>
>
>>that you only need to add one method to every inset - the Accept method. 
>>From then on, you are free to define new operations upon insets without 
>>touching the insets themselves...
>>
>
>I think this is a dubious advantage. Explain to me again why it is better
>that the information an inset should not be spellchecked is part of the
>Spell class rather than part of the MyInset class ?
>
Well, I thought that one was rather obvious actually...
It means that you can tell at a glance (ie in one place) what classes 
are affected by the operation, without having to chase all over the 
header files etc.

It also makes it very quick to define a new kind of operation, and to 
add it (even just locally for testing) without having to make changes 
everywhere else. The new operation is only kept locally.

This scheme can also be used for constructing an Inset iterator which 
iterates over all of the insets held by an Inset class (one level). You 
define an InsetVisitor which has the capacity to visit an Inset and 
return the correct kind of iterator to traverse it's contained Insets. 
If the inset contains no other insets, it just returns an empty 
iterator. Of course this could also be implemented the other way, ie by 
modifiying the individual insets, but this way keeps all of the iterator 
creation code in one place.

I find it much easier to work with the Visitor pattern than modifying 
every class in a hierarchy because I don't have to jump around every 
file to add a new operation - I onlyl have to define one new class, 
usually above the bit that needs to use it. Much easier - also helps to 
reduce the need for re-compilation.

Ben.





Re: Undo & leaking

2001-12-13 Thread Ben Stanley

Lars Gullik Bjønnes wrote:

>ref_ptr->obj->ref_ptr->obj->ref_ptr->obj
>
>and run reset(0) on the first, the refcount is decremented on all the
>rest as well and if the refcount reach zero the paragraph is deleted,
>just like we would expect.
>
>I think it would work.
>
In the case you have above, it would work. But that is not the case in 
the LyX code. From paragraph.h:

private:
/// if anything uses this we don't want it to.
Paragraph(Paragraph const &);
///
Paragraph * next_;
///
Paragraph * previous_;

So Paragraphs form a doubly linked list... this is a self-referencing 
structure, and reference counted pointers don't work there. (The 
offending data will never be deleted.)

In general, reference counted pointers do not work in cyclical 
structures. They work fine in acyclic structures (ones that don't 
reference themselves).

However, if you were to remove the doubly linked list structure from 
Paragraph and insted place reference counted paragraph pointers into a 
vector (as previously pointed out), then this would work fine. (I do 
this sort of thing all the time in my own code.) this would also allow 
you to keep a (reference counted) paragraph pointer in the undo code 
until such time as it was no longer required, and it would all 
`magically' figure itself out correctly.

The original post referred to manually unlinking from the list before 
expecting the reference counted stuff to do it's magic - that may also 
work, but is not as clean...

Ben.





Inset Visitors...

2001-12-13 Thread Ben Stanley

When I did my extended error reporting modification to LyX, I added 
Inset Visitors. I found them to be very useful...

For those unfamiliar with the Visitor pattern, I strongly suggest you 
grab a copy of "Design Patterns", by Gamma et al. See page 331. Well 
worth the read... but, I'll attempt to summarise the properties of the 
pattern here.

The Visitor pattern is useful for processing different elements in a 
polymorphic structure (eg the document tree). It allows you to define 
operations upon different classes (eg Inset types) differently depending 
upon the class type, without modifying the original class. Consider the 
following infrastructure:


class InsetVisitor;

class Inset {
// blah blah
virtual void Accept(InsetVisitor&) = 0;
};

class InsetA : public Inset {
// blah blah
virtual void Accept(InsetVisitor& iv ) { iv.VisitInsetA(*this); }
};

class InsetB : public Inset {
// blah blah
virtual void Accept(InsetVisitor& iv ) { iv.VisitInsetB(*this); }
};


class InsetVisitor {
// blah blah
virtual void VisitInsetA( InsetA& ) = 0;
virtual void VisitInsetB( InsetB& ) = 0;
};


I may now extract the, for example, spell-checking methods from 
LyXParagraph, and define a single visitor which knows what to do to any 
particular kind of inset to perform spell-checking on it (that was a bad 
example to pick, maybe someone else can come up with a better one...):

class SpellCheckInsetVisitor : public InsetVisitor {
 // blah blah
virtual void VisitInsetA( InsetA& i ) {
// Carry out spellcheck on contents of InsetA
 }
virtual void VisitInsetB( InsetB& i ) {
// InsetB doesn't have any text that you can spellcheck, so do 
nothing.
}
};

This means that all the 'spellchecking' (or whatever) code related to a 
single kind of operation is contained within a single visitor class 
instead of being strewn all over the code in methods of individual insets.

To use it, the spell checker driver does this:
SpellCheckerVisitor spell;
for( InsetIterator i = insets.begin(); i != insets.end(); ++i ) {
i->Accept(spell);
}

(I usually define some fancier ways of doing this so that information 
can be passed to the spell checker object, but this is simplest for 
illustration.)

The call to Inset::Accept bounces to the visitor's VisitInsetA or 
VisitInsetB method depending on what type of inset it is, according to 
the vtable ie it's efficient.

I actually used these for traversing the document and collecting labels, 
citations, bibliography boxes, and ERTs for use in error reporting, but 
they have so many other uses as well. The wonderful thing about it is 
that you only need to add one method to every inset - the Accept method. 
 From then on, you are free to define new operations upon insets without 
touching the insets themselves...

Note that the operations contained within the visitor classes can only 
utilise public interfaces on the insets they manipulate. This means that 
the Inset interface must be complete. - no fiddling with private innards 
may be done this way.

This pattern does have a disadvantage: If you keep adding new insets 
types, you have to go and add methods for them all to all the different 
kinds of inset visitors. This may be overcome by creating an inset 
visitor class which does nothing - ie all abstract methods from the base 
class are implemented as no-ops. Actual operation visitors would then 
inherit from this and only override the methods that they need. However, 
this leads to 'forgetting' to add the required methods to the visitors 
in the few cases where they are really necessary, as the compiler will 
no longer complain... you will just get a silent nop where perhaps you 
expected to spellcheck the contents of a caption. These kinds of 
problems are easy to fix, just not so easy to detect.

Anyway, I found that using this pattern gave me incredible flexibility 
in implementing my extended error handling code, and I wondered if 
anyone else thought there might be applications for it in the current 
LyX code base.

Ben.





Re: Undo & leaking

2001-12-13 Thread Ben Stanley

Lars Gullik Bjønnes wrote:

>One of my huge goals is to get rid of the paragraph linked list as we
>have it now, and have the paragraphs in an stl container of some sort.
>This also means moving a lot of algorithms out of LyXParagraph so it
>is a lot of work. But I have a very strong feeling that this would
>cleanup the code a _lot_.
>
I like this idea. (Just not the work involved...) Anything that cleans 
up the code can help squash strange bugs... (and introduce new ones, I 
know, but if the architecture is superior then the bugs should be fewer 
and easier to squash.)

But, als while we are at it, can someone explain to me why a Paragraph 
is not some kind of Inset? I suppose it's historical...

Ben





Re: [PATCH] mmap CRC checking 1.2cvs

2001-12-13 Thread Ben Stanley

Jean-Marc Lasgouttes wrote:

>Ben, it seems to me that you sent a patch, but I lost it. Could you
>re-send?
>
Here it is.

I'd appreciate it if people on strange platforms could test it out and 
report any problems to me, thanks. I think this one should resolve the 
compile problems we had on Solaris and compaq cxx, and satisfy the 
regulations of the style police...

Ben.




--- lyx-devel-orig/src/support/ChangeLogThu Dec  6 12:28:42 2001
+++ lyx-devel/src/support/ChangeLog Wed Dec 12 09:53:19 2001
@@ -1,3 +1,7 @@
+2001-12-12  Ben Stanley  <[EMAIL PROTECTED]>
+
+   * lyxsum.C: portability fix for mmap patch
+
 2001-12-05  Lars Gullik Bjønnes  <[EMAIL PROTECTED]>
 
* filetools.C:
--- lyx-devel-orig/src/support/lyxsum.C Thu Dec  6 12:28:42 2001
+++ lyx-devel/src/support/lyxsum.C  Wed Dec 12 09:52:15 2001
@@ -23,6 +23,10 @@
 #warning lyx::sum() using mmap (lightning fast)
 #endif
 
+// Make sure we get modern version of mmap and friends with void*,
+// not `compatibility' version with caddr_t.
+#define _POSIX_C_SOURCE 199506L
+
 #include 
 #include 
 #include 
@@ -40,7 +44,8 @@

void * mm = mmap(0, info.st_size, PROT_READ,
 MAP_PRIVATE, fd, 0);
-   if (mm == MAP_FAILED) {
+   // Some platforms have the wrong type for MAP_FAILED (compaq cxx).
+   if (mm == reinterpret_cast(MAP_FAILED)) {
close(fd);
return 0;
}



[PATCH] Re: mmap CRC checking 1.2cvs

2001-12-11 Thread Ben Stanley

Jean-Marc Lasgouttes wrote:

>I am not sure about that, but I believe you :) However, until we are
>sure we have no complaint from HP-UX, AIX SCO or whatever people, I'd
>rather not put it in 1.1.6.
>
OK. Please apply this to 1.2cvs so we can find out if this fixes it for 
everyone.

>Is it possible to do a reintepret_cast which would work always?
>Something like
> if (reinterpret_cast(mm) == reinterpret_cast(MAP_FAILED))
>or is C++ stupid enough to reject this when one type is already void*? 
>
We can't do this because we have to know what type to declare mm as... 
(I suppose we could move the cast to wrap around mmap instead, but...)

By using the _POSIX_C_SOURCE macro, I expect that mmap should return 
void* always. In fact, I want people to try out this patch and tell me 
if it doesn't work on their platform as is.

>We could also use good old C casts (since this is a C matter, after
>all), if Lars agrees. It seems that now that the problem is somewhat
>understood, a brutal cast (with a comment explaining why it is needed)
>may be enough and better than convoluted configure things.
>
I only suggested all that because somebody rejected the simple solution...

>We already define _ALL_C_SOURCE in config.h in some cases. Is it also
>useful here?
>
Don't know anything about that one.

Ben.





[PATCH] Re: DepTable patch for 1.2cvs

2001-12-11 Thread Ben Stanley

Ben Stanley wrote:

> I have now written something for 1.2 which keeps only one mtime; I'd 
> better test before posting.

Dammit I'd better hit the attach button instead of the send button...

Anyway, this patch corrects and tidies up the mtime stuff.

Ben.



--- lyx-devel-orig/src/ChangeLogWed Dec 12 09:26:32 2001
+++ lyx-devel/src/ChangeLog Wed Dec 12 09:24:51 2001
@@ -1,3 +1,9 @@
+2001-12-12  Ben Stanley  <[EMAIL PROTECTED]>
+
+   * DepTable.h
+   * DepTable.C: Implement mtime checking to reduce time
+   spent doing CRCs.
+
 2001-12-10  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
 
* tabular-old.C (getTokenValue): 
--- lyx-devel-orig/src/DepTable.h   Tue Nov 27 13:56:55 2001
+++ lyx-devel/src/DepTable.hFri Dec  7 13:01:06 2001
@@ -8,6 +8,7 @@
  *
  *   This file is Copyright 1996-2001
  *   Lars Gullik Bjønnes
+ *   Ben Stanley
  *
  * == 
  */
@@ -29,9 +30,7 @@
  filename. Should we insert files with .sty .cls etc as
  extension? */
void insert(string const & f,
-   bool upd = false,
-   unsigned long one = 0,
-   unsigned long two = 0);
+   bool upd = false);
///
void update();
 
@@ -47,14 +46,23 @@
bool extchanged(string const & ext) const;
///
bool exist(string const & fil) const;
+   /// returns true if any files with ext exist
+   bool ext_exist(string const& ext) const;
///
void remove_files_with_extension(string const &);
+   ///
+   void remove_file(string const &);
 private:
///
struct dep_info {
-   unsigned long first;
-   unsigned long second;
-   long mtime;
+   /// Previously calculated CRC value
+   unsigned long crc_prev;
+   /// Current CRC value - only re-computed if mtime has changed.
+   unsigned long crc_cur;
+   /// mtime from last time current CRC was calculated.
+   long mtime_cur;
+   ///
+   bool changed() const;
};
///
typedef std::map DepList;
@@ -63,3 +71,4 @@
 };
 
 #endif
+
--- lyx-devel-orig/src/DepTable.C   Thu Dec  6 10:57:59 2001
+++ lyx-devel/src/DepTable.CWed Dec 12 08:31:26 2001
@@ -7,6 +7,7 @@
  *
  *   This file is Copyright 1996-2001
  *   Lars Gullik Bjønnes
+ *   Ben Stanley
  *
  * == 
  */
@@ -35,69 +36,78 @@
 using std::ifstream;
 using std::endl;
 
+inline bool DepTable::dep_info::changed() const
+{
+   return crc_prev != crc_cur && crc_cur != 0;
+}
+
 void DepTable::insert(string const & fi,
- bool upd,
- unsigned long one,
- unsigned long two)
+ bool upd)
 {
// not quite sure if this is the correct place for MakeAbsPath
string f = MakeAbsPath(fi);
if (deplist.find(f) == deplist.end()) {
-   long mtime = 0;
+   dep_info di;
+   di.crc_prev = 0;
if (upd) {
-   one = two;
-   two = lyx::sum(f);
+   lyxerr[Debug::DEPEND] << " CRC..." << flush;
+   di.crc_cur = lyx::sum(f);
+   lyxerr[Debug::DEPEND] << "done." << endl;
struct stat f_info;
stat(fi.c_str(), &f_info);
-   mtime = f_info.st_mtime;
+   di.mtime_cur = f_info.st_mtime;
+   } else {
+   di.crc_cur = 0;
+   di.mtime_cur = 0;
}
-   dep_info di;
-   di.first = one;
-   di.second = two;
-   di.mtime = mtime;
-#if 0  
-   deplist[f] = make_pair(one, two);
-#else
deplist[f] = di;
-#endif
+   } else {
+   lyxerr[Debug::DEPEND] << " Already in DepTable" << endl;
}
 }

 
 void DepTable::update()
 {
-   for (DepList::iterator itr = deplist.begin();
-   itr != deplist.end();
-   ++itr) {
-   unsigned long const one = itr->second.second;
-   unsigned long two = one;
-   long mtime = itr->second.mtime;
-   struct stat f_info;
-   stat(itr->first.c_str(), &f_info);
+   lyxerr[Debug::DEPEND] << "Updating DepTable..." << endl;
+   time_t start_time = time(0);
 
-   if (mtime != f_info.st_mtime) {
-   two = lyx::sum(itr->first);
-   mtime = f_info

[PATCH] Re: DepTable patch for 1.2cvs

2001-12-11 Thread Ben Stanley

Ben Stanley wrote:

> I have now written something for 1.2 which keeps only one mtime; I'd 
> better test before posting.







Re: bugzilla components

2001-12-11 Thread Ben Stanley

It would be helpful if you could put a few '\n' chars at the appropriate 
places so I can read it! The message I got had it all on one line, 
wrapped by the mail reader...
Michael A. Koziarski wrote:

> Hey guys,
>
> The components in bugzilla are as follows,  can people step forward to:
>
> 1) take ownership of a component
> 2) provide a description that isn't useless
> 3) both 1 & 2! :)
> 4) list any missing components.
>
> Cheers
>
> Koz
>
>
> componentowner  
> description  
> frontendgnome[EMAIL PROTECTED]  The GNOME frontend for LyX. 
> mathed   [EMAIL PROTECTED]   The math 
> Editor   relyx
> [EMAIL PROTECTED]   LaTeX Import 
> program  frontendxforms   
> [EMAIL PROTECTED]   XForms Front 
> End  frontendqt2  
> [EMAIL PROTECTED]  QT 
> frontend   latex export 
> [EMAIL PROTECTED]   LaTeX 
> Export  docbook export   
> [EMAIL PROTECTED]   Export to 
> DocBook general  
> [EMAIL PROTECTED]   When you don't know the 
> component tabular  [EMAIL PROTECTED]   
> Tabular code  insettext
> [EMAIL PROTECTED]   Text 
> insets   support  
> [EMAIL PROTECTED]   support 
> thingsinsetgraphics
> [EMAIL PROTECTED]   graphics 
> insets   insets   
> [EMAIL PROTECTED]   Inset 
> codeminibuffer   
> [EMAIL PROTECTED]   
> Minibufferselection
> [EMAIL PROTECTED]   
> Selection search   
> [EMAIL PROTECTED]   
> d spell
> [EMAIL PROTECTED]   
> spell painter  
> [EMAIL PROTECTED]   
> painter   font 
> [EMAIL PROTECTED]   
> font  lyxtext  
> [EMAIL PROTECTED]   
> lyxtext   vspace   
> [EMAIL PROTECTED]   
> vspaceundo/redo
> [EMAIL PROTECTED]   
> undo/redo rtl  
> [EMAIL PROTECTED]   
> rtl   lyxlex   
> [EMAIL PROTECTED]   
> lyxlexlyxserver
> [EMAIL PROTECTED]   
> lyxserver keyboard 
> [EMAIL PROTECTED]   
> keyboard  lyxfunc  
> [EMAIL PROTECTED]   
> lyxfunc   import   
> [EMAIL PROTECTED]   Importing 
> Codeexport   
> [EMAIL PROTECTED]   Exporting 
> codemenus
> [EMAIL PROTECTED]   Menu related 
> code dialogs  
> [EMAIL PROTECTED]   Dialog related 
> code   convertors   
> [EMAIL PROTECTED]   Code that converts 
> things
>
>






[BUG] Export table to LaTeX gives errors...

2001-12-10 Thread Ben Stanley

The attached file gives some wierd error messages when you try to do a 
View|DVI on it.

Tested on today's cvs (2001-12-11).

Ben.


#LyX 1.2 created this file. For more info see http://www.lyx.org/
\lyxformat 220
\textclass article
\language english
\inputencoding auto
\fontscheme default
\graphics default
\paperfontsize default
\papersize Default
\paperpackage a4
\use_geometry 0
\use_amsmath 0
\use_natbib 0
\use_numerical_citations 0
\paperorientation portrait
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\defskip medskip
\quotes_language english
\quotes_times 2
\papercolumns 1
\papersides 1
\paperpagestyle default

\layout Standard


\begin_inset Float table
placement htbp
wide false
collapsed false

\layout Standard
\align center 

\begin_inset  Tabular








\begin_inset Text

\layout Standard

Variable
\end_inset 


\begin_inset Text

\layout Standard

Nomal Value
\end_inset 


\begin_inset Text

\layout Standard

Adjusted Value
\end_inset 


\begin_inset Text

\layout Standard

Defining Equation
\end_inset 




\begin_inset Text

\layout Standard


\begin_inset Formula $\mu $
\end_inset 


\end_inset 


\begin_inset Text

\layout Standard


\begin_inset Formula $-312,500\, \textrm{Hz}^{2}$
\end_inset 


\end_inset 


\begin_inset Text

\layout Standard


\begin_inset Formula $-312,636.8\, \textrm{Hz}^{2}$
\end_inset 


\end_inset 


\begin_inset Text

\layout Standard

(
\begin_inset LatexCommand \ref{eqn:Transmit_Frequency}

\end_inset 

)
\end_inset 




\begin_inset Text

\layout Standard


\begin_inset Formula $B$
\end_inset 


\end_inset 


\begin_inset Text

\layout Standard


\begin_inset Formula $50\, \textrm{kHz}$
\end_inset 


\end_inset 


\begin_inset Text

\layout Standard


\begin_inset Formula $50.0016\, \textrm{kHz}$
\end_inset 


\end_inset 


\begin_inset Text

\layout Standard

(
\begin_inset LatexCommand \ref{eqn:Sweep_Bandwidth}

\end_inset 

)
\end_inset 




\begin_inset Text

\layout Standard


\begin_inset Formula $f_{01}$
\end_inset 


\end_inset 


\begin_inset Text

\layout Standard

89.6552\SpecialChar ~
kHz
\end_inset 


\begin_inset Text

\layout Standard

89.6553633\SpecialChar ~
kHz
\end_inset 


\begin_inset Text

\layout Standard

(
\begin_inset LatexCommand \ref{eqn:CTFM:f_01}

\end_inset 

)
\end_inset 




\begin_inset Text

\layout Standard


\begin_inset Formula $f_{10}$
\end_inset 


\end_inset 


\begin_inset Text

\layout Standard

89.6552\SpecialChar ~
kHz
\end_inset 


\begin_inset Text

\layout Standard

89.6553633\SpecialChar ~
kHz
\end_inset 


\begin_inset Text

\layout Standard

(
\begin_inset LatexCommand \ref{eqn:CTFM:f_10}

\end_inset 

)
\end_inset 




\begin_inset Text

\layout Standard


\begin_inset Formula $f_{11}$
\end_inset 


\end_inset 


\begin_inset Text

\layout Standard

39.6552\SpecialChar ~
kHz
\end_inset 


\begin_inset Text

\layout Standard

39.6552066\SpecialChar ~
kHz
\end_inset 


\begin_inset Text

\layout Standard

(
\begin_inset LatexCommand \ref{eqn:CTFM:f_11}

\end_inset 

)
\end_inset 




\begin_inset Text

\layout Standard


\begin_inset Formula $f_{minr}$
\end_inset 


\end_inset 


\begin_inset Text

\layout Standard

39.6552\SpecialChar ~
kHz
\end_inset 


\begin_inset Text

\layout Standard

39.6552\SpecialChar ~
kHz
\end_inset 


\begin_inset Text

\layout Standard

(
\begin_inset LatexCommand \ref{eqn:CTFM:f_minr}

\end_inset 

)
\end_inset 




\begin_inset Text

\layout Standard


\begin_inset Formula $f_{maxr}$
\end_inset 


\end_inset 


\begin_inset Text

\layout Standard

36.2552\SpecialChar ~
kHz
\end_inset 


\begin_inset Text

\layout Standard
\align center 
36.25509\SpecialChar ~
kHz
\end_inset 


\begin_inset Text

\layout Standard

(
\begin_inset LatexCommand \ref{eqn:CTFM:f_maxr}

\end_inset 

)
\end_inset 




\end_inset 


\layout dummy


\begin_inset LatexCommand \label{tab:CTFMDualDemodDependVars}

\end_inset 

Dependent Variables used in our implementation of dual demodulation.
\end_inset 

 
\the_end



[PATCH] error line numbers 1.2cvs

2001-12-10 Thread Ben Stanley

This patch fixes a problem I was having with errors being reported in 
the wrong places.

Ben.


--- lyx-devel-orig/src/ChangeLogTue Dec 11 15:23:26 2001
+++ lyx-devel/src/ChangeLog Tue Dec 11 17:51:12 2001
@@ -1,3 +1,9 @@
+2001-12-11  Ben Stanley <[EMAIL PROTECTED]>
+
+   * paragraph.C: fixed missing line number count
+   when exporting Environments to LaTeX file
+   * buffer.C: added informational message for checking line numbers.
+
 2001-12-06  John Levon  <[EMAIL PROTECTED]>
 
* lyx_cb.C: another bv->text misuse, from insert label
--- lyx-devel-orig/src/buffer.C Tue Dec 11 15:23:26 2001
+++ lyx-devel/src/buffer.C  Tue Dec 11 17:02:45 2001
@@ -2449,6 +2449,7 @@
}

lyxerr[Debug::INFO] << "Finished making latex file." << endl;
+   lyxerr[Debug::INFO] << "Row count was " << texrow.rows()-1 << "." << endl;
 }
 
 
--- lyx-devel-orig/src/paragraph.C  Thu Dec  6 10:58:14 2001
+++ lyx-devel/src/paragraph.C   Tue Dec 11 17:46:06 2001
@@ -1830,6 +1830,7 @@
  
if (style.isEnvironment()) {
os << "\\end{" << style.latexname() << "}\n";
+   texrow.newline();
}
 
lyxerr[Debug::LATEX] << "TeXEnvironment...done " << par << endl;



[PATCH] Heap Corruption(!) in 1.2cvs

2001-12-10 Thread Ben Stanley
_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\the_end


--- lyx-devel-orig/src/frontends/xforms/ChangeLog   Thu Dec  6 10:58:32 2001
+++ lyx-devel/src/frontends/xforms/ChangeLogTue Dec 11 14:50:17 2001
@@ -1,3 +1,8 @@
+2001-12-11  Ben Stanley <[EMAIL PROTECTED]>
+
+   * Menubar_pimpl.C: Fixed a crashing bug when document
+   has more than 80 floats and using xforms 0.88
+
 2001-12-05  John Levon  <[EMAIL PROTECTED]>
 
* FormParagraph.C: set combo box correctly for VSpace::LENGTH
--- lyx-devel-orig/src/frontends/xforms/Menubar_pimpl.C Thu Dec  6 10:58:32 2001
+++ lyx-devel/src/frontends/xforms/Menubar_pimpl.C  Tue Dec 11 13:18:05 2001
@@ -337,10 +337,21 @@
if (cit->first == "TOC") continue;
 
// All the rest is for floats
-   int menu2 = get_new_submenu(smn, win);
+   int menu_first_sub = get_new_submenu(smn, win);
+   int menu_current = menu_first_sub;
Buffer::SingleList::const_iterator ccit = cit->second.begin();
Buffer::SingleList::const_iterator eend = cit->second.end();
+   size_type count = 0;
for (; ccit != eend; ++ccit) {
+   ++count;
+   if (count > max_number_of_items) {
+   int menu_tmp = get_new_submenu(smn, win);
+   string label = _("More");
+   label += "...%m";
+   fl_addtopup(menu_current, label.c_str(), menu_tmp);
+   count = 1;
+   menu_current = menu_tmp;
+   }
int const action =
lyxaction
.getPseudoAction(LFUN_GOTO_PARAGRAPH,
@@ -348,10 +359,10 @@
string label = fixlabel(ccit-

Re: [PATCH] mmap CRC checking 1.2cvs

2001-12-10 Thread Ben Stanley

Jean-Marc Lasgouttes wrote:

>>>>>>"Ben" == Ben Stanley <[EMAIL PROTECTED]> writes:
>>>>>>
>
>Ben> Jean-Marc, Can you please check if the #define _POSIX_C_SOURCE
>Ben> 199506L
>
>Ben> modification would fix this problem on compaq? 
>
>It does not work. 
>
Please refresh my memory... on this platform, MAP_FAILED is defined to 
be (-1L)?
With the _POSIX_C_SOURCE define, we should get void* from mmap and 
others... so it is trying to compare void* with long.
So the only solution left is a reinterpret_cast to get around the bad 
header on that platform.

I think that the _POSIX_C_SOURCE is the right thing to do - the 
MAP_FAILED thing is a separate problem.

So what kind of patch are you looking for? Some autoconf magic to 
somehow detect a bad type for MAP_FAILED and to deal with it regardless 
of platform?

ie try to compile from configure

#define _POSIX_C_SOURCE 199506L
#include 
int main()
{
void*p;
return p == MAP_FAILED;
}

If that works then #define HAVE_OK_MAP_FAILED

and then at the top of lyxsum.C

#ifdef HAVE_OK_MAP_FAILED
#define CAST_MAP(x) x
#else
#define CAST_MAP(x) reinterpret_cast(x)
#endif

and in the code

if (mm == CAST_MAP(MAP_FAILED)) {
// fail code...
}

Seems a lot easier to just do everywhere (because it will work everywhere)

if (mm == reinterpret_cast(MAP_FAILED)) {
// fail code...
}

Thanks for the reference - I think it shows the _POSIX_C_SOURCE macro is 
the right thing to do to get the correct prototype.

Ben.






Re: Heap Corruption(!) in 1.2cvs

2001-12-10 Thread Ben Stanley

John Levon wrote:

>On Sat, Dec 08, 2001 at 01:18:55PM +1100, Ben Stanley wrote:
>
>>I think I'm getting heap corruption...
>>
Well, I've carried out some testing using mpatrol, a big and thorough 
memory debugging library. It turns out that we are accessing heap memory 
after freeing it:

(Note that 0x is the value used to fill freed memory. I also set 
the mpatrol options so that freed memory is not immediately re-used.)

FREE: free (0x) [-|-|-]
0x40090423 fl_freepup+183
0x0824B59D for_each__H2ZPiZPFi_v_X01X01X11_X11+33
0x0819C9E6 MenuCallback__Q27Menubar5PimplP7flobjs_l+722
0x08199C84 C_Menubar_Pimpl_MenuCallback+20
0x4005B8BF fl_object_qread+127
0x40069B79 fl_check_forms+21
0x08159B11 runTime__10GUIRunTime+29
0x080A58C5 runTime__6LyXGUI+25
0x080A6020 __3LyXPiPPc+1660
0x080C4145 main+349
0x4103B0EE __libc_start_main+142
0x08054341 _start+33

ERROR: [NOTALL]: free: 0x has not been allocated

FREE: free (0x) [-|-|-]
0x40090453 fl_freepup+231
0x0824B59D for_each__H2ZPiZPFi_v_X01X01X11_X11+33
0x0819C9E6 MenuCallback__Q27Menubar5PimplP7flobjs_l+722
0x08199C84 C_Menubar_Pimpl_MenuCallback+20
0x4005B8BF fl_object_qread+127
0x40069B79 fl_check_forms+21
0x08159B11 runTime__10GUIRunTime+29
0x080A58C5 runTime__6LyXGUI+25
0x080A6020 __3LyXPiPPc+1660
0x080C4145 main+349
0x4103B0EE __libc_start_main+142
0x08054341 _start+33

ERROR: [NOTALL]: free: 0x has not been allocated

FREE: free (0x08626348) [-|-|-]
0x4009047E fl_freepup+274
0x0824B59D for_each__H2ZPiZPFi_v_X01X01X11_X11+33
0x0819C9E6 MenuCallback__Q27Menubar5PimplP7flobjs_l+722
0x08199C84 C_Menubar_Pimpl_MenuCallback+20
0x4005B8BF fl_object_qread+127
0x40069B79 fl_check_forms+21
0x08159B11 runTime__10GUIRunTime+29
0x080A58C5 runTime__6LyXGUI+25
0x080A6020 __3LyXPiPPc+1660
0x080C4145 main+349
0x4103B0EE __libc_start_main+142
0x08054341 _start+33

ERROR: [PRVFRD]: free: 0x08626348 was freed with free
0x08626348 (32 bytes) {free:2717722:0} [-|-|-]
0x4009047E fl_freepup+274
0x0824B59D for_each__H2ZPiZPFi_v_X01X01X11_X11+33
0x0819C9E6 MenuCallback__Q27Menubar5PimplP7flobjs_l+722
0x08199C84 C_Menubar_Pimpl_MenuCallback+20
0x4005B8BF fl_object_qread+127
0x40069B79 fl_check_forms+21
0x08159B11 runTime__10GUIRunTime+29
0x080A58C5 runTime__6LyXGUI+25
0x080A6020 __3LyXPiPPc+1660
0x080C4145 main+349
0x4103B0EE __libc_start_main+142
0x08054341 _start+33

So we are freeing stuff twice... yuck.

I poked around in Menubar_pimpl.C a little bit, but I don't know 
XForms... I could do with some help.
I have a theory that we are freeing things in the wrong order, or trying 
to free child menus after freeing the parents (which maybe already freed 
the child menus?).

Now, for those of you who run out of RAM while using electric fence, you 
might find some of this useful.

mpatrol is a debugging library, and is not very efficient in it's memory 
usage (similarly to ef). Hence I have created extra swap space and added 
it to my system without rebooting:

1) Create swapfile:
dd if=/dev/zero of=/swapfile bs=1024 count=524288
2) initialise swapfile:
mkswap /swapfile
3) start using swapfile
swapon /swapfile
4) check available memory:
free
The instructions above create a 0.5Gb swapfile. Change the count 
argument to get it bigger or smaller.
When you have finished with the swapfile, use swapoff.
Swapfiles installed in this way do not re-mount when you re-boot. You 
have to use swapon manually.

I have found that I needed 2Gb swap to use mpatrol with LyX and my thesis...

I'm on irc.openprojects.net/#lyx for a little while...

Ben.





Heap Corruption(?) in 1.2cvs

2001-12-07 Thread Ben Stanley

I think I'm getting heap corruption...

I load up my thesis into 1.2cvs just to try it out
then use navigate menu to jump to a section

I get some messages when I click on the "Navigate" menu button:
In Xpup [xpopup.c 335] too many menu items. Max=80
About 52 of them, actually...

When I release the mouse button, I get

lyx: SIGSEGV signal caught
Sorry, you have found a bug in LyX. Please read the bug-reporting 
instructions in Help->Introduction and send us a bug report, if 
necessary. Thanks !
Bye.
Aborted (core dumped)

Stack trace is (more info below):

(gdb) where
#0  0x4104d651 in __kill () from /lib/libc.so.6
#1  0x4104d3cd in raise (sig=6) at ../sysdeps/posix/raise.c:27
#2  0x4104ea38 in abort () at ../sysdeps/i386/bits/string.h:230
#3  0x081c01b7 in lyx::abort () at abort.C:9
#4  0x080a60e5 in error_handler (err_sig=11) at ../src/lyx_main.C:229
#5  
#6  0x4109b2ec in __libc_free (mem=0x4114ba08) at malloc.c:3064
#7  0x40066423 in fl_freepup () from /usr/X11R6/lib/libforms.so.0.88
#8  0x0824aa89 in void (*) for_each (__first=0x8645aec,
__last=0x8645b44, __f=0x8052a4c )
at /usr/include/g++-3/stl_algo.h:83
#9  0x0819bfaa in Menubar::Pimpl::MenuCallback (ob=0x8329d58, button=1)
at Menubar_pimpl.C:585
#10 0x08199b04 in C_Menubar_Pimpl_MenuCallback (ob=0x8329d58, button=1)
at Menubar_pimpl.C:79
#11 0x400318bf in fl_object_qread () from /usr/X11R6/lib/libforms.so.0.88
#12 0x4003fb79 in fl_check_forms () from /usr/X11R6/lib/libforms.so.0.88
#13 0x08159991 in GUIRunTime::runTime () at GUIRunTime.C:86
#14 0x080a5745 in LyXGUI::runTime (this=0x82ed778) at lyx_gui.C:315
#15 0x080a5ea0 in LyX::LyX (this=0xb6c0, argc=0xb700, 
argv=0xb764)
at ../src/lyx_main.C:177
#16 0x080c3fc5 in main (argc=1, argv=0xb764) at ../src/main.C:38
#17 0x4103b0ee in __libc_start_main (main=0x80c3e68 , argc=3,
ubp_av=0xb764, init=0x8052194 <_init>, fini=0x825a6ac <_fini>,
rtld_fini=0x4100cf28 <_dl_fini>, stack_end=0xb75c)
at ../sysdeps/generic/libc-start.c:129

This looked to me like the heap was being corrupted, because it crashed 
in free...

Now, I tried chopping my thesis in half to try to find a small document 
which still produces the error. However, I could not re-produce the 
error with either half of my thesis as input! Confused...

I have been trying to run LyX under mpatrol (a memory debugging library) 
to see if it will shed some light on the problem, but it is very 
thorough and very slow... and uses LOTS of memory. I currentlly have a 
2.5Gb swap file...

Perhaps someone else may know something more about this without using a 
debugging library?

Unfortunately I cannot send my thesis as example input - archive is 80Mb.

Ben.





Re: [PATCH] mmap CRC checking 1.2cvs

2001-12-07 Thread Ben Stanley

Jean-Marc,

Can you please check if the
#define _POSIX_C_SOURCE 199506L

modification would fix this problem on compaq?
I'd also appreciate seeing the standards(5) man page from that platform.

Ben.

Jean-Marc Lasgouttes wrote:

>Compilation of 1.2.0cvs with compaq cxx dies with:
>
>cxx: Error: ../../../lyx-devel/src/support/lyxsum.C, line 43: operand types
>  are incompatible ("void *" and "long")
>if (mm == MAP_FAILED) {
>---^
>





Re: DepTable patch for 1.2cvs

2001-12-06 Thread Ben Stanley

Lars Gullik Bjønnes wrote:

>Ben Stanley <[EMAIL PROTECTED]> writes:
>
>| However, the version currently in 1.2 writes the 3 numbers to the
>| deptable, which is incompatible with previous behaviour which
>| writes/reads only 2.
>
>No, we do not have to do that.
>Everything in LyX is written to work with USE_TEMPDIR=true, if you
>don't use that expect strange behaviour.
>
>Also I do not think that we have to be deptable compatible with 1.1.6
> (and older 1.1.2CVS does not matter).
>
Anyway, my current patch is backwards compatible - reads/writes 2 
values, and Does The Right Thing with old/new files, even if it causes 
CRCs to be calculated when not strictly necessary in the case that you 
changed LyX version and didn't use a tmp dir.

This behaviour came about without writing extra code ie for free :-).

Ben.






DepTable patch for 1.2cvs

2001-12-06 Thread Ben Stanley

Lars Gullik Bjønnes wrote:

>Ben Stanley <[EMAIL PROTECTED]> writes:
>
>| I still need to get the proper DepTable patch out. The patch that is
>| currently in 1.2 is b0rken.
>
>explain.
>
Hmmm... I have a new implementation which keeps an old and a new mtime, 
and checks that before checking the old and new crcs (and possibly 
re-calculating crcs)... but now that I think about it again, I shouldn't 
need to keep two mtimes.

However, the version currently in 1.2 writes the 3 numbers to the 
deptable, which is incompatible with previous behaviour which 
writes/reads only 2. This needs to be fixed at the very least - my new 
patch stores only 2 and 'does the right thing' when presented with an 
old file, and causes the old implementation to DTRT when presented with 
a new style file.

And the version in 1.2 doesn't behave correctly when it finds a file 
who's mtime has changed. It doesn't shuffle the crc value from second to 
first before overwriting it with the new value (in update()). This 
causes excessive LaTeX runs.

I have now written something for 1.2 which keeps only one mtime; I'd 
better test before posting.

Ben




Re: [PATCH] mmap CRC checking 1.2cvs

2001-12-06 Thread Ben Stanley

Lars Gullik Bjønnes wrote:

>"Kayvan A. Sylvan" <[EMAIL PROTECTED]> writes:
>
>| On Thu, Dec 06, 2001 at 08:39:47AM +0100, Lars Gullik Bjønnes wrote:
>
>>>Ben Stanley <[EMAIL PROTECTED]> writes:
>>>
>>>| Please let me know if the attached patch fixes this problem.
>>>
>>>| I also tried to fix the Solaris compile problem - Kayvan, could you
>>>| please test it?
>>>
>>>I am pretty sure that this is not how we are going to solve this
>>>problem.
>>>
>| I don't like adding the POSIX level hack either.
>
Hmmm... I think that this is the right approach, but what I sent in was 
a hack. See below.

>
>| How about this? (it compiles for me on Solaris).
>
>No, won't do.
>
No, I don't like that either. That won't compile elsewhere.

>Either disable mmap for those platforms of find a better solution.
>
Hmmm... let's try for the better solution.

It seems that we have 2 distinct problems:
1) Solaris headers by default provide an old version of munmap with the 
wrong type in there.
2) compaq provides a definition of MAP_FAILED with a similarly wrong type.

The Solaris headers can be told to give us a POSIX compliant definition 
of munmap by doing
#define _POSIX_C_SOURCE 199506L
before
#include 

This seems to be fairly standard - see
http://vicente.org/xclib/include/xc/standards.h.html
http://www.cs.arizona.edu/computer.help/policy/DIGITAL_unix/AA-QTLMA-TE_html/relnotes5.html
Also mentioned at 
http://mail.gnu.org/pipermail/autoconf/2000-August/006020.html, but this 
suggests problems with defining this unconditionally on Solaris...

This solution would mean that we only have to support POSIX mmap, 
instead of several non-standard variants. This removes #ifdef and 
reinterpret_cast clutter from the code, which I consider to be a great 
advantage.

It would be nice to have access to some man pages for the platforms in 
question.

The compaq headers may have a similar feature. The definition that 
Jean-Marc looked up is also a compatibility defintion. The compq man 
page suggested looking at standards(5) - Jean-Marc, could you please 
take a look at this, and perhaps send it to me? Specifically, does it 
mention _POSIX_C_SOURCE?

So, I think that the _POSIX_C_SOURCE define may fix both problems, but I 
would like to see authorative documentation.

I think it is probably safe to define this macro unconditionally for 
this file because we only need mmap here, and on Linux it has no effect.

Ben.





Re: [PATCH] mmap CRC checking 1.2cvs

2001-12-05 Thread Ben Stanley

Please let me know if the attached patch fixes this problem.

I also tried to fix the Solaris compile problem - Kayvan, could you 
please test it?

I still need to get the proper DepTable patch out. The patch that is 
currently in 1.2 is b0rken.

Ben.

Jean-Marc Lasgouttes wrote:

>>>>>>"Ben" == Ben Stanley <[EMAIL PROTECTED]> writes:
>>>>>>
>
>Ben> This is a version of the mmap patch which applies to cvs HEAD.
>
>Compilation of 1.2.0cvs with compaq cxx dies with:
>
>cxx: Error: ../../../lyx-devel/src/support/lyxsum.C, line 43: operand types
>  are incompatible ("void *" and "long")
>if (mm == MAP_FAILED) {
>---^
>
>I guess some cast is needed.
>
>This probably mean that this patch is too risky to go into 1.1.6fix4,
>unfortunately. 
>
>JMarc
>




--- lyx-devel-orig/src/support/ChangeLog    Thu Dec  6 12:28:42 2001
+++ lyx-devel/src/support/ChangeLog Thu Dec  6 12:35:48 2001
@@ -1,3 +1,7 @@
+2001-12-06 Ben Stanley <[EMAIL PROTECTED]>
+
+   * lyxsum.C: small compaq cxx and Solaris fixes for mmap.
+
 2001-12-05  Lars Gullik Bjønnes  <[EMAIL PROTECTED]>
 
* filetools.C:
--- lyx-devel-orig/src/support/lyxsum.C Thu Dec  6 12:28:42 2001
+++ lyx-devel/src/support/lyxsum.C  Thu Dec  6 12:35:39 2001
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#define _POSIX_C_SOURCE 3
 #include 
 
 unsigned long lyx::sum(string const & file)
@@ -40,7 +41,7 @@

void * mm = mmap(0, info.st_size, PROT_READ,
 MAP_PRIVATE, fd, 0);
-   if (mm == MAP_FAILED) {
+   if (mm == reinterpret_cast(MAP_FAILED)) {
close(fd);
return 0;
}



Re: Annoying LyX bugs

2001-12-05 Thread Ben Stanley

Ronald Holzloehner wrote:

>(6)  I just installed Lyx1.1.6fix3-1 (the binary rpm) on my RedHat 7.2
>box and now the rendering of eps figures in LyX is broken: It still says
>"rendering", but nothing appears. The same file works correctly under
>older RedHat versions.
>
This is actually a bug in the Ghostscript included with RH7.2. There was 
an email about it on this group recently referring to

https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=55772

Ben.





Re: Annoying LyX bugs

2001-12-05 Thread Ben Stanley

I have been working on improving error handling in my personal tree of 
lyx-1.1.6fix3... I have already written code which addresses some of 
these problems, but I have not contributed the patches. Some of the code 
required a large amount of infrastructure, and as such would not be 
accepted for a 'fix' release. I plan to port the code to 1.2, but at the 
moment I am under a lot of pressure to complete a thesis...

Ronald Holzloehner wrote:

>(2)  If I assign a label to an equation and then change my mind and
>don't want the equation number to appear anymore (and remove the label),
>the label would still sit in the lyx file. When I export it to latex,
>latex complains about duplicate labels. This happens often when I decide
>to break an equation line and want the equation number on the last line.
>It would be great if Lyx could do this automatically!
>
Well, I can take the duplicate label error from the LaTeX output and 
place an error box on every equation (or label object) containing that 
label, telling you that the label is multiply defined. This isn't 
exactly the answer you wanted, I know...

>(3)  BibTeX: When will LyX be able to tell that there are errors in
>BibTeX's result? In particular, am I supposed to check every reference
>in my document if a "[?]" appeared, instead of the citation number?
>Highly unsatisfactory.
>
My LyX can parse the BibTeX log file and extract errors, placing error 
boxes next to all undefined citations. It also places an error box next 
to the bibliography inset when there are errors detected in the 
bibliography database...

>(4)  How can I force a rerun of BibTeX? In particular, if I remove a
>citation, it won't be removed from the references list until I restart
>LyX. Guys, this is a serious bug.
>
My hacked LyX includes BibTeX bibliography databases in the DepTable, 
and as such will automatically detect changed .bib files and re-run 
BibTeX whenever you do a view DVI (or view PS) in LyX. In fact, the same 
mechanism works for updated .eps files as well...

>(5)  The citation insert dialog window is broken somehow: If you leave
>the window open (i.e. just use "Apply" rather than "OK") and edit
>different citation, sometimes the "Apply" and "OK" buttons become gray
>even when there are valid citations in the left field. One then either
>has to reopen the dialog or remove a citation from the left window and
>then reenter it.
>
Yes, I have observed this many times... but not fixed it.

>(6)  I just installed Lyx1.1.6fix3-1 (the binary rpm) on my RedHat 7.2
>box and now the rendering of eps figures in LyX is broken: It still says
>"rendering", but nothing appears. The same file works correctly under
>older RedHat versions.
>
This annoys me to, but people keep telling me it's an xforms bug and as 
such can't be fixed until GUII is complete.

I have begun investigating this myself, and can reliably reproduce it - 
for me, I just navigate around the document while the figures are 
rendering and usually the rendering queue stops. It's not actually LyX 
that's stopping the rendering - it seems to be that a ghostscript 
process is stopping. The problem with the architecture of rendering in 
LyX is that if one stops, then no more figures are rendered...

If anyone has more info on what's going on here I'd appreciate some 
discussion.

I don't know when I'll have time to get all these changes back into LyX, 
as I have to write furiously. I lost a significant amount of PhD writing 
time while making the changes, but they seem to work really well now, 
and are saving me time compared to the old method of searching log files 
for errors...

Ben Stanley.






Re: [PATCH] two fixes, broken (iterator questions)

2001-12-03 Thread Ben Stanley

Some questions on iterators below...

John Levon wrote:

>+  if (par->autoDeleteInsets()) {
>+  found = true;
>   text->redoParagraphs(this, cursor,
>cursor.par()->next());
>   text->fullRebreak(this);
>   }
>
Can someone explain to me why a full rebreak is performed after each 
error is removed?
(The old code did this too... and also when the errors are inserted.) I 
would have thought that could wait until all the errors had been processed.

And another question: You have recently added a paragraph iterator... 
does this iterator descend into paragraphs contained within insets 
belonging to a paragraph, or does it just enumerate the paragraphs at 
the level of the tree where it started?

And yet another question: Is there a way of iterating over all of the 
insets contained in a document?

(BTW, I created my own paragraph and inset iterators for my 
modifications, so now I need to figure out if there already exists in 
1.2 an equivalent or if I need to port mine...)

Ben.






Re: CVS: Compile problem on Solaris

2001-12-03 Thread Ben Stanley

So does that mean that we should
#define _POSIX_C_SOURCE 3
or something like that before
#include 

I don't have experience with Solaris on this level...

Kayvan A. Sylvan wrote:

>On Tue, Dec 04, 2001 at 12:00:46AM +0100, Lars Gullik Bjønnes wrote:
>
>>Ok, what is munmap's prototype on your box?
>>
>
>#ifdef  __STDC__
>#if (_POSIX_C_SOURCE > 2)
>[...]
>extern int munmap(void *, size_t);
>[...]
>#else
>[...]
>extern int munmap(caddr_t, size_t);
>[...]
>#endif  /* (_POSIX_C_SOURCE > 2) */
>[...]
>#else   /* __STDC__ */
>[...]
>extern int munmap();
>[...]
>#endif /* __STDC__ */
>






Re: [PATCH] mmap CRC checking 1.2cvs

2001-12-02 Thread Ben Stanley

Lars Gullik Bjønnes wrote:

>I think you should submit the complete patch again.
>
Complete patch attached.

process_block does lead to a significant improvement.

Warm cache

ben [11:26:45] 
/share/install/linux/extras/lyx/lyx-HEAD/lyx-devel/src/support/tests $ 
time crccheck.do_crc /share/mp3/bassic/EI.mp3
CRC: 3089166751

real0m0.448s
user0m0.450s
sys 0m0.000s
ben [11:26:49] 
/share/install/linux/extras/lyx/lyx-HEAD/lyx-devel/src/support/tests $ 
time crccheck.process_block /share/mp3/bassic/EI.mp3
CRC: 3089166751

real0m0.150s
user0m0.130s
sys 0m0.020s

ben [11:39:13] /share/install/linux/extras/lyx/lyx-HEAD $ ls -al 
/share/mp3/bassic/EI.mp3
-rw-r--r--1 ben  users 5661289 Nov  5 08:45 
/share/mp3/bassic/EI.mp3



--- lyx-devel/src/support/lyxsum.C.orig.cvs Mon Dec  3 09:20:46 2001
+++ lyx-devel/src/support/lyxsum.C  Mon Dec  3 11:29:17 2001
@@ -10,8 +10,6 @@
 
 #include 
 
-#include 
-#include 
 #include 
 #include 
 
@@ -31,23 +29,88 @@
 
 } // namespace
 
-
-// And this would be the file interface.
-unsigned long lyx::sum(string const & file)
+// Various implementations of lyx::sum(), depending on what methods
+// are available. Order is faster to slowest.
+#if defined(HAVE_MMAP) && defined(HAVE_MUNMAP)
+   #ifdef WITH_WARNINGS
+   #warning lyx::sum() using mmap (lightning fast)
+   #endif
+
+   #include 
+   #include 
+   #include 
+   #include 
+   #include 
+
+   unsigned long lyx::sum(string const & file)
+   {
+   int fd = open(file.c_str(), O_RDONLY);
+   if( !fd ) return 0;
+
+   struct stat info;
+   fstat(fd, &info);
+
+   void * mm = mmap(0, info.st_size, PROT_READ,
+MAP_PRIVATE, fd, 0);
+   if (mm == MAP_FAILED) {
+   close(fd);
+   return 0;
+   }
+   
+   char *beg = static_cast(mm);
+   char *end = beg + info.st_size;
+
+   boost::crc_32_type crc;
+   crc.process_block(beg,end);
+   unsigned long result = crc.checksum();
+   
+   munmap( mm, info.st_size );
+   close(fd);
+
+   return result;
+   }
+#else // No mmap
+   #include 
+   #include 
+
+   #if HAVE_DECL_ISTREAMBUF_ITERATOR
+   #ifdef WITH_WARNINGS
+   #warning lyx::sum() using istreambuf_iterator (fast)
+   #endif
+   unsigned long lyx::sum(string const & file)
+   {
+   std::ifstream ifs(file.c_str());
+   if (!ifs) return 0;
+
+   std::istreambuf_iterator beg(ifs);
+   std::istreambuf_iterator end;
+
+   return do_crc(beg,end);
+   }
+   #else
+   #ifdef WITH_WARNINGS
+   #warning lyx::sum() using istream_iterator (slow as a snail)
+   #endif
+   unsigned long lyx::sum(string const & file)
+   {
+   std::ifstream ifs(file.c_str());
+   if (!ifs) return 0;
+
+   ifs.unsetf(std::ios::skipws);
+   std::istream_iterator beg(ifs);
+   std::istream_iterator end;
+
+   return do_crc(beg,end);
+   }
+   #endif
+#endif // mmap
+
+#if 0
+#include 
+int main(int /*argc*/, char * argv[])
 {
-   std::ifstream ifs(file.c_str());
-   if (!ifs) return 0;
-   
-#ifdef HAVE_DECL_ISTREAMBUF_ITERATOR
-   // This is a lot faster...
-   std::istreambuf_iterator beg(ifs);
-   std::istreambuf_iterator end;
-#else
-   // than this.
-   ifs.unsetf(std::ios::skipws);
-   std::istream_iterator beg(ifs);
-   std::istream_iterator end;
-#endif
+   std::string const fil(argv[1]);
 
-   return do_crc(beg, end);
+   std::cout << "CRC: " << lyx::sum(fil) << std::endl;
 }
+#endif
--- lyx-devel/src/support/ChangeLog.origMon Dec  3 11:32:13 2001
+++ lyx-devel/src/support/ChangeLog Mon Dec  3 11:36:32 2001
@@ -1,3 +1,8 @@
+2001-12-03  Ben Stanley <[EMAIL PROTECTED]>
+
+   * lyxsum.C: Added mmap version of CRC and made it selected 
+   by default where available. Used process_block for crc for speedup.
+   
 2001-12-01  John Levon  <[EMAIL PROTECTED]>
 
* filetools.C: more robust failure for DirList()



Re: [PATCH] mmap CRC checking 1.2cvs

2001-12-02 Thread Ben Stanley

Lars Gullik Bjønnes wrote:

>Ben Stanley <[EMAIL PROTECTED]> writes:
>
>| +char *beg = static_cast(mm);
>| +char *end = beg + info.st_size;
>| +
>| +unsigned long result = do_crc(beg,end);
>
>Did you check the speed difference between this and crc.process_block?
>
No, I haven't - yet. I didn't investigate boost/crc.hpp.

I'll investigate crc.process_block, but it looks like the right way to 
go for mmap-ed streams.

BTW, I just did cvs up and noticed that patch wasn't applied. I thought 
it had gone in. Please let me know if I should re-submit the whole patch 
with the process_block stuff in it or just the process_block mod.

Ben.





Re: niced previews

2001-11-29 Thread Ben Stanley

Juergen Vigna wrote:

>Why don't you just reconfigure the \ps_command in your lyxrc as
>\ps_command "nice gs"
>
because nice doesn't return the right exit code, and LyX checks it. This 
doesn't work.

However, I did come up with a one liner patch for lyx-1.1.6, which calls 
the nice() system call.
It works. The patch for 1.2 looks a bit harder though, because you don't 
want to 'nice()' most of the conversions - only picture previews.

I just looked up whether nice is implemented in cygwin. It looks like it 
is *not* (but mmap is!). So a configure check will be necessary.

Ben.




Re: [RFC] Automatic preview picture updating

2001-11-29 Thread Ben Stanley

Andre Poenitz wrote:

>On Thu, Nov 29, 2001 at 07:09:53PM +1100, Ben Stanley wrote:
>
>>But does it exist on Windows and OS/2?
>>
>
>I really don't know.
>
I guess that cygwin would provide something (I assume the port uses 
cygwin), but that autoconf would look after it for us anyway.

Ben.







Re: [RFC] Automatic preview picture updating

2001-11-29 Thread Ben Stanley

Andre Poenitz wrote:

>On Thu, Nov 29, 2001 at 05:16:38PM +1100, Ben Stanley wrote:
>
>>Perhaps an extra argument to convert would be in order?
>>
>>Converters::convert(  , bool priority_nice = false )
>>
>>if( priority_nice )
>>command = string("nice ") + command;
>>
>
>And make sure that this is portable...
>
We could also modify the Systemcalls class to call nice(10) if 
necessary, after fork() but before calling exec(), ie somewhere in 
Systemcalls::fork().

nice() is part of POSIX. There are no autoconf macros to detect it.

But does it exist on Windows and OS/2?

Writing an autoconf macro to detect it should be a simple matter...

Ben.




Re: [RFC] Automatic preview picture updating

2001-11-28 Thread Ben Stanley

John Levon wrote:

>around insets/figinset.C:675, where we do the execlp
>
>Again, I wouldn't bother spending too much time on obsolete code ...
>
I think I'd only do it in a 1.2 tree.

I guess I'd have to modify converters.C somewhere around line 643:

+command = string("nice ") + command;
lyxerr[Debug::FILES] << "Calling " << command << endl;
if (buffer)
ShowMessage(buffer, _("Executing command:"), command);

Systemcalls::Starttype type = (dummy)
? Systemcalls::SystemDontWait : Systemcalls::System;
Systemcalls one;
int res;
if (conv.original_dir && buffer) {
Path p(buffer->filepath);
res = one.startscript(type, command);
} else
res = one.startscript(type, command);

But this would have the side effect of lowering the priority of LaTeX 
runs, which we probably don't want.

Perhaps an extra argument to convert would be in order?

Converters::convert(  , bool priority_nice = false )

if( priority_nice )
command = string("nice ") + command;

This would avoid disturbing existing calls to Converters::convert while 
allowing the new behaviour to be triggered from the previewers in 
insetgraphics.C: InsetGraphics::prepareFile()

static const bool use_priority_nice = true;

converters.convert(buf, params.filename, outfile, extension, 
image_target,use_priority_nice);

or maybe an enum would be a better way to achieve the argument naming.

Ben





Re: [BUG] close prefs dialog abort in 1.1.6fix3

2001-11-28 Thread Ben Stanley

Ben Stanley wrote:

> I also tried the same procedure as above except I waited until after 
> the previews were all rendered before opening the preferences dialog. 
> No crash.

Looks like I spoke too soon. When I went back to re-set the tmp dir 
preference, it did this (no preview processes running):

MainLoop Event(6,w=0xb400517 s=48124) MotionNotify Mode Hint
MainLoop Event(4,w=0xb400517 s=48149) ButtonPress
MainLoop Event(5,w=0xb400517 s=48169) ButtonRelease button: 1
Eaten Event(7,w=0xb40051a s=48800) EnterNotify Mode Normal
Eaten Event(8,w=0xb40051a s=50319) LeaveNotify Mode Normal
Eaten Event(7,w=0xb40051a s=50392) EnterNotify Mode Normal
Eaten Event(7,w=0xb40051a s=50393) EnterNotify Mode Normal
Eaten Event(8,w=0xb40051a s=50396) LeaveNotify Mode Normal
Eaten Event(18,w=0xb40051a s=50601) UnmapNotify
Eaten Event(17,w=0xb40051a s=50603) DestroyNotify
CanvasIntecept Event(17,w=0xb40051b s=50603) DestroyNotify
Eaten Event(6,w=0xb400517 s=48282) MotionNotify Mode Hint
Eaten Event(8,w=0xb400517 s=48800) LeaveNotify Mode Normal
Eaten Event(8,w=0xb400517 s=50319) LeaveNotify Mode Normal
Eaten Event(7,w=0xb400517 s=50392) EnterNotify Mode Normal
Eaten Event(7,w=0xb400517 s=50396) EnterNotify Mode Normal
Eaten Event(6,w=0xb400517 s=50401) MotionNotify Mode Hint
Eaten Event(8,w=0xb400517 s=50421) LeaveNotify Mode Normal
Eaten Event(18,w=0xb400517 s=50636) UnmapNotify
Eaten Event(22,w=0xb400517 s=50637) ConfigureNotify (322,63) w=470 h=500 Syn
Eaten Event(21,w=0xb400517 s=50637) ReparentNotify
Eaten Event(17,w=0xb400517 s=50638) DestroyNotify
CanvasIntecept Event(17,w=0xb400518 s=50638) DestroyNotify
MainLoopUser Event(7,w=0xb40051d s=48800) EnterNotify Mode Normal
In EventCallback [events.c 34] Unknown window=0xb40051d
Ignored Event(7,w=0xb40051d s=48800) EnterNotify Mode Normal
PutbackEvent Event(7,w=0xb40051d s=48800) EnterNotify Mode Normal
LyX: This shouldn't happen...
BadWindow (invalid Window parameter)
Aborted (core dumped)

backtrace:

Core was generated by `lyx -shared -sync'.
Program terminated with signal 6, Aborted.
#0  0x4104d651 in ?? ()
(gdb) where
#0  0x4104d651 in ?? ()
#1  0x4104ea38 in ?? ()
#2  0x081c163b in InsetExternal::browseCB (ob=0x57646142)
at /usr/include/g++-3/stl_alloc.h:394
#3  0x080ba825 in Converters::Convert (this=0x82d5cf8, buffer=0xb2a8,
from_file=@0x0, to_file_base=@0x0, from_format=@0x0, 
to_format=@0x82d5cf8,
to_file=@0xb40051d) at /usr/include/g++-3/std/bastring.h:75
#4  0x400fbd87 in ?? ()
#5  0x400fa3f3 in ?? ()
#6  0x400f0a3e in ?? ()
#7  0x40068156 in ?? ()
#8  0x40032227 in ?? ()
#9  0x40032273 in ?? ()
#10 0x4004037e in ?? ()
#11 0x4003f1fc in ?? ()
#12 0x4003fb49 in ?? ()
#13 0x4003fb84 in ?? ()
#14 0x08178364 in LyXText::SetCursor (this=0xb670, bview=0xb6c0,
cur=@0xb658, par=0x80bcff4, pos=137163000, boundary=244)
at text2.C:2890
#15 0x080bb9e4 in Converters::Convert (this=0x82cf0f8, buffer=0x8227ef4,
from_file=@0xb724, to_file_base=@0x41140001, 
from_format=@0x4114b9e0,
to_format=@0x4114b9e0, to_file=@0x0) at 
/usr/include/g++-3/stl_alloc.h:346
#16 0x080bcff4 in Converters::Convert (this=0xb670, buffer=0xb6c0,
from_file=@0xb724, to_file_base=@0x80591e5, from_format=@0x82b63fc,
to_format=@0x82cf0f8, to_file=@0x0)
at /usr/include/g++-3/std/bastring.h:114
#17 0x080e5e2a in MenuWrite (bv=0x1, buffer=0xb724)
at /usr/include/g++-3/stl_alloc.h:346
#18 0x4103b0ee in ?? ()
(gdb)

um... I realise that's not much use. I don't know what happened to the 
symbols... actually, the backtrace looks like it might be complete garbage.

Ben.





Re: [RFC] Automatic preview picture updating

2001-11-28 Thread Ben Stanley

John Levon wrote:

>On Thu, Nov 29, 2001 at 04:14:58PM +1100, Ben Stanley wrote:
>
>>While we are on the topic of figure previews, what do people think of 
>>using *nice* on the gs processes? My machine gets really bogged for 
>>several minutes when I open my thesis... When you have lots of figures 
>>to preview, this would make a big difference.
>>
>
>If you have this problem, just turn off the previewing !
>
Hmmm... That kind of misses the point...

>>Another alternative would be to render the preview when the figure is 
>>exposed on screen for the first time (or for extra points, render the 
>>preview when the part of the document visible in the window is getting 
>>close to the position of the figure).
>>
>
>overkill perhaps...
>
maybe. I'd do the other one first. It's easy. Probably a one liner, if I 
knew the right line...

Ben.






Re: [BUG] close prefs dialog abort in 1.1.6fix3

2001-11-28 Thread Ben Stanley

John Levon wrote:

>On Wed, Nov 28, 2001 at 11:38:18PM +1100, Ben Stanley wrote:
>
>>Now I open my thesis, and while the previews are rendering, I open the 
>>preferences dialog, change a setting (the temp dir), click save, and get
>>
>>
>>MainLoopUser Event(33,w=0x796 s=14834) ClientMessage
>>MainLoopUser Event(7,w=0x700017c s=15098) EnterNotify Mode Normal
>>In EventCallback [events.c 34] Unknown window=0x700017c
>>
>
>now I /can't/ reproduce it. How annoying.
>
>Can you add :
>
>410 lyxerr << "Canvas ID " << fl_get_canvas_id(figinset_canvas) 
><< endl;
>411 fl_set_preemptive_callback(fl_get_canvas_id(figinset_canvas), 
>GhostscriptMsg, 0);
>
>the lyxerr line into insets/figinset.C ?
>
Yes, I added it (and double checked)

>
>
>Check that the canvas id and the ClientMessage window are the same.
>
We must be barking up the wrong tree - I didn't see it.

I started lyx with

lyx -shared -sync

then loaded my thesis and while figures were rendering I toggled the tmp 
dir option in the prefs dlg, and clicked Save.

kaboom.

(see also extra test after output)
Here's the output

MainLoop Event(6,w=0xb400166 s=15345) MotionNotify Mode Hint
MainLoop Event(4,w=0xb400166 s=15468) ButtonPress
MainLoop Event(5,w=0xb400166 s=15495) ButtonRelease button: 1
In MapColor [flcolor.c 739] Changing reserved color
In MapColor [flcolor.c 739] Changing reserved color
In fl_mapcolor [flcolor.c 780] mapping 0 (0,0,0)
In MapColor [flcolor.c 739] Changing reserved color
In fl_mapcolor [flcolor.c 780] mapping 258 (0,0,0)
In fl_mapcolor [flcolor.c 780] mapping 258 (0,0,0)
In Canvas [canvas.c 397] FL_DRAW
In Canvas [canvas.c 397] FL_DRAW
In drw_text_beside [xtext.c 472] align request is inside
In Canvas [canvas.c 397] FL_DRAW
Eaten Event(7,w=0xb40017c s=17301) EnterNotify Mode Normal
Eaten Event(8,w=0xb40017c s=18069) LeaveNotify Mode Normal
Eaten Event(18,w=0xb40017c s=19945) UnmapNotify
Eaten Event(17,w=0xb40017c s=19947) DestroyNotify
CanvasIntecept Event(17,w=0xb40017d s=19947) DestroyNotify
Eaten Event(6,w=0xb400166 s=17287) MotionNotify Mode Hint
Eaten Event(8,w=0xb400166 s=17301) LeaveNotify Mode Normal
Eaten Event(8,w=0xb400166 s=18069) LeaveNotify Mode Normal
Eaten Event(18,w=0xb400166 s=19980) UnmapNotify
Eaten Event(17,w=0xb400166 s=19982) DestroyNotify
CanvasIntecept Event(17,w=0xb400167 s=19982) DestroyNotify
MainLoopUser Event(33,w=0xb400096 s=15596) ClientMessage
MainLoopUser Event(33,w=0xb400096 s=15769) ClientMessage
MainLoopUser Event(7,w=0xb40017e s=17301) EnterNotify Mode Normal
In EventCallback [events.c 34] Unknown window=0xb40017e
Ignored Event(7,w=0xb40017e s=17301) EnterNotify Mode Normal
PutbackEvent Event(7,w=0xb40017e s=17301) EnterNotify Mode Normal
LyX: This shouldn't happen...
lyx: Attempting to save document 
/home/ben/Documents/PhD_Thesis/Document/main.lyx as...
  /home/ben/Documents/PhD_Thesis/Document/main.lyx.emergency
  Save seems successful. Phew.
BadWindow (invalid Window parameter)
Aborted (core dumped)
ben [15:54:23] 
/share/install/linux/extras/lyx/lyx-BRANCH_1_1_6/lyx-devel-JL/src $ X 
Error of failed request:  BadDrawable (invalid Pixmap or Window parameter)
  Major opcode of failed request:  53 (X_CreatePixmap)
  Resource id in failed request:  0xb400096
  Serial number of failed request:  42
ben [15:54:23] 
/share/install/linux/extras/lyx/lyx-BRANCH_1_1_6/lyx-devel-JL/src $




And another stack trace

(gdb) where
#0  0x4104d651 in __kill () from /lib/libc.so.6
#1  0x4104d3cd in raise (sig=6) at ../sysdeps/posix/raise.c:27
#2  0x4104ea38 in abort () at ../sysdeps/i386/bits/string.h:230
#3  0x082548b7 in lyx::abort () at abort.C:9
#4  0x080ed3a5 in LyX_XErrHandler (display=0x833bb60, xeev=0xb2e8)
at lyx_gui.C:95
#5  0x400fbd87 in _XError () from /usr/X11R6/lib/libX11.so.6
#6  0x400fa3f3 in _XReply () from /usr/X11R6/lib/libX11.so.6
#7  0x400f0a3e in XQueryPointer () from /usr/X11R6/lib/libX11.so.6
#8  0x40068156 in fl_get_win_mouse () from /usr/X11R6/lib/libforms.so.0.88
#9  0x40032227 in fl_compress_motion () from /usr/X11R6/lib/libforms.so.0.88
#10 0x40032273 in fl_compress_event () from /usr/X11R6/lib/libforms.so.0.88
#11 0x4004037e in get_next_event () from /usr/X11R6/lib/libforms.so.0.88
#12 0x4003f1fc in do_interaction_step () from 
/usr/X11R6/lib/libforms.so.0.88
#13 0x4003fb49 in fl_treat_interaction_events ()
   from /usr/X11R6/lib/libforms.so.0.88
#14 0x4003fb84 in fl_check_forms () from /usr/X11R6/lib/libforms.so.0.88
#15 0x081f68c4 in GUIRunTime::runTime () at GUIRunTime.C:79
#16 0x080eee68 in LyXGUI::runTime (this=0x8334f58) at lyx_gui.C:419
#17 0x080f0ff3 in LyX::LyX (this=0xb690, argc=0xb6d0, 
argv=0xb734)
at ../src/lyx_main.C:168
#18 0x08138529 in main (argc=1, argv=0xb734) at ../src/main.C:40
#19 0x4103b0ee in __libc_start_main (main=0x8138390 , argc=

Re: [RFC] Automatic preview picture updating

2001-11-28 Thread Ben Stanley

While we are on the topic of figure previews, what do people think of 
using *nice* on the gs processes? My machine gets really bogged for 
several minutes when I open my thesis... When you have lots of figures 
to preview, this would make a big difference.

Another alternative would be to render the preview when the figure is 
exposed on screen for the first time (or for extra points, render the 
preview when the part of the document visible in the window is getting 
close to the position of the figure).

There isn't really any need to render most of the figure previews in my 
thesis when I'm only working on one part of it.

Ben.





Re: [RFC] Automatic preview picture updating

2001-11-28 Thread Ben Stanley

The thought had struck me that fam might help with the DepTab problem 
too, but having thought about it I have decided it doesn't help 
significantly with that problem.

Ben.




[RFC] Automatic preview picture updating

2001-11-28 Thread Ben Stanley

I just tried to get LyX to re-render a figure that I changed, and short 
of changing the file name to a bogus name and pressing OK and then 
changing it back I can't get the figure re-drawn.

I've been thinking a little about automatic preview picture updating 
when the file on disk has changed.

My recent installation of KDE utilises fam to monitor when files or 
directories have changed, and will subsequently update them in the file 
manager (Konqueror) when they have been changed by any external mechanism.

The fam page:
http://oss.sgi.com/projects/fam/

fam is implemented efficiently by utilising a kernel mechanism (imon) 
which provides the initial callback notification that a file has changed.

I propose that we could use this mechanism to automatically update the 
preview figures in LyX when they are changed on disk. This would be done 
by modifying InsetFigure to register the file it is displaying with fam. 
If fam notifies LyX that the file has changed, the figure would be re-drawn.

Of course this would have to be a --with-fam option to configure,  since 
fam is not available everywhere nor widely installed. However it could 
also be auto-detected by configure with a suitable macro.

I suppose there should also be an update button in the Figure dialog so 
that people without fam can still see new figures. :-)

RFC?

Ben.





[PATCH] recreation of .tex/.dvi 1.2

2001-11-28 Thread Ben Stanley

Here is the same patch for 1.2. Dunno why the other one didn't apply 
straight - they are pretty much the same.

Ben.



--- lyx-devel-orig/src/LaTeX.h  Sun Feb 11 20:51:17 2001
+++ lyx-devel/src/LaTeX.h   Thu Nov 29 12:44:26 2001
@@ -206,6 +206,9 @@
 
/// used by scanLogFile
int num_errors;
+   
+   /// The name of the final output file.
+   string output_file;
 };
 
 #endif
--- lyx-devel-orig/src/LaTeX.C  Fri Jul  6 04:17:28 2001
+++ lyx-devel/src/LaTeX.C   Thu Nov 29 12:52:03 2001
@@ -74,8 +74,12 @@
 {
num_errors = 0;
depfile = file + ".dep";
-   if (prefixIs(cmd, "pdf")) // Do we use pdflatex ?
+   if (prefixIs(cmd, "pdf")) { // Do we use pdflatex ?
depfile += "-pdf";
+   output_file = ChangeExtension(file,".pdf");
+   } else {
+   output_file = ChangeExtension(file,".dvi");
+   }
 }
 
 
@@ -154,12 +158,19 @@
head.read(depfile);
// Update the checksums
head.update();
-   if (!head.sumchange()) {
+   // Can't just check if anything has changed because it might have 
+aborted
+   // on error last time... in which cas we need to re-run latex
+   // and collect the error messages (even if they are the same).
+   if (!FileInfo(output_file).exist()) {
+   lyxerr[Debug::DEPEND]
+   << "re-running LaTeX because output file doesn't 
+exist." << endl;
+   } else if (!head.sumchange()) {
lyxerr[Debug::DEPEND] << "return no_change" << endl;
return NO_CHANGE;
+   } else {
+   lyxerr[Debug::DEPEND]
+   << "Dependency file has changed" << endl;
}
-   lyxerr[Debug::DEPEND]
-   << "Dependency file has changed" << endl;
 
if (head.extchanged(".bib") || head.extchanged(".bst"))
    run_bibtex = true;
--- lyx-devel-orig/ChangeLogWed Nov 28 20:05:21 2001
+++ lyx-devel/ChangeLog Thu Nov 29 13:12:54 2001
@@ -1,3 +1,9 @@
+2001-11-29 Ben Stanley <[EMAIL PROTECTED]>
+
+   * src/LaTeX.C
+   * src/LaTeX.h Fixed bug in LaTeX class where it would not
+   re-run latex if no depfiles were changed, but the .dvi was removed.
+
 2001-11-28  John Levon  <[EMAIL PROTECTED]>
 
* README: fix ghostscript comment



[BUG] lots of black in preview images with -shared 1.1.6fix3

2001-11-28 Thread Ben Stanley

I'm getting very dark/black preview images when I run under -shared. Not 
all of them are black, but it does tend to be the 
photographs/screenshots that do it. (Also some output from QCad does it).

It's usually background colours or transparent parts of the image that 
get turned to black.

What mechanism allocates colours for preview figures?

I have ghostscript 5.50-15 installed from RH7.1

Ben.




[PATCH] recreation of .tex/.dvi 1.1.6

2001-11-28 Thread Ben Stanley

Here is a minimalist patch which addresses just this problem.

I even remembered the ChangeLog this time...

This patch works on 1.1.6. I'll make up another for 1.2.

Ben.



--- lyx-devel-orig/src/LaTeX.h  Sun Feb 11 20:51:17 2001
+++ lyx-devel/src/LaTeX.h   Thu Nov 29 12:44:26 2001
@@ -206,6 +206,9 @@
 
/// used by scanLogFile
int num_errors;
+   
+   /// The name of the final output file.
+   string output_file;
 };
 
 #endif
--- lyx-devel-orig/src/LaTeX.C  Fri Jul  6 04:17:28 2001
+++ lyx-devel/src/LaTeX.C   Thu Nov 29 12:52:03 2001
@@ -74,8 +74,12 @@
 {
num_errors = 0;
depfile = file + ".dep";
-   if (prefixIs(cmd, "pdf")) // Do we use pdflatex ?
+   if (prefixIs(cmd, "pdf")) { // Do we use pdflatex ?
depfile += "-pdf";
+   output_file = ChangeExtension(file,".pdf");
+   } else {
+   output_file = ChangeExtension(file,".dvi");
+   }
 }
 
 
@@ -152,12 +156,19 @@
head.read(depfile);
// Update the checksums
head.update();
-   if (!head.sumchange()) {
+   // can't just check if anything has changed because it might have 
+aborted
+   // on error last time... in which case we need to re-run latex
+   // and collect the error messages (even if they are the same).
+   if (!FileInfo(output_file).exist()) {
+   lyxerr[Debug::DEPEND]
+   << "re-running latex because output file doesn't 
+exist." << endl;
+   } else if (!head.sumchange()) {
lyxerr[Debug::DEPEND] << "return no_change" << endl;
return LaTeX::NO_CHANGE;
+   } else {
+   lyxerr[Debug::DEPEND]
+   << "Dependency file has changed" << endl;
}
-   lyxerr[Debug::DEPEND]
-   << "Dependency file has changed" << endl;
 
if (head.extchanged(".bib") || head.extchanged(".bst"))
    run_bibtex = true;
--- lyx-devel-orig/ChangeLogWed Nov 28 20:05:21 2001
+++ lyx-devel/ChangeLog Thu Nov 29 13:12:54 2001
@@ -1,3 +1,9 @@
+2001-11-29 Ben Stanley <[EMAIL PROTECTED]>
+
+   * src/LaTeX.C
+   * src/LaTeX.h Fixed bug in LaTeX class where it would not
+   re-run latex if no depfiles were changed, but the .dvi was removed.
+
 2001-11-28  John Levon  <[EMAIL PROTECTED]>
 
* README: fix ghostscript comment



[PATCH] mmap CRC checking 1.2cvs

2001-11-28 Thread Ben Stanley

This is a version of the mmap patch which applies to cvs HEAD.



--- lyx-devel-orig/src/support/lyxsum.C Fri Jun  1 22:10:06 2001
+++ lyx-devel/src/support/lyxsum.C  Thu Nov 29 02:31:01 2001
@@ -10,8 +10,6 @@
 
 #include 
 
-#include 
-#include 
 #include 
 #include 
 
@@ -31,23 +29,85 @@
 
 } // namespace
 
-
-// And this would be the file interface.
-unsigned long lyx::sum(string const & file)
+// Various implementations of lyx::sum(), depending on what methods
+// are available. Order is faster to slowest.
+#if defined(HAVE_MMAP) && defined(HAVE_MUNMAP)
+   #ifdef WITH_WARNINGS
+   #warning lyx::sum() using mmap (lightning fast but untested)
+   #endif
+
+   #include 
+   #include 
+   #include 
+   #include 
+   #include 
+
+   unsigned long lyx::sum(string const & file)
+   {
+   int fd = open(file.c_str(), O_RDONLY);
+   if( !fd ) return 0;
+
+   struct stat info;
+   fstat(fd, &info);
+
+   void * mm = mmap(0, info.st_size, PROT_READ,
+MAP_PRIVATE, fd, 0);
+   if (mm == MAP_FAILED) {
+   close(fd);
+   return 0;
+   }
+   char *beg = static_cast(mm);
+   char *end = beg + info.st_size;
+
+   unsigned long result = do_crc(beg,end);
+
+   munmap( mm, info.st_size );
+   close(fd);
+
+   return result;
+   }
+#else // No mmap
+   #include 
+   #include 
+
+   #if HAVE_DECL_ISTREAMBUF_ITERATOR
+   #ifdef WITH_WARNINGS
+   #warning lyx::sum() using istreambuf_iterator (fast)
+   #endif
+   unsigned long lyx::sum(string const & file)
+   {
+   std::ifstream ifs(file.c_str());
+   if (!ifs) return 0;
+
+   std::istreambuf_iterator beg(ifs);
+   std::istreambuf_iterator end;
+
+   return do_crc(beg,end);
+   }
+   #else
+   #ifdef WITH_WARNINGS
+   #warning lyx::sum() using istream_iterator (slow as a snail)
+   #endif
+   unsigned long lyx::sum(string const & file)
+   {
+   std::ifstream ifs(file.c_str());
+   if (!ifs) return 0;
+
+   ifs.unsetf(std::ios::skipws);
+   std::istream_iterator beg(ifs);
+   std::istream_iterator end;
+
+   return do_crc(beg,end);
+   }
+   #endif
+#endif // mmap
+
+#if 0
+#include 
+int main(int /*argc*/, char * argv[])
 {
-   std::ifstream ifs(file.c_str());
-   if (!ifs) return 0;
-   
-#ifdef HAVE_DECL_ISTREAMBUF_ITERATOR
-   // This is a lot faster...
-   std::istreambuf_iterator beg(ifs);
-   std::istreambuf_iterator end;
-#else
-   // than this.
-   ifs.unsetf(std::ios::skipws);
-   std::istream_iterator beg(ifs);
-   std::istream_iterator end;
-#endif
+   std::string const fil(argv[1]);
 
-   return do_crc(beg, end);
+   std::cout << "CRC: " << lyx::sum(fil) << std::endl;
 }
+#endif
--- lyx-devel-orig/src/support/ChangeLogThu Nov 29 03:01:18 2001
+++ lyx-devel/src/support/ChangeLog     Thu Nov 29 05:38:31 2001
@@ -1,3 +1,8 @@
+2001-11-29  Ben Stanley <[EMAIL PROTECTED]>
+
+   * lyxsum.C: Added mmap version of CRC and made it selected 
+   by default where available.
+   
 2001-11-28  André Pönitz <[EMAIL PROTECTED]>

* Makefile.am: put types.h in



Re: Removing optimisation while debugging

2001-11-28 Thread Ben Stanley

Jean-Marc Lasgouttes wrote:

>>>>>>"Ben" == Ben Stanley <[EMAIL PROTECTED]> writes:
>>>>>>
>
>Ben> I like to use kdevelop (or some other program with a debugger)
>Ben> for investigating LyX. In fact I utilise the debugger quite
>Ben> heavily.
>
>Ben> While I was working in my private tree doing my big mods, I
>Ben> actually removed the -O from the command line for the development
>Ben> build. This allows the debugger to be more useful - no code
>Ben> motion, easier to deal with templates (no inlining), better
>Ben> correspondence between source and machine code.
>
>With 1.2.0cvs, you can do "./configure --disable-optimization".
>
>Ben> What do people think of doing this in the main tree?
>
>I seem to remember that some compilation warnings are only reported
>when doing an optimized build.
>
>JMarc
>
OK, that's what I needed to know.

Ben.






Re: [BUG] HEAD cvs InsetNote() causes assert failure

2001-11-28 Thread Ben Stanley

Andre Poenitz wrote:

>On Thu, Nov 29, 2001 at 03:47:50AM +1100, Ben Stanley wrote:
>
>>This constructor passes an un-initialised pos to insertStringAsLines. I 
>>presume it should be initialised to 0?
>>
>
>And now to the explanation: I saw the "useless" variable, removed it. Then
>noticed that the parameter was passed by (non-const) reference, and
>re-introduced it. And of course forgot that there was a initilization in
>the beginning.
>
>I hope this is the explantion for all those sudden crashes that came up
>suspiciously soon after the introduction of lyx::pos_type...
>
>Andre'
>
I propose a grep for lyx::pos_type and a double check...

Where one bug has been found, similar ones usually lurk...

Ben.





Removing optimisation while debugging

2001-11-28 Thread Ben Stanley

I like to use kdevelop (or some other program with a debugger) for 
investigating LyX. In fact I utilise the debugger quite heavily.

While I was working in my private tree doing my big mods, I actually 
removed the -O from the command line for the development build. This 
allows the debugger to be more useful - no code motion, easier to deal 
with templates (no inlining), better correspondence between source and 
machine code.

What do people think of doing this in the main tree?


--- lyx-orig/config/lyxinclude.m4   Thu Sep  6 01:19:05 2001
+++ lyx/config/lyxinclude.m4 Wed Nov 21 12:21:08 2001
@@ -181,7 +181,7 @@

 # optimize less for development versions
 if test $lyx_devel_version = yes -o $lyx_prerelease = yes ; then
-  lyx_opt="-O"
+  lyx_opt=""
 else
   lyx_opt="-O2"
 fi







[BUG] HEAD cvs InsetNote() causes assert failure

2001-11-28 Thread Ben Stanley

This constructor passes an un-initialised pos to insertStringAsLines. I 
presume it should be initialised to 0?

This causes an assert failure down in Pragraph::pimpl::insertChar().

// This constructor is used for reading old InsetInfo
InsetNote::InsetNote(Buffer const * buf, string const & contents,
 bool collapsed)
: InsetCollapsable(collapsed)
{
init();

Paragraph * par = inset.paragraph();
LyXFont font(LyXFont::ALL_INHERIT, buf->params.language);

// Since XForms doesn't support RTL, we can assume that old notes
// in RTL documents are written in English.
if (font.language()->RightToLeft())
font.setLanguage(default_language);

lyx::pos_type pos;
buf->insertStringAsLines(par, pos, font, strip(contents, '\n'));
}





Re: cvs compile error in BRANCH_1_1_6

2001-11-28 Thread Ben Stanley

Jean-Marc Lasgouttes wrote:

>>>>>>"Ben" == Ben Stanley <[EMAIL PROTECTED]> writes:
>>>>>>
>
>This is a symptom of having a bad xforms-0.88 rpm (the header is wrong
>in fact). Make sure you use the one from ftp.lyx.org.
>
>JMarc
>
Ben dutifuly downgrades his xforms installation...
Lo and behold, LyX compiles again (without the hacks).

Thanks, JMarc.





Re: [PATCH] mmap CRC checking 1.1.6

2001-11-28 Thread Ben Stanley

Ben Stanley wrote:

> I have now tested this. First number is mmap CRC. Second number is 
> istream_iterator CRC. They seem to fail differently on directories - 
> in this case, I think that istream_iterator version is wrong.
>
> This patch only applies to BRANCH_1_1_6. I will send another for 1.2.
>
> I haven't compiled the whole of LyX with this because cvs is broken 
> atm (see my other mail), but I have compiled it in 2 different ways as 
> per JML's request.

Sorry, this one didn't have the Changelog. I sent it again, with the 
changelog.





[PATCH] mmap CRC checking 1.1.6

2001-11-28 Thread Ben Stanley

I have now tested this. First number is mmap CRC. Second number is 
istream_iterator CRC. They seem to fail differently on directories - in 
this case, I think that istream_iterator version is wrong.

This patch only applies to BRANCH_1_1_6. I will send another for 1.2.

I haven't compiled the whole of LyX with this because cvs is broken atm 
(see my other mail), but I have compiled it in 2 different ways as per 
JML's request.

$ checkCRC /boot/*
/boot/boot.0300 1729887102 1729887102 OK
/boot/boot.b 2073074794 2073074794 OK
/boot/chain.b 361202963 361202963 OK
/boot/kernel.h 1951086079 1951086079 OK
/boot/kernel.h-2.4.2 1951086079 1951086079 OK
/boot/lost+found 0 4294967295 FAIL
/boot/map 0 0 OK
/boot/message 4218120946 4218120946 OK
/boot/module-info 3046675311 3046675311 OK
/boot/module-info-2.4.2-2 3046675311 3046675311 OK
/boot/os2_d.b 679864059 679864059 OK
/boot/System.map 3662491832 3662491832 OK
/boot/System.map-2.4.2-2 3542708047 3542708047 OK
/boot/System.map-2.4.4 279845350 279845350 OK
/boot/System.map-2.4.5-ac5 1886247741 1886247741 OK
/boot/System.map-2.4.6 3662491832 3662491832 OK
/boot/System.map.old 583674341 583674341 OK
/boot/vmlinux-2.4.2-2 3009846913 3009846913 OK
/boot/vmlinuz 1730371782 1730371782 OK
/boot/vmlinuz-2.4.2-2 3873679430 3873679430 OK
/boot/vmlinuz-2.4.4 1055800826 1055800826 OK
/boot/vmlinuz-2.4.5-ac5 3968027610 3968027610 OK
/boot/vmlinuz-2.4.6 1730371782 1730371782 OK
/boot/vmlinuz.old 3071668570 3071668570 OK
There was 1 failure.
/boot/lost+found

$ cat checkCRC
#!/bin/sh
# Runs the lyxsum programs on every file given in the argument list and
# records any failures.

PROG1=lyxsum.mmap
PROG2=lyxsum.istream_iterator

FAILCOUNT=0;
FAILLIST=""

for file in $@
do
  CRC1=`$PROG1 $file | awk -- '{print $2}'`
  CRC2=`$PROG2 $file | awk -- '{print $2}'`

  if [ $CRC1 -eq $CRC2 ]
  then
  RESULT="OK"
  else
  RESULT="FAIL"
  FAILCOUNT=`echo $FAILCOUNT + 1 | bc`
  FAILLIST="$FAILLIST $file"
  fi
  echo $file $CRC1 $CRC2 $RESULT
done

if [ $FAILCOUNT -ne 0 ]
then
if [ $FAILCOUNT -eq 1 ]
then
echo There was 1 failure.
else
echo "There were $FAILCOUNT failures."
fi
echo $FAILLIST
else
echo "All tests passed"
fi



--- lyx-devel-orig/src/support/lyxsum.C Wed Jun  6 02:52:55 2001
+++ lyx-devel/src/support/lyxsum.C  Thu Nov 29 02:01:41 2001
@@ -1,7 +1,7 @@
 /* This file is part of
  * ==
- * 
- *   LyX, The Document Processor
+ *
+ *   LyX, The Document Processor
  *
  *The function lyx::sum is taken from GNU textutill-1.22
  *and is there part of the program chsum. The chsum program
@@ -15,14 +15,8 @@
 
 #include 
 
-#include 
-#include 
-
 #include "support/lyxlib.h"
 
-using std::ifstream;
-using std::ios;
-
 // DO _NOT_ CHANGE _ANYTHING_ IN THIS TABLE
 static
 unsigned long const crctab[256] =
@@ -83,7 +77,7 @@
 
 /* Calculate the checksum of file FILE.
Return crc if successful, 0 if an error occurs. */
- 
+
 template
 static inline
 unsigned long do_crc(InputIterator first, InputIterator last)
@@ -104,23 +98,86 @@
 }
 
 
-// And this would be the file interface.
-unsigned long lyx::sum(string const & file)
-{
-   std::ifstream ifs(file.c_str());
-   if (!ifs) return 0;
-   
-#ifdef HAVE_DECL_ISTREAMBUF_ITERATOR
-   // This is a lot faster...
-   std::istreambuf_iterator beg(ifs);
-   std::istreambuf_iterator end;
+// Various implementations of lyx::sum(), depending on what methods
+// are available. Order is faster to slowest.
+#if defined(HAVE_MMAP) && defined(HAVE_MUNMAP)
+   #ifdef WITH_WARNINGS
+   #warning lyx::sum() using mmap (lightning fast but untested)
+   #endif
+
+   #include 
+   #include 
+   #include 
+   #include 
+   #include 
+
+   unsigned long lyx::sum(string const & file)
+   {
+   int fd = open(file.c_str(), O_RDONLY);
+   if( !fd ) return 0;
+
+   struct stat info;
+   fstat(fd, &info);
+
+   void * mm = mmap(0, info.st_size, PROT_READ,
+MAP_PRIVATE, fd, 0);
+   if (mm == MAP_FAILED) {
+   close(fd);
+   return 0;
+   }
+   char *beg = static_cast(mm);
+   char *end = beg + info.st_size;
+
+   unsigned long result = do_crc(beg,end);
+
+   munmap( mm, info.st_size );
+   close(fd);
+
+   return result;
+   }
 #else
-   // than this.
-   ifs.unsetf(std::ios::skipws);
-   std::istream_iterator beg(ifs);
-   std::istream_iterator end;
+   #include 
+   #include 
+
+   #if HAVE_DECL_ISTREAMBUF_ITERATOR
+   #ifdef WITH_WARNINGS
+   #warning lyx::sum() using istreambuf_iterator (fast)
+   #endif
+   unsigned long lyx::sum(string const &

[PATCH] mmap CRC checking 1.1.6

2001-11-28 Thread Ben Stanley

I have now tested this. First number is mmap CRC. Second number is 
istream_iterator CRC. They seem to fail differently on directories - in 
this case, I think that istream_iterator version is wrong.

This patch only applies to BRANCH_1_1_6. I will send another for 1.2.

I haven't compiled the whole of LyX with this because cvs is broken atm 
(see my other mail), but I have compiled it in 2 different ways as per 
JML's request.

$ checkCRC /boot/*
/boot/boot.0300 1729887102 1729887102 OK
/boot/boot.b 2073074794 2073074794 OK
/boot/chain.b 361202963 361202963 OK
/boot/kernel.h 1951086079 1951086079 OK
/boot/kernel.h-2.4.2 1951086079 1951086079 OK
/boot/lost+found 0 4294967295 FAIL
/boot/map 0 0 OK
/boot/message 4218120946 4218120946 OK
/boot/module-info 3046675311 3046675311 OK
/boot/module-info-2.4.2-2 3046675311 3046675311 OK
/boot/os2_d.b 679864059 679864059 OK
/boot/System.map 3662491832 3662491832 OK
/boot/System.map-2.4.2-2 3542708047 3542708047 OK
/boot/System.map-2.4.4 279845350 279845350 OK
/boot/System.map-2.4.5-ac5 1886247741 1886247741 OK
/boot/System.map-2.4.6 3662491832 3662491832 OK
/boot/System.map.old 583674341 583674341 OK
/boot/vmlinux-2.4.2-2 3009846913 3009846913 OK
/boot/vmlinuz 1730371782 1730371782 OK
/boot/vmlinuz-2.4.2-2 3873679430 3873679430 OK
/boot/vmlinuz-2.4.4 1055800826 1055800826 OK
/boot/vmlinuz-2.4.5-ac5 3968027610 3968027610 OK
/boot/vmlinuz-2.4.6 1730371782 1730371782 OK
/boot/vmlinuz.old 3071668570 3071668570 OK
There was 1 failure.
/boot/lost+found

$ cat checkCRC
#!/bin/sh
# Runs the lyxsum programs on every file given in the argument list and
# records any failures.

PROG1=lyxsum.mmap
PROG2=lyxsum.istream_iterator

FAILCOUNT=0;
FAILLIST=""

for file in $@
do
  CRC1=`$PROG1 $file | awk -- '{print $2}'`
  CRC2=`$PROG2 $file | awk -- '{print $2}'`

  if [ $CRC1 -eq $CRC2 ]
  then
  RESULT="OK"
  else
  RESULT="FAIL"
  FAILCOUNT=`echo $FAILCOUNT + 1 | bc`
  FAILLIST="$FAILLIST $file"
  fi
  echo $file $CRC1 $CRC2 $RESULT
done

if [ $FAILCOUNT -ne 0 ]
then
if [ $FAILCOUNT -eq 1 ]
then
echo There was 1 failure.
else
echo "There were $FAILCOUNT failures."
fi
echo $FAILLIST
else
echo "All tests passed"
fi



--- lyx-devel-orig/src/support/lyxsum.C Wed Jun  6 02:52:55 2001
+++ lyx-devel/src/support/lyxsum.C  Thu Nov 29 02:01:41 2001
@@ -1,7 +1,7 @@
 /* This file is part of
  * ==
- * 
- *   LyX, The Document Processor
+ *
+ *   LyX, The Document Processor
  *
  *The function lyx::sum is taken from GNU textutill-1.22
  *and is there part of the program chsum. The chsum program
@@ -15,14 +15,8 @@
 
 #include 
 
-#include 
-#include 
-
 #include "support/lyxlib.h"
 
-using std::ifstream;
-using std::ios;
-
 // DO _NOT_ CHANGE _ANYTHING_ IN THIS TABLE
 static
 unsigned long const crctab[256] =
@@ -83,7 +77,7 @@
 
 /* Calculate the checksum of file FILE.
Return crc if successful, 0 if an error occurs. */
- 
+
 template
 static inline
 unsigned long do_crc(InputIterator first, InputIterator last)
@@ -104,23 +98,86 @@
 }
 
 
-// And this would be the file interface.
-unsigned long lyx::sum(string const & file)
-{
-   std::ifstream ifs(file.c_str());
-   if (!ifs) return 0;
-   
-#ifdef HAVE_DECL_ISTREAMBUF_ITERATOR
-   // This is a lot faster...
-   std::istreambuf_iterator beg(ifs);
-   std::istreambuf_iterator end;
+// Various implementations of lyx::sum(), depending on what methods
+// are available. Order is faster to slowest.
+#if defined(HAVE_MMAP) && defined(HAVE_MUNMAP)
+   #ifdef WITH_WARNINGS
+   #warning lyx::sum() using mmap (lightning fast but untested)
+   #endif
+
+   #include 
+   #include 
+   #include 
+   #include 
+   #include 
+
+   unsigned long lyx::sum(string const & file)
+   {
+   int fd = open(file.c_str(), O_RDONLY);
+   if( !fd ) return 0;
+
+   struct stat info;
+   fstat(fd, &info);
+
+   void * mm = mmap(0, info.st_size, PROT_READ,
+MAP_PRIVATE, fd, 0);
+   if (mm == MAP_FAILED) {
+   close(fd);
+   return 0;
+   }
+   char *beg = static_cast(mm);
+   char *end = beg + info.st_size;
+
+   unsigned long result = do_crc(beg,end);
+
+   munmap( mm, info.st_size );
+   close(fd);
+
+   return result;
+   }
 #else
-   // than this.
-   ifs.unsetf(std::ios::skipws);
-   std::istream_iterator beg(ifs);
-   std::istream_iterator end;
+   #include 
+   #include 
+
+   #if HAVE_DECL_ISTREAMBUF_ITERATOR
+   #ifdef WITH_WARNINGS
+   #warning lyx::sum() using istreambuf_iterator (fast)
+   #endif
+   unsigned long lyx::sum(string const &

cvs compile error in BRANCH_1_1_6

2001-11-28 Thread Ben Stanley

make[3]: Entering directory 
`/share/install/linux/extras/lyx/lyx-BRANCH_1_1_6/lyx-devel/src'
g++ -DHAVE_CONFIG_H -I. -I. -I. -I.. -I.. -I../boost-isystem 
/usr/X11R6/include  -g -O -fno-exceptions -W -Wall -c BufferView2.C
In file included from BufferView2.C:24:
LyXView.h:38: using directive `Object' introduced ambiguous type
`_ObjectRec *'

inserting #include  at the top of LyXView.h fixes this one.

It seems to me that you need to #include the defn of Object to get this 
to compile - there is no way around having the definition of that object 
before inheriting from it.

same problem with
src/minibuffer.h, except that inserting the #include doesn't fix that ?!?

Ben.





Re: [PATCH] Re: DepTable is slooooooooowwwwwwwwww

2001-11-28 Thread Ben Stanley

| Lars Gullik Bjønnes wrote:

>>
>
istreambuf_iterator:
time ./test_crc /boot/vmlinuz-2.4.9-13
CRC: 2642954630

real0m0.252s
user0m0.130s
sys 0m0.000s


istream_iterator:
 time ./test_crc /boot/vmlinuz-2.4.9-13
CRC: 2642954630

real0m0.550s
user0m0.260s
sys 0m0.010s

(box compiling LyX at the time so there was a bit of load...)
>>

Lars,

would you mind sending me the source of that test program, and I'll test 
out this patch with the two different implementations and compare results?

I think the biggest issue with this patch is portability, which is also 
looked after by autoconf, so if I can  regression test it against the 
previous implementation and make it all come out the same we should be OK.

Lars Gullik Bjønnes wrote:

>
>| +// Figure out what iterator implementation we are going to use...
>| +// This currently selects mmap over istreambuf_iterator.
>| +#ifdef HAVE_MMAP
>| +#ifdef __GNUC__
>
>Hmm WITH_WARNINGS exist in 1.1.6 too.
>
>
>
>| +#warning lyx::sum() using mmap (lightning fast but untested)
>| +#endif
>| +#define USE_MMAP
>| +#elif HAVE_DECL_ISTREAMBUF_ITERATOR
>| +#ifdef __GNUC__
>| +#warning lyx::sum() using istreambuf_iterator (fast)
>| +#endif
>| +#define USE_ISTREAMBUF_ITER
>| +#define USE_STREAM
>| +#else
>| +#ifdef __GNUC__
>| +#warning lyx::sum() using istream_iterator (slow as a snail)
>| +#endif
>| +#define USE_ISTREAM_ITER
>| +#define USE_STREAM
>| +#endif
>
>And why are these new defines needed? Can't we just use
>
>HAVE_MMAP, HAVE_DECL_ISTREAMBUF_ITERATOR directly?
>
This seemed simpler... to decide which implementation to use when you 
may have more than one available. Extending the original scheme would 
have been *really* ugly, with #if defined(this) && !defined(that) all 
over the place.

It also simplifies the macros when you have to check multiple things eg 
I have now discovered I should check HAVE_MMAP and HAVE_MUNMAP, as well 
as possibly one other macro. With this arrangement, I only have to 
change it in *one* place. It also allows me to conveniently control 
inclusion of header files, without writing
#if blah blah blah
everywhere and risking not changing them all in a future mod.

I'd rather keep this.

>
>
>| +char *beg = (char*)mm;
>| +char *end = ((char*)mm)+info.st_size;
>
>Ok, I know I used c-style cast in my example, but here we should use
>C++-style casts. static_cast or reinterpret_cast here.
>
OK, I'm figuring out which one we should use.

>
>And we should find a way to avoid this much ifdef clutter.  
>
I'm thinking of breaking it into two separate implementations, one for 
mmap and one for streams, controlled by #ifdefs. It's looking much tidier.

Lars, thanks for taking the time to make comments.

Ben.






Re: [BUG] close prefs dialog abort in 1.1.6fix3

2001-11-28 Thread Ben Stanley

Jose Abilio Oliveira Matos wrote:

>On Wed, Nov 28, 2001 at 11:38:18PM +1100, Ben Stanley wrote:
>
>>Juergen Vigna wrote:
>>
>>I just found an xforms-0.88-15 from RH7.0-powertools. So I downloaded it 
>>and installed it.
>>
>
>  Known problem, that version of powertools is wrong, since it is
>linked against the wrong glibc version.
>
>  Please take the version from Kayvan's site. (I guess that it is also
>in the lyx ftp site). The version of the xforms rpm is correct there.
>
ftp://ftp.lyx.org/pub/lyx/contrib

has xforms-0.88-3.rpm, which is the one I just replaced. It exhibited 
the same behaviour.

I don't know where Kayvan's site is.

Ben.






Re: [PATCH] Re: DepTable is slooooooooowwwwwwwwww

2001-11-28 Thread Ben Stanley

Lars Gullik Bjønnes wrote:

>Ben Stanley <[EMAIL PROTECTED]> writes:
>
>| Andre Poenitz wrote:
>
>>>On Wed, Nov 28, 2001 at 07:00:14AM +1100, Ben Stanley wrote:
>>>
>>>>The advantage of putting everything in the deptree is that if you modify
>>>>a figure .eps and then do the latex->DVI thing from the menu, then
>>>>everything will be re-generated OK.
>>>>
>>>If that works I owe you a beer...
>>>
>>>Andre'
>>>
>| I just went to test this out...
>
>| It works - as long as you actually change the included file and don't
>| just change the mtime (eg touch it)!
>
>| So, it looks like Andre owes me a beer - except I don't drink beer. Bummer.
>
>You posted only the patch to .h...
>
Actually, it looks like the patch was missing changes to LaTeX.h/LaTeX.C 
. DepTable.h and DepTable.C were there, but they would not have compiled 
without the others... Sorry.

Anyway, I take it from the comments on the code  that this 
encouragement to re-work the mmap patch for 1.1.6 and 1.2, and to tidy 
up everything else for 1.2...

I have actually written a large amount of code to support improved error 
reporting of references/labels/citations etc, and preliminary support 
for the gloss package (glossaries), which you guys have not seen yet. 
Right now it all works for me. The problem I seem to have now is to 
break it all up into small enough patches that you guys can 
digest/review/run it, and maybe apply it to whichever branch is 
appropriate... I think it's ready for wider testing. I just came along 
at the wrong time, didn't I? (feature freeze...)

I'd really like to get these changes all sent in, but maybe for now I 
should just try to use my modified LyX for thesis writing (I *require* 
glossary support and improved error reporting). I'm just worried that if 
I leave it a while before submitting patches it will be harder to 
port/apply them...

So, at the moment I'm feeling quite discouraged... :-(  the number of 
patches I must create is large, and the patches have to be so perfect. 
But perhaps I just need to figure out your way of doing things.

So perhaps I made the wrong decision to modify 1.1.6? I need to work 
with a fairly stable LyX, so that's where I started. At least now I have 
a local version of LyX that will support my requirements, and seems stable.

Anyway, I'll try to keep to your style and submit complete patches in 
future!

Ben.





Re: [PATCH] Re: DepTable is slooooooooowwwwwwwwww

2001-11-28 Thread Ben Stanley

Jean-Marc Lasgouttes wrote:

>>"Lars" == Lars Gullik Bjønnes <[EMAIL PROTECTED]> writes:
>>
>
>Lars> I leave it to Jean-Marc to decide if this patch should go in
>Lars> 1.1.6, but I would be a bit reluctant. 
>
>Yes, I am, as I posted earlier.
>
>Lars> Perhaps only the mmap patch since that is a lot smaller and
>Lars> easier to test.
>
>I have to admit I do not know much about mmap and issues it may have
>on some systems. Is that 100% portable?
>
>JMarc
>
I don't know - that's what autoconf is for. If autoconf isn't happy with 
mmap, then my implementation defaults back to the fastest kind of 
istream iterator available.

I did notice that gettext already uses mmap (intl/loadmsgcat.c) if it is 
available. They also check HAS_MUNMAP - perhaps I should too.

With the autoconf macros, I don't think you have much to worry about.

Ben.





Re: [BUG] close prefs dialog abort in 1.1.6fix3

2001-11-28 Thread Ben Stanley

Juergen Vigna wrote:

>On 27-Nov-2001 Ben Stanley wrote:
>
>>xforms-0.88-3
>>
>>System is RH7.1
>>
>
>Hmm I had problems with that particular rpm version and therefore installed
>xforms-0.88-9, I cannot remember which problems I had thought.
>
I just found an xforms-0.88-15 from RH7.0-powertools. So I downloaded it 
and installed it.

Then started lyx 1.1.6fix3, which is dynamically linked to xforms, and 
that is the file which was just upgraded. (checked with ldd)


Now I open my thesis, and while the previews are rendering, I open the 
preferences dialog, change a setting (the temp dir), click save, and get


MainLoopUser Event(33,w=0x796 s=14834) ClientMessage
MainLoopUser Event(7,w=0x700017c s=15098) EnterNotify Mode Normal
In EventCallback [events.c 34] Unknown window=0x700017c
Ignored Event(7,w=0x700017c s=15098) EnterNotify Mode Normal
PutbackEvent Event(7,w=0x700017c s=15098) EnterNotify Mode Normal
LyX: This shouldn't happen...
BadWindow (invalid Window parameter)
Aborted (core dumped)

backtrace:

(gdb) where
#0  0x4104d651 in __kill () from /lib/libc.so.6
#1  0x4104d3cd in raise (sig=6) at ../sysdeps/posix/raise.c:27
#2  0x4104ea38 in abort () at ../sysdeps/i386/bits/string.h:230
#3  0x081c163b in fl_set_button ()
#4  0x080ba825 in fl_set_button ()
#5  0x400f7d87 in _XError () from /usr/X11R6/lib/libX11.so.6
#6  0x400f63f3 in _XReply () from /usr/X11R6/lib/libX11.so.6
#7  0x400eca3e in XQueryPointer () from /usr/X11R6/lib/libX11.so.6
#8  0x40068fdd in fl_get_win_mouse () from /usr/X11R6/lib/libforms.so.0.88
#9  0x400324a8 in fl_compress_motion () from /usr/X11R6/lib/libforms.so.0.88
#10 0x400324fe in fl_compress_event () from /usr/X11R6/lib/libforms.so.0.88
#11 0x40040383 in get_next_event () from /usr/X11R6/lib/libforms.so.0.88
#12 0x4003f213 in do_interaction_step () from 
/usr/X11R6/lib/libforms.so.0.88
#13 0x4003fb5d in fl_treat_interaction_events () from 
/usr/X11R6/lib/libforms.so.0.88
#14 0x4003fb9e in fl_check_forms () from /usr/X11R6/lib/libforms.so.0.88
#15 0x08178364 in fl_set_button ()
#16 0x080bb9e4 in fl_set_button ()
#17 0x080bcff4 in fl_set_button ()
#18 0x080e5e2a in fl_set_button ()
#19 0x4103b0ee in __libc_start_main (main=0x80e5d60 
, argc=3,
ubp_av=0xb7d4, init=0x804dd98 <_init>, fini=0x821e090 <_fini>,
rtld_fini=0x4100cf28 <_dl_fini>, stack_end=0xb7cc)
at ../sysdeps/generic/libc-start.c:129

So same as before. Probably still a bug in xforms...

Ben.




[PATCH] Re: DepTable is slooooooooowwwwwwwwww

2001-11-28 Thread Ben Stanley

Andre Poenitz wrote:

>On Wed, Nov 28, 2001 at 07:00:14AM +1100, Ben Stanley wrote:
>
>>The advantage of putting everything in the deptree is that if you modify
>>a figure .eps and then do the latex->DVI thing from the menu, then
>>everything will be re-generated OK.
>>
>
>If that works I owe you a beer...
>
>Andre'
>
I just went to test this out...

It works - as long as you actually change the included file and don't 
just change the mtime (eg touch it)!

So, it looks like Andre owes me a beer - except I don't drink beer. Bummer.

I found that without the mmap patch, updating the time to update 
dependencies takes forever (73 seconds), because it calculates the CRC 
of *all* the 153 .eps files in my thesis, and a few other things as 
well. Remember, I don't have istreambuf_iterator.

Patch attached (DepTable.patch) for cvs BRANCH_1_1_6 has the following 
features:

* Fast mtime comparison dependency checks after CRC has been calculated.
* Continues to function if you upgrade or downgrade LyX while using
  or *not* using a temporary directory.
* Remakes the output even if you delete the .dvi file (bug in
  LaTeX::run(), not DepTable).
* Re-makes the output if you change an included graphics file (or
  any other kind of included file).
* And even makes coffee... ;-)

If you combine this patch with the mmap-sum.patch you get much improved 
performance for re-building .dvi files using LyX on my system... There 
really is no comparison. Using mmap, the initial dependency update which 
calculates CRCs drops down to 14 sec for the same set of files. All this 
is with lyx compiled with -g -O.

The benefit of these two patches for me is even more than stated here, 
because the old LyX re-computed CRCs on every file in the DepTable after 
every LaTeX run. This used to make doing a View|DVI something of a 
'coffee break' item, but not any more!

Please apply these patches to cvs.

Ben.



--- lyx-devel-orig/src/DepTable.C   Wed Nov 15 14:22:06 2000
+++ lyx-devel/src/DepTable.CWed Nov 28 19:31:21 2001
@@ -18,57 +18,147 @@
 #endif
 
 #include "DepTable.h"
+#include "debug.h"
+
 #include "support/lyxlib.h"
 #include "support/filetools.h"
+
+#include 
+#include 
+#include 
+
 #include 
 
+
 using std::make_pair;
 using std::ofstream;
 using std::ifstream;
 using std::endl;
 
+/** \class DepTable
+   DepTable provides a list of files and information on
+   whether their contents have changed since the last time
+   the file was checked.
+   
+   This is performed internally using CRC computations and mtime checks.
+   
+   Computing the CRC of every file takes 28-33 seconds on my thesis...
+   (That is because a large number of large .eps files get entered into
+   the deptable..., and I do not have istreambuf_iterator :-( )
+   
+   Why does this class use CRC checks instead
+   of using the dates on the files?
+   
+   Well the answer to that is that LaTeX re-writes it's .aux files
+   every time it runs. This will change the modification date/time,
+   but the file might be exactly the same. You have to
+   determine if the new one is different from the old one
+   by doing a CRC or similar.
+   
+   20011126 bstanley If you were to maintain a record of the last modified 
+date/time
+   for each file, and if when you come to check it again and update the CRC,
+   you could avoid re-calculating the CRC if the date/time of the file
+   has not changed This produces a significant time saving,
+   whilst still providing the same functionality to clients. bstanley
+   
+   20011127 bstanley Applied patch by LGB which implements this date based
+   shortcut method. Speedup is significant except when the file is first entered
+   into the deptable. Tested on large thesis with many .eps files, bibliography,
+   glossary, index, etc.
+   
+   20011128 bstanley turns out that was too optimistic - things were being
+   returned as changed when they weren't. Should be fixed now.
+   
+   20011128 bstanley added a flag which is set when something changes,
+   to speed up lookups.
+*/
+
+inline bool DepTable::dep_info::changed() const
+{
+   return mtime_prev != mtime_curr && crc_prev != crc_curr;
+}
+
 void DepTable::insert(string const & fi,
- bool upd,
- unsigned long one,
- unsigned long two)
+ bool upd )
 {
// not quite sure if this is the correct place for MakeAbsPath
string f = MakeAbsPath(fi);
if (deplist.find(f) == deplist.end()) {
+   dep_info di;
+   di.crc_prev = 0;
+   di.mtime_prev = 0;
if (upd) {
-   one = two;
-  

Re: recreation of .tex/.dvi

2001-11-27 Thread Ben Stanley

Dekel Tsur wrote:

>On Tue, Nov 27, 2001 at 01:01:40PM +0100, Lars Gullik Bjønnes wrote:
>
>>Andre Poenitz <[EMAIL PROTECTED]> writes:
>>
>>| On Tue, Nov 27, 2001 at 12:34:30PM +0200, Dekel Tsur wrote:
>>
Do you have use_tempir=false ?

>>| Yes.
>>
>>I cannot see how the mtime patch can cause this, but it is probably
>>the culprit.
>>
>
>If you used lyx before the mtime change, then the .dep file is of the format
>  filename crc crc
>But when you try to use lyx after the change, it expects the format
>  filename crc crc mtime
>and therefore it reads the existing .dep file incorrectly.
>
>The solution, use store only one crc value in the .dep file, so the format
>is now
>  filename crc mtime
>Note that when reading old files, the mtime value will be bogus, but this
>only means that lyx will need to recompute the crc value.
>
The DepTime patch can have nothing to do with this, because it wasn't 
applied!

Actually, the old design of LaTeX::run() is enough to explain this.

First, initialise the directory by running View|DVI

Then delete the .dvi

Try running View|DVI again.

The old design of LaTeX::run() is broken - it should check for the 
existence of the output file before returning NO_CHANGE.

Ben.





Re: DepTable is slooooooooowwwwwwwwww

2001-11-27 Thread Ben Stanley

Ben Stanley wrote:

> At the moment my latex is needing 6 runs to stabilise no matter 
> whether there are pre-existing .aux files or not. Haven't figure that 
> out yet, but I'm running with a heavily modified LaTeX::run() at the 
> moment.
>
> Ben.
>
OK, it was a bug in the DepTable patch. Previously I didn't inspect it 
too closely - this time I've almost re-written it, quite carefully. I 
have verified it by inspecting files with diff, and it gets me 3 latex 
runs to completion now.

I'm working up some fixes for the case where some files in the dep tree 
might be missing completely. The advantage of putting everything in the 
deptree is that if you modify a figure .eps and then do the latex->DVI 
thing from the menu, then everything will be re-generated OK. Currently 
you would get the old .dvi file (if it still exists) because the dep 
files wouldn't include those files, and the 'no change' clause would be 
invoked.

Anyway, I'll sit on the patch until it manages to load a LyX-1.1.6fix3 
file and still have everything work.

Ben.



--- lyx-1.1.6fix3-orig/src/DepTable.h   Tue Apr  4 10:19:07 2000
+++ lyx-1.1.6fix3/src/DepTable.hWed Nov 28 06:18:07 2001
@@ -17,6 +17,7 @@
 
 #include "LString.h"
 #include 
+#include 
 
 #ifdef __GNUG__
 #pragma interface
@@ -27,11 +28,12 @@
 public:
/** This one is a little bit harder since we need the absolute
  filename. Should we insert files with .sty .cls etc as
- extension? */
+ extension?
+ \argument upd update the entry immediately instead of inserting a blank 
+entry.
+   The file must exist to use this.
+ */
void insert(string const & f,
-   bool upd = false,
-   unsigned long one = 0,
-   unsigned long two = 0);
+   bool upd = false);
///
void update();
 
@@ -43,16 +45,26 @@
bool sumchange() const;
/// return true if fil has changed.
bool haschanged(string const & fil) const;
+   /// return true if any of the files named in the set have changed.
+   bool haschanged( std::set const & files ) const;
/// return true if a file with extension ext has changed.
bool extchanged(string const & ext) const;
///
bool exist(string const & fil) const;
///
void remove_files_with_extension(string const &);
+   ///
+   void remove_file(string const &);
 private:
///
-   typedef std::map > DepList;
+   struct dep_info {
+   unsigned long crc_prev, crc_curr;
+   long mtime_prev, mtime_curr;
+   bool changed() const;
+   };
+   ///
+   typedef std::map DepList;
+
///
DepList deplist;
 };



Re: [BUG] close prefs dialog abort in 1.1.6fix3

2001-11-27 Thread Ben Stanley

John Levon wrote:

>On Tue, Nov 27, 2001 at 11:45:18PM +1100, Ben Stanley wrote:
>
>>LyX: This shouldn't happen...
>>BadWindow (invalid Window parameter)
>>Aborted (core dumped)
>>
>
>you need to run with -sync option to lyx for any chance of a useful backtrace
>
>also, which xforms version ?
>
>thanks
>john
>
ben [01:18:50] /share/install/linux/extras/lyx $ rpm -q xforms
xforms-0.88-3

System is RH7.1

This time I didn't even have to close the prefs dialog to get it to die. 
I just clicked on the input tab.

The end of the output before it crashed

In WinOpen VClass:PseudoColor VisualID:0x22 Depth:8 8 Colormap:0x21
CreateWin OK sleeping 1 seconds
waiting Event(21,w=0x9c0019a s=14169) ReparentNotify
waiting Event(19,w=0x9c0019a s=14172) MapNotify
waiting Event(12,w=0x9c0019a s=14172) Expose count=0 serial=375c
In EventCallback [events.c 34] Unknown window=0x9c0019a
Ignored Event(12,w=0x9c0019a s=14172) Expose count=0 serial=375c
In Canvas [canvas.c 397] FL_DRAW
In CanvasWindow [canvas.c 266] Depth=8 colormap=0x21, WinID=0x9c0019b
Eaten Event(7,w=0x9c00188 s=14149) EnterNotify Mode Normal
Eaten Event(6,w=0x9c00188 s=14149) MotionNotify Mode Hint
Eaten Event(8,w=0x9c00188 s=14149) LeaveNotify Mode Normal
Eaten Event(8,w=0x9c00188 s=14172) LeaveNotify Mode Normal
Eaten Event(18,w=0x9c00188 s=14282) UnmapNotify
Eaten Event(17,w=0x9c00188 s=14284) DestroyNotify
CanvasIntecept Event(17,w=0x9c00189 s=14284) DestroyNotify
MainLoop Event(6,w=0x9c00185 s=14149) MotionNotify Mode Hint
In Canvas [canvas.c 397] FL_ENTER
MainLoop Event(8,w=0x9c00185 s=14149) LeaveNotify Mode Normal
In Canvas [canvas.c 397] FL_LEAVE
MainLoopUser Event(7,w=0x9c0018a s=14149) EnterNotify Mode Normal
In EventCallback [events.c 34] Unknown window=0x9c0018a
Ignored Event(7,w=0x9c0018a s=14149) EnterNotify Mode Normal
PutbackEvent Event(7,w=0x9c0018a s=14149) EnterNotify Mode Normal
LyX: This shouldn't happen...
BadWindow (invalid Window parameter)
Aborted (core dumped)
ben [03:44:47] ~ $

and the stack trace

(gdb) where
#0  0x4104d651 in __kill () from /lib/libc.so.6
#1  0x4104d3cd in raise (sig=6) at ../sysdeps/posix/raise.c:27
#2  0x4104ea38 in abort () at ../sysdeps/i386/bits/string.h:230
#3  0x081c163b in fl_set_button ()
#4  0x080ba825 in fl_set_button ()
#5  0x400fbd87 in _XError () from /usr/X11R6/lib/libX11.so.6
#6  0x400fa3f3 in _XReply () from /usr/X11R6/lib/libX11.so.6
#7  0x400f0a3e in XQueryPointer () from /usr/X11R6/lib/libX11.so.6
#8  0x40068156 in fl_get_win_mouse () from /usr/X11R6/lib/libforms.so.0.88
#9  0x40032227 in fl_compress_motion () from /usr/X11R6/lib/libforms.so.0.88
#10 0x40032273 in fl_compress_event () from /usr/X11R6/lib/libforms.so.0.88
#11 0x4004037e in get_next_event () from /usr/X11R6/lib/libforms.so.0.88
#12 0x4003f1fc in do_interaction_step () from 
/usr/X11R6/lib/libforms.so.0.88
#13 0x4003fb49 in fl_treat_interaction_events ()
   from /usr/X11R6/lib/libforms.so.0.88
#14 0x4003fb84 in fl_check_forms () from /usr/X11R6/lib/libforms.so.0.88
#15 0x08178364 in fl_set_button ()
#16 0x080bb9e4 in fl_set_button ()
#17 0x080bcff4 in fl_set_button ()
#18 0x080e5e2a in fl_set_button ()
#19 0x4103b0ee in __libc_start_main (main=0x80e5d60 ,
argc=3, ubp_av=0xb7b4, init=0x804dd98 <_init>, fini=0x821e090 
<_fini>,
rtld_fini=0x4100cf28 <_dl_fini>, stack_end=0xb7ac)
at ../sysdeps/generic/libc-start.c:129

And trying again, I got to set 'use_temp_dir=true' and press Save (mouse 
click), and then my XTerminal started swapping (unusual) and all this 
came out on the console

In fonts.c[149]: FontResolution: 103
MainLoop Event(6,w=0x9c00160 s=14234) MotionNotify Mode Hint
MainLoop Event(4,w=0x9c00160 s=14264) ButtonPress
MainLoop Event(5,w=0x9c00160 s=14294) ButtonRelease button: 1
Eaten Event(7,w=0x9c00178 s=15934) EnterNotify Mode Normal
Eaten Event(18,w=0x9c00178 s=16746) UnmapNotify
Eaten Event(8,w=0x9c00178 s=16746) LeaveNotify Mode Normal
Eaten Event(17,w=0x9c00178 s=16748) DestroyNotify
CanvasIntecept Event(17,w=0x9c00179 s=16748) DestroyNotify
Eaten Event(6,w=0x9c00160 s=15934) MotionNotify Mode Hint
Eaten Event(8,w=0x9c00160 s=15934) LeaveNotify Mode Normal
Eaten Event(18,w=0x9c00160 s=16781) UnmapNotify
Eaten Event(8,w=0x9c00160 s=16781) LeaveNotify Mode Normal
Eaten Event(17,w=0x9c00160 s=16783) DestroyNotify
CanvasIntecept Event(17,w=0x9c00161 s=16783) DestroyNotify
MainLoopUser Event(33,w=0x9c00096 s=14295) ClientMessage
MainLoopUser Event(33,w=0x9c00096 s=14327) ClientMessage
MainLoopUser Event(33,w=0x9c00096 s=14859) ClientMessage
MainLoopUser Event(7,w=0x9c0017b s=15934) EnterNotify Mode Normal
In EventCallback [events.c 34] Unknown window=0x9c0017b
Ignored Event(7,w=0x9c0017b s=15934) EnterNotify Mode Normal
PutbackEvent Event(7,w=0x9c0017b s=15934) EnterNotify Mode Normal
LyX: This shouldn't happen...
BadWindow (invalid Window parameter)
Aborted (core dumped)
ben [03:49:50] 

Re: [PATCH] line number info on paragraph 1.1.6

2001-11-27 Thread Ben Stanley

The BRANCH_1_1_6 that I downloaded about 2 hours ago now has correct 
line numbering with my large thesis.

But is still slow to calculate CRCs :-) Those two speedups really make a 
difference to me on my tree!

Ben.

Jean-Marc Lasgouttes wrote:

>>>>>>"Ben" == Ben Stanley <[EMAIL PROTECTED]> writes:
>>>>>>
>
>Ben> The only thing I changed was owner_ to this, due to the pimpl
>Ben> representation in HEAD.
>
>I mean that Dekel already commited a patch, which is smaller than what
>you propose (only the texrow.start). I also commited your tabular fix
>(just now), so I would appreciate if you could confirm that everything
>is alright now.
>
>JMarc
>






Re: [PATCH] line number info on paragraph 1.1.6

2001-11-27 Thread Ben Stanley

Jean-Marc Lasgouttes wrote:

>>>>>>"Ben" == Ben Stanley <[EMAIL PROTECTED]> writes:
>>>>>>
>
>Ben> I will, just as soon as I figure out how to grab your cvs... give
>Ben> me a little while, I'm on a 32kbps link.
>
>Thanks. I want to check that everything is OK before releasing
>1.1.6fix4. Would a patch relative to 1.1.6fix3 help you?
>
>JMarc
>
I'm currently building cvs 1_1_6

Ben.




Re: recreation of .tex/.dvi

2001-11-27 Thread Ben Stanley

Lars Gullik Bjønnes wrote:

>Dekel Tsur <[EMAIL PROTECTED]> writes:
>
>| On Tue, Nov 27, 2001 at 01:01:40PM +0100, Lars Gullik Bjønnes wrote:
>
>>>Andre Poenitz <[EMAIL PROTECTED]> writes:
>>>
>>>| On Tue, Nov 27, 2001 at 12:34:30PM +0200, Dekel Tsur wrote:
>>>
>Do you have use_tempir=false ?
>
>>>| Yes.
>>>
>>>I cannot see how the mtime patch can cause this, but it is probably
>>>the culprit.
>>>
>| If you used lyx before the mtime change, then the .dep file is of the format
>|   filename crc crc
>| But when you try to use lyx after the change, it expects the format
>|   filename crc crc mtime
>| and therefore it reads the existing .dep file incorrectly.
>
>but it shouldn't really matter after the first latex run, since the
>.dep file is rewritten.
>
I have managed to reproduce this, and it doesn't matter that the depfile 
is re-written, because it was initialised with the wrong information - 
so the re-written dep file is wrong also.

Temporary fix is to delete the .dep file. Proper fix is ... well, I've 
written it but not tested it yet.

Ben.

>
>
>Note that usetempdir==false really was never supported, it was just a
>bandaid.
>
>I'd like to get rid of it and introduce something that I have ealier
>called Projects. (and thus a project dir that has a build dir.)
>
>
>| The solution, use store only one crc value in the .dep file, so the format
>| is now
>|   filename crc mtime
>
>nah.
>
>| Note that when reading old files, the mtime value will be bogus, but this
>| only means that lyx will need to recompute the crc value.
>
>
>






Re: [PATCH] mmap CRC

2001-11-27 Thread Ben Stanley

Angus Leeming wrote:

>On Tuesday 27 November 2001 2:01 pm, Ben Stanley wrote:
>
>>[EMAIL PROTECTED] wrote:
>>
>>>On Tue, Nov 27, 2001 at 11:57:18PM +1100, Ben Stanley wrote:
>>>
>>>>Here is the mmap patch for calculating CRCs quickly.
>>>>
>>>How about wrapping #warnings in #ifdef __GNUC__?
>>>
>>Oh - I thought that was standard... :-)
>>
>>If you insist, here's a new patch.
>>
>
>Sorry to be a PITA, but the standard way is #ifdef WITH_WARNINGS, at least 
>for 1.2.0. See config.h
>
>/* Define this if you want to see the warning directives put here and
>   there by the developpers to get attention */
>/* #undef WITH_WARNINGS */
>
>Angus
>
>
Well then I suggest you do

cat mmap-crc.patch | sed -e "s/__GNUC__/WITH_WARNINGS/g"

to port the patch to 1.2.0 (but that won't work on 1.1.6, which is where 
I'm living atm...)

because they are purely informational while testing... so that you know 
what you are testing.

I had intended for them to be removed once we've established that the 
mmap patch works. But I suppose that if they had a #ifdef WITH_WARNINGS 
in them, then we could leave them in.

Ben.






Re: [PATCH] mmap CRC

2001-11-27 Thread Ben Stanley

[EMAIL PROTECTED] wrote:

>On Tue, Nov 27, 2001 at 11:57:18PM +1100, Ben Stanley wrote:
>
>>Here is the mmap patch for calculating CRCs quickly.
>>
>
>How about wrapping #warnings in #ifdef __GNUC__?
>
Oh - I thought that was standard... :-)

If you insist, here's a new patch.


--- lyx-1.1.6fix3-orig/src/support/lyxsum.C Wed Jun  6 02:07:10 2001
+++ lyx-1.1.6fix3/src/support/lyxsum.C  Wed Nov 28 00:57:55 2001
@@ -15,11 +15,41 @@
 
 #include 
 
+// Figure out what iterator implementation we are going to use...
+// This currently selects mmap over istreambuf_iterator.
+#ifdef HAVE_MMAP
+   #ifdef __GNUC__
+   #warning lyx::sum() using mmap (lightning fast but untested)
+   #endif
+   #define USE_MMAP
+#elif HAVE_DECL_ISTREAMBUF_ITERATOR
+   #ifdef __GNUC__
+   #warning lyx::sum() using istreambuf_iterator (fast)
+   #endif
+   #define USE_ISTREAMBUF_ITER
+   #define USE_STREAM
+#else
+   #ifdef __GNUC__
+   #warning lyx::sum() using istream_iterator (slow as a snail)
+   #endif
+   #define USE_ISTREAM_ITER
+   #define USE_STREAM
+#endif
+
+
 #include 
 #include 
 
 #include "support/lyxlib.h"
 
+#ifdef USE_MMAP
+#include 
+#include 
+#include 
+#include 
+#include 
+#endif
+
 using std::ifstream;
 using std::ios;
 
@@ -104,23 +134,56 @@
 }
 
 
+
 // And this would be the file interface.
 unsigned long lyx::sum(string const & file)
 {
+
+#ifdef USE_STREAM
std::ifstream ifs(file.c_str());
if (!ifs) return 0;
-   
-#ifdef HAVE_DECL_ISTREAMBUF_ITERATOR
+#endif
+
+   // Setups
+
+#ifdef USE_ISTREAMBUF_ITER
// This is a lot faster...
std::istreambuf_iterator beg(ifs);
std::istreambuf_iterator end;
-#else
+#endif
+
+#ifdef USE_ISTREAM_ITER
// than this.
ifs.unsetf(std::ios::skipws);
std::istream_iterator beg(ifs);
std::istream_iterator end;
 #endif
 
-   return do_crc(beg, end);
+#ifdef USE_MMAP
+   int fd = open(file.c_str(), O_RDONLY);
+   if( !fd ) return 0;
+   
+   struct stat info;
+   int st = fstat(fd, &info);
+   
+   void * mm = mmap(0, info.st_size, PROT_READ,
+MAP_PRIVATE /*| MAP_ANON*/, fd, 0); // MAP_ANON is not POSIX
+   if (mm == MAP_FAILED) {
+   close(fd);
+   return 0;
+   }
+   char *beg = (char*)mm;
+   char *end = ((char*)mm)+info.st_size;
+#endif
+
+   // Do the CRC
+   unsigned long result = do_crc(beg,end);
+
+   // Clean up
+#ifdef USE_MMAP
+   munmap( mm, info.st_size );
+   close(fd);
+#endif
+   return result;
 }
 



Re: DepTable is slooooooooowwwwwwwwww

2001-11-27 Thread Ben Stanley

Lars Gullik Bjønnes wrote:

>mmm... did you know that use_tempdir==false was created as a
>workaround for a bug...
>
I vote we ditch it!





Re: [PATCH] line number info on paragraph 1.1.6

2001-11-27 Thread Ben Stanley

The only thing I changed was owner_ to this, due to the pimpl 
representation in HEAD.

Jean-Marc Lasgouttes wrote:

>>>>>>"Ben" == Ben Stanley <[EMAIL PROTECTED]> writes:
>>>>>>
>
>Ben> This is just Dekel's HEAD patch adapted for 1.1.6. I have tested
>Ben> it. Together with the previous line number patch, my entire
>Ben> thesis is now processed with the correct line count at the end.
>Ben> This includes math, figures, tables, figure and table floats, and
>Ben> probably a few other things too.
>
>Dekel, how does this compare with the patch you commited to
>BRANCH_1_1_6?
>
>JMarc
>






Re: DepTable is slooooooooowwwwwwwwww

2001-11-27 Thread Ben Stanley

Dekel Tsur wrote:

>On Tue, Nov 27, 2001 at 12:57:53PM +0100, Lars Gullik Bjønnes wrote:
>
>>| BTW, why the crc value of the file is written twice to the .dep file ?
>>| For example
>>| /usr/lib/texmf/tex/latex/base/article.cls 100888126 100888126
>>
>>old and new crc value.
>>after a latex run these will normally be equal, but during the run
>>they will differ and that is used to find out if we need to run latex
>>one more time.
>>
>
>First, if use_tempdir==true, I don't understand why lyx creates the .dep file.
>All the needed information is stored in memory.
>If use_tempdir==false, then we need to create a .dep file when quitting lyx.
>In this file, you only need to store one crc value for each file:
>the last computed value.
>
The information in memory only lasts as long as the LaTeX object, ie 
while you are converting. When you start to convert again, It re-reads 
the .dep file, supposedly to see if it can save you some latex runs.

At the moment my latex is needing 6 runs to stabilise no matter whether 
there are pre-existing .aux files or not. Haven't figure that out yet, 
but I'm running with a heavily modified LaTeX::run() at the moment.

Ben.





[PATCH] mmap CRC

2001-11-27 Thread Ben Stanley

Here is the mmap patch for calculating CRCs quickly.

This has fixed my slow CRC problem.

It seems to work for me, but I think that Lars should put it into his 
check_crc test harness and check it a bit more before applying...

In particular, I have not checked that you get the same CRC values using 
each iterator method.
Lars, were you comparing the LyX CRC routine against the boost crc 
routine in that test code of yours which was generating different 
results? I'd be interested to see if you get the same result comparing 
lyx CRC with iterators and lyx CRC with mmap pointers (just iterators, 
really...) using your check_crc program.

Ben.


--- lyx-1.1.6fix3-orig/src/support/lyxsum.C Wed Jun  6 02:07:10 2001
+++ lyx-1.1.6fix3/src/support/lyxsum.C  Tue Nov 27 19:25:19 2001
@@ -15,11 +15,33 @@
 
 #include 
 
+#ifdef HAVE_MMAP
+#warning lyx::sum() using mmap (lightning fast but untested)
+#define USE_MMAP
+#elif HAVE_DECL_ISTREAMBUF_ITERATOR
+#warning lyx::sum() using istreambuf_iterator (fast)
+#define USE_ISTREAMBUF_ITER
+#define USE_STREAM
+#else
+#warning lyx::sum() using istream_iterator (slow as a snail)
+#define USE_ISTREAM_ITER
+#define USE_STREAM
+#endif
+
+
 #include 
 #include 
 
 #include "support/lyxlib.h"
 
+#ifdef USE_MMAP
+#include 
+#include 
+#include 
+#include 
+#include 
+#endif
+
 using std::ifstream;
 using std::ios;
 
@@ -104,23 +126,56 @@
 }
 
 
+
 // And this would be the file interface.
 unsigned long lyx::sum(string const & file)
 {
+
+#ifdef USE_STREAM
std::ifstream ifs(file.c_str());
if (!ifs) return 0;
-   
-#ifdef HAVE_DECL_ISTREAMBUF_ITERATOR
+#endif
+
+   // Setups
+
+#ifdef USE_ISTREAMBUF_ITER
// This is a lot faster...
std::istreambuf_iterator beg(ifs);
std::istreambuf_iterator end;
-#else
+#endif
+
+#ifdef USE_ISTREAM_ITER
// than this.
ifs.unsetf(std::ios::skipws);
std::istream_iterator beg(ifs);
std::istream_iterator end;
 #endif
 
-   return do_crc(beg, end);
+#ifdef USE_MMAP
+   int fd = open(file.c_str(), O_RDONLY);
+   if( !fd ) return 0;
+   
+   struct stat info;
+   int st = fstat(fd, &info);
+   
+   void * mm = mmap(0, info.st_size, PROT_READ,
+MAP_PRIVATE /*| MAP_ANON*/, fd, 0); // MAP_ANON is not POSIX
+   if (mm == MAP_FAILED) {
+   close(fd);
+   return 0;
+   }
+   char *beg = (char*)mm;
+   char *end = ((char*)mm)+info.st_size;
+#endif
+
+   // Do the CRC
+   unsigned long result = do_crc(beg,end);
+
+   // Clean up
+#ifdef USE_MMAP
+   munmap( mm, info.st_size );
+   close(fd);
+#endif
+   return result;
 }
 



[BUG] close prefs dialog abort in 1.1.6fix3

2001-11-27 Thread Ben Stanley

Since I just had to set/unset my temporary directory flag, I just 
discovered a bug in the preferences dialog :-(.

My thesis has lots of pictures. Lots and lots. It takes LyX a few 
minutes to render previews of them all (I wish that the preview 
rendering was niced actually!).

If I attempt to close the preferences dialog while the previews are 
still rendering, I get the following message:

LyX: This shouldn't happen...
BadWindow (invalid Window parameter)
Aborted (core dumped)

The stack trace this time was

(gdb) where
#0  0x4104d651 in __kill () from /lib/libc.so.6
#1  0x4104d3cd in raise (sig=6) at ../sysdeps/posix/raise.c:27
#2  0x4104ea38 in abort () at ../sysdeps/i386/bits/string.h:230
#3  0x081c163b in fl_set_button ()
#4  0x080ba825 in fl_set_button ()
#5  0x400fbd87 in _XError () from /usr/X11R6/lib/libX11.so.6
#6  0x400fa3f3 in _XReply () from /usr/X11R6/lib/libX11.so.6
#7  0x400f0a3e in XQueryPointer () from /usr/X11R6/lib/libX11.so.6
#8  0x40068156 in fl_get_win_mouse () from /usr/X11R6/lib/libforms.so.0.88
#9  0x40032227 in fl_compress_motion () from /usr/X11R6/lib/libforms.so.0.88
#10 0x40032273 in fl_compress_event () from /usr/X11R6/lib/libforms.so.0.88
#11 0x4004037e in get_next_event () from /usr/X11R6/lib/libforms.so.0.88
#12 0x4003f1fc in do_interaction_step () from 
/usr/X11R6/lib/libforms.so.0.88
#13 0x4003fb49 in fl_treat_interaction_events () from 
/usr/X11R6/lib/libforms.so.0.88
#14 0x4003fb84 in fl_check_forms () from /usr/X11R6/lib/libforms.so.0.88
#15 0x08178364 in fl_set_button ()
#16 0x080bb9e4 in fl_set_button ()
#17 0x080bcff4 in fl_set_button ()
#18 0x080e5e2a in fl_set_button ()
#19 0x4103b0ee in __libc_start_main (main=0x80e5d60 
, argc=2,
ubp_av=0xb7a4, init=0x804dd98 <_init>, fini=0x821e090 <_fini>,
rtld_fini=0x4100cf28 <_dl_fini>, stack_end=0xb79c)
at ../sysdeps/generic/libc-start.c:129

But I have seen different stack traces from the same bug.

Ben.





Re: recreation of .tex/.dvi

2001-11-27 Thread Ben Stanley

Lars Gullik Bjønnes wrote:

>Andre Poenitz <[EMAIL PROTECTED]> writes:
>
>| On Tue, Nov 27, 2001 at 12:34:30PM +0200, Dekel Tsur wrote:
>
>>>Do you have use_tempir=false ?
>>>
>| Yes.
>
>I cannot see how the mtime patch can cause this, but it is probably
>the culprit.
>
I just tried turning off temporary directory usage and did View|DVI, and 
it worked fine for me. I watched all the intermediate files that LyX 
spewed out.

But, my LyX contains heavily edited LaTeX::run(), to support glossary 
generation.

I include .aux files in the dep tree to make sure that index/glossary 
page numbers have stabilised before stopping running LaTeX. The .aux 
files are comparatively short.

BTW, I've noticed that in my dep file, the set of files which is 
included is quite different when not using the temporary directory. This 
is probably the fault of LaTeX::deplog(), which checks if a file comes 
from the temporary directory.

However, I've just noticed that I've broken index generation in my 
tree... :-(

Ben.





summary caption support under LyX

2001-11-27 Thread Ben Stanley

Has any work been done to support summary captions, ie

\caption[bar]{foo}

where
bar goes in the list of figures
foo goes under the figure

I currently have ridiculously long entries in my list of figures...

Ben.





[PATCH] DepTable mtime speedup 1.1.6fix3

2001-11-26 Thread Ben Stanley

This patch adds mtime checks to speed up the updating of the DepTable. 
It is quite effective for me (I don't have istreambuf_iterator).

I have thrown my thesis at it, and it works... you guys may wish to test 
it some more before comitting it.

I have also added two new functions which I needed to add glossary 
support. These are

haschanged( set const & files )
remove_file(const string & filename )

I also found and fixed the problem that Lars mentioned.

Could someone else please try this on HEAD?

I intend to try mmap for the CRC next. It seems that there are already 
tests for HAS_MMAP in the autoconf system...

Ben.



--- lyx-1.1.6fix3-orig/src/DepTable.C   Wed Nov 15 14:22:06 2000
+++ lyx-1.1.6fix3/src/DepTable.CTue Nov 27 18:38:48 2001
@@ -18,8 +18,15 @@
 #endif
 
 #include "DepTable.h"
+#include "debug.h"
+
 #include "support/lyxlib.h"
 #include "support/filetools.h"
+
+#include 
+#include 
+#include 
+
 #include 
 
 using std::make_pair;
@@ -27,6 +34,39 @@
 using std::ifstream;
 using std::endl;
 
+/** \class DepTable
+   DepTable provides a list of files and information on
+   whether their contents have changed since the last time
+   the file was checked.
+   
+   This is performed internally using CRC computations and mtime checks.
+   
+   Computing the CRC of every file takes 28-33 seconds on my thesis...
+   (That is because a large number of large .eps files get entered into
+   the deptable..., and I do not have istreambuf_iterator :-( )
+   
+   Why does this class use CRC checks instead
+   of using the dates on the files?
+   
+   Well the answer to that is that LaTeX re-writes it's .aux files
+   every time it runs. This will change the modification date/time,
+   but the file might be exactly the same. You have to
+   determine if the new one is different from the old one
+   by doing a CRC or similar.
+   
+   20011126 bstanley If you were to maintain a record of the last modified 
+date/time
+   for each file, and if when you come to check it again and update the CRC,
+   you could avoid re-calculating the CRC if the date/time of the file
+   has not changed This produces a significant time saving,
+   whilst still providing the same functionality to clients. bstanley
+   
+   20011127 bstanley Applied patch by LGB which implements this date based
+   shortcut method. Speedup is significant except when the file is first entered
+   into the deptable. Tested on large thesis with many .eps files, bibliography,
+   glossary, index, etc.
+*/
+
+
 void DepTable::insert(string const & fi,
  bool upd,
  unsigned long one,
@@ -35,31 +75,62 @@
// not quite sure if this is the correct place for MakeAbsPath
string f = MakeAbsPath(fi);
if (deplist.find(f) == deplist.end()) {
+   unsigned long mtime = 0;
if (upd) {
one = two;
+   lyxerr[Debug::DEPEND] << " CRC..." << flush;
two = lyx::sum(f);
+   lyxerr[Debug::DEPEND] << "done." << endl;
+   struct stat f_info;
+   stat(fi.c_str(), &f_info);
+   mtime = f_info.st_mtime;
}
-   deplist[f] = make_pair(one, two);
+   dep_info di;
+   di.first = one;
+   di.second = two;
+   di.mtime = mtime;
+   deplist[f] = di;
}
 }

 
 void DepTable::update()
 {
+   lyxerr[Debug::DEPEND] << "Computing file checksums..." << endl;
+   time_t start_time = time(0);
for (DepList::iterator itr = deplist.begin();
itr != deplist.end();
++itr) {
+
+   long const mtime = itr->second.mtime;
+   struct stat f_info;
+   stat(itr->first.c_str(), &f_info);
+   
+   if (mtime == f_info.st_mtime) {
+   continue;
+   }
+
unsigned long const one = (*itr).second.second;
unsigned long const two = lyx::sum((*itr).first);
-   (*itr).second = make_pair(one, two);
+
+   dep_info di;
+   di.first = one;
+   di.second = two;
+   di.mtime = f_info.st_mtime;
+   
+   itr->second = di;
+
if (lyxerr.debugging(Debug::DEPEND)) {
lyxerr << "Update dep: " << (*itr).first << " "
-  << one << " " << two;
+  << one << " " << two << " " << f_info.st_mtime;
if (one != two)
lyxerr << " +";
lyxerr << endl;
}
}
+   time_t time_sec = time(0) - start_time;
+   lyxerr[Debug::DEPEND] << 

[PATCH] line number info on paragraph 1.1.6

2001-11-26 Thread Ben Stanley

This is just Dekel's HEAD patch adapted for 1.1.6.

I have tested it. Together with the previous line number patch, my 
entire thesis is now processed with the correct line count at the end. 
This includes math, figures, tables, figure and table floats, and 
probably a few other things too.



--- lyx-1.1.6fix3-orig/src/paragraph.C  Fri Jun 29 23:31:28 2001
+++ lyx-1.1.6fix3/src/paragraph.C   Tue Nov 27 11:37:28 2001
@@ -2893,13 +2893,14 @@
os << "}";

if (tmp) {
+   for( int j = 0; j < tmp; ++j ) {
+   texrow.newline();
+   }
+   texrow.start(this, i+1);
column = 0;
} else {
column += int(os.tellp()) - len;
}
-   for (; tmp--;) {
-   texrow.newline();
-   }
}
}
break;





[BUG] sub-figures in figures not in a figure float cause latex infinite loop

2001-11-26 Thread Ben Stanley

LyX-1.1.6fix3

I just found that having a sub-figure enabled in a figure that is not 
inside a figure float causes latex to run forever... perhaps we 
shouldn't allow this?

Perhaps this is a LaTeX bug, but we probably shouldn't allow sub-figures 
outside of figure floats.

Note that I created this particular one by copying the figure out of a 
figure float and pasting it into a top level paragraph.

Ben.





[PATCH] line number info on tables 1.1.6

2001-11-26 Thread Ben Stanley

Dekel Tsur wrote:

>On Mon, Nov 26, 2001 at 03:42:37PM +0100, Jean-Marc Lasgouttes wrote:
>
>>>"Andre" == Andre Poenitz <[EMAIL PROTECTED]> writes:
>>>
>>Andre> Please try with and without math stuff. I wouldn't be surprised
>>Andre> if there was a difference.
>>
>>I did some light testing, and it appears that the table inset may be a
>>good candidate too. Adding a bogus macro \foo after a table shows
>>error at the wrong place.
>>
>>All these remarks are with BRANCH_1_1_6. I am willing to fix these if
>>somebody finds quickly some hints on what happens.
>>
Patch for wrong line number info is below.

tabular.C lyx-1.1.6fix3/src/tabular.C
--- lyx-1.1.6fix3-orig/src/tabular.CThu Jun 28 02:06:15 2001
+++ lyx-1.1.6fix3/src/tabular.C Tue Nov 27 13:35:32 2001
@@ -2669,6 +2669,7 @@
++cell;
}
os << "\n";
+   ++ret;
ret += TeXBottomHLine(os, i);
bret = ret;
if (IsLongTabular()) {





  1   2   >