I once solved a similar problem with a pattern matching approach. The patterns were 3x3 matrices of characters. For the corner problem I'd assume you need this:
*..
##.
*..
And this:
...
##.
*#.
. means floor
# means wall
* means anything matches
The matcher code rotated the rule matrices by 0, 90, 180, 270 degrees to see if any of the configuration matches at a location, also mirrored the matrix and did another set of rotations. With that you can check for arbitrary patterns in your map. It's not very fast, but versatile.