Re: Memory leak in master?

2017-02-24 Thread Jean-Marc Lasgouttes
Hi Guillaume,

I thought about it again, and you are right, of course.

JMarc

Le 24 février 2017 22:10:17 GMT+01:00, Guillaume Munch  a écrit :
>Le 22/02/2017 à 18:03, Jean-Marc Lasgouttes a écrit :

>> It would be nice to hide these subtleties in the Cache
>implementation,
>> if possible.
>>
>I am not sure what you mean with "hide these subtleties". The
>specification is simple: if the key does not exist in the cache, you
>get
>the default object. 


Re: Regular expression search

2017-02-24 Thread Guillaume Munch

Le 24/02/2017 à 20:54, Kornel Benko a écrit :

Am Freitag, 24. Februar 2017 um 17:30:39, schrieb Jean-Marc Lasgouttes 


src/lyxfind.cpp:escape_map.push_back(P("\\",
"(?:|backslash)"));
src/lyxfind.cpp:escape_map.push_back(P("~",
"(?:textasciitilde|sim)"));
src/lyxfind.cpp:escape_map.push_back(P("^",
"(?:\\^|textasciicircum\\{\\}|mathcircumflex)"));
src/lyxfind.cpp:escape_map.push_back(P("",
"(?:|backslash|textbackslash\\{\\})"));
src/lyxfind.cpp:escape_map.push_back(P("\\^",
"(?:\\^|textasciicircum\\{\\}|mathcircumflex)"));

