Cleanup: remove unused function get_selected_dives_text()

The only caller was removed in commit c3f07b9f81.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-04-09 22:30:46 +02:00 committed by Dirk Hohndel
parent bbacdf94e3
commit 8b0055d15c
2 changed files with 0 additions and 70 deletions

View file

@ -4,7 +4,6 @@
* core logic for the Info & Stats page -
* char *get_minutes(int seconds);
* void process_all_dives(struct dive *dive, struct dive **prev_dive);
* void get_selected_dives_text(char *buffer, int size);
*/
#include "gettext.h"
#include <string.h>
@ -235,74 +234,6 @@ void process_selected_dives(void)
stats_selection.selection_size = nr;
}
/* this gets called when at least two but not all dives are selected */
static void get_ranges(char *buffer, int size)
{
int i, len;
int first = -1, last = -1;
struct dive *dive;
snprintf(buffer, size, "%s", translate("gettextFromC", "for dives #"));
for_each_dive (i, dive) {
if (!dive->selected)
continue;
if (dive->number < 1) {
/* uhh - weird numbers - bail */
snprintf(buffer, size, "%s", translate("gettextFromC", "for selected dives"));
return;
}
len = strlen(buffer);
if (last == -1) {
snprintf(buffer + len, size - len, "%d", dive->number);
first = last = dive->number;
} else {
if (dive->number == last + 1) {
last++;
continue;
} else {
if (first == last)
snprintf(buffer + len, size - len, ", %d", dive->number);
else if (first + 1 == last)
snprintf(buffer + len, size - len, ", %d, %d", last, dive->number);
else
snprintf(buffer + len, size - len, "-%d, %d", last, dive->number);
first = last = dive->number;
}
}
}
len = strlen(buffer);
if (first != last) {
if (first + 1 == last)
snprintf(buffer + len, size - len, ", %d", last);
else
snprintf(buffer + len, size - len, "-%d", last);
}
}
void get_selected_dives_text(char *buffer, size_t size)
{
if (amount_selected == 1) {
if (current_dive)
snprintf(buffer, size, translate("gettextFromC", "for dive #%d"), current_dive->number);
else
snprintf(buffer, size, "%s", translate("gettextFromC", "for selected dive"));
} else if (amount_selected == (unsigned int)dive_table.nr) {
snprintf(buffer, size, "%s", translate("gettextFromC", "for all dives"));
} else if (amount_selected == 0) {
snprintf(buffer, size, "%s", translate("gettextFromC", "(no dives)"));
} else {
get_ranges(buffer, size);
if (strlen(buffer) == size - 1) {
/* add our own ellipse... the way Pango does this is ugly
* as it will leave partial numbers there which I don't like */
size_t offset = 4;
while (offset < size && isdigit(buffer[size - offset]))
offset++;
strcpy(buffer + size - offset, "...");
}
}
}
#define SOME_GAS 5000 // 5bar drop in cylinder pressure makes cylinder used
bool has_gaschange_event(struct dive *dive, struct divecomputer *dc, int idx)

View file

@ -46,7 +46,6 @@ extern stats_t *stats_by_type;
extern char *get_minutes(int seconds);
extern void process_all_dives(struct dive *dive, struct dive **prev_dive);
extern void get_selected_dives_text(char *buffer, size_t size);
extern void get_gas_used(struct dive *dive, volume_t gases[MAX_CYLINDERS]);
extern void process_selected_dives(void);
void selected_dives_gas_parts(volume_t *o2_tot, volume_t *he_tot);