From e40e80b3a44c92c330dd44c3412f771fa1e7068a Mon Sep 17 00:00:00 2001 From: eric bryant Date: Tue, 2 Jun 2020 00:01:17 -0400 Subject: [PATCH] LABEL_INVALID_CHAR fix --- .../cplusplus/classes/Route/read_wpt.cpp | 3 +-- .../cplusplus/classes/Waypoint/Waypoint.cpp | 22 ++++++++++--------- .../cplusplus/classes/Waypoint/Waypoint.h | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/siteupdate/cplusplus/classes/Route/read_wpt.cpp b/siteupdate/cplusplus/classes/Route/read_wpt.cpp index f8d3db14..4af30af2 100644 --- a/siteupdate/cplusplus/classes/Route/read_wpt.cpp +++ b/siteupdate/cplusplus/classes/Route/read_wpt.cpp @@ -76,8 +76,7 @@ void Route::read_wpt w->label_slashes(datacheckerrors, slash); w->underscore_datachecks(datacheckerrors, slash); w->label_parens(datacheckerrors); - w->label_invalid_char(datacheckerrors, w->label); - for (std::string &a : w->alt_labels) w->label_invalid_char(datacheckerrors, a); + w->label_invalid_char(datacheckerrors); w->label_invalid_ends(datacheckerrors); w->bus_with_i(datacheckerrors); w->label_looks_hidden(datacheckerrors); diff --git a/siteupdate/cplusplus/classes/Waypoint/Waypoint.cpp b/siteupdate/cplusplus/classes/Waypoint/Waypoint.cpp index 3eea81ef..812f0df1 100644 --- a/siteupdate/cplusplus/classes/Waypoint/Waypoint.cpp +++ b/siteupdate/cplusplus/classes/Waypoint/Waypoint.cpp @@ -398,17 +398,19 @@ inline void Waypoint::label_looks_hidden(DatacheckEntryList *datacheckerrors) datacheckerrors->add(route, label, "", "", "LABEL_LOOKS_HIDDEN", ""); } -inline void Waypoint::label_invalid_char(DatacheckEntryList *datacheckerrors, std::string &lbl) +inline void Waypoint::label_invalid_char(DatacheckEntryList *datacheckerrors) { // look for labels with invalid characters - for (const char *c = lbl.data(); *c; c++) - { if (*c < 40) { datacheckerrors->add(route, lbl, "", "", "LABEL_INVALID_CHAR", ""); return; } - if (*c == 44) { datacheckerrors->add(route, lbl, "", "", "LABEL_INVALID_CHAR", ""); return; } - if (*c > 57 && *c < 65) { datacheckerrors->add(route, lbl, "", "", "LABEL_INVALID_CHAR", ""); return; } - if (*c > 90 && *c < 95) { datacheckerrors->add(route, lbl, "", "", "LABEL_INVALID_CHAR", ""); return; } - if (*c == 96) { datacheckerrors->add(route, lbl, "", "", "LABEL_INVALID_CHAR", ""); return; } - if (*c > 122) { datacheckerrors->add(route, lbl, "", "", "LABEL_INVALID_CHAR", ""); return; } - } - if (strpbrk(lbl.data()+1, "+*")) datacheckerrors->add(route, lbl, "", "", "LABEL_INVALID_CHAR", ""); + for (const char *c = label.data(); *c; c++) + if ((*c == 42 || *c == 43) && c > label.data() + || (*c < 40) || (*c == 44) || (*c > 57 && *c < 65) + || (*c == 96) || (*c > 122) || (*c > 90 && *c < 95)) + datacheckerrors->add(route, label, "", "", "LABEL_INVALID_CHAR", ""); + for (std::string& lbl : alt_labels) + for (const char *c = lbl.data(); *c; c++) + if (*c == '+' && c > lbl.data() || *c == '*' && (c > lbl.data()+1 || lbl[0] != '+') + || (*c < 40) || (*c == 44) || (*c > 57 && *c < 65) + || (*c == 96) || (*c > 122) || (*c > 90 && *c < 95)) + datacheckerrors->add(route, lbl, "", "", "LABEL_INVALID_CHAR", ""); } inline void Waypoint::label_invalid_ends(DatacheckEntryList *datacheckerrors) diff --git a/siteupdate/cplusplus/classes/Waypoint/Waypoint.h b/siteupdate/cplusplus/classes/Waypoint/Waypoint.h index 7e302c8c..9d7ddc2c 100644 --- a/siteupdate/cplusplus/classes/Waypoint/Waypoint.h +++ b/siteupdate/cplusplus/classes/Waypoint/Waypoint.h @@ -46,7 +46,7 @@ class Waypoint inline void visible_distance(DatacheckEntryList *, char *, double &, Waypoint *&); inline void bus_with_i(DatacheckEntryList *); inline void label_looks_hidden(DatacheckEntryList *); - inline void label_invalid_char(DatacheckEntryList *, std::string &); + inline void label_invalid_char(DatacheckEntryList *); inline void label_invalid_ends(DatacheckEntryList *); inline void label_parens(DatacheckEntryList *); inline void label_slashes(DatacheckEntryList *, const char *);