From: robertl Date: Fri, 24 Sep 2004 16:23:11 +0000 (+0000) Subject: If we don't have a waypoint name, create one. X-Git-Tag: archive/raspbian/1.10.0+ds-2+rpi1~1^2~12^2~11^2~3905 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=89eaebc59a0c252afbc41a6d76c83e4fb72b9e10;p=gpsbabel.git If we don't have a waypoint name, create one. --- diff --git a/gpsbabel/waypt.c b/gpsbabel/waypt.c index 9b5aa9c05..fde54f87b 100644 --- a/gpsbabel/waypt.c +++ b/gpsbabel/waypt.c @@ -74,21 +74,27 @@ void waypt_add(waypoint *wpt) { ENQUEUE_TAIL(&waypt_head, &wpt->Q); + waypt_ct++; /* * Some input may not have one or more of these types so we * try to be sure that we have these fields even if just by * copying them from elsewhere. */ + if (wpt->shortname == NULL) { if (wpt->description) { wpt->shortname = xstrdup(wpt->description); + } else if (wpt->notes) { + wpt->shortname = xstrdup(wpt->notes); } else { - if (wpt->notes) { - wpt->shortname = xstrdup(wpt->notes); - } + /* Last ditch: make up a name */ + char cbuf[10]; + snprintf(cbuf, sizeof(cbuf), "WPT%03d", waypt_ct); + wpt->shortname = xstrdup(cbuf); } } + if (wpt->description == NULL || strlen(wpt->description) == 0) { if (wpt->description) xfree(wpt->description); @@ -100,7 +106,6 @@ waypt_add(waypoint *wpt) } } } - waypt_ct++; } void