Guard against crashes when "Guide" layer active

This change implements checks against crashes in some vulnerable routines
that can fail when the current displayed layer in CharView is the
"Guide" aka 'grid' layer.

Testing of various UI actions revealed that these routines would crash
using the layer index value -1, which is the 'grid' layer index:
   fontforge/cvundoes.c    SCPreserveHints()
   fontforge/splinechar.c  SCNumberPoints()
   fontforge/autohint.c    _SCClearHintMasks()
   fontforge/stemdb.c      GlyphDataInit()
   fontforge/cvhints.c     SCModifyHintMasksAdd()
Code was added to these routines to simply return if the layer value
was outside the valid range for the layers array.

During testing using Python scripts a further set of problem routines
were identified in python.c and fixes applied.

Finally, the original investigation found a number of places where code
was using "magic numbers" that were equivalent to the `enum layer_type`
values defined in splinefont.h.  This obscured the intent of such code
and enum definitions were used to replace those numbers (-1, -2, etc.)

Tested with debug printf()'s to demonstrate usefulness, with all these
added checks being hit and preventing crashes.

"Doctor Doctor when I touch my head it hurts. When I touch my arm it hurts. When I touch my knees it hurts." The doctor replied, "You have a broken finger."
Merge pull request #1755 from tshinnic/1750_invalid_layer_index_2

Guard against crashes when "Guide" layer active