Bug 148805 - The SEARCH function is not working since after version 5.3.7.2
Summary: The SEARCH function is not working since after version 5.3.7.2
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.3.1.3 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-26 16:16 UTC by Cubic Consult
Modified: 2022-04-29 19:47 UTC (History)
1 user (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 Cubic Consult 2022-04-26 16:16:54 UTC
Description:
The results of the SEARCH seems has not been okay since after version 5.3.7.2. It returns an error result even when the item searched for is in the search string.

Steps to Reproduce:
1. =SEARCH("1","000000000000000000000000000000000000000000000000000200300000000000000000400500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",0)
2.
3.

Actual Results:
The above equation fails with an error

Expected Results:
Returned the index of the 1


Reproducible: Always


User Profile Reset: Yes


OpenGL enabled: Yes

Additional Info:
Version: 7.3.1.3 (x86) / LibreOffice Community
Build ID: a69ca51ded25f3eefd52d7bf9a5fad8c90b87951
CPU threads: 4; OS: Windows 10.0 Build 19042; UI render: Skia/Raster; VCL: win
Locale: en-GB (en_GB); UI: en-GB
Calc: CL
Comment 1 m_a_riosv 2022-04-26 16:36:34 UTC
I guess, your formula separator, it's the comma.

You have a zero after quotes at the end of the formula, before the last parenthesis. Deleting it, the formula don't result in error.
Comment 2 Mike Kaganski 2022-04-26 16:57:41 UTC
(In reply to m.a.riosv from comment #1)
> You have a zero after quotes at the end of the formula, before the last
> parenthesis. Deleting it, the formula don't result in error.

Exactly.
SEARCH function [1] takes optional third "Position" argument; and that argument, as *all* string positions in Calc, counts from 1, not 0. It is obvious from the example given there, which, although not showing the third argument itself, has the return result - and since the return from SEARCH is also position in string, 1-based count is shown:

> =SEARCH(54;998877665544) returns 10.

[1] https://help.libreoffice.org/latest/en-US/text/scalc/01/04060110.html?DbPAR=CALC#bm_id3151005
Comment 3 m_a_riosv 2022-04-26 17:17:36 UTC
Function [1] has syntax error.

You have that 'zero' without the separator after last quotes.

Please attach a sample file
Comment 4 Cubic Consult 2022-04-29 17:11:36 UTC
Confirmed. Though it work in version 5.
Comment 5 Cubic Consult 2022-04-29 17:14:16 UTC
(In reply to m.a.riosv from comment #1)
> I guess, your formula separator, it's the comma.
> 
> You have a zero after quotes at the end of the formula, before the last
> parenthesis. Deleting it, the formula don't result in error.

You are right about the last 0 parameter being the cause. 1 should have been used. Thanks.

NB:
The comma works fine.
Comment 6 Mike Kaganski 2022-04-29 19:47:58 UTC
(In reply to Cubic Consult from comment #4)
> Though it work in version 5.

Sure: since commit 07157107a3b7fd3d1b55db9ce1aeb9f6d4e204ab
  Author Winfried Donkers <winfrieddonkers@libreoffice.org>
  Sate   Wed Feb 08 16:48:58 2017 +0100
    tdf#105772 apply all ODFF constraints with function SEARCH.