Bug 105772 - SEARCH function - Constraints: Start >= 1
Summary: SEARCH function - Constraints: Start >= 1
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.4.7.2 release
Hardware: All All
: medium normal
Assignee: Winfried Donkers
URL:
Whiteboard: target:5.4.0
Keywords: regression
Depends on:
Blocks:
 
Reported: 2017-02-05 16:14 UTC by raal
Modified: 2017-02-26 12:44 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description raal 2017-02-05 16:14:17 UTC
Description:
in ODFF specification of SEARCH function is Constraints: Start >= 1, but
=SEARCH("e","LibreOffice",*-1*) returns 5. Should return error. 

Actual Results:  
.

Expected Results:
.


Reproducible: Always

User Profile Reset: No

Additional Info:


User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0
Comment 1 Xisco Faulí 2017-02-05 16:21:26 UTC
I get 'err:501' in 

Version: 5.4.0.0.alpha0+
Build ID: fc53cce64400430cdc21f79c959d75fb9a26d13d
CPU Threads: 4; OS Version: Linux 4.8; UI Render: default; VCL: gtk2; 
Locale: ca-ES (ca_ES.UTF-8); Calc: group
Comment 2 raal 2017-02-05 16:50:24 UTC
(In reply to Xisco Faulí from comment #1)
> I get 'err:501' in 
> 

Hi Xisco,
try this formula   =SEARCH("e","LibreOffice",-1)
Comment 3 Julien Nabet 2017-02-05 17:07:54 UTC
(In reply to raal from comment #2)
...
> try this formula   =SEARCH("e","LibreOffice",-1)

On pc Debian x86-64 with master sources updated today, I copied-pasted this exact expression on a brand new Calc file, I got error -501.
locale is LANG=fr_FR.UTF-8 and use English US interface in LO
Could it be localization related?
Comment 4 m_a_riosv 2017-02-05 17:24:12 UTC
Also for me first sample gives: 'err:501'

Seems that any value under 1 is treated as 1.

Last version right:
Versión: 4.2.8.2
Id. de compilación: 48d50dbfc06349262c9d50868e5c1f630a573ebd

First version bad:
Version: 4.4.7.2
Build ID: f3153a8b245191196a4b6b9abd1d0da16eead600
Locale: es_ES
Comment 5 Xisco Faulí 2017-02-05 20:29:48 UTC
(In reply to raal from comment #2)
> (In reply to Xisco Faulí from comment #1)
> > I get 'err:501' in 
> > 
> 
> Hi Xisco,
> try this formula   =SEARCH("e","LibreOffice",-1)

same result, even on Windows.
Comment 6 Winfried Donkers 2017-02-06 07:08:49 UTC
Those who tried and got Err501 as result probably just copied Raal's formula (I did at first too).
The formula does not work directly (i.e. produces Err501) unless you change the argument separator to what your locale uses and remove the * before and after -1 in argument 'Start'.

Presently, Calc accepts values for argument Start that are 0 or negative and replaces them with 1 before processing the formula. As this is not compliant with ODFF1.2 and differs from the behaviour of Excel, with which we aim for as much interoperability as possible, I will fix it.
Comment 7 Commit Notification 2017-02-21 21:52:29 UTC
Winfried Donkers committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=07157107a3b7fd3d1b55db9ce1aeb9f6d4e204ab

tdf#105772 apply all ODFF constraints with function SEARCH.

It will be available in 5.4.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.