From eeb2db283de9115f7256fa4cc49597d63e06b0ab Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 1 Oct 2017 12:52:12 +0100 Subject: New name UI_UPDATE for interpret_move's return "". Now midend.c directly tests the returned pointer for equality to this value, instead of checking whether it's the empty string. A minor effect of this is that games may now return a dynamically allocated empty string from interpret_move() and treat it as just another legal move description. But I don't expect anyone to be perverse enough to actually do that! The main purpose is that it avoids returning a string literal from a function whose return type is a pointer to _non-const_ char, i.e. we are now one step closer to being able to make this code base clean under -Wwrite-strings. --- unfinished/group.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'unfinished/group.c') diff --git a/unfinished/group.c b/unfinished/group.c index 4a4ad6c..0d2f915 100644 --- a/unfinished/group.c +++ b/unfinished/group.c @@ -1281,13 +1281,13 @@ static char *interpret_move(const game_state *state, game_ui *ui, ui->drag |= 4; /* some movement has happened */ if (tcoord >= 0 && tcoord < w) { ui->dragpos = tcoord; - return ""; + return UI_UPDATE; } } else if (IS_MOUSE_RELEASE(button)) { if (ui->drag & 4) { ui->drag = 0; /* end drag */ if (state->sequence[ui->dragpos] == ui->dragnum) - return ""; /* drag was a no-op overall */ + return UI_UPDATE; /* drag was a no-op overall */ sprintf(buf, "D%d,%d", ui->dragnum, ui->dragpos); return dupstr(buf); } else { @@ -1298,7 +1298,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, state->sequence[ui->edgepos]); return dupstr(buf); } else - return ""; /* no-op */ + return UI_UPDATE; /* no-op */ } } } else if (IS_MOUSE_DOWN(button)) { @@ -1321,7 +1321,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, ui->hpencil = 0; } ui->hcursor = 0; - return ""; /* UI activity occurred */ + return UI_UPDATE; } if (button == RIGHT_BUTTON) { /* @@ -1345,20 +1345,20 @@ static char *interpret_move(const game_state *state, game_ui *ui, ui->hshow = 0; } ui->hcursor = 0; - return ""; /* UI activity occurred */ + return UI_UPDATE; } } else if (tx >= 0 && tx < w && ty == -1) { ui->drag = 2; ui->dragnum = state->sequence[tx]; ui->dragpos = tx; ui->edgepos = FROMCOORD(x + TILESIZE/2); - return ""; + return UI_UPDATE; } else if (ty >= 0 && ty < w && tx == -1) { ui->drag = 1; ui->dragnum = state->sequence[ty]; ui->dragpos = ty; ui->edgepos = FROMCOORD(y + TILESIZE/2); - return ""; + return UI_UPDATE; } } else if (IS_MOUSE_DRAG(button)) { if (!ui->hpencil && @@ -1371,7 +1371,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, ui->odx = ui->ody = 0; ui->odn = 1; } - return ""; + return UI_UPDATE; } if (IS_CURSOR_MOVE(button)) { @@ -1381,13 +1381,13 @@ static char *interpret_move(const game_state *state, game_ui *ui, ui->hx = state->sequence[cx]; ui->hy = state->sequence[cy]; ui->hshow = ui->hcursor = 1; - return ""; + return UI_UPDATE; } if (ui->hshow && (button == CURSOR_SELECT)) { ui->hpencil = 1 - ui->hpencil; ui->hcursor = 1; - return ""; + return UI_UPDATE; } if (ui->hshow && -- cgit v1.1