[CDRIVER-2437] Standardize function for case-insensitive string comparisons Created: 20/Dec/17  Updated: 09/Feb/23

Status: Backlog
Project: C Driver
Component/s: libbson, libmongoc
Affects Version/s: 1.9.0
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Jeremy Mikola Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

In mongodb/mongo-c-driver#477, jesse suggested using the bson_strcasecmp() compatibility function instead of strcasecmp(), as the latter is not available on Windows. It turns out that the latter is actually defined for Windows via mongoc-util-private.h:

/* string comparison functions for Windows */
#ifdef _WIN32
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#endif

We should standardize on one of these two approaches, especially since libbson and libmongoc are now in the same repository. IMO, the mongoc-util-private.h approach is preferable to adding a custom function that delegates. Even if that function is inlined by the compiler, there is cognitive overhead with having to use bson_strcasecmp() for case-insensitive but strcmp() for case-sensitive comparisons.


Generated at Wed Feb 07 21:15:12 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.