Patch from Iago Rubio to fix problem with end of script detection. Extracted into a function some common code for copying from document into a string for checking and changed to use safer lower casing.
Patch from Iago Rubio to fix problem with end of script detection.
Extracted into a function some common code for copying from document into
a string for checking and changed to use safer lower casing.

timonwong/foo_uie_wsh_panel_mod.scintilla,timonwong/foo_uie_wsh_panel_mod.scintilla,timonwong/foo_uie_wsh_panel_mod.scintilla,timonwong/foo_uie_wsh_panel_mod.scintilla,timonwong/foo_uie_wsh_panel_mod.scintilla,timonwong/foo_uie_wsh_panel_mod.scintilla,timonwong/foo_uie_wsh_panel_mod.scintilla,timonwong/foo_uie_wsh_panel_mod.scintilla