Skip to content

Commit

Permalink
Merge branch 'master' into gpxmsg
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteven4 committed Nov 7, 2024
2 parents dfe9621 + 9117a3c commit 595c9d6
Show file tree
Hide file tree
Showing 113 changed files with 1,760 additions and 1,944 deletions.
23 changes: 11 additions & 12 deletions arcdist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "arcdist.h"

#include <cmath> // for round
#include <cstdio> // for printf, sscanf
#include <cstdio> // for sscanf
#include <tuple> // for tie, tuple

#include <QByteArray> // for QByteArray
Expand All @@ -37,7 +37,6 @@


#if FILTERS_ENABLED
#define MYNAME "Arc filter"

#define BADVAL 999999

Expand Down Expand Up @@ -66,10 +65,10 @@ void ArcDistanceFilter::arcdist_arc_disp_wpt_cb(const Waypoint* arcpt2)
frac = 1.0;
} else {
if (waypointp == nullptr) {
fatal(FatalMsg() << "Internal error. Attempt to project through a waypoint that doesn't exist");
gbFatal(FatalMsg() << "Internal error. Attempt to project through a waypoint that doesn't exist");
}
if (arcpt1 == nullptr) {
fatal(FatalMsg() << "Internal error: Attempt to project waypoint without predecessor");
gbFatal(FatalMsg() << "Internal error: Attempt to project waypoint without predecessor");
}

std::tie(dist, prjpos, frac) = linedistprj(arcpt1->position(),
Expand Down Expand Up @@ -112,7 +111,7 @@ void ArcDistanceFilter::process()
QString line;

gpsbabel::TextStream stream;
stream.open(arcfileopt, QIODevice::ReadOnly, MYNAME);
stream.open(arcfileopt, QIODevice::ReadOnly);

auto* arcpt1 = new Waypoint;
auto* arcpt2 = new Waypoint;
Expand All @@ -134,7 +133,7 @@ void ArcDistanceFilter::process()
int argsfound = sscanf(CSTR(line), "%lf %lf", &arcpt2->latitude, &arcpt2->longitude);

if ((argsfound != 2) && (line.trimmed().size() > 0)) {
warning(MYNAME ": Warning: Arc file contains unusable vertex on line %d.\n", fileline);
gbWarning("Warning: Arc file contains unusable vertex on line %d.\n", fileline);
} else {
Waypoint* arcpttmp = arcpt1;
arcdist_arc_disp_wpt_cb(arcpt2);
Expand Down Expand Up @@ -190,16 +189,16 @@ void ArcDistanceFilter::process()
}
}
if (global_opts.debug_level >= 1) {
warning("Including waypoint %s at dist:%f lat:%f lon:%f\n",
qPrintable(wp->shortname), ed->distance, wp->latitude, wp->longitude);
gbWarning("Including waypoint %s at dist:%f lat:%f lon:%f\n",
gbLogCStr(wp->shortname), ed->distance, wp->latitude, wp->longitude);
}
}
delete ed;
}
}
del_marked_wpts();
if (global_opts.verbose_status > 0) {
printf(MYNAME "-arc: %u waypoint(s) removed.\n", removed);
gbInfo("%u waypoint(s) removed.\n", removed);
}
}

Expand All @@ -208,14 +207,14 @@ void ArcDistanceFilter::init()
if ((!arcfileopt && !rteopt && !trkopt) ||
(arcfileopt && (rteopt || trkopt)) ||
(rteopt && trkopt)) {
fatal(MYNAME ": Incompatible or incomplete option values!\n");
gbFatal("Incompatible or incomplete option values!\n");
}

pos_dist = 0.0;

