Opened 17 years ago

Closed 17 years ago

#1605 closed enhancement (wontfix)

cpl_port.h definition of EQUAL leads to misunderstandings in reading code that employs it

Reported by: PeterHalls Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: unspecified
Severity: normal Keywords:
Cc:

Description

cpl_port.h defines EQUAL/EQUALN to perform a *case independent* comparison of two strings using strcasecmp/strncasecmp/stricmp/strnicmp as appropriate.

This behaviour is not a test of EQUALity, rather it is analogous to the SQL 'LIKE' operator, which also performs a case independent comparison of two strings. EQUALity generally implies that the two objects begin tested are equal = identical.

The present state is unecessarily confusing.

The concept of a macro that gives instant readability of purpose in such comparisons is excellent. It would be great if it were practical to rename the existing 'EQUAL' and 'EQUALN' to 'LIKE' and 'LIKEN', with EQUAL/EQUALN being introduced to do exactly what they imply: case sensitive strcmp and strncmp respectively.

Change History (1)

comment:1 by warmerdam, 17 years ago

Resolution: wontfix
Status: newclosed

Use of the EQUAL and EQUALN macro is GDAL is pervasive and I'm not about to change it. I will agree it is not immediately obvious that the comparison is case insensitive, but it is by design that I use this widely as I mostly want GDAL to be case insensitive when testing things.

Note: See TracTickets for help on using tickets.