Always cast to non-const for tparm

This is non-const on macOS, but some of the args we pass are always
const on netbsd.

I have no idea why you'd ever want this to modify its argument, but whatever.
This commit is contained in:
Fabian Homborg 2018-12-12 11:29:26 +01:00
parent a608e5d581
commit c5f9f59555
3 changed files with 14 additions and 14 deletions

View File

@ -193,7 +193,7 @@ int builtin_set_color(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
output_set_writer(set_color_builtin_outputter);
if (bold && enter_bold_mode) {
writembs_nofail(tparm(enter_bold_mode));
writembs_nofail(tparm((char *)enter_bold_mode));
}
if (underline && enter_underline_mode) {
@ -216,13 +216,13 @@ int builtin_set_color(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
if (bgcolor != NULL && bg.is_normal()) {
write_color(rgb_color_t::black(), false /* not is_fg */);
writembs_nofail(tparm(exit_attribute_mode));
writembs_nofail(tparm((char *)exit_attribute_mode));
}
if (!fg.is_none()) {
if (fg.is_normal() || fg.is_reset()) {
write_color(rgb_color_t::black(), true /* is_fg */);
writembs_nofail(tparm(exit_attribute_mode));
writembs_nofail(tparm((char *)exit_attribute_mode));
} else {
if (!write_color(fg, true /* is_fg */)) {
// We need to do *something* or the lack of any output messes up

View File

@ -66,7 +66,7 @@ unsigned char index_for_color(rgb_color_t c) {
static bool write_color_escape(char *todo, unsigned char idx, bool is_fg) {
if (term_supports_color_natively(idx)) {
// Use tparm to emit color escape.
writembs(tparm(todo, idx));
writembs(tparm((char *)todo, idx));
return true;
}
@ -332,7 +332,7 @@ void set_color(rgb_color_t c, rgb_color_t c2) {
// Lastly, we set bold, underline, italics, dim, and reverse modes correctly.
if (is_bold && !was_bold && enter_bold_mode && strlen(enter_bold_mode) > 0 && !bg_set) {
writembs_nofail(tparm(enter_bold_mode));
writembs_nofail(tparm((char *)enter_bold_mode));
was_bold = is_bold;
}

View File

@ -222,7 +222,7 @@ static bool is_color_escape_seq(const wchar_t *code, size_t *resulting_length) {
if (!esc[p]) continue;
for (int k = 0; k < max_colors; k++) {
size_t esc_seq_len = try_sequence(tparm(esc[p], k), code);
size_t esc_seq_len = try_sequence(tparm((char *)esc[p], k), code);
if (esc_seq_len) {
*resulting_length = esc_seq_len;
return true;
@ -250,7 +250,7 @@ static bool is_visual_escape_seq(const wchar_t *code, size_t *resulting_length)
if (!esc2[p]) continue;
// Test both padded and unpadded version, just to be safe. Most versions of tparm don't
// actually seem to do anything these days.
size_t esc_seq_len = maxi(try_sequence(tparm(esc2[p]), code), try_sequence(esc2[p], code));
size_t esc_seq_len = maxi(try_sequence(tparm((char *)esc2[p]), code), try_sequence(esc2[p], code));
if (esc_seq_len) {
*resulting_length = esc_seq_len;
return true;
@ -526,7 +526,7 @@ static void s_move(screen_t *s, data_buffer_t *b, int new_x, int new_y) {
bool use_multi =
multi_str != NULL && multi_str[0] != '\0' && abs(x_steps) * strlen(str) > strlen(multi_str);
if (use_multi && cur_term) {
char *multi_param = tparm(multi_str, abs(x_steps));
char *multi_param = tparm((char *)multi_str, abs(x_steps));
writembs(multi_param);
} else {
for (i = 0; i < abs(x_steps); i++) {
@ -1151,7 +1151,7 @@ void s_reset(screen_t *s, screen_reset_mode_t mode) {
if (screen_width > non_space_width) {
bool justgrey = true;
if (cur_term && enter_dim_mode) {
std::string dim = tparm(enter_dim_mode);
std::string dim = tparm((char *)enter_dim_mode);
if (!dim.empty()) {
// Use dim if they have it, so the color will be based on their actual normal
// color and the background of the termianl.
@ -1162,14 +1162,14 @@ void s_reset(screen_t *s, screen_reset_mode_t mode) {
if (cur_term && justgrey && set_a_foreground) {
if (max_colors >= 238) {
// draw the string in a particular grey
abandon_line_string.append(str2wcstring(tparm(set_a_foreground, 237)));
abandon_line_string.append(str2wcstring(tparm((char *)set_a_foreground, 237)));
} else if (max_colors >= 9) {
// bright black (the ninth color, looks grey)
abandon_line_string.append(str2wcstring(tparm(set_a_foreground, 8)));
abandon_line_string.append(str2wcstring(tparm((char *)set_a_foreground, 8)));
} else if (max_colors >= 2 && enter_bold_mode) {
// we might still get that color by setting black and going bold for bright
abandon_line_string.append(str2wcstring(tparm(enter_bold_mode)));
abandon_line_string.append(str2wcstring(tparm(set_a_foreground, 0)));
abandon_line_string.append(str2wcstring(tparm((char *)enter_bold_mode)));
abandon_line_string.append(str2wcstring(tparm((char *)set_a_foreground, 0)));
}
}
@ -1177,7 +1177,7 @@ void s_reset(screen_t *s, screen_reset_mode_t mode) {
if (cur_term && exit_attribute_mode) {
abandon_line_string.append(
str2wcstring(tparm(exit_attribute_mode))); // normal text ANSI escape sequence
str2wcstring(tparm((char *)exit_attribute_mode))); // normal text ANSI escape sequence
}
int newline_glitch_width = term_has_xn ? 0 : 1;