backends: don't run off the end of strings

Strings from the config parser can be of length 0, so we should check
that before checking the string's bytes.

The x11 backend's usage is technically safe since the null terminator
is present, but I've changed it too in case someone's looking at it as
a reference for new code.
backends: refactor transform string parsing

Most of the backends do their own parsing of transform strings, so let's
put that all in the same place (compositor.c/h)