Update AutoFormat.java to fix #2141.

Did for loops properly.
Fixed #2141.
Renamed some stuff for readability.
Moved some variables from class to method scope.
Stopped comment() from clobbering c and get_string() from clobbering cc, as it looks horrible to keep useing the same global variable - so easy to introduce a bug. Checked that nothing depended on c and cc being changed - it didn't seem to.