                 i = 0
                 longestMatchingFlag = null
 
-            while i < ext.length
-                for flag of currentMatchingFlags when flag[i] isnt ext[i]
+            while i < flagName.length
+                for flag of currentMatchingFlags when flag[i] isnt flagName[i]
                     delete currentMatchingFlags[flag]
                     --nMatching
 


# Testing code
###
timer = new Program "/home/albert/Dropbox/UPC/FIB/6eQuatri/PCA/Lab/sessio3/lab3_session/pi/pi.3gStaTicPg"
console.log timer
timer = new Program "/home/albert/Dropbox/UPC/FIB/6eQuatri/PCA/Lab/sessio3/lab3_session/pi/pi.3gspg"
console.log timer


                if nMatching is 1
                    flagMatching = _.keys(currentMatchingFlags)[0]
                    return invalidFlag flagName if flagMatching[i..] isnt flagName[i...flagMatching.length]
                    flagName = flagName[flagMatching.length..]
                    resetInfo()
                    flagString.pushBack(COMPILER_FLAGS[flagMatching])
                else if nMatching is 0
                    if longestMatchingFlag?
                        flagString.pushBack(COMPILER_FLAGS[longestMatchingFlag])
                        flagName = flagName[longestMatchingFlag.length..]
                        resetInfo()
                    else
                        return invalidFlag flagName

            if flagName.length > 0
                if longestMatchingFlag?
                    flagString.pushBack(COMPILER_FLAGS[longestMatchingFlag])
                else
                    return invalidFlag flagName

        flagString.pushBack(@flagsByProgram.all ? "",
                            @flagsByProgram[programIndex] ? "")