if (distopt) {
if (parse_distance(distopt, &pos_dist, kMetersPerMile, MYNAME) == 0) {
fatal(MYNAME ": No distance specified with distance option.\n");
if (parse_distance(distopt, &pos_dist, kMetersPerMile) == 0) {
gbFatal("No distance specified with distance option.\n");
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions bend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
#include "grtcirc.h" // for RAD, heading_true_degrees, gcdist, linepart, radtometers, DEG


#define MYNAME "bend"

#if FILTERS_ENABLED

void BendFilter::init()
Expand Down
10 changes: 4 additions & 6 deletions csv_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
#include "src/core/logging.h" // for Warning


#define MYNAME "CSV_UTIL"

/*********************************************************************/
/* csv_stringclean() - remove any unwanted characters from string. */
/* returns copy of string. */
Expand Down Expand Up @@ -229,7 +227,7 @@ csv_linesplit(const QString& string, const QString& delimited_by,
}

if (enclosed) {
Warning() << MYNAME":" <<
Warning() <<
"Warning- Unbalanced Field Enclosures" <<
enclosed_in <<
"on line" <<
Expand Down Expand Up @@ -528,7 +526,7 @@ dec_to_human(const char* format, const char* dirs, double val)
case 'x':
case 'X':
if (index>2) {
fatal(MYNAME ": too many format specifiers\n");
gbFatal("too many format specifiers\n");
}
buff += QString::asprintf(subformat, intvals[index]);
index++;
Expand All @@ -539,7 +537,7 @@ dec_to_human(const char* format, const char* dirs, double val)
case 'g':
case 'G':
if (index>2) {
fatal(MYNAME ": too many format specifiers\n");
gbFatal("too many format specifiers\n");
}
buff += QString::asprintf(subformat, dblvals[index]);
index++;
Expand All @@ -548,7 +546,7 @@ dec_to_human(const char* format, const char* dirs, double val)
buff += subformat;
break;
default:
fatal(MYNAME ": invalid format specifier\n");
gbFatal("invalid format specifier\n");
break;

}
Expand Down
27 changes: 17 additions & 10 deletions defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "src/core/datetime.h" // for DateTime


#define gbLogCStr(qstr) qUtf8Printable(qstr)
#define CSTR(qstr) ((qstr).toUtf8().constData())
#define CSTRc(qstr) ((qstr).toLatin1().constData())

Expand Down Expand Up @@ -571,7 +572,9 @@ WaypointList::waypt_disp_session(const session_t* se, T cb)
}
}
if (global_opts.verbose_status) {
fprintf(stdout, "\r\n");
// Terminate the progress line from waypt_status_disp.
fprintf(stderr, "\n");
fflush(stderr);
}
}

Expand Down Expand Up @@ -907,17 +910,21 @@ enum ff_cap {
#define FF_CAP_RW_WPT \
{ (ff_cap) (ff_cap_read | ff_cap_write), ff_cap_none, ff_cap_none}

[[noreturn]] void fatal(QDebug& msginstance);
// cppcheck 2.10.3 fails to assign noreturn attribute to fatal if
[[noreturn]] void gbFatal(QDebug& msginstance);
// cppcheck 2.10.3 fails to assign noreturn attribute to gbFatal if
// the noreturn attribute is listed before the gnu::format attribute.
// A PR to resolve this is https://github.com/danmar/cppcheck/pull/4971,
// but cppcheck works if the noreturn attribute follows the gnu::format
// attribute.
// This can have a large effect on codacy issues from cppcheck
// nullPointerRedundantCheck, nullPointerArithmeticRedundantCheck,
// negativeIndex, arrayIndexOutOfBoundsCond.
[[gnu::format(printf, 1, 2)]] [[noreturn]] void fatal(const char* fmt, ...);
[[gnu::format(printf, 1, 2)]] void warning(const char* fmt, ...);
[[gnu::format(printf, 1, 2)]] [[noreturn]] void gbFatal(const char* fmt, ...);
[[gnu::format(printf, 1, 2)]] void gbWarning(const char* fmt, ...);
[[gnu::format(printf, 1, 2)]] void gbInfo(const char* fmt, ...);
[[gnu::format(printf, 1, 2)]] void gbDebug(const char* fmt, ...);

void gbVLegacyLog(QtMsgType type, const char* fmt, va_list args1);

void printposn(double c, bool is_lat);

Expand All @@ -927,7 +934,7 @@ void* xrealloc(void* p, size_t s);
void xfree(const void* mem);
char* xstrdup(const char* s);

FILE* xfopen(const QString& fname, const char* type, const QString& errtxt);
FILE* xfopen(const QString& fname, const char* type);

// Thin wrapper around fopen() that supports Unicode fname on all platforms.
FILE* ufopen(const QString& fname, const char* mode);
Expand Down Expand Up @@ -1028,11 +1035,11 @@ int xstrtoi(const char* str, char** str_end, int base);
int parse_integer(const QString& str, const QString& id, bool* ok = nullptr, QString* end = nullptr, int base = 10);
double parse_double(const QString& str, const QString& id, bool* ok = nullptr, QString* end = nullptr);
int parse_coordinates(const char* str, int datum, grid_type grid,
double* latitude, double* longitude, const char* module);
double* latitude, double* longitude);
int parse_coordinates(const QString& str, int datum, grid_type grid,
double* latitude, double* longitude, const char* module);
int parse_distance(const QString& str, double* val, double scale, const char* module);
int parse_speed(const QString& str, double* val, double scale, const char* module);
double* latitude, double* longitude);
int parse_distance(const QString& str, double* val, double scale);
int parse_speed(const QString& str, double* val, double scale);

/*
* Color helpers.
Expand Down
Loading

0 comments on commit 595c9d6

Please sign in to comment.