So for now, we need to understand what is this syntax and use the
ECMAscript equivalent. AFAICS, the only for used is (?:, described as:


(?: is part of the ECMAScript std and should be supported:
https://www.ecma-international.org/ecma-262/5.1/#sec-15.10.2.8

Moreover it seems to be used to include the regex into another regex so
it cannot be removed.



Or use the POSIX-extension? See 
http://eli.thegreenplace.net/2012/11/14/some-notes-on-posix-regular-expressions
Shoudn't then the regexes be compatible with boost-POSIX?
In our sources we test for 'LYX_USE_STD_REGEX' only in 
src/frontends/qt4/GuiCitation.cpp,
but I'd expect to see this also in src/regex.cpp



AFAIR, the ECMAScript regexes are a proper subset of PCRE whereas there
are incompatibilities between POSIX and PCRE. Moreover ECMAScript is the
default for , so maybe it is better supported across compilers.
This makes ECMAScript the simplest for a transition.

Is the bug there with g++ 6? I remember Georg saying that the early
implementations of  in gcc were buggy.

On the other hand I do not remember that dynamically created regexes 
were reviewed for adaptation to ECMAScript so maybe there is indeed 
something to change, although not (?:.


Dear Georg, do you remember the same?


Guillaume



Re: [LyX/master] Generalise the deletion protection mechanism from math to text (#9540)

2017-02-24 Thread Guillaume Munch

Le 22/02/2017 à 14:59, Jean-Marc Lasgouttes a écrit :

Le 18/02/2017 à 23:05, Guillaume Munch a écrit :

commit 71623b88b2c613dd4ab826a9783a53e840bcd6e1
Author: Guillaume Munch 
Date:   Sat Feb 18 19:12:55 2017 +0100

Generalise the deletion protection mechanism from math to text
(#9540)

Now backspace and delete in text will select non-empty math and
text insets
before deleting them. This is consistent with what happens in math
already.

This is implemented for InsetText as well but can be disabled in
case of
negative feedback.

This can be set for any sort of inset with the new virtual method
Inset::confirmDeletion.


I like it in theory (we'll see for the practice). It would have been
nice to implement this as much as possible at generic level
(BUfferView::dispatch) so that math and text really behave identically.


I am not sure to understand your suggestion. Insets are supposed to be 
able to customize LFUN_*_DELETE_* in whichever way they want. How would 
you make this mechanism general without introducing assumptions on how 
it has to be implemented?



I do not see confirmDeletion implemented there and I do not see a
special handling for empty insets.



The checks notion of empty inset is implemented in the
Inset::confirmDeletion themselves.

Thanks for the feedback.
Guillaume



Re: Memory leak in master?

2017-02-24 Thread Guillaume Munch

Le 22/02/2017 à 18:03, Jean-Marc Lasgouttes a écrit :

Le 21/02/2017 à 20:13, Guillaume Munch a écrit :


BTW, why don't you use Cache::contains in getLayout like you do for
other cache uses?



This is explained in the documentation of Cache::object. It is enough to
check for a null pointer in that case.


It would be nice to hide these subtleties in the Cache implementation,
if possible.



Hi Jean-Marc,

I am not sure what you mean with "hide these subtleties". The
specification is simple: if the key does not exist in the cache, you get
the default object. I thought about using boost::optional at first but
for the main use I had in mind (shared_ptr) I found that the code would
be heavier (you end up having to dereference twice) for little clarity gain.

Guillaume




Re: Regular expression search

2017-02-24 Thread Kornel Benko
Am Freitag, 24. Februar 2017 um 17:30:39, schrieb Jean-Marc Lasgouttes 

> Le 24/02/2017 à 17:17, Kornel Benko a écrit :
> > Little net-search gives for example:
> > http://stackoverflow.com/questions/13526884/inconsistency-between-boostregex-and-stdregex
> > http://stackoverflow.com/questions/7589672/boost-regex-vs-c11-regex
> > http://stackoverflow.com/questions/26696250/difference-between-stdregex-match-stdregex-search
> >
> > Citing from the first url:
> > gcc of course doesn't support the tr1/c++11 regex, but to give a more 
> > general answer,
> > boost.regex's default is perl 5, according to its documentation, while 
> > C++ default is
> > ECMAScript, extended by several locale-dependent elements of POSIX BRE.
> >
> > Kornel
> >
> 
> The first link points to this:
> http://www.boost.org/doc/libs/1_52_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html#boost_regex.syntax.perl_syntax.perl_extended_patterns
> which explains that perl extended patterns start with ``(?''. So all we 
> have to do is some grep and:
> 
> src/Buffer.cpp:// chktex should be run with these flags disabled: 3, 22, 
> 25, 30, 38(?)
> src/LayoutFile.cpp: 
> "(?:\\[([^,]*)(?:,.*)*\\])*\\s*\\{(.*)\\}\\s*");
> src/frontends/qt4/GuiApplication.cpp:   QRegExp re( 
> "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ 
> ]*(?:([+-][0-9]*)){0,1}(?:([+-][0-9]*)){0,1}" );
> src/frontends/qt4/GuiDocument.cpp:  // disable if there aren't any 
> modules (?), if none of them is chosen
> src/frontends/qt4/GuiThesaurus.cpp: QRegExp 
> re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$");
> src/frontends/qt4/GuiThesaurus.cpp: QRegExp 
> rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$");
> src/frontends/qt4/GuiThesaurus.cpp: QRegExp 
> re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$");
> src/frontends/qt4/GuiThesaurus.cpp: QRegExp 
> rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$");
> src/frontends/qt4/GuiWorkArea.cpp:  // FIXME(?):
> src/frontends/qt4/LaTeXHighlighter.cpp: QRegExp 
> exprComment("(?:^|[^])(?:)*(%).*$");
> src/insets/InsetTabular.cpp:// FIXME(?): do we need 
> a second metrics call?
> src/lyxfind.cpp:escape_map.push_back(P("\\", 
> "(?:|backslash)"));
> src/lyxfind.cpp:escape_map.push_back(P("~", 
> "(?:textasciitilde|sim)"));
> src/lyxfind.cpp:escape_map.push_back(P("^", 
> "(?:\\^|textasciicircum\\{\\}|mathcircumflex)"));
> src/lyxfind.cpp:escape_map.push_back(P("", 
> "(?:|backslash|textbackslash\\{\\})"));
> src/lyxfind.cpp:escape_map.push_back(P("\\^", 
> "(?:\\^|textasciicircum\\{\\}|mathcircumflex)"));
> 
> Of course, only the last ones in lyxfonc.cpp matter here. The others are 
> interesting if only because I see now that we also use QRegex, which 
> seems to accept perl extensions.
> 
> So for now, we need to understand what is this syntax and use the 
> ECMAscript equivalent. AFAICS, the only for used is (?:, described as:

Or use the POSIX-extension? See 
http://eli.thegreenplace.net/2012/11/14/some-notes-on-posix-regular-expressions
Shoudn't then the regexes be compatible with boost-POSIX?
In our sources we test for 'LYX_USE_STD_REGEX' only in 
src/frontends/qt4/GuiCitation.cpp,
but I'd expect to see this also in src/regex.cpp

>(?:pattern) lexically groups pattern, without generating an 
> additional sub-expression.
> 
> I do not know how important this thing is. What would go wrong if we 
> just removed the grouping?

Don't know either.

> JMarc

Kornel

signature.asc
Description: This is a digitally signed message part.


How far is 2.3.0?

2017-02-24 Thread Jean-Marc Lasgouttes

Hi there,

A good subject before the week-end: what do we need to do before 
declaring feature freeze for 2.3? Personally I have finished a cycle or 
breaking/fixing the math editor and would like to refrain from doing new 
big architectural changes. I only have two or three patches pending, 
plus of course all the bugs that Guillaume keeps finding.


Who has Work In Progress that should go to 2.3? How long do we need?

JMarc


Re: Regular expression search

2017-02-24 Thread Jean-Marc Lasgouttes

Le 24/02/2017 à 17:17, Kornel Benko a écrit :

Little net-search gives for example:
http://stackoverflow.com/questions/13526884/inconsistency-between-boostregex-and-stdregex
http://stackoverflow.com/questions/7589672/boost-regex-vs-c11-regex
http://stackoverflow.com/questions/26696250/difference-between-stdregex-match-stdregex-search

Citing from the first url:
gcc of course doesn't support the tr1/c++11 regex, but to give a more 
general answer,
boost.regex's default is perl 5, according to its documentation, while 
C++ default is
ECMAScript, extended by several locale-dependent elements of POSIX BRE.

Kornel



The first link points to this:
http://www.boost.org/doc/libs/1_52_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html#boost_regex.syntax.perl_syntax.perl_extended_patterns
which explains that perl extended patterns start with ``(?''. So all we 
have to do is some grep and:


src/Buffer.cpp:// chktex should be run with these flags disabled: 3, 22, 
25, 30, 38(?)
src/LayoutFile.cpp: 
"(?:\\[([^,]*)(?:,.*)*\\])*\\s*\\{(.*)\\}\\s*");
src/frontends/qt4/GuiApplication.cpp:   QRegExp re( 
"[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ 
]*(?:([+-][0-9]*)){0,1}(?:([+-][0-9]*)){0,1}" );
src/frontends/qt4/GuiDocument.cpp:  // disable if there aren't any 
modules (?), if none of them is chosen
src/frontends/qt4/GuiThesaurus.cpp: QRegExp 
re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$");
src/frontends/qt4/GuiThesaurus.cpp: QRegExp 
rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$");
src/frontends/qt4/GuiThesaurus.cpp: QRegExp 
re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$");
src/frontends/qt4/GuiThesaurus.cpp: QRegExp 
rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$");

src/frontends/qt4/GuiWorkArea.cpp:  // FIXME(?):
src/frontends/qt4/LaTeXHighlighter.cpp: QRegExp 
exprComment("(?:^|[^])(?:)*(%).*$");
src/insets/InsetTabular.cpp:// FIXME(?): do we need 
a second metrics call?
src/lyxfind.cpp:escape_map.push_back(P("\\", 
"(?:|backslash)"));
src/lyxfind.cpp:escape_map.push_back(P("~", 
"(?:textasciitilde|sim)"));
src/lyxfind.cpp:escape_map.push_back(P("^", 
"(?:\\^|textasciicircum\\{\\}|mathcircumflex)"));
src/lyxfind.cpp:escape_map.push_back(P("", 
"(?:|backslash|textbackslash\\{\\})"));
src/lyxfind.cpp:escape_map.push_back(P("\\^", 
"(?:\\^|textasciicircum\\{\\}|mathcircumflex)"));


Of course, only the last ones in lyxfonc.cpp matter here. The others are 
interesting if only because I see now that we also use QRegex, which 
seems to accept perl extensions.


So for now, we need to understand what is this syntax and use the 
ECMAscript equivalent. AFAICS, the only for used is (?:, described as:


  (?:pattern) lexically groups pattern, without generating an 
additional sub-expression.


I do not know how important this thing is. What would go wrong if we 
just removed the grouping?


JMarc


Re: Regular expression search

2017-02-24 Thread Kornel Benko
Am Freitag, 24. Februar 2017 um 15:16:48, schrieb Jean-Marc Lasgouttes 

> Le 24/02/2017 à 11:54, Kornel Benko a écrit :
> >> I tried to bisect, but to my surprise could not find the associated commit.
> >> The only difference was that for bisecting I used another compiler (gcc 
> >> 4.8.4),
> >> while I otherwise use the version 6.1.0.
> >>
> >> So I rebuild lyx with gcc4.8, the error is gone.
> >>
> >> Now trying with gcc5.3 ... error.
> >>
> >> What are the differences between gcc5.3, 6.1 and 4.8?
> >> gcc4.8 Compiler does not support std_regex, flag = "--std=c++11"
> >> gcc5.3 Compiler supports std_regex, flag = "--std=c++14"
> >> gcc6.1 Compiler supports std_regex, flag = "--std=c++14"
> 
> What would be nice is to understand what is the regex:es features  that 
> are different between std::regex and boost:regex.
> 
> JMarc

Little net-search gives for example:
http://stackoverflow.com/questions/13526884/inconsistency-between-boostregex-and-stdregex
http://stackoverflow.com/questions/7589672/boost-regex-vs-c11-regex
http://stackoverflow.com/questions/26696250/difference-between-stdregex-match-stdregex-search

Citing from the first url:
gcc of course doesn't support the tr1/c++11 regex, but to give a more 
general answer,
boost.regex's default is perl 5, according to its documentation, while 
C++ default is
ECMAScript, extended by several locale-dependent elements of POSIX BRE.

Kornel

signature.asc
Description: This is a digitally signed message part.


Re: Regular expression search

2017-02-24 Thread Jean-Marc Lasgouttes

Le 24/02/2017 à 11:54, Kornel Benko a écrit :

I tried to bisect, but to my surprise could not find the associated commit.
The only difference was that for bisecting I used another compiler (gcc 4.8.4),
while I otherwise use the version 6.1.0.

So I rebuild lyx with gcc4.8, the error is gone.

Now trying with gcc5.3 ... error.

What are the differences between gcc5.3, 6.1 and 4.8?
gcc4.8  Compiler does not support std_regex, flag = "--std=c++11"
gcc5.3  Compiler supports std_regex, flag = "--std=c++14"
gcc6.1  Compiler supports std_regex, flag = "--std=c++14"


What would be nice is to understand what is the regex:es features  that 
are different between std::regex and boost:regex.


JMarc



Re: Regular expression search

2017-02-24 Thread Kornel Benko
Am Samstag, 26. November 2016 um 23:26:33, schrieb Scott Kostyshak 

> On Tue, Sep 27, 2016 at 02:12:49PM +0200, Kornel Benko wrote:
> 
> > What are the differences between gcc5.3, 6.1 and 4.8?
> > gcc4.8  Compiler does not support std_regex, flag = "--std=c++11"
> > gcc5.3  Compiler supports std_regex, flag = "--std=c++14"
> > gcc6.1  Compiler supports std_regex, flag = "--std=c++14"
> 
> I have no idea, but even if we don't figure out the root issue we could
> make recommendations in the relase notes.
> 
> Scott

+1
I missed this mail somehow.

Kornel

signature.asc
Description: This is a digitally signed message part.


Re: Regular expression search

2017-02-24 Thread Kornel Benko
Am Freitag, 24. Februar 2017 um 13:23:44, schrieb José Abílio Matos 

> On Tuesday, September 27, 2016 1:12:49 PM WET Kornel Benko wrote:
> > What are the differences between gcc5.3, 6.1 and 4.8?
> > gcc4.8  Compiler does not support std_regex, flag = "--std=c++11"
> > gcc5.3  Compiler supports std_regex, flag = "--std=c++14"
> > gcc6.1  Compiler supports std_regex, flag = "--std=c++14"
> > 
> > Kornel
> 
> According to https://gcc.gnu.org/gcc-4.9/changes.html  was introduced 
> in 4.9.
> 
> And, as you probably know, gcc 6.1 defaults to --std=c++14, so this is not 
> necessary.
> 

We (in cmake) try to use the best possible std-flag. We don't care about the 
compiler version
for determining it. Even if it is default, the use is not dangerous.

But the underlying problem for regex is the different behaviour in boost and 
gcc,
which we do not fully respect.
For peoples using never compiler this makes the regex searches problematic.

Kornel


signature.asc
Description: This is a digitally signed message part.


Re: Regular expression search

2017-02-24 Thread José Abílio Matos
On Tuesday, September 27, 2016 1:12:49 PM WET Kornel Benko wrote:
> What are the differences between gcc5.3, 6.1 and 4.8?
> gcc4.8  Compiler does not support std_regex, flag = "--std=c++11"
> gcc5.3  Compiler supports std_regex, flag = "--std=c++14"
> gcc6.1  Compiler supports std_regex, flag = "--std=c++14"
> 
> Kornel

According to https://gcc.gnu.org/gcc-4.9/changes.html  was introduced 
in 4.9.

And, as you probably know, gcc 6.1 defaults to --std=c++14, so this is not 
necessary.

-- 
José Abílio


Re: Use examples directory

2017-02-24 Thread Kornel Benko
Ping ...

Am Samstag, 21. Januar 2017 um 11:02:47, schrieb Kornel Benko 
> Setting the dir in preferences has no effect,
> I always get the system-examples directory.
> 
> This is in master and in branch.
> Try "File->Open...->Examples"
> 
>   Kornel

signature.asc
Description: This is a digitally signed message part.


Re: Regular expression search

2017-02-24 Thread Kornel Benko
Ping ...

Am Dienstag, 27. September 2016 um 14:12:49, schrieb Kornel Benko 

> Am Montag, 26. September 2016 um 19:06:58, schrieb Kornel Benko 
> 
> > 
> > The test keytest/findadv-05 shows a new error.
> > 
> > (Repeating commands from the test case)
> > 1.) Open new document
> > 2.) write 'foo foo foo foo'
> > 3.) make the middle 2 foo's be italic
> > 4.) move cursor to HOME position
> > 5.) open the advanced search dialog
> > 6.) go to 'Settings' part of the dialog
> > 7.) uncheck 'Ignore format'
> > 8.) go back to 'Search' part of the dialog
> > 9.) in the 'Find' field enter 'foo' in italic
> > 10.) click on 'Find Next'
> > 
> > italic (or slanted) foo is not found. Using 'foo foo' as search pattern 
> > works.
> > Try to make the 'space' between 'foo foo' be normal (e.g not italic)
> > Now searching for 'foo' will find the first 'foo' but not the second.
> > 
> 
> I tried to bisect, but to my surprise could not find the associated commit.
> The only difference was that for bisecting I used another compiler (gcc 
> 4.8.4),
> while I otherwise use the version 6.1.0.
> 
> So I rebuild lyx with gcc4.8, the error is gone.
> 
> Now trying with gcc5.3 ... error.
> 
> What are the differences between gcc5.3, 6.1 and 4.8?
> gcc4.8Compiler does not support std_regex, flag = "--std=c++11"
> gcc5.3Compiler supports std_regex, flag = "--std=c++14"
> gcc6.1Compiler supports std_regex, flag = "--std=c++14"
> 
>   Kornel

signature.asc
Description: This is a digitally signed message part.