EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: epicsStr[n]CaseCmp()
From: Benjamin Franksen <[email protected]>
To: <[email protected]>
Date: Wed, 12 Mar 2014 00:04:52 +0100
Am Montag, 10. März 2014, 17:03:06 schrieb Andrew Johnson:
> epicsStringTest.c currently proves (amongst other things) that
>
>     testOk1(epicsStrnCaseCmp(" ", "", 1) < 0);
>     testOk1(epicsStrnCaseCmp("", " ", 1) > 0);
>     testOk1(epicsStrnCaseCmp("abcd", "ABCDE", 1000) > 0);
>     testOk1(epicsStrnCaseCmp("abcde", "ABCD", 1000) < 0);
>
> Unfortunately the first group are wrong, and glibc's str[n]casecmp()
> functions on RHEL6 agree with me. Longer strings should always compare
> greater than any initial subset of themselves.

Agreed. To my knowledge, this is how lexical order is defined, so I expect the
exact opposite of what the tests say (replace '<' with '>' and v.v.).

>     testOk1(epicsStrCaseCmp("abcd", "ABCDE") != 0);
>     testOk1(epicsStrCaseCmp("abcde", "ABCD") != 0);
>     testOk1(epicsStrCaseCmp("abcde", "ABCDF") != 0);
>
> The second group probably
> uses != because the author didn't want to think about and fix the bug at
> the time...

Probably. My expectation here is

        testOk1(epicsStrCaseCmp("abcd", "ABCD") == 0);
        testOk1(epicsStrCaseCmp("abcd", "ABCDE") < 0);
        testOk1(epicsStrCaseCmp("abcde", "ABCD") > 0);
        testOk1(epicsStrCaseCmp("abcde", "ABCDF") < 0);

(First test added for clarity, this is case *in*sensitive comparison).

Cheers
Ben
--
Perl: There Is More Than One Way To Do It
Python: There Is One Way To Do It
Haskell: There Is One Way To Do It, Up To Isomorphism


________________________________

Helmholtz-Zentrum Berlin für Materialien und Energie GmbH

Mitglied der Hermann von Helmholtz-Gemeinschaft Deutscher Forschungszentren e.V.

Aufsichtsrat: Vorsitzender Prof. Dr. Dr. h.c. mult. Joachim Treusch, stv. Vorsitzende Dr. Beatrix Vierkorn-Rudolph
Geschäftsführung: Prof. Dr. Anke Rita Kaysser-Pyzalla, Thomas Frederking

Sitz Berlin, AG Charlottenburg, 89 HRB 5583

Postadresse:
Hahn-Meitner-Platz 1
D-14109 Berlin

http://www.helmholtz-berlin.de


References:
epicsStr[n]CaseCmp() Andrew Johnson

Navigate by Date:
Prev: epicsStr[n]CaseCmp() Andrew Johnson
Next: Build failed in Jenkins: epics-base-3.15-win64s #1 APS Jenkins
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: epicsStr[n]CaseCmp() Andrew Johnson
Next: Build failed in Jenkins: epics-base-3.15-win64s #1 APS Jenkins
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 16 May 2014 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·