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. The Lounge
  3. while (*s++ = ((*t & 0x60) == 0x40 ? *t ^ 0x20 : *t)) t++;

while (*s++ = ((*t & 0x60) == 0x40 ? *t ^ 0x20 : *t)) t++;

Scheduled Pinned Locked Moved The Lounge
rubyquestion
40 Posts 27 Posters 0 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 Rob Philpott

    It's turning into one of 'those' Friday afternoons. Any takers for what this gem does?

    Regards, Rob Philpott.

    J Offline
    J Offline
    Jonas Hammarberg
    wrote on last edited by
    #20

    Copying string, turning upper case into lower case...

    R 1 Reply Last reply
    0
    • R Rob Philpott

      It's turning into one of 'those' Friday afternoons. Any takers for what this gem does?

      Regards, Rob Philpott.

      H Offline
      H Offline
      hdjim
      wrote on last edited by
      #21

      increment the address of s set the value of s to the value of t and increment t. the value of t is dependent on the if statement. AND the value of t with 0x60 and if bit 6 is set, make the value of s = the value of t exclusive ored with 32,otherwise set s to the value of t... then increment the address of t. do this until the value of s is not true.

      modified on Monday, August 30, 2010 9:33 AM

      1 Reply Last reply
      0
      • R Rob Philpott

        It's turning into one of 'those' Friday afternoons. Any takers for what this gem does?

        Regards, Rob Philpott.

        E Offline
        E Offline
        ehoagland66
        wrote on last edited by
        #22

        I used to write my code like this until my boss beat me with stick and took my coffee cup :laugh:

        A 1 Reply Last reply
        0
        • M Member 96

          Cause a developer to get fired? Or at least a stern talking to?


          Yesterday they said today was tomorrow but today they know better. - Poul Anderson

          P Offline
          P Offline
          philcaetano
          wrote on last edited by
          #23

          Trying to figure this out, will causes someone to lose more productive than the multi-monitor/multi-tasking debate. ;P

          1 Reply Last reply
          0
          • E ehoagland66

            I used to write my code like this until my boss beat me with stick and took my coffee cup :laugh:

            A Offline
            A Offline
            Andreas Mertens
            wrote on last edited by
            #24

            I remember using this technique for an assembly program I wrote many years ago. When I worked out what it was doing, it took a moment to realize why it look familiar... Andreas Mertens

            1 Reply Last reply
            0
            • L Lost User

              It turns a string to lower case? edit: that is, it copies a string to s as lower case (but I'm still not actually sure)

              L Offline
              L Offline
              Larry G Grimes
              wrote on last edited by
              #25

              It definitely returns a string with all lowercase characters.

              M 1 Reply Last reply
              0
              • R Rob Philpott

                It's turning into one of 'those' Friday afternoons. Any takers for what this gem does?

                Regards, Rob Philpott.

                M Offline
                M Offline
                M i s t e r L i s t e r
                wrote on last edited by
                #26

                wastes a lot of peoples time on this site ?

                1 Reply Last reply
                0
                • R Rob Philpott

                  It's turning into one of 'those' Friday afternoons. Any takers for what this gem does?

                  Regards, Rob Philpott.

                  T Offline
                  T Offline
                  tom1443
                  wrote on last edited by
                  #27

                  This looks like an job interview question, in which case I don't want the job.

                  1 Reply Last reply
                  0
                  • R Rob Philpott

                    It's turning into one of 'those' Friday afternoons. Any takers for what this gem does?

                    Regards, Rob Philpott.

                    P Offline
                    P Offline
                    PHLIPH
                    wrote on last edited by
                    #28

                    Yeah, converts to lower case is right - but don't forget it also does '@' => '`', '[' => '{', '\' => '|', ']' => '}', '^' => '-', and '_' => del. Just felt the need to punctuate it. :)

                    1 Reply Last reply
                    0
                    • R Rob Philpott

                      It's turning into one of 'those' Friday afternoons. Any takers for what this gem does?

                      Regards, Rob Philpott.

                      N Offline
                      N Offline
                      neil hudson
                      wrote on last edited by
                      #29

                      It corrupts strings with @ [ \ ] ^ and _ in them.

                      Neil Hudson

                      1 Reply Last reply
                      0
                      • J Jonas Hammarberg

                        Copying string, turning upper case into lower case...

                        R Offline
                        R Offline
                        Rosenne
                        wrote on last edited by
                        #30

                        Only in America... I mean, only for US ASCII. :thumbsdown:

                        J 1 Reply Last reply
                        0
                        • P Pete OHanlon

                          Rob Philpott wrote:

                          Any takers for what this gem does?

                          Why that's obvious. It makes you hate the coder who spewed it into your source.

                          I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

                          My blog | My articles | MoXAML PowerToys | Onyx

                          Y Offline
                          Y Offline
                          yoni at jefco
                          wrote on last edited by
                          #31

                          I was going to say "Hopefully get someone sacked". Maybe a bit harsh on my part.

                          1 Reply Last reply
                          0
                          • L Larry G Grimes

                            It definitely returns a string with all lowercase characters.

                            M Offline
                            M Offline
                            Matthew Barnett
                            wrote on last edited by
                            #32

                            Larry G. Grimes wrote:

                            It definitely returns a string with all lowercase characters.

                            It'll change other characters too, such as '@' to '`'!

                            1 Reply Last reply
                            0
                            • R Rosenne

                              Only in America... I mean, only for US ASCII. :thumbsdown:

                              J Offline
                              J Offline
                              Jonas Hammarberg
                              wrote on last edited by
                              #33

                              Worked for ANSI to, albeit only the lower parts :rolleyes:

                              R 1 Reply Last reply
                              0
                              • R Rob Philpott

                                It's turning into one of 'those' Friday afternoons. Any takers for what this gem does?

                                Regards, Rob Philpott.

                                L Offline
                                L Offline
                                Lev Vayner
                                wrote on last edited by
                                #34

                                maybe the author should start writing normal code.. in c#, this would be done with s.ToLower() yeah.. thats it.. no non-sense pointer code with an inline loop referencing hex values

                                1 Reply Last reply
                                0
                                • J Jonas Hammarberg

                                  Worked for ANSI to, albeit only the lower parts :rolleyes:

                                  R Offline
                                  R Offline
                                  Rosenne
                                  wrote on last edited by
                                  #35

                                  I the context of software, only as well as but generally mean a bug.

                                  1 Reply Last reply
                                  0
                                  • R Rob Philpott

                                    It's turning into one of 'those' Friday afternoons. Any takers for what this gem does?

                                    Regards, Rob Philpott.

                                    S Offline
                                    S Offline
                                    stevee1984
                                    wrote on last edited by
                                    #36

                                    Maybe something like this would work better, then we can use the code for email addresses etc. while (*s++ = (*t >='A' && *t <= 'Z' ? *t ^ 0x20 : *t) ) t++;

                                    1 Reply Last reply
                                    0
                                    • R Rob Philpott

                                      ..just for fun really. It's nearly the weekend..

                                      Regards, Rob Philpott.

                                      D Offline
                                      D Offline
                                      DominLondon
                                      wrote on last edited by
                                      #37

                                      Robbo!

                                      R 1 Reply Last reply
                                      0
                                      • D DominLondon

                                        Robbo!

                                        R Offline
                                        R Offline
                                        Rob Philpott
                                        wrote on last edited by
                                        #38

                                        Dude!

                                        Regards, Rob Philpott.

                                        1 Reply Last reply
                                        0
                                        • R Rob Philpott

                                          It's turning into one of 'those' Friday afternoons. Any takers for what this gem does?

                                          Regards, Rob Philpott.

                                          L Offline
                                          L Offline
                                          leonej_dt
                                          wrote on last edited by
                                          #39

                                          I will assume both s and t are char*. *t & 0x60: Filters all but two bits of *t. I will call those bits xy (the most significant one first). (*t & 0x60) == 0x40: Tests whether xy is 10. (*t & 0x60) == 0x40 ? *t ^0x20 : *t: If xy is 10, it returns a new character equal to *t, but with xy equal to 11. Otherwise, it returns the original character. The whole loop iterates through a C string starting at s and copies it to another C string starting at t, but characters from 0x40 to 0x5F are converted into characters from 0x60 to 07F. The original string is left untouched, unless s equals t. (If t points to another character actually inside the C string pointed by s or vice versa, the program goes crazy.) To the end user, this means the following: Uppercase characters are converted into lowercase characters, square brackets are converted into braces, the backslash is converted into a vertical line character, the French circumflex accent character is converted into the tilde character, and the underline character is converted into a DEL character.

                                          If you can play The Dance of Eternity (Dream Theater), then we shall make a band.

                                          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