Skip to content

Fixes from the review of the format, order and scrub() changes - #65

Merged
AlbanSagouis merged 8 commits into
devfrom
fix/review-2026-11-23
Nov 24, 2026
Merged

AlbanSagouis merged 8 commits into
devfrom
fix/review-2026-11-23

Conversation

@AlbanSagouis

Copy link
Copy Markdown
Collaborator

Description

Fixes from a review of the changes since 0.5.0 (0f34152..3c3058d). The fixes for what #64 brought (latin1 bytes, locale-dependent tests, the "bytes" check) were pushed to #64 itself. This PR has the rest. It is based on perf/cpp-scrub, so it shows only its own 8 commits.

  • format: each number is turned into text on its own. Before, parse_lat(c(4530, 45.5), format = c("DDMM", "DD.d")) gave NA 45.5, because 4530 became "4530.0" to match the decimals of 45.5.
  • format is about 10 times faster: fields are read with regexpr() and its capture positions instead of regexec() and regmatches(). For 100 000 values, parse_lat(format = "DDMMSSH") takes 94 ms instead of 991 ms. A relative speed test now covers the format path, with a limit of 12 set from macOS only. Please check it against CI.
  • Strings marked "bytes", and latin1 strings with a byte that Windows-1252 leaves undefined, give the same error with or without format.
  • parse_llstr() reads every E as a direction letter, so "45E30.5, 10" gives lat 10, lon 45.508. In strings with an exponent, such as "1.5e2, 4", the NA now goes to the longitude instead of the latitude. The hint to try order = "lon_lat" now appears only when the latitude is out of range.
  • parse_llstr() gives NA without a warning for "" and blank strings, as parse_lat() and the format path already did.
  • Docs: the Errors sections of parse_lat() and parse_lon() list the new causes of NA. NEWS has one speed bullet, measured against 0.5.0. README is knit again (coverage 99.77%) and shows format and order, as does the vignette.

Related Issue

Follows #64.

Example

parse_lat(c(4530, 45.5), format = c("DDMM", "DD.d"))
# now 45.5 45.5, before NA 45.5

parse_llstr("45E30.5, 10")
# now lat 10, lon 45.508, before NA NA and a wrong hint to swap the order

devtools::test() passes at every commit (1934 expectations at the tip). The encoding tests were also run with LC_CTYPE set to a latin1 locale.

"45E30.5, 10" now gives lat 10 and lon 45.508, like "45W30.5, 10". Strings with an exponent, such as "1.5e2, 4", now give NA for the longitude instead of the latitude.

The "try order = lon_lat" hint now needs a latitude above 90 or below -90, not any NA latitude.
…ings

As parse_lat() and parse_llstr(format = ) already do.
… parse_lon()

A minus sign that disagrees with the letter, a number with two decimal points, and a value that does not match format.
README.md is knit again from README.Rmd, as the pre-commit hook does.
The coverage block is now current (with R/format.R and src/scrub.cpp).
AlbanSagouis added a commit that referenced this pull request Nov 23, 2026
…dling of latin1 junk bytes

On this branch the format path does not call check_encoding(), so the test pinned what R does with the byte 0x81: an error on macOS, NA with a warning on Windows. #65 replaces it with parzer's own error, the same on every platform.
@AlbanSagouis
AlbanSagouis changed the base branch from perf/cpp-scrub to dev November 24, 2026 09:19
@AlbanSagouis
AlbanSagouis merged commit 4d9a12a into dev Nov 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant