Re: Subject: [PATCH] Make text selectable in Help About LyX Version

2012-10-31 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes lasgout...@lyx.org writes:

| Le 31/10/2012 16:41, Kornel Benko a écrit :
 git log -1 --format=%H %ci

| Or simply
|   git log -1 --format=%h

| What I do not know is where to put such code so that it is always up
| to date. This should replace the date for development releases.

Hmm...

git describe is usually used for things like this.

-- 
Lgb



Re: Subject: [PATCH] Make text selectable in Help About LyX Version

2012-10-31 Thread Lars Gullik Bjønnes
Pavel Sanda sa...@lyx.org writes:

| Jean-Marc Lasgouttes wrote:
 What I do not know is where to put such code so that it is always up to 
 date. This should replace the date for development releases.

| 1) linker time, something along the lines LDFLAGS += --defsym
| __GITSHA=$$(git -1 log blablabla))
|and in the code extern char __GITSHA

Why not just genereate a small C file? ...
...but putting it directly into the executable might actually be a good
idea.

| 2) keyword substitution (this was easy in svn but far more tricky via
| gitattributes)

never liked them.

| 3) some hell with post-commit hooks

This is not a good solution methings.



| Pavel


-- 
Lgb



Re: Subject: [PATCH] Make text selectable in Help About LyX Version

2012-10-31 Thread Lars Gullik Bjønnes
Kornel Benko kor...@lyx.org writes:

| Am Mittwoch, 31. Oktober 2012 um 16:46:53, schrieb Jean-Marc
| Lasgouttes lasgout...@lyx.org
 Le 31/10/2012 16:41, Kornel Benko a écrit :
  git log -1 --format=%H %ci
 
 Or simply
git log -1 --format=%h
 
 What I do not know is where to put such code so that it is always up to 
 date. This should replace the date for development releases.
 
 JMarc

| I think, it should go to configure.ac.
| To prevent unneeded recompilation, the defines should not go to
| created config.h.

If you go that way, the solution already exists...

| Like in cmake-build maybe to a file included only by version.cpp.

... other places: generate version.cpp, let version.hpp(sic) be
constant.

-- 
Lgb



Re: Subject: [PATCH] Make text selectable in Help > About LyX > Version

2012-10-31 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes  writes:

| Le 31/10/2012 16:41, Kornel Benko a écrit :
>> git log -1 --format="%H %ci"
>
| Or simply
|   git log -1 --format="%h"
>
| What I do not know is where to put such code so that it is always up
| to date. This should replace the date for development releases.

Hmm...

git describe is usually used for things like this.

-- 
Lgb



Re: Subject: [PATCH] Make text selectable in Help > About LyX > Version

2012-10-31 Thread Lars Gullik Bjønnes
Pavel Sanda  writes:

| Jean-Marc Lasgouttes wrote:
>> What I do not know is where to put such code so that it is always up to 
>> date. This should replace the date for development releases.
>
| 1) linker time, something along the lines LDFLAGS += --defsym
| __GITSHA=$$(git -1 log blablabla))
|and in the code extern char __GITSHA

Why not just genereate a small C file? ...
...but putting it directly into the executable might actually be a good
idea.

| 2) keyword substitution (this was easy in svn but far more tricky via
| gitattributes)

never liked them.

| 3) some hell with post-commit hooks

This is not a good solution methings.


>
| Pavel
>

-- 
Lgb



Re: Subject: [PATCH] Make text selectable in Help > About LyX > Version

2012-10-31 Thread Lars Gullik Bjønnes
Kornel Benko  writes:

| Am Mittwoch, 31. Oktober 2012 um 16:46:53, schrieb Jean-Marc
| Lasgouttes 
>> Le 31/10/2012 16:41, Kornel Benko a écrit :
>> > git log -1 --format="%H %ci"
>> 
>> Or simply
>>git log -1 --format="%h"
>> 
>> What I do not know is where to put such code so that it is always up to 
>> date. This should replace the date for development releases.
>> 
>> JMarc
>
| I think, it should go to configure.ac.
| To prevent unneeded recompilation, the defines should not go to
| created config.h.

If you go that way, the solution already exists...

| Like in cmake-build maybe to a file included only by version.cpp.

... other places: generate version.cpp, let version.hpp(sic) be
constant.

-- 
Lgb



Re: git in 2.1

2012-10-30 Thread Lars Gullik Bjønnes
Alessandro Di Federico a...@clearmind.me writes:

