Skip to content
Open
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
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# statnet.common 4.14.0

## Bug fixes

* `match_names(partial = FALSE)` no longer embeds a non-UTF-8 sentinel string, which produced "strings not representable in native encoding" warnings when the package was installed in a UTF-8 locale and loaded in a C locale. (#44; originally reported against the `ergm` progress bars)

# statnet.common 4.13.0

## New utilities
Expand Down
12 changes: 5 additions & 7 deletions R/misc.utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@
#'
#' * There is ambiguity that [pmatch()] cannot resolve.
#'
#' @note At this time, passing `partial=FALSE` will use a crude
#' sentinel to prevent partial matching, which in some, extremely
#' improbable, circumstances might not work.
#'
#' @param v a vector
#' @param names a character vector of element names
#' @param default value to be used for elements of `names` not found in `v`
Expand Down Expand Up @@ -168,9 +164,11 @@
v <- v[!blanks]
}

# partial == FALSE -> add a sentinel string at the end of all strings to prevent partial matching.
namesmatch <- if(partial) pmatch(names(v), names)
else pmatch(paste(names(v), "\n\xf5\xdc\n"), paste(names, "\n\xf5\xdc\n"))
namesmatch <- pmatch(names(v), names)
# partial == FALSE -> keep only the exact matches. pmatch() assigns all
# exact matches before attempting any partial ones, so this leaves
# exactly the sequential exact matches.
if(!partial) namesmatch[which(names[namesmatch] != names(v))] <- NA

Check warning on line 171 in R/misc.utilities.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/misc.utilities.R,line=171,col=7,[spaces_left_parentheses_linter] Place a space before left parenthesis, except in a function call.

Check warning on line 171 in R/misc.utilities.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/misc.utilities.R,line=171,col=7,[spaces_left_parentheses_linter] Place a space before left parenthesis, except in a function call.
used <- !is.na(namesmatch)
found <- unwhich(na.omit(namesmatch), length(names))

Expand Down
5 changes: 0 additions & 5 deletions man/match_names.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading