Review Request 129557: [okular] Enable searching for a phrase split by a newline character in a PDF

Marduk Bolanos mardukbp at mac.com
Sun Jan 8 12:55:51 UTC 2017



> On Jan. 8, 2017, 1:27 a.m., Albert Astals Cid wrote:
> > please explain me why "a\n" and "a " should return true but "aa\n" and "aa " should return false?
> 
> Marduk Bolanos wrote:
>     I understand that you are worried about this being a general string-comparison function, but AFAIK with the current search algorithm the case you are considering will not occur. If I missed your point, please explain in more detail.
> 
> Albert Astals Cid wrote:
>     Are you really defending that 
>     
>     int addTwoNumbers(int a, int b) {
>      return 4;
>     }
>     
>     is correct because we only pass a = 2 and b = 2?
> 
> Marduk Bolanos wrote:
>     Let's think about it. 
>     
>     This is a function that compares strings. Let's agree that a string is an array of chars of size N. 
>     
>     What does it mean to compare two strings? In particular, what does it mean that two strings are equal?
>     
>     If you define that two strings are equal if both arrays are equal, then this corresponds to the original behaviour of the function. Let's say that in this case the strings are obviously equal.
>     
>     You may also define that for N = 2 two strings are equal if either they are obviously equal or the first char in both arrays is the same and the last char in one array is space and the last char in the other array is newline.
>     
>     In your previous comment you mentioned you would like to define that for all N two strings are equal if the first N-1 chars in both arrays are equal and the last char in one array is space and the last char in the other array is newline. That is fine, but it is not necessary for the search functionality.
>     
>     As you can see, there is no absolute notion of equality of two strings. What you call the correct behaviour of the function depends on how you define the equality of two strings.
> 
> Anthony Fieroni wrote:
>     So Marduk, do it that way
>     
>     if ( from.endsWith(QStringLiteral("\n") && to.endsWith(QStringLiteral(" ")) {
>         return from.trimmed().compare( to.trimmed(), Qt::CaseInsensitive ) == 0;
>     }

Done. Excellent solution! Thanks Anthony.


- Marduk


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/129557/#review101856
-----------------------------------------------------------


On Jan. 8, 2017, 12:55 p.m., Marduk Bolanos wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/129557/
> -----------------------------------------------------------
> 
> (Updated Jan. 8, 2017, 12:55 p.m.)
> 
> 
> Review request for Okular and Oliver Sander.
> 
> 
> Repository: okular
> 
> 
> Description
> -------
> 
> A blank space in the query is matched against a newline character in the PDF.
> 
> 
> Diffs
> -----
> 
>   okular/core/textpage.cpp 44dfa14 
> 
> Diff: https://git.reviewboard.kde.org/r/129557/diff/
> 
> 
> Testing
> -------
> 
> Tried a few PDF files. It works.
> 
> 
> Thanks,
> 
> Marduk Bolanos
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/okular-devel/attachments/20170108/5d5a76b5/attachment.html>


More information about the Okular-devel mailing list