diff --git a/util/ansi-print.cc b/util/ansi-print.cc index e9060af56..e0ce7b356 100644 --- a/util/ansi-print.cc +++ b/util/ansi-print.cc @@ -41,7 +41,7 @@ #include /* for isatty() */ #endif -#ifdef _MSC_VER +#if defined (_MSC_VER) && (_MSC_VER < 1800) static inline long int lround (double x) { @@ -52,6 +52,8 @@ lround (double x) } #endif +#define ESC_E (char)27 + #define MIN(a,b) ((a) < (b) ? (a) : (b)) #define CELL_W 8 @@ -298,7 +300,7 @@ block_best (const biimage_t &bi, bool *inverse) } 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 @@ block_best (const biimage_t &bi, bool *inverse) } 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 @@ ansi_print_image_rgb24 (const uint32_t *data, 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 @@ ansi_print_image_rgb24 (const uint32_t *data, 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 @@ ansi_print_image_rgb24 (const uint32_t *data, 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 50e22ab0e..450e5cf95 100644 --- a/util/helper-cairo.cc +++ b/util/helper-cairo.cc @@ -341,25 +341,25 @@ helper_cairo_create_context (double w, double h, } 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 @@ helper_cairo_line_from_buffer (helper_cairo_line_t *l, 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 ca8f90669..882e06072 100644 --- a/util/options.cc +++ b/util/options.cc @@ -569,7 +569,7 @@ font_options_t::get_font (void) const 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;