Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. Clever Code
  4. Not so much a bug...

Not so much a bug...

Scheduled Pinned Locked Moved Clever Code
c++comhelpquestionannouncement
5 Posts 4 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rob Manderson
    wrote on last edited by
    #1

    I found this in some C++ code I've inherited. The preceding code isolates a file extension into an STL string, strExt. The code then does case sensitive compares against a range of file extensions and branches to appropriate code. Somewhere along the line my predecessor must have run into a variety of capitalisations, hence this.

    else if (strExt == _T(".txt") || strExt == _T(".TXT") || strExt == _T(".Txt"))

    the mind boggles. Why didn't he go the whole hog and put in all possible variants? Who knows? :omg::omg:

    Rob Manderson I'm working on a version for Visual Lisp++ My blog http://blogs.wdevs.com/ultramaroon/[^] My blog mirror http://robmanderson.blogspot.com[^]

    C M M 3 Replies Last reply
    0
    • R Rob Manderson

      I found this in some C++ code I've inherited. The preceding code isolates a file extension into an STL string, strExt. The code then does case sensitive compares against a range of file extensions and branches to appropriate code. Somewhere along the line my predecessor must have run into a variety of capitalisations, hence this.

      else if (strExt == _T(".txt") || strExt == _T(".TXT") || strExt == _T(".Txt"))

      the mind boggles. Why didn't he go the whole hog and put in all possible variants? Who knows? :omg::omg:

      Rob Manderson I'm working on a version for Visual Lisp++ My blog http://blogs.wdevs.com/ultramaroon/[^] My blog mirror http://robmanderson.blogspot.com[^]

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      *grin* that's just great.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      1 Reply Last reply
      0
      • R Rob Manderson

        I found this in some C++ code I've inherited. The preceding code isolates a file extension into an STL string, strExt. The code then does case sensitive compares against a range of file extensions and branches to appropriate code. Somewhere along the line my predecessor must have run into a variety of capitalisations, hence this.

        else if (strExt == _T(".txt") || strExt == _T(".TXT") || strExt == _T(".Txt"))

        the mind boggles. Why didn't he go the whole hog and put in all possible variants? Who knows? :omg::omg:

        Rob Manderson I'm working on a version for Visual Lisp++ My blog http://blogs.wdevs.com/ultramaroon/[^] My blog mirror http://robmanderson.blogspot.com[^]

        M Offline
        M Offline
        Mike Dimmick
        wrote on last edited by
        #3

        NTFS does case insensitivity simply by uppercasing both strings using an upper-casing table stored in the filesystem metadata. This table is similar to using the invariant culture IIRC. See http://blogs.msdn.com/michkap/archive/2004/12/02/273619.aspx[^] and http://blogs.msdn.com/michkap/archive/2005/01/16/353873.aspx[^].

        Stability. What an interesting concept. -- Chris Maunder

        1 Reply Last reply
        0
        • R Rob Manderson

          I found this in some C++ code I've inherited. The preceding code isolates a file extension into an STL string, strExt. The code then does case sensitive compares against a range of file extensions and branches to appropriate code. Somewhere along the line my predecessor must have run into a variety of capitalisations, hence this.

          else if (strExt == _T(".txt") || strExt == _T(".TXT") || strExt == _T(".Txt"))

          the mind boggles. Why didn't he go the whole hog and put in all possible variants? Who knows? :omg::omg:

          Rob Manderson I'm working on a version for Visual Lisp++ My blog http://blogs.wdevs.com/ultramaroon/[^] My blog mirror http://robmanderson.blogspot.com[^]

          M Offline
          M Offline
          Mindflow
          wrote on last edited by
          #4

          Rob Manderson wrote:

          Why didn't he go the whole hog

          Why didn't he just LowerCase the entire string and do the one comparison :confused: not sure if he has access to a function like toLower(string s)

          R 1 Reply Last reply
          0
          • M Mindflow

            Rob Manderson wrote:

            Why didn't he go the whole hog

            Why didn't he just LowerCase the entire string and do the one comparison :confused: not sure if he has access to a function like toLower(string s)

            R Offline
            R Offline
            Rob Manderson
            wrote on last edited by
            #5

            Heh - that's the correct solution. My comment was meant to underline the silliness of his approach...

            Rob Manderson I'm working on a version for Visual Lisp++ My blog http://blogs.wdevs.com/ultramaroon/[^] My blog mirror http://robmanderson.blogspot.com[^]

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups