Discussion:
[LyX/master] lyx_pot.py: Do not strip blanks in HelpText.
Kornel Benko
2014-04-22 09:20:51 UTC
Permalink
commit 5e530e075734cee46f39d52a9f6fd7cda40545f5
Date: Tue Apr 22 10:35:20 2014 +0200
lyx_pot.py: Do not strip blanks in HelpText.
This fixes a thinko introduced in [c5ef7cfc/lyxgit]
Fixes: #9054.
diff --git a/po/lyx_pot.py b/po/lyx_pot.py
index b6f97dc..ca97416 100755
--- a/po/lyx_pot.py
+++ b/po/lyx_pot.py
Template = re.compile(r'^Template\s+(.*)', re.IGNORECASE)
GuiName = re.compile(r'\s*GuiName\s+(.*)', re.IGNORECASE)
HelpTextStart = re.compile(r'\s*HelpText\s', re.IGNORECASE)
- HelpTextSection = re.compile(r'\s*(\S.*\S)\s*$')
+ HelpTextSection = re.compile(r'\s*(\S.*)\s*$')
I do not understand.
What is the difference to re'\s*(\S.*)$'? Does '.' not include white space?
HelpTextEnd = re.compile(r'\s*HelpTextEnd\s', re.IGNORECASE)
i = -1
Kornel
Jürgen Spitzmüller
2014-04-22 09:31:36 UTC
Permalink
Post by Kornel Benko
- HelpTextSection = re.compile(r'\s*(\S.*\S)\s*$')
+ HelpTextSection = re.compile(r'\s*(\S.*)\s*$')
I do not understand.
What is the difference to re'\s*(\S.*)$'? Does '.' not include white space?
I just restored the working version previous to your erroneous fix. I did
not write the original regex.

Jürgen
Post by Kornel Benko
Kornel
Kornel Benko
2014-04-22 09:39:50 UTC
Permalink
Post by Jürgen Spitzmüller
Post by Kornel Benko
- HelpTextSection = re.compile(r'\s*(\S.*\S)\s*$')
+ HelpTextSection = re.compile(r'\s*(\S.*)\s*$')
I do not understand.
What is the difference to re'\s*(\S.*)$'? Does '.' not include white space?
I just restored the working version previous to your erroneous fix.
I understand that. The intent of my 'fix' *was* to remove the trailing blanks.
Post by Jürgen Spitzmüller
I did
not write the original regex.
I meant the difference between
re.compile(r'\s*(\S.*)\s*$')
and
re.compile(r'\s*(\S.*)$')

Why the extra "\s*" ?

Kornel
Jürgen Spitzmüller
2014-04-22 09:54:09 UTC
Permalink
Post by Kornel Benko
Post by Jürgen Spitzmüller
I did
not write the original regex.
Well, actually I did.
Post by Kornel Benko
I meant the difference between
re.compile(r'\s*(\S.*)\s*$')
and
re.compile(r'\s*(\S.*)$')
Why the extra "\s*" ?
I cannot remember. This is 7 year old code. Most likely I just took an
existing regexp as a model.

Jürgen
Post by Kornel Benko
Kornel
Kornel Benko
2014-04-22 10:01:23 UTC
Permalink
Post by Jürgen Spitzmüller
Post by Kornel Benko
Why the extra "\s*" ?
I cannot remember. This is 7 year old code. Most likely I just took an
existing regexp as a model.
Actually, the existence of this extra code was also the reason why I thought that
the intent in the original version was to remove the trailing white space.
Post by Jürgen Spitzmüller
JÃŒrgen
Kornel
Jürgen Spitzmüller
2014-04-22 10:33:30 UTC
Permalink
Post by Kornel Benko
Actually, the existence of this extra code was also the reason why I thought that
the intent in the original version was to remove the trailing white space.
It might make a difference wrt newlines (e.g. \r on *nix); I don't know. In
any case, I think it does not harm, and I won't touch it.

Jürgen
Post by Kornel Benko
Post by Jürgen Spitzmüller
Jürgen
Kornel
Richard Heck
2014-04-22 14:11:34 UTC
Permalink
Am Dienstag, 22. April 2014 um 11:54:09, schrieb Jürgen Spitzmüller
Post by Jürgen Spitzmüller
Post by Kornel Benko
Why the extra "\s*" ?
I cannot remember. This is 7 year old code. Most likely I just took an
existing regexp as a model.
Actually, the existence of this extra code was also the reason why I thought that
the intent in the original version was to remove the trailing white space.
I assume that must have been the intent:

re.compile(r'\s*(\S.*)\s*$')
re.compile(r'\s*(\S.*)$')

But of course it will not remove whitespace, since .* is greedy and eats
as much as possible, which means: to the end of the line. If one did
want to remove trailing whitespace, then:
re.compile(r'\s*(\S.*?)\s*$')
Now .*? eats as little as possible, so up until the trailing whitespace.


Richard
Kornel Benko
2014-04-22 14:32:17 UTC
Permalink
Am Dienstag, 22. April 2014 um 11:54:09, schrieb JÃŒrgen SpitzmÃŒller
Post by Jürgen Spitzmüller
Post by Kornel Benko
Why the extra "\s*" ?
I cannot remember. This is 7 year old code. Most likely I just took an
existing regexp as a model.
Actually, the existence of this extra code was also the reason why I thought that
the intent in the original version was to remove the trailing white space.
re.compile(r'\s*(\S.*)\s*$')
re.compile(r'\s*(\S.*)$')
But of course it will not remove whitespace, since .* is greedy and eats
as much as possible, which means: to the end of the line. If one did
re.compile(r'\s*(\S.*?)\s*$')
Now .*? eats as little as possible, so up until the trailing whitespace.
Oh, interesting.
Richard
Kornel

Loading...