| On Fri, 2012-10-26 at 18:03 +0200, Pavel Sanda wrote:
 No, it is not. Adding some basic support (#0) like we have with other
 RCS
 is one weekend work and you'll spend more time on testing than coding.
 
 Some folks spoke about more fancy git support - in particular
 #1) use git for bundled format
 #2) use (some of) git codebase instead of relying on external calls
we use for rcs/cvs/svn. 

| Yes, I've read the discussion about git. The problem on when to git-push
| emerged, but honestly I think that adding a dedicated
| command/button/menu item is much easier than all the other options like
| commit+push or just commit. However I may miss something.

| About #2, if I'm correct the question was just about knowing if the file
| is part of a git repo since we don't want to spawn a process each time a
| document is open. In the case we'd have to check ./.git, and
| ../.git, and ../../.git. I know this may be a problem in certain
| situations, but that's what git-status does, so we don't have much
| alternative. 

I really think that calling git status or a similar command is
perfectly ok, and while we wait for libgit to emerge, also the right
thing to do.

-- 
Lgb



Re: git in 2.1

2012-10-30 Thread Lars Gullik Bjønnes
lar...@gullik.org (Lars Gullik Bjønnes) writes:

| Alessandro Di Federico a...@clearmind.me writes:

| | On Fri, 2012-10-26 at 18:03 +0200, Pavel Sanda wrote:
 No, it is not. Adding some basic support (#0) like we have with other
 RCS
 is one weekend work and you'll spend more time on testing than coding.
 
 Some folks spoke about more fancy git support - in particular
 #1) use git for bundled format
 #2) use (some of) git codebase instead of relying on external calls
we use for rcs/cvs/svn. 

| | Yes, I've read the discussion about git. The problem on when to git-push
| | emerged, but honestly I think that adding a dedicated
| | command/button/menu item is much easier than all the other options like
| | commit+push or just commit. However I may miss something.

| | About #2, if I'm correct the question was just about knowing if the file
| | is part of a git repo since we don't want to spawn a process each time a
| | document is open. In the case we'd have to check ./.git, and
| | ../.git, and ../../.git. I know this may be a problem in certain
| | situations, but that's what git-status does, so we don't have much
| | alternative. 

| I really think that calling git status or a similar command is
| perfectly ok, and while we wait for libgit to emerge, also the right
| thing to do.

git config --local core.repositoryFormatVersion

might be the correct thing to use.

-- 
Lgb



Re: git in 2.1

2012-10-30 Thread Lars Gullik Bjønnes
Alessandro Di Federico  writes:

| On Fri, 2012-10-26 at 18:03 +0200, Pavel Sanda wrote:
>> No, it is not. Adding some basic support (#0) like we have with other
>> RCS
>> is one weekend work and you'll spend more time on testing than coding.
>> 
>> Some folks spoke about more fancy git support - in particular
>> #1) use git for bundled format
>> #2) use (some of) git codebase instead of relying on external calls
>>we use for rcs/cvs/svn. 
>
| Yes, I've read the discussion about git. The problem on when to git-push
| emerged, but honestly I think that adding a dedicated
| command/button/menu item is much easier than all the other options like
| commit+push or just commit. However I may miss something.
>
| About #2, if I'm correct the question was just about knowing if the file
| is part of a git repo since we don't want to spawn a process each time a
| document is open. In the case we'd have to check "./.git", and
| "../.git", and "../../.git". I know this may be a problem in certain
| situations, but that's what git-status does, so we don't have much
| alternative. 

I really think that calling "git status" or a similar command is
perfectly ok, and while we wait for libgit to emerge, also the right
thing to do.

-- 
Lgb



Re: git in 2.1

2012-10-30 Thread Lars Gullik Bjønnes
lar...@gullik.org (Lars Gullik Bjønnes) writes:

| Alessandro Di Federico <a...@clearmind.me> writes:
>
| | On Fri, 2012-10-26 at 18:03 +0200, Pavel Sanda wrote:
>>> No, it is not. Adding some basic support (#0) like we have with other
>>> RCS
>>> is one weekend work and you'll spend more time on testing than coding.
>>> 
>>> Some folks spoke about more fancy git support - in particular
>>> #1) use git for bundled format
>>> #2) use (some of) git codebase instead of relying on external calls
>>>we use for rcs/cvs/svn. 
>>
| | Yes, I've read the discussion about git. The problem on when to git-push
| | emerged, but honestly I think that adding a dedicated
| | command/button/menu item is much easier than all the other options like
| | commit+push or just commit. However I may miss something.
>>
| | About #2, if I'm correct the question was just about knowing if the file
| | is part of a git repo since we don't want to spawn a process each time a
| | document is open. In the case we'd have to check "./.git", and
| | "../.git", and "../../.git". I know this may be a problem in certain
| | situations, but that's what git-status does, so we don't have much
| | alternative. 
>
| I really think that calling "git status" or a similar command is
| perfectly ok, and while we wait for libgit to emerge, also the right
| thing to do.

git config --local core.repositoryFormatVersion

might be the correct thing to use.

-- 
Lgb



Re: Compilers used for compiling LyX?

2012-10-29 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes lasgout...@lyx.org writes:

| Le 29/10/2012 06:36, Liviu Andronic a écrit :
 On Sun, Oct 28, 2012 at 11:58 AM, Jean-Marc Lasgouttes
 lasgout...@lyx.org wrote:
 I have 4.4 on my ubuntu 10.04 install.

 Are you sure? Ubuntu Lucid ships Qt 4.6.2 [1].
 [1]
 http://packages.ubuntu.com/search?keywords=libqt4searchon=namessuite=allsection=all

| I meant gcc 4.4. Qt is 4.6 of course.

When does support of 10.04 stop?

IMHO, when a distro goes into not-supported-mode we should not have to
care about it anymore. Of course the LTS distros pose a problem in that
respect.

-- 
Lgb



Re: Compilers used for compiling LyX?

2012-10-29 Thread Lars Gullik Bjønnes
Pavel Sanda sa...@lyx.org writes:

| Lars Gullik Bj?nnes wrote:
 Would be fun to see how far off we are from being able to use C++11.

| Which minimum version of gcc/MSVC is needed for your fun?

I think we have to wait a bit.
I'd prefere c++11 to be out of experimental state in gcc. So gcc 4.8
earliest, although in reality 4.6 might be ok, 4.7 certainly is.

| Are there other projects around KDE/Qt already using C++11?
| Perhaps the natural time would be when Qt start to use it.

Dunno. I'd say no... we can certainly use c++11 features even if Qt or
other libraries do not use it. More dependant on if the toolchain (read:
gcc) manage to keep the C++03 and C++11 stdlib versions ABI compatible.

MSVC seems yet again to be falling behind.

-- 
Lgb



Re: Compilers used for compiling LyX?

2012-10-29 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes  writes:

| Le 29/10/2012 06:36, Liviu Andronic a écrit :
>> On Sun, Oct 28, 2012 at 11:58 AM, Jean-Marc Lasgouttes
>>  wrote:
>>> I have 4.4 on my ubuntu 10.04 install.
>>>
>> Are you sure? Ubuntu Lucid ships Qt 4.6.2 [1].
>> [1]
>> http://packages.ubuntu.com/search?keywords=libqt4=names=all=all
>
| I meant gcc 4.4. Qt is 4.6 of course.

When does support of 10.04 stop?

IMHO, when a distro goes into not-supported-mode we should not have to
care about it anymore. Of course the LTS distros pose a problem in that
respect.

-- 
Lgb



Re: Compilers used for compiling LyX?

2012-10-29 Thread Lars Gullik Bjønnes
Pavel Sanda  writes:

| Lars Gullik Bj?nnes wrote:
>> Would be fun to see how far off we are from being able to use C++11.
>
| Which minimum version of gcc/MSVC is needed for your fun?

I think we have to wait a bit.
I'd prefere c++11 to be out of experimental state in gcc. So gcc 4.8
earliest, although in reality 4.6 might be ok, 4.7 certainly is.

| Are there other projects around KDE/Qt already using C++11?
| Perhaps the natural time would be when Qt start to use it.

Dunno. I'd say no... we can certainly use c++11 features even if Qt or
other libraries do not use it. More dependant on if the toolchain (read:
gcc) manage to keep the C++03 and C++11 stdlib versions ABI compatible.

MSVC seems yet again to be falling behind.

-- 
Lgb



Re: boost

2012-10-28 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes lasgout...@lyx.org writes:

| Le 26/10/12 19:05, Pavel Sanda a écrit :
 BTW after some decade we still include boost in our tarballs and maintain
 its updates. What was the original reason and is it still needed? Some
 distributions disable internal boost and we do not see any flood of bug
 reports.

| If one wants to compile with external boost, then it is not possible
| to compile with stdlib-debug.

That is a problem if we would want to ditch internal boost completely,
but as long as we keep the copy it is not a problem.

I have seen some discussion about this on the boost list in the last few
days, and they talked about createing a super-debug version that is
compiled with stdlib-debug turned on. A distro with a boost-debug variant
like that would probably work for us as well with stdlib-debug on.

-- 
Lgb



Retina support on Mac

2012-10-28 Thread Lars Gullik Bjønnes

What would having retina support on Mac entail for LyX?

I just got a request for that (together with a donation).

-- 
Lgb



Re: [PATCH] src/*.cpp: reformatting to increase consistency

2012-10-28 Thread Lars Gullik Bjønnes
Stephan Witt st.w...@gmx.net writes:

| Am 27.10.2012 um 22:21 schrieb Lars Gullik Bjønnes lar...@gullik.org:

 On 27 October 2012 21:31, Stephan Witt st.w...@gmx.net wrote:
 Am 27.10.2012 um 21:12 schrieb Lars Gullik Bjønnes lar...@gullik.org:
 
 This invalidates all patches hanging around for cosmetic reasons.
 Is this really necessary?
 
 Why do you have patches hanging around?
 
 Because I didn't apply them?
 
 Commit them to one or more branches and I'll rebase them to HEAD for you.

| Thanks, but Abdel is probably right. I can easily do this myself.

 
 Are you saying that changes are hostage to undisclosed patches that
 someone might have?
 
 No, I asked if it's necessary to change the code for increased
 consistency of coding style.
 
 Not necessary, but nice. Esp. consistency within a single file.
 
 Can you point me to the rules for coding style please?
 
 I only know of the old files in development/coding.

| The best match I found is:

|  - Adapt the formatting of your code to the one used in the
|other parts of LyX. In case there is different formatting for
|the same construct, use the one used more often.

| So this implies one should care for *own* code, IMHO.

What if one has not done this? Who will ever to it then?
(I'd call it a bug in the commit even, even if it can feel overly
pedantic I do belive that should be part of review comments.)

| I can understand your goal and I'm often tempted to change the formatting of 
our code base at work myself.
| But because it is a matter of taste until it's not well defined there is some 
chance of code format bouncing.

It is pretty well defined how we format code in LyX.
We can get some bouncing of course, but sometime it is not obvious how
to format everyting. esp. when it compes to overlong constructs and who
to make it more readable.

(As as to work... there I do it completely different. You wouldn't want
that style here.)

-- 
Lgb



Re: boost

2012-10-28 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes  writes:

| Le 26/10/12 19:05, Pavel Sanda a écrit :
>> BTW after some decade we still include boost in our tarballs and maintain
>> its updates. What was the original reason and is it still needed? Some
>> distributions disable internal boost and we do not see any flood of bug
>> reports.
>
| If one wants to compile with external boost, then it is not possible
| to compile with stdlib-debug.

That is a problem if we would want to ditch internal boost completely,
but as long as we keep the copy it is not a problem.

I have seen some discussion about this on the boost list in the last few
days, and they talked about createing a "super-debug" version that is
compiled with stdlib-debug turned on. A distro with a boost-debug variant
like that would probably work for us as well with stdlib-debug on.

-- 
Lgb



Retina support on Mac

2012-10-28 Thread Lars Gullik Bjønnes

What would having retina support on Mac entail for LyX?

I just got a request for that (together with a donation).

-- 
Lgb



Re: [PATCH] src/*.cpp: reformatting to increase consistency

2012-10-28 Thread Lars Gullik Bjønnes
Stephan Witt <st.w...@gmx.net> writes:

| Am 27.10.2012 um 22:21 schrieb Lars Gullik Bjønnes <lar...@gullik.org>:
>
>> On 27 October 2012 21:31, Stephan Witt <st.w...@gmx.net> wrote:
>>> Am 27.10.2012 um 21:12 schrieb Lars Gullik Bjønnes <lar...@gullik.org>:
>>> 
>>>>> This invalidates all patches hanging around for cosmetic reasons.
>>>>> Is this really necessary?
>>>> 
>>>> Why do you have patches hanging around?
>>> 
>>> Because I didn't apply them?
>> 
>> Commit them to one or more branches and I'll rebase them to HEAD for you.
>
| Thanks, but Abdel is probably right. I can easily do this myself.
>
>> 
>>>> Are you saying that changes are hostage to undisclosed patches that
>>>> someone might have?
>>> 
>>> No, I asked if it's necessary to change the code for increased
>>> consistency of coding style.
>> 
>> Not necessary, but nice. Esp. consistency within a single file.
>> 
>>> Can you point me to the rules for coding style please?
>> 
>> I only know of the old files in development/coding.
>
| The best match I found is:
>
|  - Adapt the formatting of your code to the one used in the
|other parts of LyX. In case there is different formatting for
|the same construct, use the one used more often.
>
| So this implies one should care for *own* code, IMHO.

What if "one" has not done this? Who will ever to it then?
(I'd call it a "bug" in the commit even, even if it can feel overly
pedantic I do belive that should be part of review comments.)

| I can understand your goal and I'm often tempted to change the formatting of 
our code base at work myself.
| But because it is a matter of taste until it's not well defined there is some 
chance of "code format bouncing".

It is pretty well defined how we format code in LyX.
We can get some bouncing of course, but sometime it is not obvious how
to format everyting. esp. when it compes to overlong constructs and who
to make it more readable.

(As as to work... there I do it completely different. You wouldn't want
that style here.)

-- 
Lgb



Re: boost

2012-10-27 Thread Lars Gullik Bjønnes
André Pönitz andre.poen...@mathematik.tu-chemnitz.de writes:

| I thought I could simply shut up. Alas, it looks like I can't.

| On Sat, Oct 27, 2012 at 01:12:21AM +0200, Lars Gullik Bjønnes wrote:
 lar...@gullik.org (Lars Gullik Bjønnes) writes:
 
 | | BTW after some decade we still include boost in our tarballs and maintain
 | | its updates. What was the original reason and is it still needed?
 
 | My preferences are as follows:
 
 | 0. Standard C++
 | 1. Something with the same apis/behaviour as standard C++
 | 2. Use something that is destined for standardization.
 | 3. third party libraries.
 
 These are guidlines of course. More special requirements require more
 special measures.

| My preferences are

tl;dr

-- 
Lgb



Re: boost

2012-10-27 Thread Lars Gullik Bjønnes
André Pönitz andre.poen...@mathematik.tu-chemnitz.de writes:

| I thought I could simply shut up. Alas, it looks like I can't.

| On Sat, Oct 27, 2012 at 01:12:21AM +0200, Lars Gullik Bjønnes wrote:
 lar...@gullik.org (Lars Gullik Bjønnes) writes:
 
 | | BTW after some decade we still include boost in our tarballs and maintain
 | | its updates. What was the original reason and is it still needed?
 
 | My preferences are as follows:
 
 | 0. Standard C++
 | 1. Something with the same apis/behaviour as standard C++
 | 2. Use something that is destined for standardization.
 | 3. third party libraries.
 
 These are guidlines of course. More special requirements require more
 special measures.

| Keep your list of preferences, in the order you have, but, _please_,
| qualify the items with a if it helps the users.

Note that users in this setting is just as well other developers as
users of lyx the application.

OTOH. We are in much more agreement than you think.

-- 
Lgb



Re: Compilers used for compiling LyX?

2012-10-27 Thread Lars Gullik Bjønnes
André Pönitz andre.poen...@mathematik.tu-chemnitz.de writes:

| On Sat, Oct 27, 2012 at 01:35:26AM +0200, Lars Gullik Bjønnes wrote:
 
 Do any of you have feeling what compilers are use to compile LyX
 now-a-days, that at what version they are?
 
 Would be fun to see how far off we are from being able to use C++11.

| Might be worth a look:

| http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.aspx

Yes.
VC11, suprisingly bad. I really thought it to be a lot better.

-- 
Lgb



Berntein's hash

2012-10-27 Thread Lars Gullik Bjønnes

static int computeHash(docstring const  name,
docstring const  email)
{
string const full_author_string = to_utf8(name + email);
// Bernstein's hash function
unsigned int hash = 5381;
for (unsigned int c: full_author_string)
hash = ((hash  5) + hash) + c;
return int(hash);
}

This Bernstein's hash, where does it come from. There referneces I have
found fot Bernstein's hash is rather different, or at the very least
hast=0 as initial value.

Allso the ' 5' is suspicious since that is * 32, whereas the
references I have found uses * 33. No... by bad it adds another hash by
hand, resulting in 33. Hmm... does that generate better code? really?


This is the Modified Bernstein's hash function:

unsigned djb_hash ( void *key, int len )
{
  unsigned char *p = key;
  unsigned h = 0;
  int i;

  for ( i = 0; i  len; i++ )
h = 33 * h ^ p[i];

  return h;
}


Adapted to our code that would be:

(C++11)

static int computeHash(docstring const  name,
   docstring const  email)
{
string const full_author_string = to_utf8(name + email);

// Modified Bernstein's hash function
unsigned int hash = 0;

for (unsigned int c: full_author_string)
hash = 33 * hash ^ c;

return int(hash);
}

-- 
Lgb



[PATCH 1/2] Author.cpp: Change to use Modified Bernstein's hash function

2012-10-27 Thread Lars Gullik Bjønnes
Also remove the manual optimization: 33 * hash == (hash  5) + hash,
and just let the compiler handle that. The 33 really is important for
the function so it is nicer to let it stand out more.
---
 src/Author.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Author.cpp b/src/Author.cpp
index f4658e6..b19e2be 100644
--- a/src/Author.cpp
+++ b/src/Author.cpp
@@ -27,10 +27,10 @@ static int computeHash(docstring const  name,
docstring const  email)
 {
string const full_author_string = to_utf8(name + email);
-   // Bernstein's hash function
+   // Modified Bernstein's hash function
unsigned int hash = 5381;
for (unsigned int i = 0; i  full_author_string.length(); ++i)
-   hash = ((hash  5) + hash) + (unsigned 
int)(full_author_string[i]);
+   hash = 33 * hash ^ (unsigned int)(full_author_string[i]);
return int(hash);
 }
 
-- 
1.8.0



[PATCH 2/2] Author.{h,cpp}: remove last_id

2012-10-27 Thread Lars Gullik Bjønnes
We can get the id from the size of the author container.
---
 src/Author.cpp | 3 +--
 src/Author.h   | 2 --
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/Author.cpp b/src/Author.cpp
index b19e2be..5efa1fa 100644
--- a/src/Author.cpp
+++ b/src/Author.cpp
@@ -77,7 +77,6 @@ bool author_smaller(Author const  lhs, Author const  rhs)
 
 
 AuthorList::AuthorList()
-   : last_id_(0)
 {}
 
 
@@ -96,7 +95,7 @@ int AuthorList::record(Author const  a)
return i;
}
authors_.push_back(a);
-   return last_id_++;
+   return authors_.size() - 1;
 }
 
 
diff --git a/src/Author.h b/src/Author.h
index 7d9f3dd..4ce2bcb 100644
--- a/src/Author.h
+++ b/src/Author.h
@@ -79,8 +79,6 @@ public:
std::ostream  operator(std::ostream  os, AuthorList const  a);
 private:
///
-   int last_id_;
-   ///
Authors authors_;
 };
 
-- 
1.8.0



Re: [PATCH 1/2] Author.cpp: Change to use Modified Bernstein's hash function

2012-10-27 Thread Lars Gullik Bjønnes
Pavel Sanda sa...@lyx.org writes:

| Lars Gullik Bj??nnes wrote:
Change to use Modified Bernstein's hash function

| Doesn't this imply fileformat change/conversions so hashes generated 
| in 2.0 are correctly recognized in 2.1?

Right. The Author feature is really lacking in documentation.

This really seems like a bad thing to use hashes for, and specially a
hash that can easily get collisions.

But the case 2.0 - 2.1 and not recoginized or recoginzed wrongly isn't
that already presetn for all users? Hmm... and you store the full name
in the .lyx file anyway, so what is the hash really used for?

Forget this patch, except perhaps the part that makes the 33 stand
out.

(and int for hashes... hm)

-- 
Lgb



Re: [PATCH 1/2] Author.cpp: Change to use Modified Bernstein's hash function

2012-10-27 Thread Lars Gullik Bjønnes
Pavel Sanda sa...@lyx.org writes:

| Lars Gullik Bj??nnes wrote:
Change to use Modified Bernstein's hash function

| Doesn't this imply fileformat change/conversions so hashes generated 
| in 2.0 are correctly recognized in 2.1?

Actually if I read the usage correctly we are free to change the hash
function. A new hash is created only for new authors.

And if I am not missing something, the author list is per document
without any cross hearing.


-- 
Lgb



Re: [PATCH] src/*.cpp: reformatting to increase consistency

2012-10-27 Thread Lars Gullik Bjønnes
 This invalidates all patches hanging around for cosmetic reasons.
 Is this really necessary?

Why do you have patches hanging around?

Are you saying that changes are hostage to undisclosed patches that
someone might have?

And if it takes you more than 5 minutes to fix the conflicts that you
get, of all
will be trivial. Then I'll go crawl back under a rock again.

-- 
Lgb


Re: Compile problem with latest pull

2012-10-27 Thread Lars Gullik Bjønnes
Kayvan Sylvan kayvansyl...@gmail.com writes:

| On Fedora 16:

| CXXInsetListings.o
| insets/InsetLine.cpp: In member function 'virtual void
| lyx::InsetLine::metrics(lyx::MetricsInfo, lyx::Dimension) const':
| insets/InsetLine.cpp:121:33: error: 'abs' was not declared in this scope

On F16, that is actually surprising.

does an include of cstdlib fix it?

What about cmath?

-- 
Lgb



Re: [PATCH] src/*.cpp: reformatting to increase consistency

2012-10-27 Thread Lars Gullik Bjønnes
Stephan Witt st.w...@gmx.net writes:

| Am 27.10.2012 um 15:46 schrieb Lars Gullik Bjønnes lar...@gullik.org:

 ---
 src/AppleSpellChecker.cpp |   6 +-
 src/AspellChecker.cpp |  32 +++--
 src/Author.cpp|  13 +-
 src/BiblioInfo.cpp| 233 +-
 src/Bidi.cpp  |   1 +
 src/BranchList.cpp|   5 +-
 src/Buffer.cpp|  16 ++-
 src/BufferList.cpp|   2 +
 src/BufferParams.cpp  |   5 +-
 src/BufferView.cpp|   1 +
 src/Changes.cpp   |   2 +
 src/Chktex.cpp|   3 +-
 src/CmdDef.cpp|   2 +-
 src/Color.cpp |   1 +
 src/Compare.cpp   |  28 +++--
 src/ConverterCache.cpp|   6 +-
 src/CoordCache.cpp|   1 +
 src/Counters.cpp  |   2 +-
 src/Cursor.cpp| 314 
 +++---
 src/CutAndPaste.cpp   |   1 +
 src/DepTable.cpp  |   6 +-
 src/DocIterator.cpp   |   1 +
 src/EnchantChecker.cpp|  12 +-
 src/Encoding.cpp  |   3 +-
 src/FontInfo.cpp  | 192 ++--
 src/Format.cpp|  15 ++-
 src/FuncStatus.cpp|   3 +-
 src/HSpace.cpp|   1 +
 src/HunspellChecker.cpp   |  34 +++--
 src/IndicesList.cpp   |   8 +-
 src/LaTeXFeatures.cpp |   2 +
 src/Layout.cpp|  19 +--
 src/LayoutFile.cpp|  11 +-
 src/LyX.cpp   |  10 +-
 src/ModuleList.cpp|  10 +-
 src/Paragraph.cpp |  32 +++--
 src/ParagraphMetrics.cpp  |   3 +-
 src/PersonalWordList.cpp  |   1 +
 src/Server.cpp|   8 +-
 src/ServerSocket.cpp  |   1 -
 src/Session.cpp   |   1 -
 src/Text.cpp  |   1 +
 src/TextClass.cpp |  92 +++---
 src/Thesaurus.cpp |   9 +-
 src/VCBackend.cpp |   1 +
 src/VSpace.cpp|   1 +
 src/WordList.cpp  |   3 +-
 src/factory.cpp   |  15 ++-
 src/lengthcommon.cpp  |   2 +
 src/lyxfind.cpp   |  25 ++--
 src/output_docbook.cpp|  49 
 src/output_latex.cpp  |   6 +-
 src/output_plaintext.cpp  |   1 +
 src/output_xhtml.cpp  |  17 +--
 src/rowpainter.cpp|   2 +
 55 files changed, 719 insertions(+), 552 deletions(-)

| This invalidates all patches hanging around for cosmetic reasons.
| Is this really necessary?

I can spread it out if you want to.
Only fix inconsistencies when I am going to make some other changes
anyway.

But I do not understand why some patches that hang around should be
allowed to decide anything.

-- 
Lgb



Re: [PATCH] src/*.cpp: reformatting to increase consistency

2012-10-27 Thread Lars Gullik Bjønnes
On 27 October 2012 21:31, Stephan Witt st.w...@gmx.net wrote:
 Am 27.10.2012 um 21:12 schrieb Lars Gullik Bjønnes lar...@gullik.org:

 This invalidates all patches hanging around for cosmetic reasons.
 Is this really necessary?

 Why do you have patches hanging around?

 Because I didn't apply them?

Commit them to one or more branches and I'll rebase them to HEAD for you.

 Are you saying that changes are hostage to undisclosed patches that
 someone might have?

 No, I asked if it's necessary to change the code for increased consistency of 
 coding style.

Not necessary, but nice. Esp. consistency within a single file.

 Can you point me to the rules for coding style please?

I only know of the old files in development/coding.


-- 
Lgb


Re: boost

2012-10-27 Thread Lars Gullik Bjønnes
André Pönitz <andre.poen...@mathematik.tu-chemnitz.de> writes:

| I thought I could simply shut up. Alas, it looks like I can't.
>
| On Sat, Oct 27, 2012 at 01:12:21AM +0200, Lars Gullik Bjønnes wrote:
>> lar...@gullik.org (Lars Gullik Bjønnes) writes:
>> 
>> | | BTW after some decade we still include boost in our tarballs and maintain
>> | | its updates. What was the original reason and is it still needed?
>> >
>> | My preferences are as follows:
>> >
>> | 0. Standard C++
>> | 1. Something with the same apis/behaviour as standard C++
>> | 2. Use something that is destined for standardization.
>> | 3. third party libraries.
>> 
>> These are guidlines of course. More special requirements require more
>> special measures.
>
| My preferences are

tl;dr

-- 
Lgb



Re: boost

2012-10-27 Thread Lars Gullik Bjønnes
André Pönitz <andre.poen...@mathematik.tu-chemnitz.de> writes:

| I thought I could simply shut up. Alas, it looks like I can't.
>
| On Sat, Oct 27, 2012 at 01:12:21AM +0200, Lars Gullik Bjønnes wrote:
>> lar...@gullik.org (Lars Gullik Bjønnes) writes:
>> 
>> | | BTW after some decade we still include boost in our tarballs and maintain
>> | | its updates. What was the original reason and is it still needed?
>> >
>> | My preferences are as follows:
>> >
>> | 0. Standard C++
>> | 1. Something with the same apis/behaviour as standard C++
>> | 2. Use something that is destined for standardization.
>> | 3. third party libraries.
>> 
>> These are guidlines of course. More special requirements require more
>> special measures.
>
| Keep your list of preferences, in the order you have, but, _please_,
| qualify the items with a "if it helps the users."

Note that "users" in this setting is just as well other developers as
users of lyx the application.

OTOH. We are in much more agreement than you think.

-- 
Lgb



Re: Compilers used for compiling LyX?

2012-10-27 Thread Lars Gullik Bjønnes
André Pönitz <andre.poen...@mathematik.tu-chemnitz.de> writes:

| On Sat, Oct 27, 2012 at 01:35:26AM +0200, Lars Gullik Bjønnes wrote:
>> 
>> Do any of you have feeling what compilers are use to compile LyX
>> now-a-days, that at what version they are?
>> 
>> Would be fun to see how far off we are from being able to use C++11.
>
| Might be worth a look:
>
| http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.aspx

Yes.
VC11, suprisingly bad. I really thought it to be a lot better.

-- 
Lgb



Berntein's hash

2012-10-27 Thread Lars Gullik Bjønnes

static int computeHash(docstring const & name,
docstring const & email)
{
string const full_author_string = to_utf8(name + email);
// Bernstein's hash function
unsigned int hash = 5381;
for (unsigned int c: full_author_string)
hash = ((hash << 5) + hash) + c;
return int(hash);
}

This Bernstein's hash, where does it come from. There referneces I have
found fot Bernstein's hash is rather different, or at the very least
hast=0 as initial value.

Allso the '<< 5' is suspicious since that is * 32, whereas the
references I have found uses * 33. No... by bad it adds another hash by
hand, resulting in 33. Hmm... does that generate better code? really?


This is the Modified Bernstein's hash function:

unsigned djb_hash ( void *key, int len )
{
  unsigned char *p = key;
  unsigned h = 0;
  int i;

  for ( i = 0; i < len; i++ )
h = 33 * h ^ p[i];

  return h;
}


Adapted to our code that would be:

(C++11)

static int computeHash(docstring const & name,
   docstring const & email)
{
string const full_author_string = to_utf8(name + email);

// Modified Bernstein's hash function
unsigned int hash = 0;

for (unsigned int c: full_author_string)
hash = 33 * hash ^ c;

return int(hash);
}

-- 
Lgb



[PATCH 1/2] Author.cpp: Change to use Modified Bernstein's hash function

2012-10-27 Thread Lars Gullik Bjønnes
Also remove the manual "optimization": 33 * hash == (hash << 5) + hash,
and just let the compiler handle that. The 33 really is important for
the function so it is nicer to let it stand out more.
---
 src/Author.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Author.cpp b/src/Author.cpp
index f4658e6..b19e2be 100644
--- a/src/Author.cpp
+++ b/src/Author.cpp
@@ -27,10 +27,10 @@ static int computeHash(docstring const & name,
docstring const & email)
 {
string const full_author_string = to_utf8(name + email);
-   // Bernstein's hash function
+   // Modified Bernstein's hash function
unsigned int hash = 5381;
for (unsigned int i = 0; i < full_author_string.length(); ++i)
-   hash = ((hash << 5) + hash) + (unsigned 
int)(full_author_string[i]);
+   hash = 33 * hash ^ (unsigned int)(full_author_string[i]);
return int(hash);
 }
 
-- 
1.8.0



[PATCH 2/2] Author.{h,cpp}: remove last_id

2012-10-27 Thread Lars Gullik Bjønnes
We can get the id from the size of the author container.
---
 src/Author.cpp | 3 +--
 src/Author.h   | 2 --
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/Author.cpp b/src/Author.cpp
index b19e2be..5efa1fa 100644
--- a/src/Author.cpp
+++ b/src/Author.cpp
@@ -77,7 +77,6 @@ bool author_smaller(Author const & lhs, Author const & rhs)
 
 
 AuthorList::AuthorList()
-   : last_id_(0)
 {}
 
 
@@ -96,7 +95,7 @@ int AuthorList::record(Author const & a)
return i;
}
authors_.push_back(a);
-   return last_id_++;
+   return authors_.size() - 1;
 }
 
 
diff --git a/src/Author.h b/src/Author.h
index 7d9f3dd..4ce2bcb 100644
--- a/src/Author.h
+++ b/src/Author.h
@@ -79,8 +79,6 @@ public:
std::ostream & operator<<(std::ostream & os, AuthorList const & a);
 private:
///
-   int last_id_;
-   ///
Authors authors_;
 };
 
-- 
1.8.0



Re: [PATCH 1/2] Author.cpp: Change to use Modified Bernstein's hash function

2012-10-27 Thread Lars Gullik Bjønnes
Pavel Sanda  writes:

| Lars Gullik Bj??nnes wrote:
>>Change to use Modified Bernstein's hash function
>
| Doesn't this imply fileformat change/conversions so hashes generated 
| in 2.0 are correctly recognized in 2.1?

Right. The Author feature is really lacking in documentation.

This really seems like a bad thing to use hashes for, and specially a
hash that can easily get collisions.

But the case 2.0 -> 2.1 and not recoginized or recoginzed wrongly isn't
that already presetn for all users? Hmm... and you store the full name
in the .lyx file anyway, so what is the hash really used for?

Forget this patch, except perhaps the part that makes the 33 stand
out.

(and int for hashes... hm)

-- 
Lgb



Re: [PATCH 1/2] Author.cpp: Change to use Modified Bernstein's hash function

2012-10-27 Thread Lars Gullik Bjønnes
Pavel Sanda  writes:

| Lars Gullik Bj??nnes wrote:
>>Change to use Modified Bernstein's hash function
>
| Doesn't this imply fileformat change/conversions so hashes generated 
| in 2.0 are correctly recognized in 2.1?

Actually if I read the usage correctly we are free to change the hash
function. A new hash is created only for new authors.

And if I am not missing something, the author list is per document
without any cross hearing.


-- 
Lgb



Re: [PATCH] src/*.cpp: reformatting to increase consistency

2012-10-27 Thread Lars Gullik Bjønnes
> This invalidates all patches hanging around for cosmetic reasons.
> Is this really necessary?

Why do you have patches hanging around?

Are you saying that changes are hostage to undisclosed patches that
someone might have?

And if it takes you more than 5 minutes to fix the conflicts that you
get, of all
will be trivial. Then I'll go crawl back under a rock again.

-- 
Lgb


Re: Compile problem with latest pull

2012-10-27 Thread Lars Gullik Bjønnes
Kayvan Sylvan  writes:

| On Fedora 16:
>
| CXXInsetListings.o
| insets/InsetLine.cpp: In member function 'virtual void
| lyx::InsetLine::metrics(lyx::MetricsInfo&, lyx::Dimension&) const':
| insets/InsetLine.cpp:121:33: error: 'abs' was not declared in this scope

On F16, that is actually surprising.

does an include of  fix it?

What about ?

-- 
Lgb



Re: [PATCH] src/*.cpp: reformatting to increase consistency

2012-10-27 Thread Lars Gullik Bjønnes
Stephan Witt <st.w...@gmx.net> writes:

| Am 27.10.2012 um 15:46 schrieb Lars Gullik Bjønnes <lar...@gullik.org>:
>
>> ---
>> src/AppleSpellChecker.cpp |   6 +-
>> src/AspellChecker.cpp |  32 +++--
>> src/Author.cpp|  13 +-
>> src/BiblioInfo.cpp| 233 +-
>> src/Bidi.cpp  |   1 +
>> src/BranchList.cpp|   5 +-
>> src/Buffer.cpp|  16 ++-
>> src/BufferList.cpp|   2 +
>> src/BufferParams.cpp  |   5 +-
>> src/BufferView.cpp|   1 +
>> src/Changes.cpp   |   2 +
>> src/Chktex.cpp|   3 +-
>> src/CmdDef.cpp|   2 +-
>> src/Color.cpp |   1 +
>> src/Compare.cpp   |  28 +++--
>> src/ConverterCache.cpp|   6 +-
>> src/CoordCache.cpp|   1 +
>> src/Counters.cpp  |   2 +-
>> src/Cursor.cpp| 314 
>> +++---
>> src/CutAndPaste.cpp   |   1 +
>> src/DepTable.cpp  |   6 +-
>> src/DocIterator.cpp   |   1 +
>> src/EnchantChecker.cpp|  12 +-
>> src/Encoding.cpp  |   3 +-
>> src/FontInfo.cpp  | 192 ++--
>> src/Format.cpp|  15 ++-
>> src/FuncStatus.cpp|   3 +-
>> src/HSpace.cpp|   1 +
>> src/HunspellChecker.cpp   |  34 +++--
>> src/IndicesList.cpp   |   8 +-
>> src/LaTeXFeatures.cpp |   2 +
>> src/Layout.cpp|  19 +--
>> src/LayoutFile.cpp|  11 +-
>> src/LyX.cpp   |  10 +-
>> src/ModuleList.cpp|  10 +-
>> src/Paragraph.cpp |  32 +++--
>> src/ParagraphMetrics.cpp  |   3 +-
>> src/PersonalWordList.cpp  |   1 +
>> src/Server.cpp|   8 +-
>> src/ServerSocket.cpp  |   1 -
>> src/Session.cpp   |   1 -
>> src/Text.cpp  |   1 +
>> src/TextClass.cpp |  92 +++---
>> src/Thesaurus.cpp |   9 +-
>> src/VCBackend.cpp |   1 +
>> src/VSpace.cpp|   1 +
>> src/WordList.cpp  |   3 +-
>> src/factory.cpp   |  15 ++-
>> src/lengthcommon.cpp  |   2 +
>> src/lyxfind.cpp   |  25 ++--
>> src/output_docbook.cpp|  49 
>> src/output_latex.cpp  |   6 +-
>> src/output_plaintext.cpp  |   1 +
>> src/output_xhtml.cpp  |  17 +--
>> src/rowpainter.cpp|   2 +
>> 55 files changed, 719 insertions(+), 552 deletions(-)
>
| This invalidates all patches hanging around for cosmetic reasons.
| Is this really necessary?

I can spread it out if you want to.
Only fix inconsistencies when I am going to make some other changes
anyway.

But I do not understand why some patches that "hang around" should be
allowed to decide anything.

-- 
Lgb



Re: [PATCH] src/*.cpp: reformatting to increase consistency

2012-10-27 Thread Lars Gullik Bjønnes
On 27 October 2012 21:31, Stephan Witt <st.w...@gmx.net> wrote:
> Am 27.10.2012 um 21:12 schrieb Lars Gullik Bjønnes <lar...@gullik.org>:
>
>>> This invalidates all patches hanging around for cosmetic reasons.
>>> Is this really necessary?
>>
>> Why do you have patches hanging around?
>
> Because I didn't apply them?

Commit them to one or more branches and I'll rebase them to HEAD for you.

>> Are you saying that changes are hostage to undisclosed patches that
>> someone might have?
>
> No, I asked if it's necessary to change the code for increased consistency of 
> coding style.

Not necessary, but nice. Esp. consistency within a single file.

> Can you point me to the rules for coding style please?

I only know of the old files in development/coding.


-- 
Lgb


[PATCH] insets/InsetLine.cpp: use std::abs

2012-10-26 Thread Lars Gullik Bjønnes
Use std::abs in stead of std::max(v, -v).
---
 src/insets/InsetLine.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/insets/InsetLine.cpp b/src/insets/InsetLine.cpp
index 86a7e5c..f72fe64 100644
--- a/src/insets/InsetLine.cpp
+++ b/src/insets/InsetLine.cpp
@@ -118,7 +118,7 @@ void InsetLine::metrics(MetricsInfo  mi, Dimension  dim) 
const
 
// set a minimal width
int const minw = (dim.wid  0) ? 24 : 4;
-   dim.wid = max(minw, max(dim.wid, -dim.wid));
+   dim.wid = max(minw, abs(dim.wid));
 
Length height = Length(to_ascii(getParam(height)));
height_ = height.inPixels(max_width, fm.width(char_type('M')));
-- 
1.8.0



[PATCH 2/2] Use clamp

2012-10-26 Thread Lars Gullik Bjønnes
---
 src/BufferView.cpp| 5 +++--
 src/Text3.cpp | 3 ++-
 src/frontends/qt4/GuiWorkArea.cpp | 3 ++-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index bb5ed50..079ee1c 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -77,6 +77,7 @@
 #include support/lstrings.h
 #include support/Package.h
 #include support/types.h
+#include support/lyxalgo.h
 
 #include cerrno
 #include fstream
@@ -653,7 +654,7 @@ void BufferView::setCursorFromScrollbar()
break;
case CUR_INSIDE:
int const y = getPos(oldcur).y_;
-   newy = min(last, max(y, first));
+   newy = clamp(y, last, first);
if (y == newy) 
return;
}
@@ -2171,7 +2172,7 @@ void BufferView::mouseEventDispatch(FuncRequest const  
cmd0)
// surrounding Text will handle this event.
 
// make sure we stay within the screen...
-   cmd.set_y(min(max(cmd.y(), -1), height_));
+   cmd.set_y(clamp(cmd.y(), -1, height_));
 
d-mouse_position_cache_.x_ = cmd.x();
d-mouse_position_cache_.y_ = cmd.y();
diff --git a/src/Text3.cpp b/src/Text3.cpp
index ecb5d25..783f600 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -70,6 +70,7 @@
 #include support/gettext.h
 #include support/lassert.h
 #include support/lstrings.h
+#include support/lyxalgo.h
 #include support/lyxtime.h
 #include support/os.h
 
@@ -1530,7 +1531,7 @@ void Text::dispatch(Cursor  cur, FuncRequest  cmd)
CursorSlice old = bvcur.top();
 
int const wh = bv-workHeight();
-   int const y = max(0, min(wh - 1, cmd.y()));
+   int const y = clamp(cmd.y(), 0, wh - 1);
 
tm-setCursorFromCoordinates(cur, cmd.x(), y);
cur.setTargetX(cmd.x());
diff --git a/src/frontends/qt4/GuiWorkArea.cpp 
b/src/frontends/qt4/GuiWorkArea.cpp
index b0dd01e..77b81cd 100644
--- a/src/frontends/qt4/GuiWorkArea.cpp
+++ b/src/frontends/qt4/GuiWorkArea.cpp
@@ -49,6 +49,7 @@
 #include support/gettext.h
 #include support/FileName.h
 #include support/lassert.h
+#include support/lyxalgo.h
 
 #include frontends/Application.h
 #include frontends/FontMetrics.h
@@ -935,7 +936,7 @@ void GuiWorkArea::generateSyntheticMouseEvent()
int time = 200;
if (up || down) {
int dist = up ? -e_y : e_y - wh;
-   time = max(min(200, 25 / (dist * dist)), 1) ;
+   time = clamp(25 / (dist * dist), 1, 200);

if (time  40) {
step = 8 / (time * time);
-- 
1.8.0



[PATCH 1/2] support/lyxalgo.h: introduce lyx::clamp

2012-10-26 Thread Lars Gullik Bjønnes
This returns a clamped value, requiring it to be between low and high.

clamp(5, 0, 10) == min(max(5, 0), 10) == max(min(5, 10), 0)
---
 src/support/lyxalgo.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/support/lyxalgo.h b/src/support/lyxalgo.h
index f747e27..6ffb59b 100644
--- a/src/support/lyxalgo.h
+++ b/src/support/lyxalgo.h
@@ -83,6 +83,12 @@ void eliminate_duplicates(C  c)
c.erase(std::unique(c.begin(), c.end()), c.end());
 }
 
+template typename T
+T const  clamp(T const  value, T const  low, T const  high)
+{
+   return std::min(high, std::max(value, low));
+}
+
 } // namespace lyx
 
 #endif // LYX_ALGO_H
-- 
1.8.0



Re: [PATCH 1/3] Buffer.cpp: drop unused stack

2012-10-26 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes lasgout...@lyx.org writes:

| Lars,

| I propose that you commit the patches that you know are not
| controversial. This series of patches is a good example IMO.

The problem is that somethings that I find highly non-controversial are
not thought so by others.

| Pavel, Vincent, this is probably the moment where you should weigh in
| the discussion.

I'd really that you though about how to solve the using namespace std
debacle, and the ugly workarounds you have to counter measure the
namespace pollution you get because of it. Also how that affects TR1 vs.
C++11 vs. boost incompabilities.

(Basically TR1 is dead and is often incompatible with C++11. Boost
almost always changes to be compatible with C++11).

-- 
   Lgb



Re: [PATCH 1/3] Buffer.cpp: drop unused stack

2012-10-26 Thread Lars Gullik Bjønnes
lar...@gullik.org (Lars Gullik Bjønnes) writes:

| Jean-Marc Lasgouttes lasgout...@lyx.org writes:

| | Lars,

| | I propose that you commit the patches that you know are not
| | controversial. This series of patches is a good example IMO.

| The problem is that somethings that I find highly non-controversial are
| not thought so by others.

But of course something is more obvious than others.

-- 
   Lgb



Re: git in 2.1

2012-10-26 Thread Lars Gullik Bjønnes
Pavel Sanda sa...@lyx.org writes:

| Alessandro Di Federico wrote:
 This year I'm planning to put up a SVN server

| Right and it must be 1.7 :-/

 (sigh, no git support yet, and it may be too late now)

| No, it is not. Adding some basic support (#0) like we have with other RCS
| is one weekend work and you'll spend more time on testing than coding.

| Some folks spoke about more fancy git support - in particular
| #1) use git for bundled format
| #2) use (some of) git codebase instead of relying on external calls
|we use for rcs/cvs/svn.

ad #2 ... very hard. really. but feel free to use plumbing. That can
give better control, but is a bit harder to work with.

| I don't see anyone working on this goal for 2.1 so the poor-man's 
| solution #0 wouldn't harm #1/#2. At least it would recover the
| possibility to use RCS interface for our own documentation we lost
| during (in)famous git transition of lyx codebase.

RCS?
lost?

-- 
Lgb



Re: boost

2012-10-26 Thread Lars Gullik Bjønnes
Pavel Sanda sa...@lyx.org writes:

| Lars Gullik Bj?nnes wrote:
 The problem is that somethings that I find highly non-controversial are
 not thought so by others.

| If this is the problem, you can always go through the usual route
| if no one objects I'll commit this later.

 (Basically TR1 is dead and is often incompatible with C++11. Boost
 almost always changes to be compatible with C++11).

| Correct me if I don't remember right, but TR1 (and conversion to standard
| once settled) was just excursion how far can we get while ditching
| boost, no? IIRC we were immediately hit by MSVC errors and the rest of
| TR1 ifdefs are zombies of this track in the code.

(if I read commit logs etc correctly...)

the tr1 stuff is there and the support/functional.h, support/smartptr.h,
... is there since you do using namespace std and becuase you get tr1
stuff just due to included of memory f.ex.

| BTW after some decade we still include boost in our tarballs and maintain
| its updates. What was the original reason and is it still needed?

My preferences are as follows:

0. Standard C++
1. Something with the same apis/behaviour as standard C++
2. Use something that is destined for standardization.
3. third party libraries.

In a lot of cases 1  2 is solved by boost, when the stdlib/toolchain at
hand does not support it directly.

-- 
Lgb



Re: boost

2012-10-26 Thread Lars Gullik Bjønnes
lar...@gullik.org (Lars Gullik Bjønnes) writes:

| Pavel Sanda sa...@lyx.org writes:

| | Lars Gullik Bj?nnes wrote:
 The problem is that somethings that I find highly non-controversial are
 not thought so by others.

| | If this is the problem, you can always go through the usual route
| | if no one objects I'll commit this later.

 (Basically TR1 is dead and is often incompatible with C++11. Boost
 almost always changes to be compatible with C++11).

| | Correct me if I don't remember right, but TR1 (and conversion to standard
| | once settled) was just excursion how far can we get while ditching
| | boost, no? IIRC we were immediately hit by MSVC errors and the rest of
| | TR1 ifdefs are zombies of this track in the code.

| (if I read commit logs etc correctly...)

| the tr1 stuff is there and the support/functional.h, support/smartptr.h,
| ... is there since you do using namespace std and becuase you get tr1
| stuff just due to included of memory f.ex.

with msvc.

-- 
Lgb



Re: boost

2012-10-26 Thread Lars Gullik Bjønnes
lar...@gullik.org (Lars Gullik Bjønnes) writes:

| | BTW after some decade we still include boost in our tarballs and maintain
| | its updates. What was the original reason and is it still needed?

| My preferences are as follows:

| 0. Standard C++
| 1. Something with the same apis/behaviour as standard C++
| 2. Use something that is destined for standardization.
| 3. third party libraries.

These are guidlines of course. More special requirements require more
special measures.

-- 
Lgb



Compilers used for compiling LyX?

2012-10-26 Thread Lars Gullik Bjønnes

Do any of you have feeling what compilers are use to compile LyX
now-a-days, that at what version they are?

Would be fun to see how far off we are from being able to use C++11.

-- 
Lgb



Re: boost

2012-10-26 Thread Lars Gullik Bjønnes
Pavel Sanda sa...@lyx.org writes:

| Lars Gullik Bj?nnes wrote:
 My preferences are as follows:
 
 0. Standard C++
 1. Something with the same apis/behaviour as standard C++
 2. Use something that is destined for standardization.
 3. third party libraries.
 
 In a lot of cases 1  2 is solved by boost, when the stdlib/toolchain at
 hand does not support it directly.

| At the moment I was not asking about using boost dependency as such,
| but whether there are still valid reasons for maintaining it in our
| devel tree and distribute it within tarbals (the actual size of boost/
| is 2x bigger than src/ btw).

I guess the case is basically for the same people with old compilers
which tends to sit on old distros.

-- 
Lgb



[PATCH] insets/InsetLine.cpp: use std::abs

2012-10-26 Thread Lars Gullik Bjønnes
Use std::abs in stead of std::max(v, -v).
---
 src/insets/InsetLine.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/insets/InsetLine.cpp b/src/insets/InsetLine.cpp
index 86a7e5c..f72fe64 100644
--- a/src/insets/InsetLine.cpp
+++ b/src/insets/InsetLine.cpp
@@ -118,7 +118,7 @@ void InsetLine::metrics(MetricsInfo & mi, Dimension & dim) 
const
 
// set a minimal width
int const minw = (dim.wid < 0) ? 24 : 4;
-   dim.wid = max(minw, max(dim.wid, -dim.wid));
+   dim.wid = max(minw, abs(dim.wid));
 
Length height = Length(to_ascii(getParam("height")));
height_ = height.inPixels(max_width, fm.width(char_type('M')));
-- 
1.8.0



[PATCH 2/2] Use clamp

2012-10-26 Thread Lars Gullik Bjønnes
---
 src/BufferView.cpp| 5 +++--
 src/Text3.cpp | 3 ++-
 src/frontends/qt4/GuiWorkArea.cpp | 3 ++-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index bb5ed50..079ee1c 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -77,6 +77,7 @@
 #include "support/lstrings.h"
 #include "support/Package.h"
 #include "support/types.h"
+#include "support/lyxalgo.h"
 
 #include 
 #include 
@@ -653,7 +654,7 @@ void BufferView::setCursorFromScrollbar()
break;
case CUR_INSIDE:
int const y = getPos(oldcur).y_;
-   newy = min(last, max(y, first));
+   newy = clamp(y, last, first);
if (y == newy) 
return;
}
@@ -2171,7 +2172,7 @@ void BufferView::mouseEventDispatch(FuncRequest const & 
cmd0)
// surrounding Text will handle this event.
 
// make sure we stay within the screen...
-   cmd.set_y(min(max(cmd.y(), -1), height_));
+   cmd.set_y(clamp(cmd.y(), -1, height_));
 
d->mouse_position_cache_.x_ = cmd.x();
d->mouse_position_cache_.y_ = cmd.y();
diff --git a/src/Text3.cpp b/src/Text3.cpp
index ecb5d25..783f600 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -70,6 +70,7 @@
 #include "support/gettext.h"
 #include "support/lassert.h"
 #include "support/lstrings.h"
+#include "support/lyxalgo.h"
 #include "support/lyxtime.h"
 #include "support/os.h"
 
@@ -1530,7 +1531,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
CursorSlice old = bvcur.top();
 
int const wh = bv->workHeight();
-   int const y = max(0, min(wh - 1, cmd.y()));
+   int const y = clamp(cmd.y(), 0, wh - 1);
 
tm->setCursorFromCoordinates(cur, cmd.x(), y);
cur.setTargetX(cmd.x());
diff --git a/src/frontends/qt4/GuiWorkArea.cpp 
b/src/frontends/qt4/GuiWorkArea.cpp
index b0dd01e..77b81cd 100644
--- a/src/frontends/qt4/GuiWorkArea.cpp
+++ b/src/frontends/qt4/GuiWorkArea.cpp
@@ -49,6 +49,7 @@
 #include "support/gettext.h"
 #include "support/FileName.h"
 #include "support/lassert.h"
+#include "support/lyxalgo.h"
 
 #include "frontends/Application.h"
 #include "frontends/FontMetrics.h"
@@ -935,7 +936,7 @@ void GuiWorkArea::generateSyntheticMouseEvent()
int time = 200;
if (up || down) {
int dist = up ? -e_y : e_y - wh;
-   time = max(min(200, 25 / (dist * dist)), 1) ;
+   time = clamp(25 / (dist * dist), 1, 200);

if (time < 40) {
step = 8 / (time * time);
-- 
1.8.0



[PATCH 1/2] support/lyxalgo.h: introduce lyx::clamp

2012-10-26 Thread Lars Gullik Bjønnes
This returns a clamped value, requiring it to be between low and high.

clamp(5, 0, 10) == min(max(5, 0), 10) == max(min(5, 10), 0)
---
 src/support/lyxalgo.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/support/lyxalgo.h b/src/support/lyxalgo.h
index f747e27..6ffb59b 100644
--- a/src/support/lyxalgo.h
+++ b/src/support/lyxalgo.h
@@ -83,6 +83,12 @@ void eliminate_duplicates(C & c)
c.erase(std::unique(c.begin(), c.end()), c.end());
 }
 
+template 
+T const & clamp(T const & value, T const & low, T const & high)
+{
+   return std::min(high, std::max(value, low));
+}
+
 } // namespace lyx
 
 #endif // LYX_ALGO_H
-- 
1.8.0



Re: [PATCH 1/3] Buffer.cpp: drop unused

2012-10-26 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes  writes:

| Lars,
>
| I propose that you commit the patches that you know are not
| controversial. This series of patches is a good example IMO.

The problem is that somethings that I find highly non-controversial are
not thought so by others.

| Pavel, Vincent, this is probably the moment where you should weigh in
| the discussion.

I'd really that you though about how to solve the "using namespace std"
debacle, and the ugly workarounds you have to counter measure the
namespace pollution you get because of it. Also how that affects TR1 vs.
C++11 vs. boost incompabilities.

(Basically TR1 is dead and is often incompatible with C++11. Boost
almost always changes to be compatible with C++11).

-- 
   Lgb



Re: [PATCH 1/3] Buffer.cpp: drop unused

2012-10-26 Thread Lars Gullik Bjønnes
lar...@gullik.org (Lars Gullik Bjønnes) writes:

| Jean-Marc Lasgouttes <lasgout...@lyx.org> writes:
>
| | Lars,
>>
| | I propose that you commit the patches that you know are not
| | controversial. This series of patches is a good example IMO.
>
| The problem is that somethings that I find highly non-controversial are
| not thought so by others.

But of course something is more obvious than others.

-- 
   Lgb



Re: git in 2.1

2012-10-26 Thread Lars Gullik Bjønnes
Pavel Sanda  writes:

| Alessandro Di Federico wrote:
>> This year I'm planning to put up a SVN server
>
| Right and it must be <1.7 :-/
>
>> (sigh, no git support yet, and it may be too late now)
>
| No, it is not. Adding some basic support (#0) like we have with other RCS
| is one weekend work and you'll spend more time on testing than coding.
>
| Some folks spoke about more fancy git support - in particular
| #1) use git for bundled format
| #2) use (some of) git codebase instead of relying on external calls
|we use for rcs/cvs/svn.

ad #2 ... very hard. really. but feel free to use plumbing. That can
give better control, but is a bit "harder" to work with.

| I don't see anyone working on this goal for 2.1 so the poor-man's 
| solution #0 wouldn't harm #1/#2. At least it would recover the
| possibility to use RCS interface for our own documentation we lost
| during (in)famous git transition of lyx codebase.

RCS?
lost?

-- 
Lgb



Re: boost

2012-10-26 Thread Lars Gullik Bjønnes
Pavel Sanda  writes:

| Lars Gullik Bj?nnes wrote:
>> The problem is that somethings that I find highly non-controversial are
>> not thought so by others.
>
| If this is the problem, you can always go through the usual route
| "if no one objects I'll commit this later".
>
>> (Basically TR1 is dead and is often incompatible with C++11. Boost
>> almost always changes to be compatible with C++11).
>
| Correct me if I don't remember right, but TR1 (and conversion to standard
| once settled) was just excursion how far can we get while ditching
| boost, no? IIRC we were immediately hit by MSVC errors and the rest of
| TR1 ifdefs are zombies of this track in the code.

(if I read commit logs etc correctly...)

the tr1 stuff is there and the support/functional.h, support/smartptr.h,
... is there since you do "using namespace std" and becuase you get tr1
stuff just due to included of  f.ex.

| BTW after some decade we still include boost in our tarballs and maintain
| its updates. What was the original reason and is it still needed?

My preferences are as follows:

0. Standard C++
1. Something with the same apis/behaviour as standard C++
2. Use something that is destined for standardization.
3. third party libraries.

In a lot of cases 1 & 2 is solved by boost, when the stdlib/toolchain at
hand does not support it directly.

-- 
Lgb



Re: boost

2012-10-26 Thread Lars Gullik Bjønnes
lar...@gullik.org (Lars Gullik Bjønnes) writes:

| Pavel Sanda <sa...@lyx.org> writes:
>
| | Lars Gullik Bj?nnes wrote:
>>> The problem is that somethings that I find highly non-controversial are
>>> not thought so by others.
>>
| | If this is the problem, you can always go through the usual route
| | "if no one objects I'll commit this later".
>>
>>> (Basically TR1 is dead and is often incompatible with C++11. Boost
>>> almost always changes to be compatible with C++11).
>>
| | Correct me if I don't remember right, but TR1 (and conversion to standard
| | once settled) was just excursion how far can we get while ditching
| | boost, no? IIRC we were immediately hit by MSVC errors and the rest of
| | TR1 ifdefs are zombies of this track in the code.
>
| (if I read commit logs etc correctly...)
>
| the tr1 stuff is there and the support/functional.h, support/smartptr.h,
| ... is there since you do "using namespace std" and becuase you get tr1
| stuff just due to included of  f.ex.

with msvc.

-- 
Lgb



Re: boost

2012-10-26 Thread Lars Gullik Bjønnes
lar...@gullik.org (Lars Gullik Bjønnes) writes:

| | BTW after some decade we still include boost in our tarballs and maintain
| | its updates. What was the original reason and is it still needed?
>
| My preferences are as follows:
>
| 0. Standard C++
| 1. Something with the same apis/behaviour as standard C++
| 2. Use something that is destined for standardization.
| 3. third party libraries.

These are guidlines of course. More special requirements require more
special measures.

-- 
Lgb



Compilers used for compiling LyX?

2012-10-26 Thread Lars Gullik Bjønnes

Do any of you have feeling what compilers are use to compile LyX
now-a-days, that at what version they are?

Would be fun to see how far off we are from being able to use C++11.

-- 
Lgb



Re: boost

2012-10-26 Thread Lars Gullik Bjønnes
Pavel Sanda  writes:

| Lars Gullik Bj?nnes wrote:
>> My preferences are as follows:
>> 
>> 0. Standard C++
>> 1. Something with the same apis/behaviour as standard C++
>> 2. Use something that is destined for standardization.
>> 3. third party libraries.
>> 
>> In a lot of cases 1 & 2 is solved by boost, when the stdlib/toolchain at
>> hand does not support it directly.
>
| At the moment I was not asking about using boost dependency as such,
| but whether there are still valid reasons for maintaining it in our
| devel tree and distribute it within tarbals (the actual size of boost/
| is 2x bigger than src/ btw).

I guess the case is basically for the same people with old compilers
which tends to sit on old distros.

-- 
Lgb



Re: [PATCH 10/13] More idiomatic way of checking if a shared_ptr has an associated managed object

2012-10-25 Thread Lars Gullik Bjønnes
lar...@gullik.org (Lars Gullik Bjønnes) writes:

Ok for me to commit this?

| ---
|  src/KeyMap.cpp | 17 -
|  src/frontends/qt4/LayoutBox.cpp|  4 ++--
|  src/graphics/GraphicsCacheItem.cpp |  2 +-
|  src/graphics/GraphicsLoader.cpp| 22 +++---
|  src/support/ForkedCalls.cpp|  2 +-
|  5 files changed, 23 insertions(+), 24 deletions(-)

| diff --git a/src/KeyMap.cpp b/src/KeyMap.cpp
| index ffd55c4..50833c9 100644
| --- a/src/KeyMap.cpp
| +++ b/src/KeyMap.cpp
| @@ -115,13 +115,12 @@ void KeyMap::bind(KeySequence * seq, FuncRequest const 
 func, unsigned int r)
|   LYXERR(Debug::KBMAP, Warning: New binding for 
'
|
to_utf8(seq-print(KeySequence::Portable))
|' is overriding old binding...);
| - if (it-prefixes.get()) {
| + if (it-prefixes)
|   it-prefixes.reset();
| - }
|   it-func = func;
|   it-func.setOrigin(FuncRequest::KEYBOARD);
|   return;
| - } else if (!it-prefixes.get()) {
| + } else if (!it-prefixes) {
|   lyxerr  Error: New binding for '
|   
to_utf8(seq-print(KeySequence::Portable))
|   ' is overriding old binding...
| @@ -168,10 +167,10 @@ void KeyMap::unbind(KeySequence * seq, FuncRequest 
const  func, unsigned int r)
|   if (r + 1 == seq-length()) {
|   if (it-func == func) {
|   remove = it;
| - if (it-prefixes.get())
| + if (it-prefixes)
|   it-prefixes.reset();
|   }
| - } else if (it-prefixes.get()) {
| + } else if (it-prefixes) {
|   it-prefixes-unbind(seq, func, r + 1);
|   if (it-prefixes-empty())
|   remove = it;
| @@ -201,7 +200,7 @@ FuncRequest KeyMap::getBinding(KeySequence const  seq, 
unsigned int r)
|mod2 == it-mod.second) {
|   if (r + 1 == seq.length())
|   return it-func;
| - else if (it-prefixes.get())
| + else if (it-prefixes)
|   return it-prefixes-getBinding(seq, r + 1);
|   }
|   }
| @@ -441,7 +440,7 @@ FuncRequest const  KeyMap::lookup(KeySymbol const key,
|  
|   if (cit-code == key  cit-mod.first == check) {
|   // match found
| - if (cit-prefixes.get()) {
| + if (cit-prefixes) {
|   // this is a prefix key - set new map
|   seq-curmap = cit-prefixes.get();
|   static FuncRequest prefix(LFUN_COMMAND_PREFIX);
| @@ -507,7 +506,7 @@ KeyMap::Bindings KeyMap::findBindings(FuncRequest const  
func,
|  
|   Table::const_iterator end = table.end();
|   for (Table::const_iterator cit = table.begin(); cit != end; ++cit) {
| - if (cit-prefixes.get()) {
| + if (cit-prefixes) {
|   KeySequence seq = prefix;
|   seq.addkey(cit-code, cit-mod.first);
|   Bindings res2 = cit-prefixes-findBindings(func, seq);
| @@ -555,7 +554,7 @@ void KeyMap::listBindings(BindingList  list,
|   Table::const_iterator it_end = table.end();
|   for (; it != it_end; ++it) {
|   // a LFUN_COMMAND_PREFIX
| - if (it-prefixes.get()) {
| + if (it-prefixes) {
|   KeySequence seq = prefix;
|   seq.addkey(it-code, it-mod.first);
|   it-prefixes-listBindings(list, seq, tag);
| diff --git a/src/frontends/qt4/LayoutBox.cpp b/src/frontends/qt4/LayoutBox.cpp
| index aa22e60..e11a63d 100644
| --- a/src/frontends/qt4/LayoutBox.cpp
| +++ b/src/frontends/qt4/LayoutBox.cpp
| @@ -536,7 +536,7 @@ void LayoutBox::set(docstring const  layout)
|  {
|   d-resetFilter();
|  
| - if (!d-text_class_.get())
| + if (!d-text_class_)
|   return;
|  
|   if (!d-text_class_-hasLayout(layout))
| @@ -691,7 +691,7 @@ void LayoutBox::selected(int index)
|   d-model_-itemFromIndex(mindex)-text());
|   d-owner_.setFocus();
|  
| - if (!d-text_class_.get()) {
| + if (!d-text_class_) {
|   updateContents(false);
|   d-resetFilter();
|   return;
| diff --git a/src/graphics/GraphicsCacheItem.cpp 
b/src

[PATCH 1/3] Buffer.cpp: drop unused stack

2012-10-25 Thread Lars Gullik Bjønnes
---
 src/Buffer.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 8b052ad..ebc5d3a 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -113,7 +113,6 @@
 #include map
 #include set
 #include sstream
-#include stack
 #include vector
 
 using namespace std;
-- 
1.8.0



[PATCH 2/3] WS cleanup, remove extraeneous spaces

2012-10-25 Thread Lars Gullik Bjønnes
---
 src/BufferParams.h  | 2 +-
 src/CutAndPaste.cpp | 2 +-
 src/LyX.h   | 3 +--
 src/graphics/GraphicsLoader.cpp | 5 ++---
 4 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/BufferParams.h b/src/BufferParams.h
index 306e5bc..98f79a5 100644
--- a/src/BufferParams.h
+++ b/src/BufferParams.h
@@ -134,7 +134,7 @@ public:
DocumentClass const  documentClass() const;
/// \return A pointer to the DocumentClass currently in use: the 
BaseClass
/// as modified by modules.
-   DocumentClassConstPtr  documentClassPtr() const;
+   DocumentClassConstPtr documentClassPtr() const;
/// This bypasses the baseClass and sets the textClass directly.
/// Should be called with care and would be better not being here,
/// but it seems to be needed by CutAndPaste::putClipboard().
diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp
index 4b95b9b..9a336a1 100644
--- a/src/CutAndPaste.cpp
+++ b/src/CutAndPaste.cpp
@@ -631,7 +631,7 @@ bool multipleCellsSelected(Cursor const  cur)
 }
 
 
-void switchBetweenClasses(DocumentClassConstPtr  oldone,
+void switchBetweenClasses(DocumentClassConstPtr oldone,
DocumentClassConstPtr newone, InsetText  in, ErrorList  
errorlist)
 {
errorlist.clear();
diff --git a/src/LyX.h b/src/LyX.h
index af43edc..70b8b7e 100644
--- a/src/LyX.h
+++ b/src/LyX.h
@@ -144,7 +144,7 @@ private:
friend Messages const  getGuiMessages();
friend KeyMap  theTopLevelKeymap();
friend Movers  theMovers();
-   friend Mover const  getMover(std::string  const  fmt);
+   friend Mover const  getMover(std::string const  fmt);
friend void setMover(std::string const  fmt, std::string const  
command);
friend Movers  theSystemMovers();
friend frontend::Application * theApp();
@@ -180,4 +180,3 @@ void dispatch(FuncRequest const  action, DispatchResult  
dr);
 } // namespace lyx
 
 #endif // LYX_H
-
diff --git a/src/graphics/GraphicsLoader.cpp b/src/graphics/GraphicsLoader.cpp
index f635e0b..5ed19c6 100644
--- a/src/graphics/GraphicsLoader.cpp
+++ b/src/graphics/GraphicsLoader.cpp
@@ -96,11 +96,10 @@ void LoaderQueue::loadNext()
if (ptr-status() == WaitingToLoad)
ptr-startLoading();
}
-   if (!cache_queue_.empty()) {
+   if (!cache_queue_.empty())
startLoader();
-   } else {
+   else
stopLoader();
-   }
 }
 
 
-- 
1.8.0



[PATCH 3/3] Use empty() to check empty and non-empty'ness not size()

2012-10-25 Thread Lars Gullik Bjønnes
Also add FormatList::empty().
---
 src/BiblioInfo.cpp   |  8 +++---
 src/Cursor.cpp   |  4 +--
 src/Format.h |  2 ++
 src/KeySequence.cpp  |  3 +-
 src/Paragraph.cpp|  4 +--
 src/client/client.cpp| 10 +++
 src/frontends/qt4/GuiPrefs.cpp   |  4 +--
 src/frontends/qt4/GuiToolbar.cpp |  2 +-
 src/frontends/qt4/Menus.cpp  | 12 
 src/graphics/GraphicsLoader.cpp  |  2 +-
 src/lyxfind.cpp  |  4 +--
 src/mathed/CommandInset.cpp  |  2 +-
 src/mathed/InsetMathBox.cpp  |  4 +--
 src/mathed/InsetMathExInt.cpp|  6 ++--
 src/mathed/InsetMathGrid.cpp |  4 +--
 src/mathed/InsetMathHull.cpp |  4 +--
 src/mathed/InsetMathScript.cpp   | 62 
 src/mathed/InsetMathXArrow.cpp   |  2 +-
 src/mathed/InsetMathXYArrow.cpp  |  4 +--
 src/mathed/MathAutoCorrect.cpp   |  2 +-
 src/mathed/MathData.cpp  |  4 +--
 src/mathed/MathExtern.cpp| 12 
 src/mathed/MathMacro.cpp |  5 ++--
 src/mathed/MathMacroTemplate.cpp | 13 -
 src/mathed/MathParser.cpp| 22 +++---
 src/rowpainter.cpp   |  4 +--
 src/support/docstring.cpp|  2 +-
 src/support/weighted_btree.h |  4 +--
 src/tex2lyx/text.cpp |  2 +-
 29 files changed, 106 insertions(+), 107 deletions(-)

diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp
index bc46e17..93094f8 100644
--- a/src/BiblioInfo.cpp
+++ b/src/BiblioInfo.cpp
@@ -66,7 +66,7 @@ docstring familyName(docstring const  name)
vectordocstring::const_iterator it = pieces.begin();
vectordocstring::const_iterator en = pieces.end();
for (; it != en; ++it) {
-   if ((*it).size() == 0)
+   if ((*it).empty())
continue;
char_type const c = (*it)[0];
if (isLower(c))
@@ -99,7 +99,7 @@ docstring convertLaTeXCommands(docstring const  str)
bool scanning_cmd = false;
bool scanning_math = false;
bool escaped = false; // used to catch \$, etc.
-   while (val.size()) {
+   while (!val.empty()) {
char_type const ch = val[0];
 
// if we're scanning math, we output everything until we
@@ -323,7 +323,7 @@ namespace {
fmt = fmt.substr(2);
// we'll remove characters from the front of fmt as we
// deal with them
-   while (fmt.size()) {
+   while (!fmt.empty()) {
if (fmt[0] == ']'  fmt.size()  1  fmt[1] == ']') {
// that's the end
fmt = fmt.substr(2);
@@ -415,7 +415,7 @@ docstring BibTeXInfo::expandFormat(string const  format,
string fmt = format;
// we'll remove characters from the front of fmt as we
// deal with them
-   while (fmt.size()) {
+   while (!fmt.empty()) {
if (counter++  max_passes) {
LYXERR0(Recursion limit reached while parsing `
 format  '.);
diff --git a/src/Cursor.cpp b/src/Cursor.cpp
index b0f7b70..e38ca5e 100644
--- a/src/Cursor.cpp
+++ b/src/Cursor.cpp
@@ -588,7 +588,7 @@ void Cursor::checkNewWordPosition()
clearNewWordPosition();
else {
FontSpan nw = locateWord(WHOLE_WORD);
-   if (nw.size()) {
+   if (!nw.empty()) {
FontSpan ow = new_word_.locateWord(WHOLE_WORD);
if (nw.intersect(ow).empty())
clearNewWordPosition();
@@ -1637,7 +1637,7 @@ bool Cursor::macroModeClose()
// we have to resolve the macro here manually and check its 
arity
// to put the selection behind it if arity  0.
MacroData const * data = 
buffer()-getMacro(atomAsMacro-name());
-   if (selection.size()  0  data  data-numargs() - 
data-optionals()  0) {
+   if (!selection.empty()  data  data-numargs() - 
data-optionals()  0) {
macroArg = true;

atomAsMacro-setDisplayMode(MathMacro::DISPLAY_INTERACTIVE_INIT, 1);
} else
diff --git a/src/Format.h b/src/Format.h
index 9d91ae1..b96120b 100644
--- a/src/Format.h
+++ b/src/Format.h
@@ -201,6 +201,8 @@ public:
///
const_iterator end() const { return formatlist.end(); }
///
+   bool empty() const { return formatlist.empty(); }
+   ///
FormatList::size_type size() const { return formatlist.size(); }
 private:
///
diff --git a/src/KeySequence.cpp b/src/KeySequence.cpp
index a0f2f5b..3bee9ca 100644
--- a/src/KeySequence.cpp
+++ b/src/KeySequence.cpp
@@ -125,8 +125,7 @@ size_t KeySequence::parse(string const  s)
}
}
 
-   // 

[PATCH] Use new T not new T()

2012-10-25 Thread Lars Gullik Bjønnes
---
 src/Buffer.cpp| 4 ++--
 src/LyX.cpp   | 8 
 src/WordList.cpp  | 2 +-
 src/frontends/qt4/GuiApplication.cpp  | 4 ++--
 src/frontends/qt4/GuiClipboard.cpp| 2 +-
 src/frontends/qt4/GuiProgressView.cpp | 2 +-
 src/frontends/qt4/GuiView.cpp | 2 +-
 src/frontends/qt4/GuiViewSource.cpp   | 2 +-
 src/frontends/qt4/PanelStack.cpp  | 2 +-
 src/insets/InsetListingsParams.cpp| 4 ++--
 10 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index ebc5d3a..a045dea 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -493,7 +493,7 @@ Buffer::~Buffer()
 Buffer * Buffer::cloneFromMaster() const
 {
BufferMap bufmap;
-   cloned_buffers.push_back(new CloneList());
+   cloned_buffers.push_back(new CloneList);
CloneList * clones = cloned_buffers.back();
 
masterBuffer()-cloneWithChildren(bufmap, clones);
@@ -549,7 +549,7 @@ void Buffer::cloneWithChildren(BufferMap  bufmap, 
CloneList * clones) const
 
 
 Buffer * Buffer::cloneBufferOnly() const {
-   cloned_buffers.push_back(new CloneList());
+   cloned_buffers.push_back(new CloneList);
CloneList * clones = cloned_buffers.back();
Buffer * buffer_clone = new Buffer(fileName().absFileName(), false, 
this);
clones-insert(buffer_clone);
diff --git a/src/LyX.cpp b/src/LyX.cpp
index 722f040..2962207 100644
--- a/src/LyX.cpp
+++ b/src/LyX.cpp
@@ -1424,7 +1424,7 @@ void setSpellChecker()
if (lyxrc.spellchecker == native) {
 #if defined(USE_MACOSX_PACKAGING)
if (!singleton_-pimpl_-apple_spell_checker_)
-   singleton_-pimpl_-apple_spell_checker_ = new 
AppleSpellChecker();
+   singleton_-pimpl_-apple_spell_checker_ = new 
AppleSpellChecker;
singleton_-pimpl_-spell_checker_ = 
singleton_-pimpl_-apple_spell_checker_;
 #else
singleton_-pimpl_-spell_checker_ = 0;
@@ -1432,7 +1432,7 @@ void setSpellChecker()
} else if (lyxrc.spellchecker == aspell) {
 #if defined(USE_ASPELL)
if (!singleton_-pimpl_-aspell_checker_)
-   singleton_-pimpl_-aspell_checker_ = new 
AspellChecker();
+   singleton_-pimpl_-aspell_checker_ = new AspellChecker;
singleton_-pimpl_-spell_checker_ = 
singleton_-pimpl_-aspell_checker_;
 #else
singleton_-pimpl_-spell_checker_ = 0;
@@ -1440,7 +1440,7 @@ void setSpellChecker()
} else if (lyxrc.spellchecker == enchant) {
 #if defined(USE_ENCHANT)
if (!singleton_-pimpl_-enchant_checker_)
-   singleton_-pimpl_-enchant_checker_ = new 
EnchantChecker();
+   singleton_-pimpl_-enchant_checker_ = new 
EnchantChecker;
singleton_-pimpl_-spell_checker_ = 
singleton_-pimpl_-enchant_checker_;
 #else
singleton_-pimpl_-spell_checker_ = 0;
@@ -1448,7 +1448,7 @@ void setSpellChecker()
} else if (lyxrc.spellchecker == hunspell) {
 #if defined(USE_HUNSPELL)
if (!singleton_-pimpl_-hunspell_checker_)
-   singleton_-pimpl_-hunspell_checker_ = new 
HunspellChecker();
+   singleton_-pimpl_-hunspell_checker_ = new 
HunspellChecker;
singleton_-pimpl_-spell_checker_ = 
singleton_-pimpl_-hunspell_checker_;
 #else
singleton_-pimpl_-spell_checker_ = 0;
diff --git a/src/WordList.cpp b/src/WordList.cpp
index 191dc33..5dcbc14 100644
--- a/src/WordList.cpp
+++ b/src/WordList.cpp
@@ -37,7 +37,7 @@ WordList * theWordList(Language const  lang)
if (it != theGlobalWordList.end())
return it-second;
else
-   theGlobalWordList[lang] = new WordList();
+   theGlobalWordList[lang] = new WordList;
return theGlobalWordList[lang];
 }
 
diff --git a/src/frontends/qt4/GuiApplication.cpp 
b/src/frontends/qt4/GuiApplication.cpp
index 7806624..60473c9 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -737,7 +737,7 @@ struct GuiApplication::Private
{
#ifdef Q_WS_WIN
/// WMF Mime handler for Windows clipboard.
-   wmf_mime_ = new QWindowsMimeMetafile();
+   wmf_mime_ = new QWindowsMimeMetafile;
#endif
initKeySequences(theTopLevelKeymap());
}
@@ -2145,7 +2145,7 @@ void GuiApplication::execBatchCommands()
// Create the global default menubar which is shown for the dialogs
// and if no GuiView is visible.
// This must be done after the session was recovered to know the last 
files.
-   d-global_menubar_ = new GlobalMenuBar();
+   d-global_menubar_ = new GlobalMenuBar;
d-menus_.fillMenuBar(d-global_menubar_, 0, true);
 #endif
 
diff --git a/src/frontends/qt4/GuiClipboard.cpp 
b/src/frontends/qt4/GuiClipboard.cpp
index 

Re: [PATCH 10/13] More idiomatic way of checking if a shared_ptr has an associated managed object

2012-10-25 Thread Lars Gullik Bjønnes
lar...@gullik.org (Lars Gullik Bjønnes) writes:

Ok for me to commit this?

| ---
|  src/KeyMap.cpp | 17 -
|  src/frontends/qt4/LayoutBox.cpp|  4 ++--
|  src/graphics/GraphicsCacheItem.cpp |  2 +-
|  src/graphics/GraphicsLoader.cpp| 22 +++---
|  src/support/ForkedCalls.cpp|  2 +-
|  5 files changed, 23 insertions(+), 24 deletions(-)
>
| diff --git a/src/KeyMap.cpp b/src/KeyMap.cpp
| index ffd55c4..50833c9 100644
| --- a/src/KeyMap.cpp
| +++ b/src/KeyMap.cpp
| @@ -115,13 +115,12 @@ void KeyMap::bind(KeySequence * seq, FuncRequest const 
& func, unsigned int r)
|   LYXERR(Debug::KBMAP, "Warning: New binding for 
'"
|   << 
to_utf8(seq->print(KeySequence::Portable))
|   << "' is overriding old binding...");
| - if (it->prefixes.get()) {
| + if (it->prefixes)
|   it->prefixes.reset();
| - }
|   it->func = func;
|   it->func.setOrigin(FuncRequest::KEYBOARD);
|   return;
| - } else if (!it->prefixes.get()) {
| + } else if (!it->prefixes) {
|   lyxerr << "Error: New binding for '"
|  << 
to_utf8(seq->print(KeySequence::Portable))
|  << "' is overriding old binding..."
| @@ -168,10 +167,10 @@ void KeyMap::unbind(KeySequence * seq, FuncRequest 
const & func, unsigned int r)
|   if (r + 1 == seq->length()) {
|   if (it->func == func) {
|   remove = it;
| - if (it->prefixes.get())
| + if (it->prefixes)
|   it->prefixes.reset();
|   }
| - } else if (it->prefixes.get()) {
| + } else if (it->prefixes) {
|   it->prefixes->unbind(seq, func, r + 1);
|   if (it->prefixes->empty())
|   remove = it;
| @@ -201,7 +200,7 @@ FuncRequest KeyMap::getBinding(KeySequence const & seq, 
unsigned int r)
|   && mod2 == it->mod.second) {
|   if (r + 1 == seq.length())
|   return it->func;
| - else if (it->prefixes.get())
| + else if (it->prefixes)
|   return it->prefixes->getBinding(seq, r + 1);
|   }
|   }
| @@ -441,7 +440,7 @@ FuncRequest const & KeyMap::lookup(KeySymbol const ,
|  
|   if (cit->code == key && cit->mod.first == check) {
|   // match found
| - if (cit->prefixes.get()) {
| + if (cit->prefixes) {
|   // this is a prefix key - set new map
|   seq->curmap = cit->prefixes.get();
|   static FuncRequest prefix(LFUN_COMMAND_PREFIX);
| @@ -507,7 +506,7 @@ KeyMap::Bindings KeyMap::findBindings(FuncRequest const & 
func,
|  
|   Table::const_iterator end = table.end();
|   for (Table::const_iterator cit = table.begin(); cit != end; ++cit) {
| - if (cit->prefixes.get()) {
| + if (cit->prefixes) {
|   KeySequence seq = prefix;
|   seq.addkey(cit->code, cit->mod.first);
|   Bindings res2 = cit->prefixes->findBindings(func, seq);
| @@ -555,7 +554,7 @@ void KeyMap::listBindings(BindingList & list,
|   Table::const_iterator it_end = table.end();
|   for (; it != it_end; ++it) {
|   // a LFUN_COMMAND_PREFIX
| - if (it->prefixes.get()) {
| + if (it->prefixes) {
|   KeySequence seq = prefix;
|   seq.addkey(it->code, it->mod.first);
|   it->prefixes->listBindings(list, seq, tag);
| diff --git a/src/frontends/qt4/LayoutBox.cpp b/src/frontends/qt4/LayoutBox.cpp
| index aa22e60..e11a63d 100644
| --- a/src/frontends/qt4/LayoutBox.cpp
| +++ b/src/frontends/qt4/LayoutBox.cpp
| @@ -536,7 +536,7 @@ void LayoutBox::set(docstring const & layout)
|  {
|   d->resetFilter();
|  
| - if (!d->text_class_.get())
| + if (!d->text_class_)
|   return;
|  
|   if (!d->text_class_->hasLayout(layout))
| @@ -691,7 +691,7 @@ vo

[PATCH 1/3] Buffer.cpp: drop unused

2012-10-25 Thread Lars Gullik Bjønnes
---
 src/Buffer.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 8b052ad..ebc5d3a 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -113,7 +113,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 using namespace std;
-- 
1.8.0



[PATCH 2/3] WS cleanup, remove extraeneous spaces

2012-10-25 Thread Lars Gullik Bjønnes
---
 src/BufferParams.h  | 2 +-
 src/CutAndPaste.cpp | 2 +-
 src/LyX.h   | 3 +--
 src/graphics/GraphicsLoader.cpp | 5 ++---
 4 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/BufferParams.h b/src/BufferParams.h
index 306e5bc..98f79a5 100644
--- a/src/BufferParams.h
+++ b/src/BufferParams.h
@@ -134,7 +134,7 @@ public:
DocumentClass const & documentClass() const;
/// \return A pointer to the DocumentClass currently in use: the 
BaseClass
/// as modified by modules.
-   DocumentClassConstPtr  documentClassPtr() const;
+   DocumentClassConstPtr documentClassPtr() const;
/// This bypasses the baseClass and sets the textClass directly.
/// Should be called with care and would be better not being here,
/// but it seems to be needed by CutAndPaste::putClipboard().
diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp
index 4b95b9b..9a336a1 100644
--- a/src/CutAndPaste.cpp
+++ b/src/CutAndPaste.cpp
@@ -631,7 +631,7 @@ bool multipleCellsSelected(Cursor const & cur)
 }
 
 
-void switchBetweenClasses(DocumentClassConstPtr  oldone,
+void switchBetweenClasses(DocumentClassConstPtr oldone,
DocumentClassConstPtr newone, InsetText & in, ErrorList & 
errorlist)
 {
errorlist.clear();
diff --git a/src/LyX.h b/src/LyX.h
index af43edc..70b8b7e 100644
--- a/src/LyX.h
+++ b/src/LyX.h
@@ -144,7 +144,7 @@ private:
friend Messages const & getGuiMessages();
friend KeyMap & theTopLevelKeymap();
friend Movers & theMovers();
-   friend Mover const & getMover(std::string  const & fmt);
+   friend Mover const & getMover(std::string const & fmt);
friend void setMover(std::string const & fmt, std::string const & 
command);
friend Movers & theSystemMovers();
friend frontend::Application * theApp();
@@ -180,4 +180,3 @@ void dispatch(FuncRequest const & action, DispatchResult & 
dr);
 } // namespace lyx
 
 #endif // LYX_H
-
diff --git a/src/graphics/GraphicsLoader.cpp b/src/graphics/GraphicsLoader.cpp
index f635e0b..5ed19c6 100644
--- a/src/graphics/GraphicsLoader.cpp
+++ b/src/graphics/GraphicsLoader.cpp
@@ -96,11 +96,10 @@ void LoaderQueue::loadNext()
if (ptr->status() == WaitingToLoad)
ptr->startLoading();
}
-   if (!cache_queue_.empty()) {
+   if (!cache_queue_.empty())
startLoader();
-   } else {
+   else
stopLoader();
-   }
 }
 
 
-- 
1.8.0



[PATCH 3/3] Use empty() to check empty and non-empty'ness not size()

2012-10-25 Thread Lars Gullik Bjønnes
Also add FormatList::empty().
---
 src/BiblioInfo.cpp   |  8 +++---
 src/Cursor.cpp   |  4 +--
 src/Format.h |  2 ++
 src/KeySequence.cpp  |  3 +-
 src/Paragraph.cpp|  4 +--
 src/client/client.cpp| 10 +++
 src/frontends/qt4/GuiPrefs.cpp   |  4 +--
 src/frontends/qt4/GuiToolbar.cpp |  2 +-
 src/frontends/qt4/Menus.cpp  | 12 
 src/graphics/GraphicsLoader.cpp  |  2 +-
 src/lyxfind.cpp  |  4 +--
 src/mathed/CommandInset.cpp  |  2 +-
 src/mathed/InsetMathBox.cpp  |  4 +--
 src/mathed/InsetMathExInt.cpp|  6 ++--
 src/mathed/InsetMathGrid.cpp |  4 +--
 src/mathed/InsetMathHull.cpp |  4 +--
 src/mathed/InsetMathScript.cpp   | 62 
 src/mathed/InsetMathXArrow.cpp   |  2 +-
 src/mathed/InsetMathXYArrow.cpp  |  4 +--
 src/mathed/MathAutoCorrect.cpp   |  2 +-
 src/mathed/MathData.cpp  |  4 +--
 src/mathed/MathExtern.cpp| 12 
 src/mathed/MathMacro.cpp |  5 ++--
 src/mathed/MathMacroTemplate.cpp | 13 -
 src/mathed/MathParser.cpp| 22 +++---
 src/rowpainter.cpp   |  4 +--
 src/support/docstring.cpp|  2 +-
 src/support/weighted_btree.h |  4 +--
 src/tex2lyx/text.cpp |  2 +-
 29 files changed, 106 insertions(+), 107 deletions(-)

diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp
index bc46e17..93094f8 100644
--- a/src/BiblioInfo.cpp
+++ b/src/BiblioInfo.cpp
@@ -66,7 +66,7 @@ docstring familyName(docstring const & name)
vector::const_iterator it = pieces.begin();
vector::const_iterator en = pieces.end();
for (; it != en; ++it) {
-   if ((*it).size() == 0)
+   if ((*it).empty())
continue;
char_type const c = (*it)[0];
if (isLower(c))
@@ -99,7 +99,7 @@ docstring convertLaTeXCommands(docstring const & str)
bool scanning_cmd = false;
bool scanning_math = false;
bool escaped = false; // used to catch \$, etc.
-   while (val.size()) {
+   while (!val.empty()) {
char_type const ch = val[0];
 
// if we're scanning math, we output everything until we
@@ -323,7 +323,7 @@ namespace {
fmt = fmt.substr(2);
// we'll remove characters from the front of fmt as we
// deal with them
-   while (fmt.size()) {
+   while (!fmt.empty()) {
if (fmt[0] == ']' && fmt.size() > 1 && fmt[1] == ']') {
// that's the end
fmt = fmt.substr(2);
@@ -415,7 +415,7 @@ docstring BibTeXInfo::expandFormat(string const & format,
string fmt = format;
// we'll remove characters from the front of fmt as we
// deal with them
-   while (fmt.size()) {
+   while (!fmt.empty()) {
if (counter++ > max_passes) {
LYXERR0("Recursion limit reached while parsing `"
<< format << "'.");
diff --git a/src/Cursor.cpp b/src/Cursor.cpp
index b0f7b70..e38ca5e 100644
--- a/src/Cursor.cpp
+++ b/src/Cursor.cpp
@@ -588,7 +588,7 @@ void Cursor::checkNewWordPosition()
clearNewWordPosition();
else {
FontSpan nw = locateWord(WHOLE_WORD);
-   if (nw.size()) {
+   if (!nw.empty()) {
FontSpan ow = new_word_.locateWord(WHOLE_WORD);
if (nw.intersect(ow).empty())
clearNewWordPosition();
@@ -1637,7 +1637,7 @@ bool Cursor::macroModeClose()
// we have to resolve the macro here manually and check its 
arity
// to put the selection behind it if arity > 0.
MacroData const * data = 
buffer()->getMacro(atomAsMacro->name());
-   if (selection.size() > 0 && data && data->numargs() - 
data->optionals() > 0) {
+   if (!selection.empty() && data && data->numargs() - 
data->optionals() > 0) {
macroArg = true;

atomAsMacro->setDisplayMode(MathMacro::DISPLAY_INTERACTIVE_INIT, 1);
} else
diff --git a/src/Format.h b/src/Format.h
index 9d91ae1..b96120b 100644
--- a/src/Format.h
+++ b/src/Format.h
@@ -201,6 +201,8 @@ public:
///
const_iterator end() const { return formatlist.end(); }
///
+   bool empty() const { return formatlist.empty(); }
+   ///
FormatList::size_type size() const { return formatlist.size(); }
 private:
///
diff --git a/src/KeySequence.cpp b/src/KeySequence.cpp
index a0f2f5b..3bee9ca 100644
--- a/src/KeySequence.cpp
+++ b/src/KeySequence.cpp
@@ -125,8 +125,7 @@ size_t KeySequence::parse(string const & s)
}
  

[PATCH] Use new T not new T()

2012-10-25 Thread Lars Gullik Bjønnes
---
 src/Buffer.cpp| 4 ++--
 src/LyX.cpp   | 8 
 src/WordList.cpp  | 2 +-
 src/frontends/qt4/GuiApplication.cpp  | 4 ++--
 src/frontends/qt4/GuiClipboard.cpp| 2 +-
 src/frontends/qt4/GuiProgressView.cpp | 2 +-
 src/frontends/qt4/GuiView.cpp | 2 +-
 src/frontends/qt4/GuiViewSource.cpp   | 2 +-
 src/frontends/qt4/PanelStack.cpp  | 2 +-
 src/insets/InsetListingsParams.cpp| 4 ++--
 10 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index ebc5d3a..a045dea 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -493,7 +493,7 @@ Buffer::~Buffer()
 Buffer * Buffer::cloneFromMaster() const
 {
BufferMap bufmap;
-   cloned_buffers.push_back(new CloneList());
+   cloned_buffers.push_back(new CloneList);
CloneList * clones = cloned_buffers.back();
 
masterBuffer()->cloneWithChildren(bufmap, clones);
@@ -549,7 +549,7 @@ void Buffer::cloneWithChildren(BufferMap & bufmap, 
CloneList * clones) const
 
 
 Buffer * Buffer::cloneBufferOnly() const {
-   cloned_buffers.push_back(new CloneList());
+   cloned_buffers.push_back(new CloneList);
CloneList * clones = cloned_buffers.back();
Buffer * buffer_clone = new Buffer(fileName().absFileName(), false, 
this);
clones->insert(buffer_clone);
diff --git a/src/LyX.cpp b/src/LyX.cpp
index 722f040..2962207 100644
--- a/src/LyX.cpp
+++ b/src/LyX.cpp
@@ -1424,7 +1424,7 @@ void setSpellChecker()
if (lyxrc.spellchecker == "native") {
 #if defined(USE_MACOSX_PACKAGING)
if (!singleton_->pimpl_->apple_spell_checker_)
-   singleton_->pimpl_->apple_spell_checker_ = new 
AppleSpellChecker();
+   singleton_->pimpl_->apple_spell_checker_ = new 
AppleSpellChecker;
singleton_->pimpl_->spell_checker_ = 
singleton_->pimpl_->apple_spell_checker_;
 #else
singleton_->pimpl_->spell_checker_ = 0;
@@ -1432,7 +1432,7 @@ void setSpellChecker()
} else if (lyxrc.spellchecker == "aspell") {
 #if defined(USE_ASPELL)
if (!singleton_->pimpl_->aspell_checker_)
-   singleton_->pimpl_->aspell_checker_ = new 
AspellChecker();
+   singleton_->pimpl_->aspell_checker_ = new AspellChecker;
singleton_->pimpl_->spell_checker_ = 
singleton_->pimpl_->aspell_checker_;
 #else
singleton_->pimpl_->spell_checker_ = 0;
@@ -1440,7 +1440,7 @@ void setSpellChecker()
} else if (lyxrc.spellchecker == "enchant") {
 #if defined(USE_ENCHANT)
if (!singleton_->pimpl_->enchant_checker_)
-   singleton_->pimpl_->enchant_checker_ = new 
EnchantChecker();
+   singleton_->pimpl_->enchant_checker_ = new 
EnchantChecker;
singleton_->pimpl_->spell_checker_ = 
singleton_->pimpl_->enchant_checker_;
 #else
singleton_->pimpl_->spell_checker_ = 0;
@@ -1448,7 +1448,7 @@ void setSpellChecker()
} else if (lyxrc.spellchecker == "hunspell") {
 #if defined(USE_HUNSPELL)
if (!singleton_->pimpl_->hunspell_checker_)
-   singleton_->pimpl_->hunspell_checker_ = new 
HunspellChecker();
+   singleton_->pimpl_->hunspell_checker_ = new 
HunspellChecker;
singleton_->pimpl_->spell_checker_ = 
singleton_->pimpl_->hunspell_checker_;
 #else
singleton_->pimpl_->spell_checker_ = 0;
diff --git a/src/WordList.cpp b/src/WordList.cpp
index 191dc33..5dcbc14 100644
--- a/src/WordList.cpp
+++ b/src/WordList.cpp
@@ -37,7 +37,7 @@ WordList * theWordList(Language const & lang)
if (it != theGlobalWordList.end())
return it->second;
else
-   theGlobalWordList[lang] = new WordList();
+   theGlobalWordList[lang] = new WordList;
return theGlobalWordList[lang];
 }
 
diff --git a/src/frontends/qt4/GuiApplication.cpp 
b/src/frontends/qt4/GuiApplication.cpp
index 7806624..60473c9 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -737,7 +737,7 @@ struct GuiApplication::Private
{
#ifdef Q_WS_WIN
/// WMF Mime handler for Windows clipboard.
-   wmf_mime_ = new QWindowsMimeMetafile();
+   wmf_mime_ = new QWindowsMimeMetafile;
#endif
initKeySequences(());
}
@@ -2145,7 +2145,7 @@ void GuiApplication::execBatchCommands()
// Create the global default menubar which is shown for the dialogs
// and if no GuiView is visible.
// This must be done after the session was recovered to know the "last 
files".
-   d->global_menubar_ = new GlobalMenuBar();
+   d->global_menubar_ = new GlobalMenuBar;
d->menus_.fillMenuBar(d->global_menubar_, 0, true);
 #endif
 
diff --git a/src/frontends/qt4/GuiClipboard.cpp 

[PATCH] config/lyxinclude.m4: add support for -flto

2012-10-24 Thread Lars Gullik Bjønnes
Add feature --enable-lto, link-time optimization.

Enabling link-time optimization turns debug information off (-g),
sine -flto and -g does not currently well work together.

Also stdlib-debug is turned off, does also not work well with -flto.
---
 config/lyxinclude.m4 | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/config/lyxinclude.m4 b/config/lyxinclude.m4
index 2e529ea..67aea1f 100644
--- a/config/lyxinclude.m4
+++ b/config/lyxinclude.m4
@@ -236,6 +236,24 @@ AC_ARG_ENABLE(cxx11,
   AC_HELP_STRING([--enable-cxx11],[enable C++11 mode]),,
   enable_cxx11=no;)
 
+AC_ARG_ENABLE(lto,
+  AC_HELP_STRING([--enable-lto],[enable link time optimization]),,
+  enable_lto=no;)
+case $enable_lto in
+yes)
+   lto_opt=-flto
+   enable_debug=no
+   enable_stdlib_debug=no
+   ;;
+no)
+   lto_opt=;;
+*)
+   lto_opt=-flto=${enable_lto}
+   enable_debug=no
+   enable_stdlib_debug=no
+   ;;
+esac
+
 AC_ARG_ENABLE(assertions,
   AC_HELP_STRING([--enable-assertions],[add runtime sanity checks in the 
program]),,
   [AS_CASE([$build_type], [dev*|pre*], [enable_assertions=yes],
@@ -322,6 +340,15 @@ if test x$GXX = xyes; then
  ;;
   esac
   fi
+  if test x$enable_lto != xno ; then
+  case $gxx_version in
+ 4.7*|4.8*)
+ lyx_flags=$lyx_flags link-time-optimization
+ CFLAGS=$lto_opt $CFLAGS
+ CXXFLAGS=$lto_opt $CXXFLAGS
+ ;;
+  esac
+  fi
 fi
 test $lyx_pch_comp = yes  lyx_flags=$lyx_flags pch
 AM_CONDITIONAL(LYX_BUILD_PCH, test $lyx_pch_comp = yes)
-- 
1.8.0



Re: [PATCH] config/lyxinclude.m4: add support for -flto

2012-10-24 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes lasgout...@lyx.org writes:

| Le 24/10/2012 13:13, Lars Gullik Bjønnes a écrit :
 Add feature --enable-lto, link-time optimization.

| Do you see a visible gain, that would make it worth using on release builds?

textdatabss   dec  hexfilename
8042443 28616   39624 8110683  7bc25b src/lyx-flto
8912062 31888   40760 8984710  891886 src/lyx

(or there about). If that is enough gain to be worth it? Dunno.

It if faster is not that easy to measure.

-- 
   Lgb



Re: [PATCH 5/5] src/lyxfind.cpp: use local typedef to simplify

2012-10-24 Thread Lars Gullik Bjønnes
André Pönitz andre.poen...@mathematik.tu-chemnitz.de writes:

| On Wed, Oct 24, 2012 at 01:27:40AM +0200, Lars Gullik Bjønnes wrote:
 André Pönitz andre.poen...@mathematik.tu-chemnitz.de writes:
 
 | On Tue, Oct 23, 2012 at 11:14:42PM +0200, lar...@gullik.org wrote:
  From: Lars Gullik Bjønnes lar...@gullik.org
  
  Use a local typedef pairstring, string P to avoid having to repeat
  that multiple times.
  ---
   src/lyxfind.cpp | 72
  -
   1 file changed, 40 insertions(+), 32 deletions(-)
  
  diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
  index a19724b..33dbd8a 100644
  --- a/src/lyxfind.cpp
  +++ b/src/lyxfind.cpp
  @@ -495,54 +495,62 @@ typedef vectorpairstring, string  Escapes;
   /// @note Beware of order
   Escapes const  get_regexp_escapes()
   {
  + typedef std::pairstd::string, std::string P;
  +
 
 | Conveniently adding a std:: or three, so next time the discussion
 | comes up we can reasonably claim that it is used inconsistently
 | and the 'using' on top could go...
 
 What is your agenda really?

| Preventing attempts to turn the LyX code base into a guinea pig for
| programming experiments again. Especially the kind of experiment that
| add a burden for others.

Since you are not doing any, perhaps you should let those that do
decide? I am not going to push anything without a +1 anyway.

-- 
   Lgb



Re: [PATCH 2/2] config/lyxinclude.m4: add support for --enable-cxx11

2012-10-24 Thread Lars Gullik Bjønnes
Richard Heck rgh...@lyx.org writes:

| On 10/23/2012 09:07 PM, Lars Gullik Bjønnes wrote:
 Using --enable-cxx11 turns on C++11 mode in gcc.
| Seems like a good idea.

I will have to commit 1/2 in this series as well.

Ok?

-- 
   Lgb



Re: [PATCH] config/lyxinclude.m4: add support for -flto

2012-10-24 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes lasgout...@lyx.org writes:

| Le 24/10/12 22:18, Lars Gullik Bjønnes a écrit :
 Jean-Marc Lasgouttes lasgout...@lyx.org writes:

 | Le 24/10/2012 13:13, Lars Gullik Bjønnes a écrit :
 Add feature --enable-lto, link-time optimization.

 | Do you see a visible gain, that would make it worth using on release 
 builds?

 textdatabss   dec  hexfilename
 8042443 28616   39624 8110683  7bc25b src/lyx-flto
 8912062 31888   40760 8984710  891886 src/lyx

 (or there about). If that is enough gain to be worth it? Dunno.

 It if faster is not that easy to measure.

| And is the link significantly more painful (time/memory)?

Oh, yes to both.
All optimization is redone, although wiht -flto=6 will will run the
optmization/assembly 6-way paralell so it is not that bad on a multicore
machine. Also you can compile with -flto -O0 and link with -flto
-O2. So you might get a huge speed bonus on the compiling and only way
when linking/optimizing.

As a side note:

textdatabss   dec  hexfilename
8817187 31904   40760 8889851  87a5fb src/lyx-cxx11

(Most likely due to rvalue-references and move semantics.)

-- 
   Lgb



[PATCH] config/lyxinclude.m4: add support for -flto

2012-10-24 Thread Lars Gullik Bjønnes
Add feature --enable-lto, link-time optimization.

Enabling link-time optimization turns debug information off (-g),
sine -flto and -g does not currently well work together.

Also stdlib-debug is turned off, does also not work well with -flto.
---
 config/lyxinclude.m4 | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/config/lyxinclude.m4 b/config/lyxinclude.m4
index 2e529ea..67aea1f 100644
--- a/config/lyxinclude.m4
+++ b/config/lyxinclude.m4
@@ -236,6 +236,24 @@ AC_ARG_ENABLE(cxx11,
   AC_HELP_STRING([--enable-cxx11],[enable C++11 mode]),,
   enable_cxx11=no;)
 
+AC_ARG_ENABLE(lto,
+  AC_HELP_STRING([--enable-lto],[enable link time optimization]),,
+  enable_lto=no;)
+case $enable_lto in
+yes)
+   lto_opt=-flto
+   enable_debug=no
+   enable_stdlib_debug=no
+   ;;
+no)
+   lto_opt=;;
+*)
+   lto_opt="-flto=${enable_lto}"
+   enable_debug=no
+   enable_stdlib_debug=no
+   ;;
+esac
+
 AC_ARG_ENABLE(assertions,
   AC_HELP_STRING([--enable-assertions],[add runtime sanity checks in the 
program]),,
   [AS_CASE([$build_type], [dev*|pre*], [enable_assertions=yes],
@@ -322,6 +340,15 @@ if test x$GXX = xyes; then
  ;;
   esac
   fi
+  if test x$enable_lto != xno ; then
+  case $gxx_version in
+ 4.7*|4.8*)
+ lyx_flags="$lyx_flags link-time-optimization"
+ CFLAGS="$lto_opt $CFLAGS"
+ CXXFLAGS="$lto_opt $CXXFLAGS"
+ ;;
+  esac
+  fi
 fi
 test "$lyx_pch_comp" = yes && lyx_flags="$lyx_flags pch"
 AM_CONDITIONAL(LYX_BUILD_PCH, test "$lyx_pch_comp" = yes)
-- 
1.8.0



Re: [PATCH] config/lyxinclude.m4: add support for -flto

2012-10-24 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes <lasgout...@lyx.org> writes:

| Le 24/10/2012 13:13, Lars Gullik Bjønnes a écrit :
>> Add feature --enable-lto, link-time optimization.
>
| Do you see a visible gain, that would make it worth using on release builds?

textdatabss   dec  hexfilename
8042443 28616   39624 8110683  7bc25b src/lyx-flto
8912062 31888   40760 8984710  891886 src/lyx

(or there about). If that is enough gain to be worth it? Dunno.

It if faster is not that easy to measure.

-- 
   Lgb



Re: [PATCH 5/5] src/lyxfind.cpp: use local typedef to simplify

2012-10-24 Thread Lars Gullik Bjønnes
André Pönitz <andre.poen...@mathematik.tu-chemnitz.de> writes:

| On Wed, Oct 24, 2012 at 01:27:40AM +0200, Lars Gullik Bjønnes wrote:
>> André Pönitz <andre.poen...@mathematik.tu-chemnitz.de> writes:
>> 
>> | On Tue, Oct 23, 2012 at 11:14:42PM +0200, lar...@gullik.org wrote:
>> >> From: Lars Gullik Bjønnes <lar...@gullik.org>
>> >> 
>> >> Use a local typedef pair<string, string> P to avoid having to repeat
>> >> that multiple times.
>> >> ---
>> >>  src/lyxfind.cpp | 72
>> >> -
>> >>  1 file changed, 40 insertions(+), 32 deletions(-)
>> >> 
>> >> diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
>> >> index a19724b..33dbd8a 100644
>> >> --- a/src/lyxfind.cpp
>> >> +++ b/src/lyxfind.cpp
>> >> @@ -495,54 +495,62 @@ typedef vector<pair<string, string> > Escapes;
>> >>  /// @note Beware of order
>> >>  Escapes const & get_regexp_escapes()
>> >>  {
>> >> + typedef std::pair<std::string, std::string> P;
>> >> +
>> >
>> | Conveniently adding a std:: or three, so next time the discussion
>> | comes up we can reasonably claim that it is used "inconsistently"
>> | and the 'using' on top could go...
>> 
>> What is your agenda really?
>
| Preventing attempts to turn the LyX code base into a guinea pig for
| programming experiments again. Especially the kind of experiment that
| add a burden for others.

Since you are not doing any, perhaps you should let those that do
decide? I am not going to push anything without a +1 anyway.

-- 
   Lgb



Re: [PATCH 2/2] config/lyxinclude.m4: add support for --enable-cxx11

2012-10-24 Thread Lars Gullik Bjønnes
Richard Heck <rgh...@lyx.org> writes:

| On 10/23/2012 09:07 PM, Lars Gullik Bjønnes wrote:
>> Using --enable-cxx11 turns on C++11 mode in gcc.
| Seems like a good idea.

I will have to commit 1/2 in this series as well.

Ok?

-- 
   Lgb



Re: [PATCH] config/lyxinclude.m4: add support for -flto

2012-10-24 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes <lasgout...@lyx.org> writes:

| Le 24/10/12 22:18, Lars Gullik Bjønnes a écrit :
>> Jean-Marc Lasgouttes <lasgout...@lyx.org> writes:
>>
>> | Le 24/10/2012 13:13, Lars Gullik Bjønnes a écrit :
>>>> Add feature --enable-lto, link-time optimization.
>>>
>> | Do you see a visible gain, that would make it worth using on release 
>> builds?
>>
>> textdatabss   dec  hexfilename
>> 8042443 28616   39624 8110683  7bc25b src/lyx-flto
>> 8912062 31888   40760 8984710  891886 src/lyx
>>
>> (or there about). If that is enough gain to be worth it? Dunno.
>>
>> It if faster is not that easy to measure.
>
| And is the link significantly more painful (time/memory)?

Oh, yes to both.
All optimization is redone, although wiht -flto=6 will will run the
optmization/assembly 6-way paralell so it is not that bad on a multicore
machine. Also you can compile with "-flto -O0" and link with "-flto
-O2". So you might get a huge speed bonus on the compiling and only way
when linking/optimizing.

As a side note:

textdatabss   dec  hexfilename
8817187 31904   40760 8889851  87a5fb src/lyx-cxx11

(Most likely due to rvalue-references and move semantics.)

-- 
   Lgb



Re: [PATCH 11/13] Use make_shared to create shared_ptr

2012-10-23 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes lasgout...@lyx.org writes:

| Le 23/10/12 01:21, Lars Gullik Bjønnes a écrit :
 Anyhow... I am going to ditch the hole series. Pick what you want from
 it if anything.

 I just cannot stand the hostility.

| Come on. André is bored and he feel happy to be rude like in the good
| old days. Nothing really personnal :)

I am pretty sure he means is personal, and I just cannot be bothered
with it.

| Apart from the std:: namespace issue that seems a bit disruptive and
| controversial, the other patches make sense to me. Moving away from
| tr1 in particular.

What I think you should do is to remove the using namespace std, and
add std:: wherever needed except for on string, as that really is all
over, and use using std::string for that.

-- 
   Lgb



Re: [PATCH 11/13] Use make_shared to create shared_ptr

2012-10-23 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes lasgout...@lyx.org writes:

| Le 23/10/2012 14:27, Lars Gullik Bjønnes a écrit :
 C++11 would make the code look a lot nicer, esp. thru the use of range
 based for, and auto:

  std::vectorstring::iterator at = somevec.begin();
  std::vectorstring::iterator end = someved.end();
  for (; at != end; ++at) {
  ...
  }

 would be replaced with:

  for (auto  s: somevec) {
  ...
  }

| We already have a foreach macro that is not to bad, but we do not use
| it much:
| foreach (string  s, somevec) {
|  ...
| }

| This is admittedly not as nice as real C++11, but if we converted code
| to use it, it would be trivial later to switch to the real thing.

| Concerning auto, I am still not sure that I like it.

Liking it took me some 5 seconds.

Auto suddenly makes it nice to work with the complex types you get in
C++.

Imagine:

auto func = [](){};
func();

try to figure out what type func really is. Do you care?

--
Lgb



Re: [PATCH 11/13] Use make_shared to create shared_ptr

2012-10-23 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes lasgout...@lyx.org writes:

| Le 23/10/2012 15:41, Abdelrazak Younes a écrit :
 I really don't understand the rationale, sorry. I'd consider very bad
 style to create our own lyx::vector or lyx::iostream, so what's the
 point?

| FWIW, we already define lyx::assert, lyx::shared_ptr, lyx::bind.

To note: the lyx::shared_ptr is there _because_ of the using namespace
std, and the pollution that drags in on some compilers.

-- 
   Lgb



Re: [PATCH 11/13] Use make_shared to create shared_ptr

2012-10-23 Thread Lars Gullik Bjønnes
Abdelrazak Younes you...@lyx.org writes:

| On Tue, Oct 23, 2012 at 2:27 PM, Lars Gullik Bjønnes lar...@gullik.org 
wrote:
 C++11 would make the code look a lot nicer, esp. thru the use of range
 based for, and auto:

 std::vectorstring::iterator at = somevec.begin();
 std::vectorstring::iterator end = someved.end();
 for (; at != end; ++at) {
 ...
 }

 would be replaced with:

 for (auto  s: somevec) {
 ...
 }

 and

 std::vectorstd::pairstring, string   vs = getVector();

 would be replaced with:

 auto  vs = getVector();

| That would be nice indeed but we would then require a recent version
| of gcc and msvc. Not a real problem for msvc but gcc is a problem if
| we want to support older distribution.

Not too much. Quite a bit of C++11 is supported in compilers back to gcc
gcc 4.3, but not really useful until 4.6. (auto in 4.5, range based for
in 4.6).

CentOS 4 has gcc 4.4 (as gcc4) but is rather ancient in itself.

I am not suggesting to begin using C++11 now, but in about a year it
should be really possible.

msvc 11 has ok support I think, same with clang.

Do you have other compilers that people use regularly?

-- 
   Lgb



Re: [PATCH 13/13] boost: changes to make it compile cleanly with gcc 4.8

2012-10-23 Thread Lars Gullik Bjønnes
lar...@gullik.org (Lars Gullik Bjønnes) writes:

| ---
|  boost/boost/lexical_cast.hpp  | 1 -
|  boost/boost/math/special_functions/fpclassify.hpp | 4 
|  boost/boost/math/special_functions/sign.hpp   | 2 --
|  boost/boost/regex/v4/regex_format.hpp | 2 --
|  boost/boost/regex/v4/regex_split.hpp  | 1 -
|  boost/boost/static_assert.hpp | 2 +-
|  boost/boost/tuple/detail/tuple_basic.hpp  | 1 -
|  7 files changed, 1 insertion(+), 12 deletions(-)

I'd really like to commit this one. Since current status makes it
very tiresome to work with. (warnings galore).

(If I have to redo this later on a boost upgrade is no problem.)

Ok?

-- 
   Lgb



Re: [PATCH 11/13] Use make_shared to create shared_ptr

2012-10-23 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes lasgout...@lyx.org writes:

| Le 23/10/12 21:18, Lars Gullik Bjønnes a écrit :
 | Concerning auto, I am still not sure that I like it.

 Liking it took me some 5 seconds.

 Auto suddenly makes it nice to work with the complex types you get in
 C++.

 Imagine:

 auto func = [](){};
 func();

 try to figure out what type func really is. Do you care?

| I care that I am wirting code with unknown types and suddenly I might
| be doing something awfully inefficient without knowing it. Plus I
| suspect that people who have not read the standard will not know wheat
| are the cases where auto is fine and where are the ones where you
| obviously can't because XXX.

| JMarc

| PS: are you really telling me that [](){} is something valid? Frightening.

:-) heh

That is the new lambda expressions in C++11. Yes, it looks weird at
first, but are not hard to get used to and lambdas are nice.

Shortest possible C++ program that call a function:

--
int main(){[](){}();}
--

  / capture list
 /  argument list
/  /function body
   /  //
auto lambda = [](...){ ... };

example:

---
#include vector
#include algorithm
#include iterator
#include iostream

// Compile on a newer gcc:
// g++ -std=c++11 lambda_and_more.cpp

int main() {
std::vectorint v({9,8,7,6,5,4,3,2,1}); 
std::for_each(v.begin(), v.end(), [](int i){std::cout  i;});
std::sort(v.begin(), v.end(), [](int lhs, int rhs){ return lhs  rhs; });
std::copy(v.begin(), v.end(), std::ostream_iteratorint(std::cout, ,));

int sum = 0;
std::for_each(v.begin(), v.end(), [](int i){ sum += i;});
std::cout  sum  std::endl;
}


-- 
   Lgb



FYI: compiling with gcc 4.8

2012-10-23 Thread Lars Gullik Bjønnes

(AMD Phenom(tm) II X6 1090T Processor)

gcc 4.7.2 (4.7.2 20120921 (Red Hat 4.7.2-2)):

time make CXX=/usr/bin/g++ -j6
real3m1.055s
user10m31.367s
sys 0m49.691s

size src/lyx
text   data bss dec   hexfilename
11339834   3133645416   11416586  ae340a src/lyx

ls -l ./src/lyx
169405554 ./src/lyx


gcc 4.8.0 (4.8.0 20121023 (experimental)):

time make -j6
real3m9.445s
user11m53.000s
sys 0m51.485s

size src/lyx
text   databss dec   hexfilename
11348213   31352   44504   11424069  ae5145 src/lyx

ls -l ./src/lyx
172783951 ./src/lyx

It seems that size and compile time not much has happened.
(a good thing)

No warnings¹ with gcc 4.7 nor with 4.8 (except one in Qt but I bet that
will get fixed when gcc comes closer to release)

¹ That is with my boost warnings removed patch applied.

-- 
   Lgb



Re: [PATCH 5/5] src/lyxfind.cpp: use local typedef to simplify

2012-10-23 Thread Lars Gullik Bjønnes
André Pönitz andre.poen...@mathematik.tu-chemnitz.de writes:

| On Tue, Oct 23, 2012 at 11:14:42PM +0200, lar...@gullik.org wrote:
 From: Lars Gullik Bjønnes lar...@gullik.org
 
 Use a local typedef pairstring, string P to avoid having to repeat
 that multiple times.
 ---
  src/lyxfind.cpp | 72
 -
  1 file changed, 40 insertions(+), 32 deletions(-)
 
 diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
 index a19724b..33dbd8a 100644
 --- a/src/lyxfind.cpp
 +++ b/src/lyxfind.cpp
 @@ -495,54 +495,62 @@ typedef vectorpairstring, string  Escapes;
  /// @note Beware of order
  Escapes const  get_regexp_escapes()
  {
 +typedef std::pairstd::string, std::string P;
 +

| Conveniently adding a std:: or three, so next time the discussion
| comes up we can reasonably claim that it is used inconsistently
| and the 'using' on top could go...

What is your agenda really?



Re: FYI: compiling with gcc 4.8

2012-10-23 Thread Lars Gullik Bjønnes
lar...@gullik.org (Lars Gullik Bjønnes) writes:

| gcc 4.8.0 (4.8.0 20121023 (experimental)):

| time make -j6
| real3m9.445s
| user11m53.000s
| sys 0m51.485s

| size src/lyx
| text   databss dec   hexfilename
| 11348213   31352   44504   11424069  ae5145 src/lyx

| ls -l ./src/lyx
| 172783951 ./src/lyx

gcc 4.8.0 (4.8.0 20121023 (experimental)) in gnu++11 mode:
(some warnings about deprecated auto_ptr)

time make -j6
real2m59.968s
user12m54.708s
sys 0m53.020s

size src/lyx
text   databss dec   hexfilename
11012251   31344   44408   11088003  a93083 src/lyx

ls -l src/lyx
180181591 Oct 24 02:52 src/lyx

-- 
   Lgb



[PATCH 2/2] config/lyxinclude.m4: add support for --enable-cxx11

2012-10-23 Thread Lars Gullik Bjønnes
Using --enable-cxx11 turns on C++11 mode in gcc.
---
 config/lyxinclude.m4 | 16 
 1 file changed, 16 insertions(+)

diff --git a/config/lyxinclude.m4 b/config/lyxinclude.m4
index e532c54..2e529ea 100644
--- a/config/lyxinclude.m4
+++ b/config/lyxinclude.m4
@@ -232,6 +232,10 @@ AC_ARG_ENABLE(pch,
enable_pch=no;)
 lyx_pch_comp=no
 
+AC_ARG_ENABLE(cxx11,
+  AC_HELP_STRING([--enable-cxx11],[enable C++11 mode]),,
+  enable_cxx11=no;)
+
 AC_ARG_ENABLE(assertions,
   AC_HELP_STRING([--enable-assertions],[add runtime sanity checks in the 
program]),,
   [AS_CASE([$build_type], [dev*|pre*], [enable_assertions=yes],
@@ -306,6 +310,18 @@ if test x$GXX = xyes; then
;;
 esac
   fi
+  if test x$enable_cxx11 = xyes ; then
+  case $gxx_version in
+ 4.3*|4.4*|4.5*|4.6*)
+ lyx_flags=$lyx_flags c++11-mode
+ CXXFLAGS=-std=gnu++0x $CXXFLAGS
+ ;;
+ 4.7*|4.8*)
+ lyx_flags=$lyx_flags c++11-mode
+ CXXFLAGS=-std=gnu++11 $CXXFLAGS
+ ;;
+  esac
+  fi
 fi
 test $lyx_pch_comp = yes  lyx_flags=$lyx_flags pch
 AM_CONDITIONAL(LYX_BUILD_PCH, test $lyx_pch_comp = yes)
-- 
1.8.0



[PATCH 1/2] support/Messages.cpp: add space to not be taken as user defined literal

2012-10-23 Thread Lars Gullik Bjønnes
In C++11 you are not allowed to have non-literal specifiers right
after a string literal.
---
 src/support/Messages.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/support/Messages.cpp b/src/support/Messages.cpp
index ca5c110..fdcaf66 100644
--- a/src/support/Messages.cpp
+++ b/src/support/Messages.cpp
@@ -119,7 +119,7 @@ bool Messages::available(string const  c)
// this loops at most twice
while (true) {
string const filen = locale_dir + / + code 
-   + /LC_MESSAGES/PACKAGE.mo;
+   + /LC_MESSAGES/ PACKAGE .mo;
if (FileName(filen).isReadableFile())
return true;
if (contains(code, '_'))
-- 
1.8.0



Re: [PATCH 11/13] Use make_shared to create shared_ptr

2012-10-23 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes <lasgout...@lyx.org> writes:

| Le 23/10/12 01:21, Lars Gullik Bjønnes a écrit :
>> Anyhow... I am going to ditch the hole series. Pick what you want from
>> it if anything.
>>
>> I just cannot stand the hostility.
>
| Come on. André is bored and he feel happy to be rude like in the good
| old days. Nothing really personnal :)

I am pretty sure he means is personal, and I just cannot be bothered
with it.

| Apart from the std:: namespace issue that seems a bit disruptive and
| controversial, the other patches make sense to me. Moving away from
| tr1 in particular.

What I think you should do is to remove the "using namespace std", and
add std:: wherever needed except for on string, as that really is all
over, and use "using std::string" for that.

-- 
   Lgb



Re: [PATCH 11/13] Use make_shared to create shared_ptr

2012-10-23 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes <lasgout...@lyx.org> writes:

| Le 23/10/2012 14:27, Lars Gullik Bjønnes a écrit :
>> C++11 would make the code look a lot nicer, esp. thru the use of range
>> based for, and auto:
>>
>>  std::vector::iterator at = somevec.begin();
>>  std::vector::iterator end = someved.end();
>>  for (; at != end; ++at) {
>>  ...
>>  }
>>
>> would be replaced with:
>>
>>  for (auto & s: somevec) {
>>  ...
>>  }
>
| We already have a foreach macro that is not to bad, but we do not use
| it much:
| foreach (string & s, somevec) {
|  ...
| }
>
| This is admittedly not as nice as real C++11, but if we converted code
| to use it, it would be trivial later to switch to the real thing.
>
| Concerning auto, I am still not sure that I like it.

Liking it took me some 5 seconds.

Auto suddenly makes it nice to work with the complex types you get in
C++.

Imagine:

auto func = [](){};
func();

try to figure out what type func really is. Do you care?

--
Lgb



Re: [PATCH 11/13] Use make_shared to create shared_ptr

2012-10-23 Thread Lars Gullik Bjønnes
Jean-Marc Lasgouttes  writes:

| Le 23/10/2012 15:41, Abdelrazak Younes a écrit :
>> I really don't understand the rationale, sorry. I'd consider very bad
>> style to create our own lyx::vector or lyx::iostream, so what's the
>> point?
>
| FWIW, we already define lyx::assert, lyx::shared_ptr, lyx::bind.

To note: the lyx::shared_ptr is there _because_ of the "using namespace
std", and the pollution that drags in on some compilers.

-- 
   Lgb



  1   2   3   4   5   6   7   8   9   10   >