Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

miscellaneous minor fixes III #776

Merged
merged 2 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bcr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ bcr_data_read()
route->rte_name = routename;
}

for (int index = 1; index > 0; index ++) {
for (int index = 1; ; index++) {
char station[32];
QString str;
int mlat, mlon; /* mercator data */
Expand Down
48 changes: 2 additions & 46 deletions util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#include <QtGlobal> // for qAsConst, QAddConst<>::Type, qPrintable

#include "defs.h"
#include "cet.h" // for cet_utf8_to_ucs4
#include "src/core/datetime.h" // for DateTime
#include "src/core/logging.h" // for Warning
#include "src/core/xmltag.h" // for xml_tag, xml_attribute, xml_findfirst, xml_findnext
Expand Down Expand Up @@ -1524,16 +1523,13 @@ static
char*
entitize(const char* str, bool is_html)
{
int ecount;
int nsecount;
char* p;
char* tmp;
char* xstr;

int bytes = 0;
int value = 0;
entity_types* ep = stdentities;
int elen = ecount = nsecount = 0;
int elen = 0;
int ecount = 0;

/* figure # of entity replacements and additional size. */
while (ep->text) {
Expand All @@ -1546,29 +1542,10 @@ entitize(const char* str, bool is_html)
ep++;
}

/* figure the same for other than standard entities (i.e. anything
* that isn't in the range U+0000 to U+007F */

#if 0
for (cp = str; *cp; cp++) {
if (*cp & 0x80) {
cet_utf8_to_ucs4(cp, &bytes, &value);
cp += bytes-1;
elen += sprintf(tmpsub, "&#x%x;", value) - bytes;
nsecount++;
}
}
#endif

/* enough space for the whole string plus entity replacements, if any */
tmp = (char*) xcalloc((strlen(str) + elen + 1), 1);
strcpy(tmp, str);

/* no entity replacements */
if (ecount == 0 && nsecount == 0) {
return (tmp);
}

if (ecount != 0) {
for (ep = stdentities; ep->text; ep++) {
p = tmp;
Expand All @@ -1590,27 +1567,6 @@ entitize(const char* str, bool is_html)
}
}

if (nsecount != 0) {
p = tmp;
while (*p) {
if (*p & 0x80) {
cet_utf8_to_ucs4(p, &bytes, &value);
if (p[bytes]) {
xstr = xstrdup(p + bytes);
} else {
xstr = nullptr;
}
sprintf(p, "&#x%x;", value);
p = p+strlen(p);
if (xstr) {
strcpy(p, xstr);
xfree(xstr);
}
} else {
p++;
}
}
}
return (tmp);
}

Expand Down