X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=main.c;h=ee09b9a82e50b4ee0bceda0ef9eebdd7cadaae64;hb=6231b64d3de47dde9420d35ea7e6d620a3a2b966;hp=a09bfe03a01099efebe11f7337df2838a775e3f3;hpb=88e679ab1df89b2b14f40f4566095d5a01439c05;p=ext%2Fsubsurface.git diff --git a/main.c b/main.c index a09bfe0..ee09b9a 100644 --- a/main.c +++ b/main.c @@ -97,11 +97,16 @@ static void try_to_renumber(struct dive *last, int preexisting) } } +/* + * track whether we switched to importing dives + */ +static gboolean imported = FALSE; + /* * This doesn't really report anything at all. We just sort the * dives, the GUI does the reporting */ -void report_dives(void) +void report_dives(gboolean imported) { int i; int preexisting = dive_table.preexisting; @@ -135,13 +140,15 @@ void report_dives(void) i--; } - /* Was the previous dive table state numbered? */ - if (last && last->number) - try_to_renumber(last, preexisting); + if (imported) { + /* Was the previous dive table state numbered? */ + if (last && last->number) + try_to_renumber(last, preexisting); - /* did we have dives in the table and added more? */ - if (last && preexisting != dive_table.nr) - mark_divelist_changed(TRUE); + /* did we have dives in the table and added more? */ + if (last && preexisting != dive_table.nr) + mark_divelist_changed(TRUE); + } dive_table.preexisting = dive_table.nr; dive_list_update_dives(); } @@ -155,6 +162,16 @@ static void parse_argument(const char *arg) case 'v': verbose++; continue; + case '-': + /* long options with -- */ + if (strcmp(arg,"--import") == 0) { + /* mark the dives so far as the base, + * everything after is imported */ + report_dives(FALSE); + imported = TRUE; + return; + } + /* fallthrough */ default: fprintf(stderr, "Bad argument '%s'\n", arg); exit(1); @@ -218,7 +235,7 @@ int main(int argc, char **argv) } } - report_dives(); + report_dives(imported); run_ui(); return 0;