util: Fix build on Visual Studio

Use the fallback implementation for lround() only on pre-2013 Visual
Studio, and ensure we are clear about the types of the parameters for
lround() and scalbnf(), since Visual Studio can be quite picky on
ambiguous parameter types.  Also, use g_ascii_strcasecmp() rather than
strcasecmp() as we are already using GLib for this code and we are
assured that g_ascii_strcasemp() is available.

For scalbnf() on pre-2013 Visaul Studio, a fallback implementation is
needed, but use another forced-included header for those compilers, which
will be added later.

Also use (char)27 on Visual Studio builds as '\e' is not a recognized
escape sequence, which will do the same thing.
diff --git a/util/ansi-print.cc b/util/ansi-print.cc
index e9060af..e0ce7b3 100644
--- a/util/ansi-print.cc
+++ b/util/ansi-print.cc
@@ -41,7 +41,7 @@
 #include <unistd.h> /* for isatty() */
 #endif
 
-#ifdef _MSC_VER
+#if defined (_MSC_VER) && (_MSC_VER < 1800)
 static inline long int
 lround (double x)
 {
@@ -52,6 +52,8 @@
 }
 #endif
 
+#define ESC_E (char)27
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 
 #define CELL_W 8
@@ -298,7 +300,7 @@
     }
     if (best_s < score) {
       static const char *lower[7] = {"▁", "▂", "▃", "▄", "▅", "▆", "▇"};
-      unsigned int which = lround (((best_i + 1) * 8) / bi.height);
+      unsigned int which = lround ((double) ((best_i + 1) * 8) / bi.height);
       if (1 <= which && which <= 7) {
 	score = best_s;
 	*inverse = best_inv;
@@ -330,7 +332,7 @@
     }
     if (best_s < score) {
       static const char *left [7] = {"▏", "▎", "▍", "▌", "▋", "▊", "▉"};
-      unsigned int which = lround (((best_i + 1) * 8) / bi.width);
+      unsigned int which = lround ((double) ((best_i + 1) * 8) / bi.width);
       if (1 <= which && which <= 7) {
 	score = best_s;
 	*inverse = best_inv;
@@ -395,7 +397,7 @@
       bi.set (cell);
       if (bi.unicolor) {
         if (last_bg != bi.bg) {
-	  printf ("\e[%dm", 40 + bi.bg);
+	  printf ("%c[%dm", ESC_E, 40 + bi.bg);
 	  last_bg = bi.bg;
 	}
 	printf (" ");
@@ -405,13 +407,13 @@
         const char *c = block_best (bi, &inverse);
 	if (inverse) {
 	  if (last_bg != bi.fg || last_fg != bi.bg) {
-	    printf ("\e[%d;%dm", 30 + bi.bg, 40 + bi.fg);
+	    printf ("%c[%d;%dm", ESC_E, 30 + bi.bg, 40 + bi.fg);
 	    last_bg = bi.fg;
 	    last_fg = bi.bg;
 	  }
 	} else {
 	  if (last_bg != bi.bg || last_fg != bi.fg) {
-	    printf ("\e[%d;%dm", 40 + bi.bg, 30 + bi.fg);
+	    printf ("%c[%d;%dm", ESC_E, 40 + bi.bg, 30 + bi.fg);
 	    last_bg = bi.bg;
 	    last_fg = bi.fg;
 	  }
@@ -419,7 +421,7 @@
 	printf ("%s", c);
       }
     }
-    printf ("\e[0m\n"); /* Reset */
+    printf ("%c[0m\n", ESC_E); /* Reset */
     last_bg = last_fg = -1;
   }
 }
diff --git a/util/helper-cairo.cc b/util/helper-cairo.cc
index 50e22ab..450e5cf 100644
--- a/util/helper-cairo.cc
+++ b/util/helper-cairo.cc
@@ -341,25 +341,25 @@
   }
   if (0)
     ;
-    else if (0 == strcasecmp (extension, "ansi"))
+    else if (0 == g_ascii_strcasecmp (extension, "ansi"))
       constructor2 = _cairo_ansi_surface_create_for_stream;
   #ifdef CAIRO_HAS_PNG_FUNCTIONS
-    else if (0 == strcasecmp (extension, "png"))
+    else if (0 == g_ascii_strcasecmp (extension, "png"))
       constructor2 = _cairo_png_surface_create_for_stream;
   #endif
   #ifdef CAIRO_HAS_SVG_SURFACE
-    else if (0 == strcasecmp (extension, "svg"))
+    else if (0 == g_ascii_strcasecmp (extension, "svg"))
       constructor = cairo_svg_surface_create_for_stream;
   #endif
   #ifdef CAIRO_HAS_PDF_SURFACE
-    else if (0 == strcasecmp (extension, "pdf"))
+    else if (0 == g_ascii_strcasecmp (extension, "pdf"))
       constructor = cairo_pdf_surface_create_for_stream;
   #endif
   #ifdef CAIRO_HAS_PS_SURFACE
-    else if (0 == strcasecmp (extension, "ps"))
+    else if (0 == g_ascii_strcasecmp (extension, "ps"))
       constructor = cairo_ps_surface_create_for_stream;
    #ifdef HAS_EPS
-    else if (0 == strcasecmp (extension, "eps"))
+    else if (0 == g_ascii_strcasecmp (extension, "eps"))
       constructor = _cairo_eps_surface_create_for_stream;
    #endif
   #endif
@@ -478,16 +478,16 @@
   for (i = 0; i < (int) l->num_glyphs; i++)
   {
     l->glyphs[i].index = hb_glyph[i].codepoint;
-    l->glyphs[i].x = scalbn ( hb_position->x_offset + x, scale_bits);
-    l->glyphs[i].y = scalbn (-hb_position->y_offset + y, scale_bits);
+    l->glyphs[i].x = scalbn ((double)  hb_position->x_offset + x, scale_bits);
+    l->glyphs[i].y = scalbn ((double) -hb_position->y_offset + y, scale_bits);
     x +=  hb_position->x_advance;
     y += -hb_position->y_advance;
 
     hb_position++;
   }
   l->glyphs[i].index = -1;
-  l->glyphs[i].x = scalbn (x, scale_bits);
-  l->glyphs[i].y = scalbn (y, scale_bits);
+  l->glyphs[i].x = scalbn ((double) x, scale_bits);
+  l->glyphs[i].y = scalbn ((double) y, scale_bits);
 
   if (l->num_clusters) {
     memset ((void *) l->clusters, 0, l->num_clusters * sizeof (l->clusters[0]));
diff --git a/util/options.cc b/util/options.cc
index ca8f906..882e060 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -569,7 +569,7 @@
   else
   {
     for (unsigned int i = 0; i < ARRAY_LENGTH (supported_font_funcs); i++)
-      if (0 == strcasecmp (font_funcs, supported_font_funcs[i].name))
+      if (0 == g_ascii_strcasecmp (font_funcs, supported_font_funcs[i].name))
       {
 	set_font_funcs = supported_font_funcs[i].func;
 	break;