Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-28612

Review toupper/tolower uses [QtCreator]

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • Qt Creator 9.0.1
    • None
    • 11569852d (master)

    Description

      The C toupper/tolower functions are locale-dependent. Given the right locale (Türkiye, e.g.):

      • tolower(I) is either
        • ı (LATIN SMALL LETTER DOTLESS I; if representable in current charset) or
        • I (unchanged; if it isn't)
      • toupper(i) is either
        • İ (LATIN CAPITAL LETTER I WITH DOT ABOVE; if representable) or
        • i (unchanged; if it isn't)
          Both results are wrong.

      Please check your respective code bases, book patches, if any, onto this ticket, and, once merged, remove your component from the Jira field.

      The below is a slightly curated list of hits:

      ~/Qt/qt-creator$ git grep --color=always --recurse-submodules  -wE 'tolower|toupper' | grep -v /3rdparty/
      share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp:            processName[i] = std::toupper(processName[i]);
      src/plugins/cppeditor/cppquickfixes.cpp:    const bool isBinary = numberLength > 2 && str[0] == '0' && tolower(str[1]) == 'b';
      src/shared/qbs/src/lib/pkgconfig/pkgconfig.cpp:        int c = std::toupper(p);
      

      We have QtMiscUtils::asciiToLower() in QtCore/private/qtools_p.h. It's been backported to 5.15. We don't have asciiToUpper(). You can either port to asciiToLower() or use caseCompareAscii() (which may not be available in Qt 6.2 and 5.15), or wait for asciiToUpper() (from https://codereview.qt-project.org/c/qt/qtbase/+/449457) to make its way through the branches, or simply copy it into one of your local utility libraries.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              knud Knud Dollereder
              mmutz Marc Mutz
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes