Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-2437

Standardize function for case-insensitive string comparisons

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor - P4 Minor - P4
    • None
    • 1.9.0
    • libbson, libmongoc

    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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: