Skip to content

Commit

Permalink
twaeks for macOS 14
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@85238 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
ripley committed Sep 30, 2023
1 parent 34629ae commit 5064517
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
12 changes: 10 additions & 2 deletions src/library/base/man/iconv.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ iconvlist()
\section{Implementation Details}{
There are three main implementations of \code{iconv} in use. Linux's
most common C runtime, \samp{glibc}, contains one. Several platforms
supply GNU \samp{libiconv}, including macOS and FreeBSD, in
supply versions of GNU \samp{libiconv}, including macOS and FreeBSD, in
some cases with additional encodings. On Windows we use a version of
Yukihiro Nakadaira's \samp{win_iconv}, which is based on Windows'
codepages. (We have added many encoding names for compatibility with
Expand All @@ -87,6 +87,13 @@ iconvlist()
results, and for \samp{win_iconv} currently a \sQuote{best fit}
strategy is used except for \code{to = "ASCII"}).

%% https://github.com/apple-oss-distributions/libiconv/blob/libiconv-80.1.1/citrus/iconv.h
The macOS implemetation is attribted to the \sQuote{Citrus Project}:
the Apple sources declare it as \sQuote{compatible} with GNU \samp{libiconv}
1.11 from 2006. Howver, it is has diverged notably since and in macOS
14 uses a \sQuote{best fit} for conversions at least for \code{to =
"ASCII"} and \code{to = "latin1"}.

Most commercial Unixes contain an implementation of \code{iconv} but
none we have encountered have supported the encoding names we need:
the \sQuote{R Installation and Administration} manual recommends
Expand Down Expand Up @@ -140,7 +147,8 @@ iconvlist()
If \code{toRaw = FALSE} (the default), the value is a character vector
of the same length and the same attributes as \code{x} (after
conversion to a character vector). If conversion fails for an element
that element of the result is set to \code{NA_character_}.
that element of the result is set to \code{NA_character_}. (NB:
whether conversion fails is implementation-specific.)

If \code{mark = TRUE} (the default) the elements of the result have a
declared encoding if \code{to} is \code{"latin1"} or \code{"UTF-8"},
Expand Down
5 changes: 5 additions & 0 deletions src/library/tools/man/showNonASCII.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ showNonASCIIfile(file)
It prints all element of \code{x} which contain non-ASCII characters,
preceded by the element number and with non-ASCII bytes highlighted
\emph{via} \code{\link{iconv}(sub = "byte")}.

However, this depends on \code{\link{iconv}(to = "ASCII")} failing to
convert, and macOS 14 no longer does so reliably.
}
\value{
The elements of \code{x} containing non-ASCII characters will be returned
Expand All @@ -43,7 +46,9 @@ out <- c(
f <- tempfile()
cat(out, file = f, sep = "\n")

## IGNORE_RDIFF_BEGIN
showNonASCIIfile(f)
## IGNORE_RDIFF_END
unlink(f)
}
\keyword{utilities}
5 changes: 5 additions & 0 deletions src/main/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -3628,7 +3628,12 @@ do_eSoftVersion(SEXP call, SEXP op, SEXP args, SEXP rho)
#ifdef _LIBICONV_VERSION
{
int ver = _libiconv_version;
#ifdef __APPLE__
// Apple patch to Citrix libiconv
snprintf(p, 256, "Apple libiconv %d.%d", ver/0x0100, ver%0x0100);
#else
snprintf(p, 256, "GNU libiconv %d.%d", ver/0x0100, ver%0x0100);
#endif
}
#elif defined(_WIN32)
snprintf(p, 256, "%s", "win_iconv");
Expand Down
14 changes: 8 additions & 6 deletions tests/Examples/tools-Ex.Rout.save
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

R Under development (unstable) (2023-07-11 r84677) -- "Unsuffered Consequences"
R Under development (unstable) (2023-09-29 r85235) -- "Unsuffered Consequences"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin22.5.0
Platform: aarch64-apple-darwin23.0.0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Expand Down Expand Up @@ -204,7 +204,7 @@ Error in assertWarning(ff()) :
> bibstyle("unsorted", sortKeys = function(refs) seq_along(refs),
+ fmtPrefix = function(paper) paste0("[", paper$.index, "]"),
+ .init = TRUE)
<environment: 0x126cbf4f8>
<environment: 0x119d11bf0>
> print(refs, .bibstyle = "unsorted")
[1] R Core Team (2013). _R: A Language and Environment for Statistical
Computing_. R Foundation for Statistical Computing, Vienna, Austria.
Expand Down Expand Up @@ -865,9 +865,11 @@ function (x, ...)
> f <- tempfile()
> cat(out, file = f, sep = "\n")
>
> ## IGNORE_RDIFF_BEGIN
> showNonASCIIfile(f)
1: fran<e7>ais: test of showNonASCII():
4: This has an <fc>mlaut in it.
1: francais: test of showNonASCII():
4: This has an "umlaut in it.
> ## IGNORE_RDIFF_END
> unlink(f)
>
>
Expand Down Expand Up @@ -1155,7 +1157,7 @@ needs Deep Thought
> cleanEx()
> options(digits = 7L)
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
Time elapsed: 0.132 0.012 0.145 0 0
Time elapsed: 0.163 0.015 0.179 0 0
> grDevices::dev.off()
null device
1
Expand Down

0 comments on commit 5064517

Please sign in to comment.