Google Summer of Code & NT debugging Puzzler #3

As you probably know, Google launch every year the Summer of Code. Yesterday, Google published official 2008 result and I’ll be part of the Samba Team. My work is to implement compression functions into Samba.

Microsoft Advanced Windows Debugging Team published their third puzzler: Matrix Edition #3 . It looks they’ll publish one puzzler per week. As far I understand, the goal of this puzzler is to translate a function from Assembly to C.

Here is my solution:

    1. void myfun(char *string)
    2. {
    3. int lenString, countLoop, index;
    4. char savedByte;
    5. lenString = strlen(string);
    6.      for (countLoop = lenString; countLoop; countLoop–)
    7.      {
    8.          for(index = 0; index < (countLoop – 1); index++)
    9.          {
    10.              if (string[index] > string[index + 1])
    11.              {
    12.                  savedByte = string[index];
    13.                  string[index] = string[index + 1];
    14.                  string[index + 1] = savedByte;
    15.              }
    16.          }
    17.      }
    18. }