The attached patch is my interpretation of what the existing patch is trying to do. Patching the singlefile build is really not a good idea; patch the source files and then use the build tool instead:
http://docs.openlayers.org/library/deploying.html#building-the-single-file-build