gbranden pushed a commit to branch master
in repository groff.
commit 87b60fb4578f2cacc00c87869a80bebb5432aa1c
Author: G. Branden Robinson <[email protected]>
AuthorDate: Tue Mar 15 19:37:30 2022 +1100
Fix Savannah #61964.
* src/devices/grodvi/dvi.cpp (dvi_printer::set_color,
draw_dvi_printer::fill_next):
* src/devices/grops/ps.cpp (output::put_color):
* src/libs/libgroff/color.cpp (color::print_color): Explicitly cast
`enum` divisors to `double`; quietens
`-Wdeprecated-enum-float-conversion` warnings.
Fixes <https://savannah.gnu.org/bugs/?61964>. Thanks to Bjarni Ingi
Gislason for the report.
Also update editor aid comments; drop old-style Emacs file-local
variable setting.
---
ChangeLog | 12 ++++++++++++
src/devices/grodvi/dvi.cpp | 25 +++++++++++++++----------
src/devices/grops/ps.cpp | 2 +-
src/libs/libgroff/color.cpp | 36 +++++++++++++++++++-----------------
4 files changed, 47 insertions(+), 28 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7510d12f..0539597b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2022-03-15 G. Branden Robinson <[email protected]>
+
+ * src/devices/grodvi/dvi.cpp (dvi_printer::set_color,
+ draw_dvi_printer::fill_next):
+ * src/devices/grops/ps.cpp (output::put_color):
+ * src/libs/libgroff/color.cpp (color::print_color): Explicitly
+ cast `enum` divisors to `double`; quietens
+ `-Wdeprecated-enum-float-conversion` warnings.
+
+ Fixes <https://savannah.gnu.org/bugs/?61964>. Thanks to Bjarni
+ Ingi Gislason for the report.
+
2022-03-15 G. Branden Robinson <[email protected]>
* tmac/an.tmac: Recover more quickly from missing `EE` calls.
diff --git a/src/devices/grodvi/dvi.cpp b/src/devices/grodvi/dvi.cpp
index cdab35ac..ca4a52eb 100644
--- a/src/devices/grodvi/dvi.cpp
+++ b/src/devices/grodvi/dvi.cpp
@@ -1,4 +1,3 @@
-// -*- C++ -*-
/* Copyright (C) 1989-2020 Free Software Foundation, Inc.
Written by James Clark ([email protected])
@@ -316,23 +315,23 @@ void dvi_printer::set_color(color *col)
break;
case RGB:
sprintf(buf, "color rgb %.3g %.3g %.3g",
- double(Red) / color::MAX_COLOR_VAL,
- double(Green) / color::MAX_COLOR_VAL,
- double(Blue) / color::MAX_COLOR_VAL);
+ double(Red) / (double)color::MAX_COLOR_VAL,
+ double(Green) / (double)color::MAX_COLOR_VAL,
+ double(Blue) / (double)color::MAX_COLOR_VAL);
break;
case CMY:
col->get_cmyk(&Cyan, &Magenta, &Yellow, &Black);
// fall through
case CMYK:
sprintf(buf, "color cmyk %.3g %.3g %.3g %.3g",
- double(Cyan) / color::MAX_COLOR_VAL,
- double(Magenta) / color::MAX_COLOR_VAL,
- double(Yellow) / color::MAX_COLOR_VAL,
- double(Black) / color::MAX_COLOR_VAL);
+ double(Cyan) / (double)color::MAX_COLOR_VAL,
+ double(Magenta) / (double)color::MAX_COLOR_VAL,
+ double(Yellow) / (double)color::MAX_COLOR_VAL,
+ double(Black) / (double)color::MAX_COLOR_VAL);
break;
case GRAY:
sprintf(buf, "color gray %.3g",
- double(Gray) / color::MAX_COLOR_VAL);
+ double(Gray) / (double)color::MAX_COLOR_VAL);
break;
}
do_special(buf);
@@ -694,7 +693,7 @@ void draw_dvi_printer::fill_next(const environment *env)
env->fill->get_gray(&g);
}
char buf[256];
- sprintf(buf, "sh %.3g", 1 - double(g)/color::MAX_COLOR_VAL);
+ sprintf(buf, "sh %.3g", 1 - double(g) / (double)color::MAX_COLOR_VAL);
do_special(buf);
}
@@ -976,3 +975,9 @@ static void usage(FILE *stream)
fprintf(stream, "usage: %s [-dv] [-F dir] [-w n] [files ...]\n",
program_name);
}
+
+// Local Variables:
+// fill-column: 72
+// mode: C++
+// End:
+// vim: set cindent noexpandtab shiftwidth=2 textwidth=72:
diff --git a/src/devices/grops/ps.cpp b/src/devices/grops/ps.cpp
index 80dde2bb..6d5adf4d 100644
--- a/src/devices/grops/ps.cpp
+++ b/src/devices/grops/ps.cpp
@@ -371,7 +371,7 @@ ps_output &ps_output::put_symbol(const char *s)
ps_output &ps_output::put_color(unsigned int c)
{
char buf[128];
- sprintf(buf, "%.3g", double(c) / color::MAX_COLOR_VAL);
+ sprintf(buf, "%.3g", double(c) / (double)color::MAX_COLOR_VAL);
int len = strlen(buf);
if (col > 0 && col + len + need_space > max_line_length) {
putc('\n', fp);
diff --git a/src/libs/libgroff/color.cpp b/src/libs/libgroff/color.cpp
index 6653a270..6e7e79b8 100644
--- a/src/libs/libgroff/color.cpp
+++ b/src/libs/libgroff/color.cpp
@@ -1,9 +1,5 @@
-// -*- C++ -*-
-
-/* <groff_src_dir>/src/libs/libgroff/color.cpp
-
-Copyright (C) 2001-2020 Free Software Foundation, Inc.
- Written by Gaius Mulley <[email protected]>
+/* Copyright (C) 2001-2020 Free Software Foundation, Inc.
+ Written by Gaius Mulley <[email protected]>
This file is part of groff.
@@ -373,29 +369,35 @@ char *color::print_color()
break;
case RGB:
sprintf(s, "rgb %.2ff %.2ff %.2ff",
- double(Red) / MAX_COLOR_VAL,
- double(Green) / MAX_COLOR_VAL,
- double(Blue) / MAX_COLOR_VAL);
+ double(Red) / (double)MAX_COLOR_VAL,
+ double(Green) / (double)MAX_COLOR_VAL,
+ double(Blue) / (double)MAX_COLOR_VAL);
break;
case CMY:
sprintf(s, "cmy %.2ff %.2ff %.2ff",
- double(Cyan) / MAX_COLOR_VAL,
- double(Magenta) / MAX_COLOR_VAL,
- double(Yellow) / MAX_COLOR_VAL);
+ double(Cyan) / (double)MAX_COLOR_VAL,
+ double(Magenta) / (double)MAX_COLOR_VAL,
+ double(Yellow) / (double)MAX_COLOR_VAL);
break;
case CMYK:
sprintf(s, "cmyk %.2ff %.2ff %.2ff %.2ff",
- double(Cyan) / MAX_COLOR_VAL,
- double(Magenta) / MAX_COLOR_VAL,
- double(Yellow) / MAX_COLOR_VAL,
- double(Black) / MAX_COLOR_VAL);
+ double(Cyan) / (double)MAX_COLOR_VAL,
+ double(Magenta) / (double)MAX_COLOR_VAL,
+ double(Yellow) / (double)MAX_COLOR_VAL,
+ double(Black) / (double)MAX_COLOR_VAL);
break;
case GRAY:
sprintf(s, "gray %.2ff",
- double(Gray) / MAX_COLOR_VAL);
+ double(Gray) / (double)MAX_COLOR_VAL);
break;
}
return s;
}
color default_color;
+
+// Local Variables:
+// fill-column: 72
+// mode: C++
+// End:
+// vim: set cindent noexpandtab shiftwidth=2 textwidth=72:
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit